From 072c64de99be550d52f81f99a2b56894ab0b422c Mon Sep 17 00:00:00 2001 From: Adriano Cunha Date: Thu, 25 Nov 2021 23:02:42 -0800 Subject: [PATCH] Make AutomaticShutdown work with OctoPi 0.18.0 + OctoPrint 1.7.2 * Fixed identations * Fixed `sarge.run` usage * Updated Python compatibility * Changed all Github references to this repo --- README.md | 5 +- extras/automaticshutdown.md | 6 +- octoprint_automaticshutdown/__init__.py | 75 +++++++++++++------------ setup.py | 4 +- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 8a12c4d..f6d7978 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,9 @@ The user can enable automatic shutdown for each print by using a checkbox in the ## Setup -Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager) -or manually using this URL: +Install manually using this URL: - https://github.com/OctoPrint/OctoPrint-AutomaticShutdown/archive/master.zip + https://github.com/adrcunha/OctoPrint-AutomaticShutdown/archive/master.zip ## Configuration diff --git a/extras/automaticshutdown.md b/extras/automaticshutdown.md index cba2122..89be865 100644 --- a/extras/automaticshutdown.md +++ b/extras/automaticshutdown.md @@ -9,9 +9,9 @@ license: AGPLv3 date: 2015-08-27 -homepage: https://github.com/OctoPrint/OctoPrint-AutomaticShutdown -source: https://github.com/OctoPrint/OctoPrint-AutomaticShutdown -archive: https://github.com/OctoPrint/OctoPrint-AutomaticShutdown/archive/master.zip +homepage: https://github.com/adrcunha/OctoPrint-AutomaticShutdown +source: https://github.com/adrcunha/OctoPrint-AutomaticShutdown +archive: https://github.com/adrcunha/OctoPrint-AutomaticShutdown/archive/master.zip follow_dependency_links: false diff --git a/octoprint_automaticshutdown/__init__.py b/octoprint_automaticshutdown/__init__.py index d75339e..d2d8b37 100644 --- a/octoprint_automaticshutdown/__init__.py +++ b/octoprint_automaticshutdown/__init__.py @@ -10,20 +10,20 @@ import time class AutomaticshutdownPlugin(octoprint.plugin.TemplatePlugin, - octoprint.plugin.AssetPlugin, - octoprint.plugin.SimpleApiPlugin, - octoprint.plugin.EventHandlerPlugin, - octoprint.plugin.SettingsPlugin, - octoprint.plugin.StartupPlugin): + octoprint.plugin.AssetPlugin, + octoprint.plugin.SimpleApiPlugin, + octoprint.plugin.EventHandlerPlugin, + octoprint.plugin.SettingsPlugin, + octoprint.plugin.StartupPlugin): - def __init__(self): + def __init__(self): self.abortTimeout = 0 self.rememberCheckBox = False self.lastCheckBoxValue = False self._automatic_shutdown_enabled = False self._timeout_value = None - self._abort_timer = None - self._wait_for_timelapse_timer = None + self._abort_timer = None + self._wait_for_timelapse_timer = None def initialize(self): self.abortTimeout = self._settings.get_int(["abortTimeout"]) @@ -37,23 +37,23 @@ def initialize(self): if self.rememberCheckBox: self._automatic_shutdown_enabled = self.lastCheckBoxValue - def get_assets(self): - return dict(js=["js/automaticshutdown.js"]) - - def get_template_configs(self): - return [dict(type="sidebar", - name="Automatic Shutdown", - custom_bindings=False, - icon="power-off"), + def get_assets(self): + return dict(js=["js/automaticshutdown.js"]) + + def get_template_configs(self): + return [dict(type="sidebar", + name="Automatic Shutdown", + custom_bindings=False, + icon="power-off"), dict(type="settings", custom_bindings=False)] - def get_api_commands(self): - return dict(enable=[], - disable=[], - abort=[]) + def get_api_commands(self): + return dict(enable=[], + disable=[], + abort=[]) - def on_api_command(self, command, data): + def on_api_command(self, command, data): if not user_permission.can(): return make_response("Insufficient rights", 403) @@ -152,15 +152,15 @@ def _timer_task(self): self._abort_timer = None self._shutdown_system() - def _shutdown_system(self): - shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"]) - self._logger.info("Shutting down system with command: {command}".format(command=shutdown_command)) - try: - import sarge - p = sarge.run(shutdown_command, async=True) - except Exception as e: - self._logger.exception("Error when shutting down: {error}".format(error=e)) - return + def _shutdown_system(self): + shutdown_command = self._settings.global_get(["server", "commands", "systemShutdownCommand"]) + self._logger.info("Shutting down system with command: {command}".format(command=shutdown_command)) + try: + import sarge + p = sarge.run(shutdown_command, async_=True) + except Exception as e: + self._logger.exception("Error when shutting down: {error}".format(error=e)) + return def get_settings_defaults(self): return dict( @@ -189,17 +189,18 @@ def get_update_information(self): current=self._plugin_version, # update method: pip w/ dependency links - pip="https://github.com/OctoPrint/OctoPrint-AutomaticShutdown/archive/{target_version}.zip" + pip="https://github.com/adrcunha/OctoPrint-AutomaticShutdown/archive/{target_version}.zip" ) ) __plugin_name__ = "Automatic Shutdown" +__plugin_pythoncompat__ = ">=2.7,<4" def __plugin_load__(): - global __plugin_implementation__ - __plugin_implementation__ = AutomaticshutdownPlugin() + global __plugin_implementation__ + __plugin_implementation__ = AutomaticshutdownPlugin() - global __plugin_hooks__ - __plugin_hooks__ = { - "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information - } + global __plugin_hooks__ + __plugin_hooks__ = { + "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information + } diff --git a/setup.py b/setup.py index 2f50b7e..be8c6aa 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_name = "OctoPrint-AutomaticShutdown" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.4" +plugin_version = "0.1.5" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module @@ -27,7 +27,7 @@ plugin_author_email = "nicanor.romerovenier@bq.com" # The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module -plugin_url = "https://github.com/OctoPrint/OctoPrint-AutomaticShutdown" +plugin_url = "https://github.com/adrcunha/OctoPrint-AutomaticShutdown" # The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module plugin_license = "AGPLv3"