From f8dc5047732ad1e270760c090e4172e675507371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20L=C3=B8vdal?= Date: Fri, 5 Apr 2019 00:47:42 +0200 Subject: [PATCH 001/105] Add example of using explicit python version --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a77a96dbe..13e326d2e 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ you already have Python 2.7, pip and virtualenv set up on your system: 1. Checkout OctoPrint: `git clone https://github.com/foosel/OctoPrint.git` 2. Change into the OctoPrint folder: `cd OctoPrint` -3. Create a user-owned virtual environment therein: `virtualenv venv` +3. Create a user-owned virtual environment therein: `virtualenv venv` if your system default python version is + python 2.7, otherwise you need to specify the version explicitly, e.g. `virtualenv --python=python2.7 venv`. 4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .` You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage) From a3254466f73cdc835e36834b52958f1c91f5fca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20L=C3=B8vdal?= Date: Fri, 5 Apr 2019 00:47:59 +0200 Subject: [PATCH 002/105] Whitespace fixes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 13e326d2e..c3144cd5b 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!** You are currently looking at the source code repository of OctoPrint. If you already installed it (e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki) -might be of more interest for you. You might also want to subscribe to join +might be of more interest for you. You might also want to subscribe to join [the community forum at community.octoprint.org](https://community.octoprint.org) where there are other active users who might be able to help you with any questions you might have. @@ -39,7 +39,7 @@ able to help you with any questions you might have. Contributions of all kinds are welcome, not only in the form of code but also with regards to the [official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), debugging help -in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on +in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on [the community forum at community.octoprint.org](https://community.octoprint.org) and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme). @@ -73,7 +73,7 @@ You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octopri for details. After installation, please make sure you follow the first-run wizard and set up -access control as necessary. +access control as necessary. ## Dependencies From 03e328fd1392161c44a7170dc086e6bcfca8b200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 10 Apr 2019 17:04:01 +0200 Subject: [PATCH 003/105] =?UTF-8?q?=F0=9F=93=9D=20Fix=20a=20documentation?= =?UTF-8?q?=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3117 --- docs/configuration/config_yaml.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index bb1236c38..88fa4545e 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -409,8 +409,7 @@ The following settings are only relevant to you if you want to do OctoPrint deve # Lines to send on simulated reset resetLines: - start - - Marlin: Virtual Marlin! - - "\x80" + - "Marlin: Virtual Marlin!" - "SD card ok" # Initial set of prepared oks to use instead of regular ok (e.g. to simulate From 07423712a6d6731ac720a061ffdf34091092bea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 May 2019 11:48:45 +0200 Subject: [PATCH 004/105] =?UTF-8?q?=F0=9F=90=9B=20Fix=20wrong=20variable?= =?UTF-8?q?=20name=20in=20exception=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3153 & Sentry SERVER-11A --- src/octoprint/server/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 366f23c2a..c8213cd38 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -485,7 +485,7 @@ class Server(object): except: self._logger.exception("Error while trying to migrate settings for " "plugin {}, ignoring it".format(implementation._identifier), - extra=dict(plugin=plugin._identifier)) + extra=dict(plugin=implementation._identifier)) pluginManager.implementation_post_inits=[settings_plugin_config_migration_and_cleanup] From b03d43156defe3b4159d5fd239b06f1c454bd12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 May 2019 13:19:14 +0200 Subject: [PATCH 005/105] =?UTF-8?q?=F0=9F=90=9B=20Strip=20interface=20tags?= =?UTF-8?q?=20from=20addresses=20on=20local=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3143 and Sentry SERVER-11B --- src/octoprint/util/net.py | 24 +++++++++++++++++------- tests/util/test_net.py | 24 +++++++++++++++++++++++- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py index f8cb2c311..9feadb65b 100644 --- a/src/octoprint/util/net.py +++ b/src/octoprint/util/net.py @@ -46,9 +46,8 @@ else: def is_lan_address(address, additional_private=None): try: - if address.lower().startswith("::ffff:") and "." in address: - # ipv6 mapped ipv4 address, unmap - address = address[len("::ffff:"):] + address = unmap_v4_as_v6(address) + address = strip_interface_tag(address) ip = netaddr.IPAddress(address) if ip.is_private() or ip.is_loopback(): @@ -71,10 +70,7 @@ def is_lan_address(address, additional_private=None): # v6 notation in netifaces output, e.g. "ffff:ffff:ffff:ffff::/64" _, prefix = prefix.split("/") - addr = address["addr"] - if "%" in addr: - # interface comment in netifaces output, e.g. "fe80::457f:bbee:d579:1063%wlan0" - addr = addr[:addr.find("%")] + addr = strip_interface_tag(address["addr"]) return netaddr.IPNetwork("{}/{}".format(addr, prefix)) for interface in netifaces.interfaces(): @@ -103,3 +99,17 @@ def is_lan_address(address, additional_private=None): # we are extra careful here since an unhandled exception in this method will effectively nuke the whole UI logging.getLogger(__name__).exception("Error while trying to determine whether {} is a local address".format(address)) return True + + +def strip_interface_tag(address): + if "%" in address: + # interface comment, e.g. "fe80::457f:bbee:d579:1063%wlan0" + address = address[:address.find("%")] + return address + + +def unmap_v4_as_v6(address): + if address.lower().startswith("::ffff:") and "." in address: + # ipv6 mapped ipv4 address, unmap + address = address[len("::ffff:"):] + return address diff --git a/tests/util/test_net.py b/tests/util/test_net.py index a1a33cec0..2f90bb2de 100644 --- a/tests/util/test_net.py +++ b/tests/util/test_net.py @@ -43,7 +43,8 @@ class UtilNetTest(unittest.TestCase): ("11.1.2.3", [], False), ("11.1.2.3", ["11/8"], True), ("12.1.1.123", [], True), - ("2a01:4f8:1c0c:6958::1:23", [], True) + ("2a01:4f8:1c0c:6958::1:23", [], True), + ("fe80::89f3:31bb:ced0:2093%wlan0", [], True) ) @ddt.unpack @mock.patch("netifaces.interfaces", side_effect=patched_interfaces) @@ -52,3 +53,24 @@ class UtilNetTest(unittest.TestCase): def test_is_lan_address(self, input_address, input_additional, expected, nifa, nifs): actual = octoprint.util.net.is_lan_address(input_address, additional_private=input_additional) self.assertEqual(expected, actual) + + @ddt.data( + ("fe80::89f3:31bb:ced0:2093%wlan0", "fe80::89f3:31bb:ced0:2093"), + ("2a01:4f8:1c0c:6958::1:23", "2a01:4f8:1c0c:6958::1:23"), + ("10.1.2.3", "10.1.2.3") + ) + @ddt.unpack + def test_strip_interface_tag(self, address, expected): + actual = octoprint.util.net.strip_interface_tag(address) + self.assertEqual(expected, actual) + + @ddt.data( + ("::ffff:192.168.1.1", "192.168.1.1"), + ("::ffff:2a01:4f8", "::ffff:2a01:4f8"), + ("2a01:4f8:1c0c:6958::1:23", "2a01:4f8:1c0c:6958::1:23"), + ("11.1.2.3", "11.1.2.3") + ) + @ddt.unpack + def test_unmap_v4_in_v6(self, address, expected): + actual = octoprint.util.net.unmap_v4_as_v6(address) + self.assertEqual(expected, actual) From 2387b4a7710884271987033343b0a6516a4d850c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 May 2019 15:15:25 +0200 Subject: [PATCH 006/105] =?UTF-8?q?=F0=9F=90=9B=20backup:=20make=20sure=20?= =?UTF-8?q?exclude=20is=20always=20a=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3155 and Sentry SERVER-119 --- src/octoprint/plugins/backup/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 14cacaf08..5408e71ad 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -619,6 +619,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, try: if exclude is None: exclude = [] + if not isinstance(exclude, list): + exclude = list(exclude) if "timelapse" in exclude: exclude.append("timelapse_tmp") From d6516e4a4c1ad36f4b2cc22a98184f39ff53aeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 May 2019 15:19:57 +0200 Subject: [PATCH 007/105] =?UTF-8?q?=F0=9F=90=9B=20tracking:=20handle=20tim?= =?UTF-8?q?e=3D=3DNone=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3156 and Sentry SERVER-WR --- src/octoprint/plugins/tracking/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py index 1aa8d91c6..b7e3ca894 100644 --- a/src/octoprint/plugins/tracking/__init__.py +++ b/src/octoprint/plugins/tracking/__init__.py @@ -305,7 +305,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, elapsed = int(payload.get(b"time", 0)) if elapsed: args[b"elapsed"] = elapsed - except ValueError: + except (ValueError, TypeError): pass track_event = "print_done" elif event == Events.PRINT_FAILED: @@ -313,7 +313,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, elapsed = int(payload.get(b"time", 0)) if elapsed: args[b"elapsed"] = elapsed - except ValueError: + except (ValueError, TypeError): pass args[b"reason"] = payload.get(b"reason", "unknown") @@ -326,7 +326,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin, elapsed = int(payload.get(b"time", 0)) if elapsed: args[b"elapsed"] = elapsed - except ValueError: + except (ValueError, TypeError): pass track_event = "print_cancelled" From 547db7c1f565b5025d96a34af755db3229424c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 May 2019 17:34:54 +0200 Subject: [PATCH 008/105] =?UTF-8?q?=E2=98=94=20pmgr:=20better=20handling?= =?UTF-8?q?=20of=20unexpected=20repository=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3157 and Sentry SERVER-116 --- src/octoprint/plugins/pluginmanager/__init__.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 5caa980b6..ea8d99cc4 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -37,6 +37,9 @@ _DATA_FORMAT_VERSION = "v2" def map_repository_entry(entry): + if not isinstance(entry, dict): + return None + result = copy.deepcopy(entry) if not "follow_dependency_links" in result: @@ -797,7 +800,16 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin, self._logger.exception("Could not fetch plugins from repository at {repository_url}: {message}".format(repository_url=repository_url, message=str(e))) return None - repo_data = r.json() + try: + repo_data = r.json() + except Exception as e: + self._logger.exception("Error while reading repository data") + return None + + # validation + if not isinstance(repo_data, (list, tuple)): + self._logger.warn("Invalid repository data: expected a list, got {!r}".format(repo_data)) + return None try: import json @@ -814,7 +826,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin, if repo_data is None: return False - self._repository_plugins = map(map_repository_entry, repo_data) + self._repository_plugins = filter(lambda x: x is not None, + map(map_repository_entry, repo_data)) return True def _fetch_notices_from_disk(self): From e864d6b03efb589ea975b85ab55e67506846a954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 15 May 2019 17:35:57 +0200 Subject: [PATCH 009/105] =?UTF-8?q?=F0=9F=9A=B8=20Ensure=20line=20breaks?= =?UTF-8?q?=20on=20copy=20of=20terminal=20contents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/templates/tabs/terminal.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/templates/tabs/terminal.jinja2 b/src/octoprint/templates/tabs/terminal.jinja2 index ba6c20482..4ecded92b 100644 --- a/src/octoprint/templates/tabs/terminal.jinja2 +++ b/src/octoprint/templates/tabs/terminal.jinja2 @@ -1,5 +1,5 @@
-
+
+
+ +
+ + + +
+
{{ _('Serial logging') }} diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 97b3d360e..bb9563eb3 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2625,14 +2625,15 @@ class MachineCom(object): serial_obj = serial.Serial(**serial_port_args) serial_obj.port = str(port) - # This may also not be applicable to other platforms, in which case - # this should probably get rewritten as a whitelist for the platforms - # that have issues here. - if get_os() != 'freebsd': + use_parity_workaround = settings().get(["serial", "useParityWorkaround"]) + needs_parity_workaround = True #get_os() == "linux" and os.path.exists("/etc/debian_version") # See #673 + + if use_parity_workaround == "always" or (needs_parity_workaround and use_parity_workaround == "detect"): serial_obj.parity = serial.PARITY_ODD serial_obj.open() serial_obj.close() serial_obj.parity = serial.PARITY_NONE + serial_obj.open() return BufferedReadlineWrapper(serial_obj) From 1b82aa859fbe8bc9c8fe868c29dbd8e8d7ac4dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 20 May 2019 16:48:00 +0200 Subject: [PATCH 012/105] =?UTF-8?q?=F0=9F=90=9B=20Fix=20accidental=20test?= =?UTF-8?q?=20code=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/util/comm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index bb9563eb3..69a17d642 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2626,7 +2626,7 @@ class MachineCom(object): serial_obj.port = str(port) use_parity_workaround = settings().get(["serial", "useParityWorkaround"]) - needs_parity_workaround = True #get_os() == "linux" and os.path.exists("/etc/debian_version") # See #673 + needs_parity_workaround = get_os() == "linux" and os.path.exists("/etc/debian_version") # See #673 if use_parity_workaround == "always" or (needs_parity_workaround and use_parity_workaround == "detect"): serial_obj.parity = serial.PARITY_ODD From 28229928436e89dc5034fd8807255f56bc6016a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 20 May 2019 19:49:06 +0200 Subject: [PATCH 013/105] =?UTF-8?q?=F0=9F=9A=B8=20action=20prompt:=20allow?= =?UTF-8?q?=20to=20cancel=20dialogs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3171 --- .../action_command_prompt/static/js/action_command_prompt.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js index e077903a2..c55ab7909 100644 --- a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js +++ b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js @@ -24,6 +24,7 @@ $(function() { title: gettext("Message from your printer"), message: text, selections: buttons, + maycancel: true, // see #3171 onselect: function(index) { if (index > -1) { self._select(index); From 59b60f5dada691c1f2ecfe4acd3b58a07b0b343e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 20 May 2019 19:55:10 +0200 Subject: [PATCH 014/105] =?UTF-8?q?=F0=9F=90=9B=20action=20prompt:=20close?= =?UTF-8?q?=20&=20delete=20prompt=20on=20disconnect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As mentioned in #3171 --- src/octoprint/plugins/action_command_prompt/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index 467aac652..77f3f6e40 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -69,6 +69,8 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin, def on_event(self, event, payload): if event == Events.CONNECTED and self._enable == "always" and self._enable_signal_support: self._printer.commands(["{command} P1".format(command=self._command)]) + elif event == Events.DISCONNECTED: + self._close_prompt() #~ SettingsPlugin From 6765b25803f95eeb460e51618ae4f2ed82d7051c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 May 2019 10:37:47 +0200 Subject: [PATCH 015/105] =?UTF-8?q?=F0=9F=9A=B8=20action=20prompt:=20show?= =?UTF-8?q?=20icon=20for=20dismissed=20prompts=20in=20navbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/js/action_command_prompt.js | 42 +++++++++++++++---- .../action_command_prompt_navbar.jinja2 | 3 ++ 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/octoprint/plugins/action_command_prompt/templates/action_command_prompt_navbar.jinja2 diff --git a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js index c55ab7909..cb7181cda 100644 --- a/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js +++ b/src/octoprint/plugins/action_command_prompt/static/js/action_command_prompt.js @@ -4,7 +4,17 @@ $(function() { self.loginState = parameters[0]; - self._modal = undefined; + self.modal = ko.observable(undefined); + + self.text = ko.observable(); + self.buttons = ko.observableArray([]); + + self.active = ko.pureComputed(function() { + return self.text() !== undefined; + }); + self.visible = ko.pureComputed(function() { + return self.modal() !== undefined; + }); self.requestData = function() { if (!self.loginState.isUser()) return; @@ -15,11 +25,19 @@ $(function() { self.fromResponse = function(data) { if (data.hasOwnProperty("text") && data.hasOwnProperty("choices")) { - self._showPrompt(data.text, data.choices); + self.text(data.text); + self.buttons(data.choices); + self.showPrompt(); + } else { + self.text(undefined); + self.buttons([]); } }; - self._showPrompt = function(text, buttons) { + self.showPrompt = function() { + var text = self.text(); + var buttons = self.buttons(); + var opts = { title: gettext("Message from your printer"), message: text, @@ -31,11 +49,11 @@ $(function() { } }, onclose: function() { - self._modal = undefined; + self.modal(undefined); } }; - self._modal = showSelectionDialog(opts) + self.modal(showSelectionDialog(opts)); }; self._select = function(index) { @@ -43,8 +61,9 @@ $(function() { }; self._closePrompt = function() { - if (self._modal) { - self._modal.modal("hide"); + var modal = self.modal(); + if (modal) { + modal.modal("hide"); } }; @@ -60,10 +79,14 @@ $(function() { switch (data.action) { case "show": { - self._showPrompt(data.text, data.choices); + self.text(data.text); + self.buttons(data.choices); + self.showPrompt(); break; } case "close": { + self.text(undefined); + self.buttons([]); self._closePrompt(); break; } @@ -74,6 +97,7 @@ $(function() { OCTOPRINT_VIEWMODELS.push({ construct: ActionCommandPromptViewModel, - dependencies: ["loginStateViewModel"] + dependencies: ["loginStateViewModel"], + elements: ["#navbar_plugin_action_command_prompt"] }); }); diff --git a/src/octoprint/plugins/action_command_prompt/templates/action_command_prompt_navbar.jinja2 b/src/octoprint/plugins/action_command_prompt/templates/action_command_prompt_navbar.jinja2 new file mode 100644 index 000000000..584c486b2 --- /dev/null +++ b/src/octoprint/plugins/action_command_prompt/templates/action_command_prompt_navbar.jinja2 @@ -0,0 +1,3 @@ + From c7b933ba007cd7ae27d364dd5f467c00cac111d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 May 2019 12:07:39 +0200 Subject: [PATCH 016/105] =?UTF-8?q?=F0=9F=90=9B=20forcelogin:=20Do=20not?= =?UTF-8?q?=20touch=20static=20endpoints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #3176 --- src/octoprint/plugins/forcelogin/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/forcelogin/__init__.py b/src/octoprint/plugins/forcelogin/__init__.py index 03b0083ac..d9654798e 100644 --- a/src/octoprint/plugins/forcelogin/__init__.py +++ b/src/octoprint/plugins/forcelogin/__init__.py @@ -123,7 +123,7 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, # not active, no handling return - if flask.request.endpoint in ("api.login",): + if flask.request.endpoint in ("api.login",) or flask.request.endpoint.endswith(".static"): return if plugin is not None and not plugin.is_blueprint_protected(): From 9ff44c49a6e73f7538d7dbd3c3308ef234735e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 May 2019 14:20:41 +0200 Subject: [PATCH 017/105] =?UTF-8?q?=F0=9F=90=9B=20Fix=20broken=20tool=20fi?= =?UTF-8?q?ltering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/util/comm.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 69a17d642..9acc6272e 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -3479,7 +3479,7 @@ class MachineCom(object): if not self._validate_tool(new_tool): self._log("Not queuing T{}, that tool doesn't exist according to the printer profile or " "was reported as invalid by the firmware".format(new_tool)) - return None + return None, before = self._getGcodeScript("beforeToolChange", replacements=dict(tool=dict(old=current_tool, new=new_tool))) after = self._getGcodeScript("afterToolChange", replacements=dict(tool=dict(old=current_tool, new=new_tool))) @@ -3496,15 +3496,19 @@ class MachineCom(object): return convert(before) + [cmd] + convert(after) - def _gcode_T_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs): + def _gcode_T_sending(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs): toolMatch = regexes_parameters["intT"].search(cmd) if toolMatch: new_tool = int(toolMatch.group("value")) if not self._validate_tool(new_tool): self._log("Not sending T{}, that tool doesn't exist according to the printer profile or " "was reported as invalid by the firmware".format(new_tool)) - return None + return None, + def _gcode_T_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs): + toolMatch = regexes_parameters["intT"].search(cmd) + if toolMatch: + new_tool = int(toolMatch.group("value")) self._toolBeforeChange = self._currentTool self._currentTool = new_tool eventManager().fire(Events.TOOL_CHANGE, dict(old=self._toolBeforeChange, new=self._currentTool)) From e94f789b727f554b33181aab2e5036bf92e722b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 May 2019 14:29:15 +0200 Subject: [PATCH 018/105] =?UTF-8?q?=F0=9F=90=9B=20Always=20report=20all=20?= =?UTF-8?q?tools=20in=20sharedNozzle=20setups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3177 See also https://community.octoprint.org/t/9620/4 --- src/octoprint/util/comm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 9acc6272e..4b60ca2af 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1542,6 +1542,8 @@ class MachineCom(object): current_tool_key = "T%d" % current_tool maxToolNum, parsedTemps = parse_temperature_line(line, current_tool) + maxToolNum = max(maxToolNum, self._printerProfileManager.get_current_or_default()["extruder"]["count"] - 1) + for name, hook in self._temperature_hooks.items(): try: parsedTemps = hook(self, parsedTemps) @@ -1551,7 +1553,7 @@ class MachineCom(object): self._logger.exception("Error while processing temperatures in {}, skipping".format(name), extra=dict(plugin=name)) - if current_tool_key in parsedTemps.keys(): + if current_tool_key in parsedTemps: shared_nozzle = self._printerProfileManager.get_current_or_default()["extruder"]["sharedNozzle"] for n in range(maxToolNum + 1): tool = "T%d" % n From d40c3e6241bcf244315492da37e8622d52c1d35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 May 2019 15:05:28 +0200 Subject: [PATCH 019/105] =?UTF-8?q?=F0=9F=9A=B8=20Add=20upload=20date=20to?= =?UTF-8?q?=20selected=20file=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should make it more clear when an update due to a new upload happens. Closes #3174 --- .../static/js/app/viewmodels/printerstate.js | 24 ++++++++++++++----- src/octoprint/templates/sidebar/state.jinja2 | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/printerstate.js b/src/octoprint/static/js/app/viewmodels/printerstate.js index 27ae3b0a5..dd38ed0b1 100644 --- a/src/octoprint/static/js/app/viewmodels/printerstate.js +++ b/src/octoprint/static/js/app/viewmodels/printerstate.js @@ -30,9 +30,10 @@ $(function() { self.filename = ko.observable(undefined); self.filepath = ko.observable(undefined); self.filedisplay = ko.observable(undefined); - self.progress = ko.observable(undefined); self.filesize = ko.observable(undefined); self.filepos = ko.observable(undefined); + self.filedate = ko.observable(undefined); + self.progress = ko.observable(undefined); self.printTime = ko.observable(undefined); self.printTimeLeft = ko.observable(undefined); self.printTimeLeftOrigin = ko.observable(undefined); @@ -62,7 +63,7 @@ $(function() { if (self.estimatedPrintTime()) return fmt(self.estimatedPrintTime()); return "-"; - } + }; self.estimatedPrintTimeString = ko.pureComputed(function() { return estimatedPrintTimeStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration); }); @@ -95,7 +96,7 @@ $(function() { } else { return fmt(self.printTimeLeft()); } - } + }; self.printTimeLeftString = ko.pureComputed(function() { return printTimeLeftStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration); }); @@ -194,6 +195,15 @@ $(function() { return (user ? user : (file ? "-" : "")); }); + self.dateString = ko.pureComputed(function() { + var date = self.filedate(); + if (!date) { + return ""; + } + + return formatDate(date); + }); + self.fromCurrentData = function(data) { self._fromData(data); }; @@ -228,7 +238,7 @@ $(function() { self.isReady(data.flags.ready); self.isSdReady(data.flags.sdReady); - if (self.isPaused() != prevPaused) { + if (self.isPaused() !== prevPaused) { if (self.isPaused()) { self.titlePrintButton(self.TITLE_PRINT_BUTTON_PAUSED); self.titlePauseButton(self.TITLE_PAUSE_BUTTON_PAUSED); @@ -245,12 +255,14 @@ $(function() { self.filepath(data.file.path); self.filesize(data.file.size); self.filedisplay(data.file.display); - self.sd(data.file.origin == "sdcard"); + self.filedate(data.file.date); + self.sd(data.file.origin === "sdcard"); } else { self.filename(undefined); self.filepath(undefined); self.filesize(undefined); self.filedisplay(undefined); + self.filedate(undefined); self.sd(undefined); } @@ -258,7 +270,7 @@ $(function() { self.lastPrintTime(data.lastPrintTime); var result = []; - if (data.filament && typeof(data.filament) == "object" && _.keys(data.filament).length > 0) { + if (data.filament && typeof(data.filament) === "object" && _.keys(data.filament).length > 0) { var keys = _.keys(data.filament); keys.sort(); _.each(keys, function(key) { diff --git a/src/octoprint/templates/sidebar/state.jinja2 b/src/octoprint/templates/sidebar/state.jinja2 index 30e4f9839..d6429da9f 100644 --- a/src/octoprint/templates/sidebar/state.jinja2 +++ b/src/octoprint/templates/sidebar/state.jinja2 @@ -1,6 +1,7 @@ {{ _('State') }}:

{{ _('File') }}:  (SD)
+{{ _('Uploaded') }}:
{{ _('User') }}:
From c8ea808d93a8a63ad4909327cee6c3daaf5f7748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 21 May 2019 15:18:24 +0200 Subject: [PATCH 020/105] =?UTF-8?q?=F0=9F=9A=B8=20Include=20seconds=20in?= =?UTF-8?q?=20upload=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See #3174 --- src/octoprint/static/js/app/helpers.js | 14 ++++++++++++-- .../static/js/app/viewmodels/printerstate.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index 172ab3eab..1ebd1adbd 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -576,9 +576,19 @@ function formatFuzzyPrintTime(totalSeconds) { return _.sprintf(text, replacements); } -function formatDate(unixTimestamp) { +function formatDate(unixTimestamp, options) { + if (!options) { + options = { seconds: false }; + } + if (!unixTimestamp) return "-"; - return moment.unix(unixTimestamp).format(gettext(/* L10N: Date format */ "YYYY-MM-DD HH:mm")); + + var format = gettext(/* L10N: Date format */ "YYYY-MM-DD HH:mm"); + if (options.seconds) { + format = gettext(/* L10N: Date format with seconds */ "YYYY-MM-DD HH:mm:ss"); + } + + return moment.unix(unixTimestamp).format(format); } function formatTimeAgo(unixTimestamp) { diff --git a/src/octoprint/static/js/app/viewmodels/printerstate.js b/src/octoprint/static/js/app/viewmodels/printerstate.js index dd38ed0b1..b27466e91 100644 --- a/src/octoprint/static/js/app/viewmodels/printerstate.js +++ b/src/octoprint/static/js/app/viewmodels/printerstate.js @@ -201,7 +201,7 @@ $(function() { return ""; } - return formatDate(date); + return formatDate(date, {seconds:true}); }); self.fromCurrentData = function(data) { From e9b0bd9e65ec10f2e361c3fc202a72c2ceab2275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 23 May 2019 13:08:50 +0200 Subject: [PATCH 021/105] Create FUNDING.yml --- .github/FUNDING.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..c55ac50cf --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,5 @@ +# These are supported funding model platforms + +github: [foosel] +patreon: foosel +custom: https://octoprint.org/support-octoprint/ From 352b190a72a7226476750d65238f5a15089b1e63 Mon Sep 17 00:00:00 2001 From: AndyQ Date: Sun, 26 May 2019 12:49:03 +0100 Subject: [PATCH 022/105] Added button to terminal window to all log window to be cleared out --- src/octoprint/static/js/app/viewmodels/terminal.js | 8 ++++++++ src/octoprint/templates/tabs/terminal.jinja2 | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/octoprint/static/js/app/viewmodels/terminal.js b/src/octoprint/static/js/app/viewmodels/terminal.js index cd853fe25..5fecaffc9 100644 --- a/src/octoprint/static/js/app/viewmodels/terminal.js +++ b/src/octoprint/static/js/app/viewmodels/terminal.js @@ -338,6 +338,14 @@ $(function() { copyToClipboard(lines.join("\n")); }; + self.clearLogWidow = function() { + if (self.fancyFunctionality()) { + self.log([]); + } else { + self.plainLogLines([]); + } + + }; // command matching regex // (Example output for inputs G0, G1, G28.1, M117 test) // - 1: code including optional subcode. Example: G0, G1, G28.1, M117 diff --git a/src/octoprint/templates/tabs/terminal.jinja2 b/src/octoprint/templates/tabs/terminal.jinja2 index 4ecded92b..e1284eb22 100644 --- a/src/octoprint/templates/tabs/terminal.jinja2 +++ b/src/octoprint/templates/tabs/terminal.jinja2 @@ -13,7 +13,8 @@ ({{ _("Scroll to end") }}) - {{ _('Copy all') }} + {{ _('Copy all') }}
+ {{ _('Clear log widow') }}
{{ _('Copy all') }}
- {{ _('Clear log widow') }} + {{ _('Clear log window') }}
{{ _('Copy all') }}
- {{ _('Clear log window') }} + {{ _('Clear all') }}