summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2016-07-15 22:09:54 +1200
committerFlorian Baumann <derflob@derflob.de>2016-07-15 22:09:54 +1200
commited4de5feb3d6c6e4e42fc6441b790d81828e526d (patch)
tree089d73f27130a7d374675530b3d8938e03296dd4
parente0428e2d84a94505d511f89f10f62f4b2d1f6ffc (diff)
downloadxmpp-ed4de5feb3d6c6e4e42fc6441b790d81828e526d.tar.gz
xmpp-ed4de5feb3d6c6e4e42fc6441b790d81828e526d.tar.bz2
cmd job
-rw-r--r--__init__.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/__init__.py b/__init__.py
index 0e690f6..5589b86 100644
--- a/__init__.py
+++ b/__init__.py
@@ -227,6 +227,51 @@ class OctoXMPP(EventHandlerPlugin, SettingsPlugin):
self._xmpp.add_event_handler("http_upload::{}::finished".format(i),
__send_get_url, disposable=True)
+ def _cmd_job(self, msg, action=None):
+ actions = ['start', 'pause', 'resume', 'cancel', 'abort']
+ job = self._printer.get_current_job()
+ if (action in actions):
+ if (not job['file']['origin']):
+ reply = "No job loaded."
+ else:
+ reply = getattr(self, "_job_{}".format(action))()
+ else
+ reply = "Unknown action ({}).\nAvailable: {}".format(action, ", ".join(actions))
+
+ msg.reply(body=reply).send()
+
+ def _job_start(self):
+ job = self._printer.get_current_job()
+ if (self._printer.is_ready()):
+ self._printer.start_print()
+ return "Started new Print Job: {}".format(job['file']['name'])
+ else:
+ return "Could not start Print Job."
+
+ def _job_pause(self):
+ if (self._printer.is_printing()):
+ self._printer.pause_print()
+ return "Paused Print Job."
+ else:
+ return "Could not pause Print Job."
+
+ def _job_resume(self):
+ if (self._printer.is_paused()):
+ self._printer.toggle_pause_print()
+ return "Resumed Print Job."
+ else:
+ return "Could not resume Print Job."
+
+ def _job_cancel(self):
+ if (self._printer.is_printing() or self._printer.is_paused()):
+ self._printer.cancel_print()
+ return "Canceld Print Job."
+ else:
+ return "Could not cancel Print Job."
+
+ def _job_abort(self):
+ return self._job_cancel()
+
__plugin_name__ = "OctoXMPP"
__plugin_version__ = "0.2.0"