diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index 595c91d0d..0b5033def 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -485,6 +485,50 @@ GCODE analysis information - 0..1 - Float - The minimum Z coordinate of the printed model, in mm + * - ``travelArea`` + - 0..1 + - Object + - Information regarding the bounding box of all moves + * - ``travelArea.maxX`` + - 0..1 + - Float + - The maximum X coordinate of all moves, in mm + * - ``travelArea.maxY`` + - 0..1 + - Float + - The maximum Y coordinate of all moves, in mm + * - ``travelArea.maxZ`` + - 0..1 + - Float + - The maximum Z coordinate of all moves, in mm + * - ``travelArea.minX`` + - 0..1 + - Float + - The minimum X coordinate of all moves, in mm + * - ``travelArea.minY`` + - 0..1 + - Float + - The minimum Y coordinate of all moves, in mm + * - ``travelArea.minZ`` + - 0..1 + - Float + - The minimum Z coordinate of all moves, in mm + * - ``travelDimensions`` + - 0..1 + - Object + - Information regarding the size of the travel area + * - ``travelDimensions.depth`` + - 0..1 + - Float + - The depth of the travel area, in mm + * - ``travelDimensions.height`` + - 0..1 + - Float + - The height of the travel area, in mm + * - ``travelDimensions.width`` + - 0..1 + - Float + - The width of the travel area, in mm .. _sec-api-datamodel-files-ref: diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index baa7e5519..71bf107cc 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -764,6 +764,10 @@ Use the following settings to configure the serial connection to the printer: # during connect. waitForStartOnConnect: false + # Specifies whether OctoPrint should wait to load the SD card file list until the first firmware capability + # report is processed. + waitToLoadSdFileList: false + # Specifies whether OctoPrint should send linenumber + checksum with every printer command. Needed for # successful communication with Repetier firmware alwaysSendChecksum: false diff --git a/docs/plugins/controlproperties.rst b/docs/plugins/controlproperties.rst index b5905fa07..48fdd5b52 100644 --- a/docs/plugins/controlproperties.rst +++ b/docs/plugins/controlproperties.rst @@ -53,6 +53,11 @@ The following properties are recognized: ``__plugin_license__`` License of your plugin, optional, overrides the license specified in ``setup.py`` if provided. +.. _sec-plugins-controlproperties-plugin_privacypolicy: + +``__plugin_privacypolicy__`` + URL of the privacy policy of your plugin, optional. + .. _sec-plugins-controlproperties-plugin_pythoncompat: ``__plugin_pythoncompat__`` diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index 47822eb48..bf4207bea 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -509,6 +509,30 @@ octoprint.comm.protocol.firmware.capabilities .. _sec-plugins-hook-comm-protocol-action: +octoprint.comm.protocol.firmware.capability_report +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. py:function:: firmware_capability_report_hook(comm_instance, firmware_capabilities, *args, **kwargs) + + .. versionadded:: 1.9.0 + + Be notified when all capability report entries are received from the printer. + + Hook handlers may use this to react to the end of the custom firmware capability report. OctoPrint parses the received + capability lines and provides a dictionary of all reported capabilities and whether they're enabled to the handler. + + .. warning:: + + Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as + you will effectively block the receive loop, causing the communication with the printer to stall. + + This includes I/O of any kind. + + :param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook. + :param dict firmware_capabilities: Reported capabilities (capability name mapped to enabled flag) + +.. _sec-plugins-hook-comm-protocol-action: + octoprint.comm.protocol.action ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/octoprint/cli/analysis.py b/src/octoprint/cli/analysis.py index 617663b84..1bd3c63bc 100644 --- a/src/octoprint/cli/analysis.py +++ b/src/octoprint/cli/analysis.py @@ -13,7 +13,7 @@ click.disable_unicode_literals_warning = True dimensions = ("depth", "height", "width") -printing_area = ("maxX", "maxY", "maxZ", "minX", "minY", "minZ") +area = ("maxX", "maxY", "maxZ", "minX", "minY", "minZ") def empty_result(result): @@ -37,15 +37,21 @@ def validate_result(result): if "dimensions" not in result or not validate_dict(result["dimensions"], dimensions): return False + if "travel_dimensions" not in result or not validate_dict( + result["travel_dimensions"], dimensions + ): + return False + if "extrusion_length" not in result or not validate_list(result["extrusion_length"]): return False if "extrusion_volume" not in result or not validate_list(result["extrusion_volume"]): return False - if "printing_area" not in result or not validate_dict( - result["printing_area"], printing_area - ): + if "printing_area" not in result or not validate_dict(result["printing_area"], area): + return False + + if "travel_area" not in result or not validate_dict(result["travel_area"], area): return False if "total_time" not in result or invalid_float(result["total_time"]): diff --git a/src/octoprint/filemanager/analysis.py b/src/octoprint/filemanager/analysis.py index b6c01de93..6eea16c47 100644 --- a/src/octoprint/filemanager/analysis.py +++ b/src/octoprint/filemanager/analysis.py @@ -27,7 +27,16 @@ EMPTY_RESULT = { "minZ": 0, "maxZ": 0, }, + "travelArea": { + "minX": 0, + "maxX": 0, + "minY": 0, + "maxY": 0, + "minZ": 0, + "maxZ": 0, + }, "dimensions": {"width": 0, "height": 0, "depth": 0}, + "travelDimensions": {"width": 0, "height": 0, "depth": 0}, "filament": {}, } @@ -390,6 +399,28 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): * Depth of the printed model along the Y axis, in mm - * ``dimensions.height`` * Height of the printed model along the Z axis, in mm + - * ``travelArea`` + * Bounding box of all machine movements (minimum and maximum coordinates) + - * ``travelArea.minX`` + * Minimum X coordinate of the machine movement + - * ``travelArea.maxX`` + * Maximum X coordinate of the machine movement + - * ``travelArea.minY`` + * Minimum Y coordinate of the machine movement + - * ``travelArea.maxY`` + * Maximum Y coordinate of the machine movement + - * ``travelArea.minZ`` + * Minimum Z coordinate of the machine movement + - * ``travelArea.maxZ`` + * Maximum Z coordinate of the machine movement + - * ``travelDimensions`` + * Dimensions of the travel area in X, Y, Z + - * ``travelDimensions.width`` + * Width of the travel area along the X axis, in mm + - * ``travelDimensions.depth`` + * Depth of the travel area along the Y axis, in mm + - * ``travelDimensions.height`` + * Height of the travel area along the Z axis, in mm """ def __init__(self, finished_callback): @@ -406,7 +437,14 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): if self._current.analysis and all( map( lambda x: x in self._current.analysis, - ("printingArea", "dimensions", "estimatedPrintTime", "filament"), + ( + "printingArea", + "dimensions", + "travelArea", + "travelDimensions", + "estimatedPrintTime", + "filament", + ), ) ): return self._current.analysis @@ -499,6 +537,8 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): result["printingArea"] = analysis["printing_area"] result["dimensions"] = analysis["dimensions"] + result["travelArea"] = analysis["travel_area"] + result["travelDimensions"] = analysis["travel_dimensions"] if analysis["total_time"]: result["estimatedPrintTime"] = analysis["total_time"] * 60 if analysis["extrusion_length"]: diff --git a/src/octoprint/filemanager/storage.py b/src/octoprint/filemanager/storage.py index ef64fc954..e4ae04bdf 100644 --- a/src/octoprint/filemanager/storage.py +++ b/src/octoprint/filemanager/storage.py @@ -445,8 +445,7 @@ class StorageError(Exception): NOT_EMPTY = "not_empty" def __init__(self, message, code=None, cause=None): - BaseException.__init__(self) - self.message = message + Exception.__init__(self, message) self.cause = cause if code is None: diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 411ea6004..0d8fe2246 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -177,6 +177,9 @@ class ControlProperties: attr_license = "__plugin_license__" """ Module attribute from which to retrieve the plugin's license. """ + attr_privacypolicy = "__plugin_privacypolicy__" + """ Module attribute from which to retrieve the plugin's privacy policy URL, if any. """ + attr_pythoncompat = "__plugin_pythoncompat__" """ Module attribute from which to retrieve the plugin's python compatibility string. @@ -617,6 +620,19 @@ class PluginInfo: ControlProperties.attr_license, default=self._license, incl_metadata=True ) + @property + def privacypolicy(self): + """ + Privacy Policy URL of the plugin. Will be taken from the privacy policy attribute of the plugin module + as defined in :attr:`attr_privacypolicy` if available. May be None. + + Returns: + str or None: Privacy Policy URL of the plugin. + """ + return self._get_instance_attribute( + ControlProperties.attr_privacypolicy, default=None, incl_metadata=True + ) + @property def pythoncompat(self): """ diff --git a/src/octoprint/plugins/corewizard/subwizards.py b/src/octoprint/plugins/corewizard/subwizards.py index 2a2e04fac..42b9ee04e 100644 --- a/src/octoprint/plugins/corewizard/subwizards.py +++ b/src/octoprint/plugins/corewizard/subwizards.py @@ -85,7 +85,7 @@ class AclSubwizard: ): abort(404) - data = request.get_json() + data = request.get_json(silent=True) if data is None: data = request.values diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 9a0dae841..1063aa5d1 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -66,6 +66,8 @@ def map_repository_entry(entry): if "follow_dependency_links" not in result: result["follow_dependency_links"] = False + if "privacypolicy" not in result: + result["privacypolicy"] = False result["is_compatible"] = {"octoprint": True, "os": True, "python": True} @@ -1998,6 +2000,7 @@ class PluginManagerPlugin( "version": plugin.version, "url": plugin.url, "license": plugin.license, + "privacypolicy": plugin.privacypolicy, "python": plugin.pythoncompat, "bundled": plugin.bundled, "managable": plugin.managable, diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index aaea76ef1..49bcf6705 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -149,12 +149,13 @@
" + - _.sprintf( - gettext( - "Object in %(name)s exceeds the print volume of the currently selected printer profile, be careful when printing this." - ), - {name: _.escape(data.name)} - ) + - "
"; var info = ""; + var objectFits = true; + var travelFits = true; - var formatData = { - profile: boundaries, - object: printingArea - }; - - // find exceeded dimensions - if ( - printingArea["minX"] < boundaries["minX"] || - printingArea["maxX"] > boundaries["maxX"] - ) { - info += gettext("Object exceeds print volume in width." + + _.sprintf( + gettext( + "%(culprit)s in %(name)s exceeds the print volume of the currently selected printer profile, be careful when printing this." + ), + formatData + ) + + "
"; + warning += pnotifyAdditionalInfo(info); warning += 'You can disable this check via Settings > Features > "Enable model size detection [...]"
'; + //warn user new PNotify({ - title: gettext("Object doesn't fit print volume"), + title: _.sprintf( + gettext("%(culprit)s exceeds print volume"), + formatData + ), text: warning, type: "warning", hide: false }); } return false; - } else { - return true; } }; @@ -1420,7 +1468,7 @@ $(function () { self.uploadProgress.addClass("progress-striped").addClass("active"); self.uploadProgressBar.css("width", "100%"); if (payload.progressAvailable) { - self.uploadProgressPercentage(percentage); + self.uploadProgressPercentage(0); self.uploadProgressText( _.sprintf(gettext("Slicing ... (%(percentage)d%%)"), {percentage: 0}) ); @@ -1566,12 +1614,13 @@ $(function () { url: url, dataType: "json", dropZone: enable ? drop : null, + sequentialUploads: true, drop: function (e, data) {}, add: self._handleUploadAdd, submit: self._handleUploadStart, done: self._handleUploadDone, fail: self._handleUploadFail, - always: self._handleUploadAlways, + stop: self._handleUploadStop, progressall: self._handleUploadProgress }); }; @@ -1600,6 +1649,88 @@ $(function () { } }; + self._uploadExistsQueue = []; // Files will be in this queue if their test fails and something needs to be done + self._uploadExistsOpen = false; + + self._processUploadQueue = function () { + if (!self._uploadExistsQueue.length > 0 || self._uploadExistsOpen) return; + + const hideAndSubmit = function (data) { + self.uploadExistsDialog.modal("hide"); + self._uploadExistsOpen = false; + data.submit(); + // Recursively move on to process the queue every time a dialog is closed + if (self._uploadExistsQueue.length > 0) { + self._processUploadQueue(); + } + }; + + // Collect an item from the queue that needs an overwrite dialog + const {data, response, path, fileSizeTooBig} = + self._uploadExistsQueue.shift(); + const file = data.files[0]; + + const formData = {}; + if (path !== "") { + formData.path = path; + } + + // Build and show a dialog + self._uploadExistsOpen = true; + + $("h3", self.uploadExistsDialog).text( + _.sprintf(gettext("File already exists: %(name)s"), { + name: file.name + }) + ); + $("p, form", self.uploadExistsDialog).toggle(!fileSizeTooBig); + $("span", self.uploadExistsDialog).toggle(fileSizeTooBig); + $("input", self.uploadExistsDialog) + .val("") + .prop("placeholder", response.suggestion); + $("a.upload-rename", self.uploadExistsDialog) + .toggle(!fileSizeTooBig) + .prop("disabled", false) + .off("click") + .on("click", function () { + var newName = $("input", self.uploadExistsDialog).val(); + if (newName === "") newName = response.suggestion; + + OctoPrint.files.exists("local", path, newName).done(function (r) { + if (r.exists) { + $(".control-group", self.uploadExistsDialog).addClass( + "error" + ); + $(".help-block", self.uploadExistsDialog).show(); + } else { + $(".control-group", self.uploadExistsDialog).removeClass( + "error" + ); + $(".help-block", self.uploadExistsDialog).hide(); + + formData.filename = newName; + formData.noOverwrite = true; + data.formData = formData; + + hideAndSubmit(data); + } + }); + }); + if (self.loginState.hasPermission(self.access.permissions.FILES_DELETE)) { + $("a.upload-overwrite", self.uploadExistsDialog) + .off("click") + .show() + .on("click", function () { + data.formData = formData; + hideAndSubmit(data); + }); + } else { + $("a.upload-overwrite", self.uploadExistsDialog).hide(); + } + + self.uploadExistsDialog.modal("show"); + }; + self._handleUploadAdd = function (e, data) { var file = data.files[0]; var path = self.currentPath(); @@ -1615,73 +1746,15 @@ $(function () { .exists("local", path, file.name) .done(function (response) { if (response.exists) { - $("h3", self.uploadExistsDialog).text( - _.sprintf(gettext("File already exists: %(name)s"), { - name: file.name - }) - ); - $("p, form", self.uploadExistsDialog).toggle(!fileSizeTooBig); - $("span", self.uploadExistsDialog).toggle(fileSizeTooBig); - $("input", self.uploadExistsDialog).val(response.suggestion); - $("a.upload-rename", self.uploadExistsDialog) - .toggle(!fileSizeTooBig) - .prop("disabled", false) - .off("click") - .on("click", function () { - var newName = $( - "input", - self.uploadExistsDialog - ).val(); - - OctoPrint.files - .exists("local", path, newName) - .done(function (r) { - if (r.exists) { - $( - ".control-group", - self.uploadExistsDialog - ).addClass("error"); - $( - ".help-block", - self.uploadExistsDialog - ).show(); - } else { - $( - ".control-group", - self.uploadExistsDialog - ).removeClass("error"); - $( - ".help-block", - self.uploadExistsDialog - ).hide(); - - self.uploadExistsDialog.modal("hide"); - - formData.filename = newName; - formData.noOverwrite = true; - data.formData = formData; - - data.submit(); - } - }); - }); - if ( - self.loginState.hasPermission( - self.access.permissions.FILES_DELETE - ) - ) { - $("a.upload-overwrite", self.uploadExistsDialog) - .off("click") - .show() - .on("click", function () { - self.uploadExistsDialog.modal("hide"); - data.formData = formData; - data.submit(); - }); - } else { - $("a.upload-overwrite", self.uploadExistsDialog).hide(); - } - self.uploadExistsDialog.modal("show"); + const queueEntry = { + data, + response, + path, + fileSizeTooBig + }; + self._uploadExistsQueue.push(queueEntry); + // Start processing queue - if already processing, this will do nothing + self._processUploadQueue(); } else { data.formData = formData; data.submit(); @@ -1726,32 +1799,46 @@ $(function () { }; self._handleUploadDone = function (e, data) { - self._setProgressBar(100, gettext("Refreshing list ..."), true); - var focus = undefined; if (data.result.files.hasOwnProperty("sdcard")) { focus = {location: "sdcard", path: data.result.files.sdcard.path}; } else if (data.result.files.hasOwnProperty("local")) { focus = {location: "local", path: data.result.files.local.path}; } - self.requestData({focus: focus}).done(function () { - if (data.result.done) { - self._setProgressBar(0, "", false); - } - }); + + if (focus) { + self._filesToFocus.push(focus); + } if (focus && _.endsWith(focus.path.toLowerCase(), ".stl")) { self.slicing.show(focus.location, focus.path); } }; + self._handleUploadStop = function (e, data) { + var reset = function () { + self.ignoreUpdatedFilesEvent = false; + self._setProgressBar(0, "", false); + }; + + if (self._filesToFocus.length > 0) { + // Only refresh the list if there were files uploaded successfully + self._setProgressBar(100, gettext("Refreshing list ..."), true); + self.requestData({focus: self._filesToFocus}).always(function () { + reset(); + }); + } else { + reset(); + } + }; + self._handleUploadFail = function (e, data) { var extensions = _.map(SUPPORTED_EXTENSIONS, function (extension) { return extension.toLowerCase(); }).sort(); extensions = extensions.join(", "); - var error = ""; + var error = "
" + _.escape(data.files[0].name) + "
"; switch (data.jqXHR.status) { case 409: // already printing or otherwise busy @@ -1796,11 +1883,6 @@ $(function () { type: "error", hide: false }); - self._setProgressBar(0, "", false); - }; - - self._handleUploadAlways = function (e, data) { - self.ignoreUpdatedFilesEvent = false; }; self._handleUploadProgress = function (e, data) { diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 1762d5b74..a3e628637 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -209,6 +209,7 @@ $(function () { self.serial_serialErrorBehaviour = ko.observable("cancel"); self.serial_triggerOkForM29 = ko.observable(undefined); self.serial_waitForStart = ko.observable(undefined); + self.serial_waitToLoadSdFileList = ko.observable(undefined); self.serial_sendChecksum = ko.observable("print"); self.serial_sendChecksumWithUnknownCommands = ko.observable(undefined); self.serial_unknownCommandsNeedAck = ko.observable(undefined); @@ -391,6 +392,7 @@ $(function () { self.observableCopies = { feature_waitForStart: "serial_waitForStart", + feature_waitToLoadSdFileList: "serial_waitToLoadSdFileList", feature_sendChecksum: "serial_sendChecksum", feature_sdRelativePath: "serial_sdRelativePath", feature_sdAlwaysAvailable: "serial_sdAlwaysAvailable", diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 885b86d25..2a147052a 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -453,6 +453,12 @@ {{ _('Try checking this if you run into connection timeouts due to your printer taking too long to respond to OctoPrint\'s handshake attempts on connect.') }}