From d68949680246cfdb7f7c3816e63a3302558b88a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 1 Jun 2017 16:29:49 +0200 Subject: [PATCH 1/8] Fix stupid typo causing unnecessary creation of default profile --- src/octoprint/printer/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/printer/profile.py b/src/octoprint/printer/profile.py index fb9493c67..989e03fe7 100644 --- a/src/octoprint/printer/profile.py +++ b/src/octoprint/printer/profile.py @@ -228,7 +228,7 @@ class PrinterProfileManager(object): self._logger.info("Migrated default printer profile from settings to _default.profile: {!r}".format(default_overrides)) def _verify_default_available(self): - default_id = settings().get(["printerProfile", "default"]) + default_id = settings().get(["printerProfiles", "default"]) if default_id is None: default_id = "_default" From a681048df6249517a2b106896fc2db276c80100d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 1 Jun 2017 17:08:28 +0200 Subject: [PATCH 2/8] Enable blockWhileDwelling for Malyan printers See #1941 and #1762 --- src/octoprint/util/comm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 2c262e310..e409ca2c3 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1294,6 +1294,7 @@ class MachineCom(object): self._logger.info("Detected Malyan firmware, enabling relevant features for issue free communication") self._alwaysSendChecksum = True + self._blockWhileDwelling = True sd_always_available = self._sdAlwaysAvailable self._sdAlwaysAvailable = True From 8603ea4b6fa1e380a13bc002c1a7da0871bb33c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 14:20:06 +0200 Subject: [PATCH 3/8] Fix stupid typo causing printerProfileManager.set_default Thanks for the heads-up @erikheidstra! --- src/octoprint/printer/profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/printer/profile.py b/src/octoprint/printer/profile.py index 989e03fe7..7809325f6 100644 --- a/src/octoprint/printer/profile.py +++ b/src/octoprint/printer/profile.py @@ -342,7 +342,7 @@ class PrinterProfileManager(object): if identifier is not None and not identifier in all_identifiers: return - settings().set(["printerProfile", "default"], identifier) + settings().set(["printerProfiles", "default"], identifier) settings().save() def get_current_or_default(self): From d39c124f35b53a02b80134af28962fe26dc4b1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 14:25:02 +0200 Subject: [PATCH 4/8] Allow empty & custom size in print job events Thanks to @erikheidstra for the heads-up --- src/octoprint/printer/standard.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 75e6798b5..aa5428582 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -1174,8 +1174,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): except: self._logger.exception("Error while trying to persist print recovery data") - def _payload_for_print_job_event(self, location=None, print_job_file=None, position=None): - print_job_size = None + def _payload_for_print_job_event(self, location=None, print_job_file=None, print_job_size=None, position=None): if print_job_file is None: with self._selectedFileMutex: selected_file = self._selectedFile @@ -1186,7 +1185,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): print_job_size = selected_file.get("filesize", None) location = FileDestinations.SDCARD if selected_file.get("sd", False) else FileDestinations.LOCAL - if not print_job_file or not print_job_size or not location: + if not print_job_file or not location: return dict() if location == FileDestinations.SDCARD: From e3d44d7d0649cb05cdef65cd015568b1ad9526d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 16:05:12 +0200 Subject: [PATCH 5/8] Use client default if server default printer profile in unavailable --- .../static/js/app/viewmodels/printerprofiles.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/printerprofiles.js b/src/octoprint/static/js/app/viewmodels/printerprofiles.js index f19484a64..368f80ce1 100644 --- a/src/octoprint/static/js/app/viewmodels/printerprofiles.js +++ b/src/octoprint/static/js/app/viewmodels/printerprofiles.js @@ -476,8 +476,16 @@ $(function() { }); self.profiles.updateItems(items); self.defaultProfile(defaultProfile); - self.currentProfile(currentProfile); - self.currentProfileData(currentProfileData); + + if (currentProfile && currentProfileData) { + self.currentProfile(currentProfile); + self.currentProfileData(currentProfileData); + } else { + // shouldn't normally happen, but just to not have anything else crash... + log.warn("Current printer profile could not be detected, using default values"); + self.currentProfile(""); + self.currentProfileData(ko.mapping.fromJS(cleanProfile(), self.currentProfileData)); + } }; self.addProfile = function(callback) { From 3d3e0212c65f744f573a218490963266fce6f3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 16:06:00 +0200 Subject: [PATCH 6/8] Corewizard: Disable client if not required --- .../corewizard/static/js/corewizard.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/corewizard/static/js/corewizard.js b/src/octoprint/plugins/corewizard/static/js/corewizard.js index 1c37e2666..b59b676b2 100644 --- a/src/octoprint/plugins/corewizard/static/js/corewizard.js +++ b/src/octoprint/plugins/corewizard/static/js/corewizard.js @@ -11,6 +11,8 @@ $(function() { self.setup = ko.observable(false); self.decision = ko.observable(); + self.required = false; + self.passwordMismatch = ko.pureComputed(function() { return self.password() != self.confirmedPassword(); }); @@ -72,6 +74,8 @@ $(function() { }; self.onBeforeWizardTabChange = function(next, current) { + if (!self.required) return true; + if (!current || !_.startsWith(current, "wizard_plugin_corewizard_acl_") || self.setup()) { return true; } @@ -82,7 +86,13 @@ $(function() { return false; }; + self.onWizardDetails = function(response) { + self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.acl && response.corewizard.details.acl.required; + }; + self.onWizardFinish = function() { + if (!self.required) return; + if (!self.decision()) { return "reload"; } @@ -94,7 +104,14 @@ $(function() { self.settingsViewModel = parameters[0]; + self.required = false; + + self.onWizardDetails = function(response) { + self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.webcam && response.corewizard.details.webcam.required; + }; + self.onWizardFinish = function() { + if (!self.required) return; if (self.settingsViewModel.webcam_streamUrl() || (self.settingsViewModel.webcam_snapshotUrl() && self.settingsViewModel.webcam_ffmpegPath())) { return "reload"; @@ -113,18 +130,29 @@ $(function() { self.printerProfiles = parameters[0]; + self.required = false; + self.editor = self.printerProfiles.createProfileEditor(); self.editorLoaded = ko.observable(false); - self.onStartup = function() { + self.onWizardDetails = function(response) { + self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.printerprofile && response.corewizard.details.printerprofile.required; + if (!self.required) return; + OctoPrint.printerprofiles.get("_default") .done(function(data) { self.editor.fromProfileData(data); self.editorLoaded(true); + }) + .fail(function() { + self.editor.fromProfileData(); + self.editorLoaded(true); }); }; self.onWizardFinish = function() { + if (!self.required) return; + OctoPrint.printerprofiles.update("_default", self.editor.toProfileData()) .done(function() { self.printerProfiles.requestData(); From 5d321926bbda51f25f25f712dceee4118cb08fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 16:06:11 +0200 Subject: [PATCH 7/8] Corewizard: Don't load js if not required --- src/octoprint/plugins/corewizard/__init__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index d9c61f67d..e2b1851fc 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -49,9 +49,12 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, #~~ AssetPlugin API def get_assets(self): - return dict( - js=["js/corewizard.js"] - ) + if self.is_wizard_required(): + return dict( + js=["js/corewizard.js"] + ) + else: + return dict() #~~ WizardPlugin API @@ -74,7 +77,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, return self._user_manager.enabled and not self._user_manager.hasBeenCustomized() def _get_acl_wizard_details(self): - return dict() + return dict(required=self._is_acl_wizard_required()) def _get_acl_wizard_name(self): return gettext("Access Control") @@ -119,7 +122,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, return not (webcam_snapshot_url and webcam_stream_url and ffmpeg_path) def _get_webcam_wizard_details(self): - return dict() + return dict(required=self._is_webcam_wizard_required()) def _get_webcam_wizard_name(self): return gettext("Webcam & Timelapse") @@ -134,7 +137,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, return not (system_shutdown_command and system_restart_command and server_restart_command) def _get_servercommands_wizard_details(self): - return dict() + return dict(required=self._is_servercommands_wizard_required()) def _get_servercommands_wizard_name(self): return gettext("Server Commands") @@ -145,7 +148,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin, return self._printer_profile_manager.is_default_unmodified() and self._printer_profile_manager.profile_count == 1 def _get_printerprofile_wizard_details(self): - return dict() + return dict(required=self._is_printerprofile_wizard_required()) def _get_printerprofile_wizard_name(self): return gettext("Default Printer Profile") From 9e207ca8a116c3d145123475b51b1938d815fd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 2 Jun 2017 16:27:25 +0200 Subject: [PATCH 8/8] SWU: Force exact version update for OctoPrint when tracking releases --- src/octoprint/plugins/softwareupdate/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index ee0df3dad..b322e1842 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -917,8 +917,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, result["force_base"] = False if check.get("update_script", None): - # if we are using the update_script, we need to set our update_branch and force - # to install the exact version we requested + # if we are using the update_script, we need to set our update_branch if check.get("prerelease", None): # we are tracking prereleases => we want to be on the correct prerelease channel/branch @@ -928,14 +927,13 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, # in case it's not already set result["update_branch"] = check.get("update_branch", channel) - # we also force our target version in the update - result["force_exact_version"] = True - else: # we are not tracking prereleases, but aren't on the stable branch either => switch back # to stable branch on update result["update_branch"] = check.get("update_branch", stable_branch) + # we also force an exact version + result["force_exact_version"] = True if BRANCH != result.get("prerelease_channel"): # we force python unequality check here because that will also allow us to