From 69dec6e83fccdded026c33c35a35aa1c5285ae00 Mon Sep 17 00:00:00 2001 From: Daniele Forsi Date: Sat, 29 Jul 2017 16:12:08 +0200 Subject: [PATCH 1/6] Fix typos in strings and comments Those typos were found with codespell which is available from https://github.com/lucasdemarchi/codespell.git --- docs/events/index.rst | 2 +- docs/jsclientlib/base.rst | 2 +- docs/jsclientlib/util.rst | 2 +- src/octoprint/printer/standard.py | 2 +- src/octoprint/static/js/app/main.js | 10 +++++----- src/octoprint/static/js/app/viewmodels/slicing.js | 2 +- src/octoprint/static/js/app/viewmodels/system.js | 2 +- src/octoprint/templates/tabs/terminal.jinja2 | 2 +- src/octoprint/util/__init__.py | 2 +- src/octoprint/util/comm.py | 4 ++-- src/octoprint_client/__init__.py | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/events/index.rst b/docs/events/index.rst index 225331f5a..4e675c8f8 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -237,7 +237,7 @@ UpdatedFiles .. deprecated:: 1.2.0 - The ``gcode`` modification type has been superceeded by ``printables``. It is currently still available for + The ``gcode`` modification type has been superseded by ``printables``. It is currently still available for reasons of backwards compatibility and will also be sent on modification of ``printables``. It will however be removed with 1.4.0. diff --git a/docs/jsclientlib/base.rst b/docs/jsclientlib/base.rst index d393f27e2..618299fd1 100644 --- a/docs/jsclientlib/base.rst +++ b/docs/jsclientlib/base.rst @@ -119,7 +119,7 @@ :param string method: The HTTP method to use for the request (optional) :param string url: The URL to perform the request against (optional) :param object data: The data to send in the request body (optional) - :param object opts: Additonal options to use for the request (optional) + :param object opts: Additional options to use for the request (optional) :returns Promise: A `jQuery Promise `_ for the request's response .. js:function:: OctoPrintClient.get(url, opts) diff --git a/docs/jsclientlib/util.rst b/docs/jsclientlib/util.rst index 6168e1af5..74b10cbea 100644 --- a/docs/jsclientlib/util.rst +++ b/docs/jsclientlib/util.rst @@ -21,7 +21,7 @@ .. js:function:: OctoPrintClient.util.testPath(path, additional, opts) - Test the provided ``path`` for existance. More test criteria supported by the :ref:`path test command ` + Test the provided ``path`` for existence. More test criteria supported by the :ref:`path test command ` can be provided via the ``additional`` object. **Example 1** diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 873dfec2f..184bb564e 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -958,7 +958,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): }) callback.on_printer_send_initial_data(data) except: - self._logger.exception("Error while trying to send inital state update") + self._logger.exception("Error while trying to send initial state update") def _getStateFlags(self): return { diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index 5960bc7b9..be684ab63 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -125,7 +125,7 @@ $(function() { return exports; })(); - log.debug("Browser enviroment:", OctoPrint.coreui.browser); + log.debug("Browser environment:", OctoPrint.coreui.browser); //~~ AJAX setup @@ -180,7 +180,7 @@ $(function() { gettext("Printing"), gettext("Paused"), gettext("Closed"), - gettext("Transfering file to SD") + gettext("Transferring file to SD") ]; //~~ Initialize PNotify @@ -340,7 +340,7 @@ $(function() { continue; } - // we could resolve the depdendencies and the view model is not defined yet => add it, it's now fully processed + // we could resolve the dependencies and the view model is not defined yet => add it, it's now fully processed var viewModelBindTargets = viewModel.elements; if (additionalBindings.hasOwnProperty(viewModel.name)) { @@ -672,7 +672,7 @@ $(function() { * onServerConnect below takes care of the passive login. Only once that's completed it tells * our DataUpdater that it's ok to trigger any callbacks in view models. On the initial * server connect (during first initialization) we also trigger the settings fetch and - * binding proceedure once that's done, but only then. + * binding procedure once that's done, but only then. * * Or, as a fancy diagram: https://gist.githubusercontent.com/foosel/0cdc3a03cf5311804271f12e87293c0c/raw/abc84fdc3b13030d70961539d9c132ae39c32085/octoprint_web_startup.txt */ @@ -686,7 +686,7 @@ $(function() { // passive login request. // // This is to ensure that we have no concurrent requests triggered by socket events - // overriding each other's session during app intialization + // overriding each other's session during app initialization dataUpdater.initialized(); }); }; diff --git a/src/octoprint/static/js/app/viewmodels/slicing.js b/src/octoprint/static/js/app/viewmodels/slicing.js index d2d47098a..a02a6a5eb 100644 --- a/src/octoprint/static/js/app/viewmodels/slicing.js +++ b/src/octoprint/static/js/app/viewmodels/slicing.js @@ -15,7 +15,7 @@ $(function() { self.defaultProfile = undefined; self.destinationFilename = ko.observable(); - self.gcodeFilename = self.destinationFilename; // TODO: for backwards compatiblity, mark deprecated ASAP + self.gcodeFilename = self.destinationFilename; // TODO: for backwards compatibility, mark deprecated ASAP self.title = ko.observable(); self.slicer = ko.observable(); diff --git a/src/octoprint/static/js/app/viewmodels/system.js b/src/octoprint/static/js/app/viewmodels/system.js index 6b3002c0f..7637c04ac 100644 --- a/src/octoprint/static/js/app/viewmodels/system.js +++ b/src/octoprint/static/js/app/viewmodels/system.js @@ -51,7 +51,7 @@ $(function() { if (commandSpec.async) { text = gettext("The command \"%(command)s\" executed successfully"); } else { - text = gettext("The command \"%(command)s\" was triggered asychronously"); + text = gettext("The command \"%(command)s\" was triggered asynchronously"); } new PNotify({ diff --git a/src/octoprint/templates/tabs/terminal.jinja2 b/src/octoprint/templates/tabs/terminal.jinja2 index d86b18f84..ea351e5c2 100644 --- a/src/octoprint/templates/tabs/terminal.jinja2 +++ b/src/octoprint/templates/tabs/terminal.jinja2 @@ -27,7 +27,7 @@

- {{ _("If acknowledgements (\"ok\"s) sent by the firmware get lost due to issues with the serial communication to your printer, OctoPrint's communication with it can become stuck. If that happens, this can help. Please be advised that such occurences hint at general communication issues with your printer which will probably negatively influence your printing results and which you should therefore try to resolve!") }} + {{ _("If acknowledgements (\"ok\"s) sent by the firmware get lost due to issues with the serial communication to your printer, OctoPrint's communication with it can become stuck. If that happens, this can help. Please be advised that such occurrences hint at general communication issues with your printer which will probably negatively influence your printing results and which you should therefore try to resolve!") }}

diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 950946cf8..862347c70 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -2,7 +2,7 @@ from __future__ import absolute_import """ -This module bundles commonly used utility methods or helper classes that are used in multiple places withing +This module bundles commonly used utility methods or helper classes that are used in multiple places within OctoPrint's source code. """ from __future__ import absolute_import, division, print_function diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index cdad51302..b1782f680 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -578,7 +578,7 @@ class MachineCom(object): if state == self.STATE_CLOSED_WITH_ERROR: return "Offline: %s" % (self.getErrorString()) if state == self.STATE_TRANSFERING_FILE: - return "Transfering file to SD" + return "Transferring file to SD" return "Unknown State (%d)" % (self._state) def getErrorString(self): @@ -1953,7 +1953,7 @@ class MachineCom(object): #Also skip errors with the SD card pass elif 'unknown command' in lower_line: - #Ignore unkown command errors, it could be a typo or some missing feature + #Ignore unknown command errors, it could be a typo or some missing feature pass elif not self.isError(): error_text = line[6:] if lower_line.startswith("error:") else line[2:] diff --git a/src/octoprint_client/__init__.py b/src/octoprint_client/__init__.py index 33afec862..49adb5618 100644 --- a/src/octoprint_client/__init__.py +++ b/src/octoprint_client/__init__.py @@ -164,7 +164,7 @@ class SocketClient(object): If no timeout is provided, the method will block until the connection could be re-established. - If disconnect is set to ``True`` will disconnect the socket explictly + If disconnect is set to ``True`` will disconnect the socket explicitly first if it is currently connected. Arguments: From 56ad1841d4b2645a053cc01a65a02fde80059346 Mon Sep 17 00:00:00 2001 From: Teja Date: Fri, 8 Sep 2017 16:20:37 +0200 Subject: [PATCH 2/6] added decorator for before firstrun only calls. --- src/octoprint/server/util/flask.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 682b90538..2d0a76f8b 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -1110,6 +1110,23 @@ def restricted_access(func): return decorated_view +def firstrun_only_access(func): + """ + If you decorate a view with this, it will ensure that first setup has _not_ been + done for OctoPrint's Access Control. Otherwise it + will cause a HTTP 403 status code to be returned by the decorated resource. + """ + @functools.wraps(func) + def decorated_view(*args, **kwargs): + # if OctoPrint has been set up yet, abort + if settings().getBoolean(["server", "firstRun"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()): + return func(*args, **kwargs) + else: + return flask.make_response("OctoPrint is already setup, this resource is not longer available.", 403) + + return decorated_view + + class AppSessionManager(object): VALIDITY_UNVERIFIED = 1 * 60 # 1 minute From 791f0457fb007c2ba8ab9b15f8d9be26ff6b2230 Mon Sep 17 00:00:00 2001 From: Luke McKechnie Date: Thu, 21 Sep 2017 09:30:10 -0400 Subject: [PATCH 3/6] Fix for SharedNozzle, replicating temp from current tool to all tools. Issue # 2077 --- AUTHORS.md | 1 + src/octoprint/util/comm.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index a56725a75..c7f585f86 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -81,6 +81,7 @@ date of first contribution): * [Shawn Bruce](https://github.com/kantlivelong) * [Claudiu Ceia] (https://github.com/ClaudiuCeia) * [Goswin von Brederlow](https://github.com/mrvn) + * [Luke McKechnie](https://github.com/galamdring) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index ecd0a74e0..dbfe7029c 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1130,7 +1130,7 @@ class MachineCom(object): def _processTemperatures(self, line): current_tool = self._currentTool if self._currentTool is not None else 0 maxToolNum, parsedTemps = parse_temperature_line(line, current_tool) - +# self._logger.info("current_tool: %d, maxToolNum: %d, parsedTemps: %s"%(current_tool,maxToolNum,parsedTemps)) for name, hook in self._temperature_hooks.items(): try: parsedTemps = hook(self, parsedTemps) @@ -1139,13 +1139,19 @@ class MachineCom(object): except: self._logger.exception("Error while processing temperatures in {}, skipping".format(name)) - if "T0" in parsedTemps.keys(): + printer_profile=self._printerProfileManager.get_current_or_default() + shared_nozzle = printer_profile["extruder"]["sharedNozzle"] + + if "T%d"%current_tool in parsedTemps.keys(): for n in range(maxToolNum + 1): tool = "T%d" % n - if not tool in parsedTemps.keys(): + if not tool in parsedTemps.keys() and not shared_nozzle: continue + elif not tool in parsedTemps.keys() and shared_nozzle: + actual, target = parsedTemps["T%d"%current_tool] - actual, target = parsedTemps[tool] + else: + actual, target = parsedTemps[tool] self.last_temperature.set_tool(n, actual=actual, target=target) # bed temperature From 0f325b95c1c84c9fdc387d07fc5b3f50ef18f50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 29 Sep 2017 16:18:52 +0200 Subject: [PATCH 4/6] Minor changes to #2123 for better readability --- src/octoprint/util/comm.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index dbfe7029c..8078495a2 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1129,8 +1129,9 @@ class MachineCom(object): def _processTemperatures(self, line): current_tool = self._currentTool if self._currentTool is not None else 0 + current_tool_key = "T%d" % current_tool maxToolNum, parsedTemps = parse_temperature_line(line, current_tool) -# self._logger.info("current_tool: %d, maxToolNum: %d, parsedTemps: %s"%(current_tool,maxToolNum,parsedTemps)) + for name, hook in self._temperature_hooks.items(): try: parsedTemps = hook(self, parsedTemps) @@ -1139,17 +1140,15 @@ class MachineCom(object): except: self._logger.exception("Error while processing temperatures in {}, skipping".format(name)) - printer_profile=self._printerProfileManager.get_current_or_default() - shared_nozzle = printer_profile["extruder"]["sharedNozzle"] - - if "T%d"%current_tool in parsedTemps.keys(): + if current_tool_key in parsedTemps.keys(): + shared_nozzle = self._printerProfileManager.get_current_or_default()["extruder"]["sharedNozzle"] for n in range(maxToolNum + 1): tool = "T%d" % n - if not tool in parsedTemps.keys() and not shared_nozzle: - continue - elif not tool in parsedTemps.keys() and shared_nozzle: - actual, target = parsedTemps["T%d"%current_tool] - + if not tool in parsedTemps: + if shared_nozzle: + actual, target = parsedTemps[current_tool_key] + else: + continue else: actual, target = parsedTemps[tool] self.last_temperature.set_tool(n, actual=actual, target=target) From 0f8f4579d6bf5afdaaa1217975fd02bbb2da49ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 2 Oct 2017 16:39:57 +0200 Subject: [PATCH 5/6] Add no-op default action to login form That way people clicking too fast on login before the view models are bound won't be able to make the form submit username and password as GET parameter to the base URL. Closes #2108 --- src/octoprint/templates/navbar/login.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/templates/navbar/login.jinja2 b/src/octoprint/templates/navbar/login.jinja2 index bc215b904..370ed299b 100644 --- a/src/octoprint/templates/navbar/login.jinja2 +++ b/src/octoprint/templates/navbar/login.jinja2 @@ -3,7 +3,7 @@

- {{ _('This does not look like a valid "http://" or "https://" URL.') }} + {{ _('This does not look like a valid URL. Expected http, https or any of the supported VCS URLs.', url='https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support') }}

{{ _('... from an uploaded archive') }}