diff --git a/src/octoprint/plugins/cura/__init__.py b/src/octoprint/plugins/cura/__init__.py index 30de8874..4dab650f 100644 --- a/src/octoprint/plugins/cura/__init__.py +++ b/src/octoprint/plugins/cura/__init__.py @@ -16,6 +16,8 @@ import octoprint.util import octoprint.slicing import octoprint.settings +from octoprint.util.paths import normalize as normalize_path + from .profile import Profile class CuraPlugin(octoprint.plugin.SlicerPlugin, @@ -156,7 +158,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin, ##~~ SlicerPlugin API def is_slicer_configured(self): - cura_engine = self._settings.get(["cura_engine"]) + cura_engine = normalize_path(self._settings.get(["cura_engine"])) if cura_engine is not None and os.path.exists(cura_engine): return True else: @@ -230,7 +232,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin, engine_settings = self._convert_to_engine(profile_path, printer_profile, posX, posY) - executable = self._settings.get(["cura_engine"]) + executable = normalize_path(self._settings.get(["cura_engine"])) if not executable: return False, "Path to CuraEngine is not configured " diff --git a/src/octoprint/plugins/cura/static/js/cura.js b/src/octoprint/plugins/cura/static/js/cura.js index 23068292..99820e2e 100644 --- a/src/octoprint/plugins/cura/static/js/cura.js +++ b/src/octoprint/plugins/cura/static/js/cura.js @@ -6,6 +6,13 @@ $(function() { self.settingsViewModel = parameters[1]; self.slicingViewModel = parameters[2]; + self.pathBroken = ko.observable(false); + self.pathOk = ko.observable(false); + self.pathText = ko.observable(); + self.pathHelpVisible = ko.computed(function() { + return self.pathBroken() || self.pathOk(); + }); + self.fileName = ko.observable(); self.placeholderName = ko.observable(); @@ -157,6 +164,36 @@ $(function() { $("#settings_plugin_cura_import").modal("show"); }; + self.testEnginePath = function() { + $.ajax({ + url: API_BASEURL + "util/test", + type: "POST", + dataType: "json", + data: JSON.stringify({ + command: "path", + path: self.settings.plugins.cura.cura_engine(), + check_type: "file", + check_access: "x" + }), + contentType: "application/json; charset=UTF-8", + success: function(response) { + if (!response.result) { + if (!response.exists) { + self.pathText(gettext("The path doesn't exist")); + } else if (!response.typeok) { + self.pathText(gettext("The path is not a file")); + } else if (!response.access) { + self.pathText(gettext("The path is not an executable")); + } + } else { + self.pathText(gettext("The path is valid")); + } + self.pathOk(response.result); + self.pathBroken(!response.result); + } + }) + }; + self.requestData = function() { $.ajax({ url: API_BASEURL + "slicing/cura/profiles", @@ -184,6 +221,12 @@ $(function() { self.settings = self.settingsViewModel.settings; self.requestData(); }; + + self.onSettingsHidden = function() { + self.pathBroken(false); + self.pathOk(false); + self.pathText(""); + }; } // view model class, parameters for constructor, container to bind to @@ -192,4 +235,4 @@ $(function() { ["loginStateViewModel", "settingsViewModel", "slicingViewModel"], "#settings_plugin_cura" ]); -}); \ No newline at end of file +}); diff --git a/src/octoprint/plugins/cura/templates/cura_settings.jinja2 b/src/octoprint/plugins/cura/templates/cura_settings.jinja2 index 6779f95c..1cacf658 100644 --- a/src/octoprint/plugins/cura/templates/cura_settings.jinja2 +++ b/src/octoprint/plugins/cura/templates/cura_settings.jinja2 @@ -1,10 +1,14 @@