From d091d2de28744de89167044a2857bfc35acf51b5 Mon Sep 17 00:00:00 2001 From: cp2004 <31997505+cp2004@users.noreply.github.com> Date: Thu, 31 Dec 2020 12:01:51 +0000 Subject: [PATCH 01/13] :bug: Improve firmware name splitting Marlin includes the build time in it's firmware name, until now the expression split it on the colon, and failed to do it properly. Example format that now works: ``` FIRMWARE_NAME:Marlin 2.0.7.2 (Nov 27 2020 14:30:11) ``` --- 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 00a2e6f13..2045c7e94 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -182,7 +182,7 @@ Groups will be as follows: * ``value``: reported position value """ -regex_firmware_splitter = re.compile(r"\s*([A-Z0-9_]+):\s*") +regex_firmware_splitter = re.compile(r"\s*([A-Z_]+):\s*") """Regex to use for splitting M115 responses.""" regex_resend_linenumber = re.compile(r"(N|N:)?(?P%s)" % regex_int_pattern) From 14b462ae98bf63ee669edbd1deecd1a0f5b705d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 12 Feb 2021 10:24:52 +0100 Subject: [PATCH 02/13] :children_crossing: Bug issue form v2 --- .github/ISSUE_TEMPLATE/bug_report_v2.yml | 136 +++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report_v2.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report_v2.yml b/.github/ISSUE_TEMPLATE/bug_report_v2.yml new file mode 100644 index 000000000..784d39c09 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_v2.yml @@ -0,0 +1,136 @@ +name: Bug report +about: Create a report to help improve OctoPrint +title: "" +issue_body: true +body: + - type: markdown + attributes: + value: > + **Thank you for wanting to report a bug in OctoPrint!** + + + If this is the first time you are doing this, please take a few moments to read + through the [Contribution Guidelines](https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md). + Also check out [the FAQ](https://faq.octoprint.org) if your + problem is maybe already covered there. + + + You are about to report a bug in **OctoPrint**. Do not proceed if your issues + occurs with OctoPi, any third party OctoPrint plugins, unofficial or outdated + OctoPrint versions. If you are unsure of the difference between OctoPrint and + OctoPi, [read this FAQ entry](https://faq.octoprint.org/octoprint-vs-octopi). + + + Do also not seek support here ("I need help with ...", "I have a + question ...", "Can someone walk me through ..."), that belongs into the + [community forum at community.octoprint.org](https://community.octoprint.org) or on the [Discord server](https://discord.octoprint.org). + + + And finally, make sure any bug you want to report is still present with the **current** + OctoPrint version and that it does not vanish when you start OctoPrint + in [safe mode](https://docs.octoprint.org/en/master/features/safemode.html) either. + + + Thank you for your collaboration! + - type: textarea + attributes: + label: The problem + description: >- + Describe the issue you are experiencing here. Tell us what you were trying to do + step by step, and what happened that you did not expect. + + Provide a clear and concise description of what the problem is and include as many + details as possible. + placeholder: | + 1. ... + 2. ... + 3. ... + validations: + required: true + - type: dropdown + attributes: + label: Did the issue persist even in safe mode? + description: >- + Testing in safe mode is required to make sure the issue you are reporting is not + caused by a third party plugin. Please see [here](https://docs.octoprint.org/en/master/features/safemode.html) + on how to run OctoPrint in safe mode. + options: + - Yes, it did persist + - No, it did not persist (it's an issue with one of your installed plugins, don't report here) + - I cannot test this issue in safe mode (state why below) + validations: + required: true + - type: input + attributes: + label: If you could not test in safe mode, please state why + description: >- + Issues caused by a third party plugin are a major cause of bugs reported here, so we really need to + rule out that a plugin is at fault here. [Safe mode](https://docs.octoprint.org/en/master/features/safemode.html) is an easy way to do that. Only skip safe mode + if your particular problem *absolutely requires* third party plugins to be enabled. "It would take + too long" is **not** a reason to skip testing in safe mode, neither is "I do not know how to + enable it" as you can find info on that [here](https://docs.octoprint.org/en/master/features/safemode.html). + + If you really *cannot* test in safe mode, leave a short explanation as to why. + - type: markdown + attributes: + value: | + ## Environment + - type: input + attributes: + label: Version of OctoPrint + description: Can be found in the lower left corner of the web interface. + validations: + required: true + - type: input + attributes: + label: Operating system running OctoPrint + description: >- + OctoPi, Linux, Windows, MacOS, something else? With version please? OctoPi's + version can be found in `/etc/octopi_version` or in the lower left corner of the + web interface. + validations: + required: true + - type: input + attributes: + label: Printer model & used firmware incl. version + description: If applicable, always include if unsure + - type: input + attributes: + label: Browser and version of browser, operating system running browser + description: If applicable, always include if unsure + - type: markdown + attributes: + value: | + ## Logs and other files needed for analysis + - type: markdown + attributes: + value: >- + Please also be sure to upload the following files below: + + * `octoprint.log`: See [here](https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299) if you don't know where to find that. Just attach down below as-is. + * `serial.log` or the contents of your terminal tab, if applicable. Always + include if unsure. **Please note that you need to enable `serial.log` first**, + see [here](https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299) if you don't know how to do or where to find it. Just attach down below as-is. + * Your browser's JavaScript console, if you are reporting a problem with the + user interface. See [here](https://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers) on where to find that. + * If possible, screenshots or videos showing the problem, especially if you + are reporting a problem with the user interface! + * GCODE files with which to reproduce, if you are reporting an issue with + GCODE file analysis or printing behaviour. + + Please be aware that unless at least `octoprint.log` is included, your bug report + will not be processed. + - type: checkboxes + attributes: + label: Checklist of files to include below + options: + - label: octoprint.log + required: true + - label: serial.log or contents of your terminal tab (always include in cases of issues with printer communication) + - label: Contents of the JavaScript browser console (always include in cases of issues with the user interface) + - label: Screenshots and/or videos showing the problem (always include in case of issues with the user interface) + - label: GCODE file with which to reproduce (always include in case of issues with GCODE analysis or printing behaviour) + - type: markdown + attributes: + value: | + ## Additional information & file uploads From 27af9721e5bfb4d5d788cf79050c769e9a087d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 17 Feb 2021 17:47:40 +0100 Subject: [PATCH 03/13] =?UTF-8?q?=F0=9F=93=9D=20Update=20title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report_v2.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report_v2.yml b/.github/ISSUE_TEMPLATE/bug_report_v2.yml index 784d39c09..1e4093eae 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_v2.yml +++ b/.github/ISSUE_TEMPLATE/bug_report_v2.yml @@ -1,5 +1,5 @@ -name: Bug report -about: Create a report to help improve OctoPrint +name: 🐛 Report a bug +about: Create a bug report to help improve OctoPrint title: "" issue_body: true body: From a628549ad32a8d4ce27510967e5befc1a9d73594 Mon Sep 17 00:00:00 2001 From: Levi Blaney Date: Sat, 20 Feb 2021 10:12:16 -0500 Subject: [PATCH 04/13] Fixes #3999 test fails to reload config file --- tests/settings/test_settings.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/settings/test_settings.py b/tests/settings/test_settings.py index a4815ecc1..c57521410 100644 --- a/tests/settings/test_settings.py +++ b/tests/settings/test_settings.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals +from time import sleep + """ Tests for OctoPrint's Settings class @@ -606,6 +608,9 @@ class TestSettings(unittest.TestCase): basedir, configfile = paths settings = octoprint.settings.Settings() + # Make sure the config files last modified time changes + sleep(0.3) + self.assertEqual("0.0.0.0", settings.get(["server", "host"])) # modify yaml file externally From 5335750939b271750e8943167ef4c100f8a8f207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 22 Feb 2021 15:45:23 +0100 Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=91=B7=20New=20issue=20form=20yaml?= =?UTF-8?q?=20is=20live?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report.yml | 26 +++-- .github/ISSUE_TEMPLATE/bug_report_v2.yml | 136 ----------------------- 2 files changed, 15 insertions(+), 147 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report_v2.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e0816d0f9..1e4093eae 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,9 +1,9 @@ -name: Bug report -about: Create a report to help improve OctoPrint +name: 🐛 Report a bug +about: Create a bug report to help improve OctoPrint title: "" issue_body: true -inputs: - - type: description +body: + - type: markdown attributes: value: > **Thank you for wanting to report a bug in OctoPrint!** @@ -35,7 +35,6 @@ inputs: - type: textarea attributes: label: The problem - required: true description: >- Describe the issue you are experiencing here. Tell us what you were trying to do step by step, and what happened that you did not expect. @@ -46,6 +45,8 @@ inputs: 1. ... 2. ... 3. ... + validations: + required: true - type: dropdown attributes: label: Did the issue persist even in safe mode? @@ -53,10 +54,11 @@ inputs: Testing in safe mode is required to make sure the issue you are reporting is not caused by a third party plugin. Please see [here](https://docs.octoprint.org/en/master/features/safemode.html) on how to run OctoPrint in safe mode. - choices: + options: - Yes, it did persist - No, it did not persist (it's an issue with one of your installed plugins, don't report here) - I cannot test this issue in safe mode (state why below) + validations: required: true - type: input attributes: @@ -69,7 +71,7 @@ inputs: enable it" as you can find info on that [here](https://docs.octoprint.org/en/master/features/safemode.html). If you really *cannot* test in safe mode, leave a short explanation as to why. - - type: description + - type: markdown attributes: value: | ## Environment @@ -77,6 +79,7 @@ inputs: attributes: label: Version of OctoPrint description: Can be found in the lower left corner of the web interface. + validations: required: true - type: input attributes: @@ -85,6 +88,7 @@ inputs: OctoPi, Linux, Windows, MacOS, something else? With version please? OctoPi's version can be found in `/etc/octopi_version` or in the lower left corner of the web interface. + validations: required: true - type: input attributes: @@ -94,11 +98,11 @@ inputs: attributes: label: Browser and version of browser, operating system running browser description: If applicable, always include if unsure - - type: description + - type: markdown attributes: value: | ## Logs and other files needed for analysis - - type: description + - type: markdown attributes: value: >- Please also be sure to upload the following files below: @@ -119,14 +123,14 @@ inputs: - type: checkboxes attributes: label: Checklist of files to include below - choices: + options: - label: octoprint.log required: true - label: serial.log or contents of your terminal tab (always include in cases of issues with printer communication) - label: Contents of the JavaScript browser console (always include in cases of issues with the user interface) - label: Screenshots and/or videos showing the problem (always include in case of issues with the user interface) - label: GCODE file with which to reproduce (always include in case of issues with GCODE analysis or printing behaviour) - - type: description + - type: markdown attributes: value: | ## Additional information & file uploads diff --git a/.github/ISSUE_TEMPLATE/bug_report_v2.yml b/.github/ISSUE_TEMPLATE/bug_report_v2.yml deleted file mode 100644 index 1e4093eae..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report_v2.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: 🐛 Report a bug -about: Create a bug report to help improve OctoPrint -title: "" -issue_body: true -body: - - type: markdown - attributes: - value: > - **Thank you for wanting to report a bug in OctoPrint!** - - - If this is the first time you are doing this, please take a few moments to read - through the [Contribution Guidelines](https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md). - Also check out [the FAQ](https://faq.octoprint.org) if your - problem is maybe already covered there. - - - You are about to report a bug in **OctoPrint**. Do not proceed if your issues - occurs with OctoPi, any third party OctoPrint plugins, unofficial or outdated - OctoPrint versions. If you are unsure of the difference between OctoPrint and - OctoPi, [read this FAQ entry](https://faq.octoprint.org/octoprint-vs-octopi). - - - Do also not seek support here ("I need help with ...", "I have a - question ...", "Can someone walk me through ..."), that belongs into the - [community forum at community.octoprint.org](https://community.octoprint.org) or on the [Discord server](https://discord.octoprint.org). - - - And finally, make sure any bug you want to report is still present with the **current** - OctoPrint version and that it does not vanish when you start OctoPrint - in [safe mode](https://docs.octoprint.org/en/master/features/safemode.html) either. - - - Thank you for your collaboration! - - type: textarea - attributes: - label: The problem - description: >- - Describe the issue you are experiencing here. Tell us what you were trying to do - step by step, and what happened that you did not expect. - - Provide a clear and concise description of what the problem is and include as many - details as possible. - placeholder: | - 1. ... - 2. ... - 3. ... - validations: - required: true - - type: dropdown - attributes: - label: Did the issue persist even in safe mode? - description: >- - Testing in safe mode is required to make sure the issue you are reporting is not - caused by a third party plugin. Please see [here](https://docs.octoprint.org/en/master/features/safemode.html) - on how to run OctoPrint in safe mode. - options: - - Yes, it did persist - - No, it did not persist (it's an issue with one of your installed plugins, don't report here) - - I cannot test this issue in safe mode (state why below) - validations: - required: true - - type: input - attributes: - label: If you could not test in safe mode, please state why - description: >- - Issues caused by a third party plugin are a major cause of bugs reported here, so we really need to - rule out that a plugin is at fault here. [Safe mode](https://docs.octoprint.org/en/master/features/safemode.html) is an easy way to do that. Only skip safe mode - if your particular problem *absolutely requires* third party plugins to be enabled. "It would take - too long" is **not** a reason to skip testing in safe mode, neither is "I do not know how to - enable it" as you can find info on that [here](https://docs.octoprint.org/en/master/features/safemode.html). - - If you really *cannot* test in safe mode, leave a short explanation as to why. - - type: markdown - attributes: - value: | - ## Environment - - type: input - attributes: - label: Version of OctoPrint - description: Can be found in the lower left corner of the web interface. - validations: - required: true - - type: input - attributes: - label: Operating system running OctoPrint - description: >- - OctoPi, Linux, Windows, MacOS, something else? With version please? OctoPi's - version can be found in `/etc/octopi_version` or in the lower left corner of the - web interface. - validations: - required: true - - type: input - attributes: - label: Printer model & used firmware incl. version - description: If applicable, always include if unsure - - type: input - attributes: - label: Browser and version of browser, operating system running browser - description: If applicable, always include if unsure - - type: markdown - attributes: - value: | - ## Logs and other files needed for analysis - - type: markdown - attributes: - value: >- - Please also be sure to upload the following files below: - - * `octoprint.log`: See [here](https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299) if you don't know where to find that. Just attach down below as-is. - * `serial.log` or the contents of your terminal tab, if applicable. Always - include if unsure. **Please note that you need to enable `serial.log` first**, - see [here](https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299) if you don't know how to do or where to find it. Just attach down below as-is. - * Your browser's JavaScript console, if you are reporting a problem with the - user interface. See [here](https://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers) on where to find that. - * If possible, screenshots or videos showing the problem, especially if you - are reporting a problem with the user interface! - * GCODE files with which to reproduce, if you are reporting an issue with - GCODE file analysis or printing behaviour. - - Please be aware that unless at least `octoprint.log` is included, your bug report - will not be processed. - - type: checkboxes - attributes: - label: Checklist of files to include below - options: - - label: octoprint.log - required: true - - label: serial.log or contents of your terminal tab (always include in cases of issues with printer communication) - - label: Contents of the JavaScript browser console (always include in cases of issues with the user interface) - - label: Screenshots and/or videos showing the problem (always include in case of issues with the user interface) - - label: GCODE file with which to reproduce (always include in case of issues with GCODE analysis or printing behaviour) - - type: markdown - attributes: - value: | - ## Additional information & file uploads From 2fc287768bb097035cd26826362016c50d0701a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 22 Feb 2021 16:07:51 +0100 Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=9A=B8=20Migrate=20request=20templa?= =?UTF-8?q?te=20to=20forms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add link to support.octoprint.org to issue selection. --- .github/ISSUE_TEMPLATE/config.yml | 7 ++-- .github/ISSUE_TEMPLATE/feature_request.md | 22 ------------- .github/ISSUE_TEMPLATE/feature_request.yml | 37 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 24 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index eb9fb4bd9..ed748bff5 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,7 @@ contact_links: - - name: Have questions or need support? + - name: 🤔 Have questions or need support? url: https://community.octoprint.org - about: Please get in touch on the OctoPrint Community Forum! + about: Please get in touch on the OctoPrint Community Forums! + - name: 💸 Want to donate? + url: https://support.octoprint.org + about: Please take a look at the various options to support OctoPrint's development financially! diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index cd4966224..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '[Request]' - ---- - - - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..f054080f7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,37 @@ +name: ✨ Request a feature +about: Request a new feature to implement in OctoPrint +title: "[Request]" +issue_body: true +body: + - type: markdown + attributes: + value: > + **Thank you for wanting to request a feature in OctoPrint!** + + + Before you go ahead with your request, please first consider if it wouldn't be + better suited for a plugin. As a general rule of thumb, any feature that is only + of interest to a small sub group should be moved into a plugin. Only such features + that are of interest to a majority of OctoPrint's users will be implemented as + part of the core itself. + + - type: textarea + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Eg, "I'm always frustrated when [...]". + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. Explain why it needs to be included in OctoPrint's core and can't become a plugin. + validations: + required: true + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + - type: markdown + attributes: + value: > + **Additional context** + + Add any other context or screenshots about the feature request here. From 86aa5548c63222e9730422226fb6775c47bd6f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 22 Feb 2021 16:47:05 +0100 Subject: [PATCH 07/13] =?UTF-8?q?=E2=9C=85=20Make=20test=20fix=20align=20w?= =?UTF-8?q?ith=20other=20such=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/settings/test_settings.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/settings/test_settings.py b/tests/settings/test_settings.py index c57521410..e2bd2ac52 100644 --- a/tests/settings/test_settings.py +++ b/tests/settings/test_settings.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals -from time import sleep - """ Tests for OctoPrint's Settings class @@ -609,7 +607,7 @@ class TestSettings(unittest.TestCase): settings = octoprint.settings.Settings() # Make sure the config files last modified time changes - sleep(0.3) + time.sleep(1.0) self.assertEqual("0.0.0.0", settings.get(["server", "host"])) From d0f6bf3e0634020130e6efa8b44a086bed6ecead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 22 Feb 2021 18:53:45 +0100 Subject: [PATCH 08/13] =?UTF-8?q?=F0=9F=90=9B=20Allow=20numbers,=20but=20n?= =?UTF-8?q?ot=20at=20the=20start?= 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 2045c7e94..36921a7b6 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -182,7 +182,7 @@ Groups will be as follows: * ``value``: reported position value """ -regex_firmware_splitter = re.compile(r"\s*([A-Z_]+):\s*") +regex_firmware_splitter = re.compile(r"\s*([A-Z][A-Z0-9_]*):\s*") """Regex to use for splitting M115 responses.""" regex_resend_linenumber = re.compile(r"(N|N:)?(?P%s)" % regex_int_pattern) From e43f4ddb50352cbb65ad726b26f3add69a121950 Mon Sep 17 00:00:00 2001 From: cp2004 <31997505+cp2004@users.noreply.github.com> Date: Mon, 22 Feb 2021 18:34:15 +0000 Subject: [PATCH 09/13] :green_heart: Add more tests for firmware info splitting Part of #3916 --- tests/util/test_comm_helpers.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py index 32926470f..4a0fb4e0e 100644 --- a/tests/util/test_comm_helpers.py +++ b/tests/util/test_comm_helpers.py @@ -376,6 +376,25 @@ class TestCommHelpers(unittest.TestCase): "UUID": "00000000-0000-0000-0000-000000000000", }, ), + # Test firmware name with time created + ( + "FIRMWARE_NAME:Marlin 2.0.7.2 (Nov 27 2020 14:30:11) SOURCE_CODE_URL:https://github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender 5 Pro EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff", + { + "FIRMWARE_NAME": "Marlin 2.0.7.2 (Nov 27 2020 14:30:11)", + "SOURCE_CODE_URL": "https://github.com/MarlinFirmware/Marlin", + "PROTOCOL_VERSION": "1.0", + "MACHINE_TYPE": "Ender 5 Pro", + "EXTRUDER_COUNT": "1", + "UUID": "cede2a2f-41a2-4748-9b12-c55c62f367ff", + } + ), + # Test that keys beginning with _ or number are ignored + ( + "KEY1:VALUE1 _KEY2:INVALID 123:INVALID", + { + "KEY1": "VALUE1 _", "KEY2": "INVALID 123:INVALID" + } + ) ) @unpack def test_parse_firmware_line(self, line, expected): From bd3f7f8897a6ab6b20be0f137f177a099d8b3a59 Mon Sep 17 00:00:00 2001 From: cp2004 <31997505+cp2004@users.noreply.github.com> Date: Mon, 22 Feb 2021 18:46:24 +0000 Subject: [PATCH 10/13] :art: Make black happy again --- tests/util/test_comm_helpers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py index 4a0fb4e0e..81b01f07b 100644 --- a/tests/util/test_comm_helpers.py +++ b/tests/util/test_comm_helpers.py @@ -386,15 +386,13 @@ class TestCommHelpers(unittest.TestCase): "MACHINE_TYPE": "Ender 5 Pro", "EXTRUDER_COUNT": "1", "UUID": "cede2a2f-41a2-4748-9b12-c55c62f367ff", - } + }, ), # Test that keys beginning with _ or number are ignored ( "KEY1:VALUE1 _KEY2:INVALID 123:INVALID", - { - "KEY1": "VALUE1 _", "KEY2": "INVALID 123:INVALID" - } - ) + {"KEY1": "VALUE1 _", "KEY2": "INVALID 123:INVALID"}, + ), ) @unpack def test_parse_firmware_line(self, line, expected): From fec2f9b83e3e17341f6cbbc2dd1afc96ade519c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 23 Feb 2021 11:32:36 +0100 Subject: [PATCH 11/13] =?UTF-8?q?=F0=9F=90=9B=20Further=20firmware=20line?= =?UTF-8?q?=20parser=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Something like _KEY should never get recognized as a key. --- src/octoprint/util/comm.py | 8 ++++++-- tests/util/test_comm_helpers.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 36921a7b6..e29f1b971 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -182,7 +182,7 @@ Groups will be as follows: * ``value``: reported position value """ -regex_firmware_splitter = re.compile(r"\s*([A-Z][A-Z0-9_]*):\s*") +regex_firmware_splitter = re.compile(r"(^|\s+)([A-Z][A-Z0-9_]*):") """Regex to use for splitting M115 responses.""" regex_resend_linenumber = re.compile(r"(N|N:)?(?P%s)" % regex_int_pattern) @@ -6091,6 +6091,10 @@ def parse_firmware_line(line): The result will be a dictionary mapping from the contained keys to the contained values. + Valid keys must only contain A-Z, 0-9 and _ and must start with a letter. See the + unit tests for valid and invalid examples. There sadly is no existing specification + of the key format, but this is the format extracted from real life logs. + Arguments: line (str): the line to parse @@ -6108,7 +6112,7 @@ def parse_firmware_line(line): split_line = regex_firmware_splitter.split(line.strip())[ 1: ] # first entry is empty start of trimmed string - for key, value in chunks(split_line, 2): + for _, key, value in chunks(split_line, 3): result[key] = value.strip() return result diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py index 81b01f07b..1d1969b65 100644 --- a/tests/util/test_comm_helpers.py +++ b/tests/util/test_comm_helpers.py @@ -390,8 +390,8 @@ class TestCommHelpers(unittest.TestCase): ), # Test that keys beginning with _ or number are ignored ( - "KEY1:VALUE1 _KEY2:INVALID 123:INVALID", - {"KEY1": "VALUE1 _", "KEY2": "INVALID 123:INVALID"}, + "KEY1:VALUE1 _KEY2:INVALID 123:INVALID 1KEY:INVALID KEY2:VALUE2", + {"KEY1": "VALUE1 _KEY2:INVALID 123:INVALID 1KEY:INVALID", "KEY2": "VALUE2"}, ), ) @unpack From 0dc452e445b345d2a42d133467d0833a90af6b6b Mon Sep 17 00:00:00 2001 From: LazeMSS Date: Thu, 11 Feb 2021 12:58:25 +0100 Subject: [PATCH 12/13] =?UTF-8?q?=E2=9C=A8=20Add=20support=20for=20skippin?= =?UTF-8?q?g=20gcode=20in=20the=20gcode=20viewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bundledplugins/gcodeviewer.rst | 1 + src/octoprint/plugins/gcodeviewer/__init__.py | 5 +++-- .../gcodeviewer/static/js/gcodeviewer.js | 19 +++++++++++++++++-- .../templates/gcodeviewer_settings.jinja2 | 11 +++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/docs/bundledplugins/gcodeviewer.rst b/docs/bundledplugins/gcodeviewer.rst index 704d04213..8af5f971c 100644 --- a/docs/bundledplugins/gcodeviewer.rst +++ b/docs/bundledplugins/gcodeviewer.rst @@ -27,6 +27,7 @@ The plugin supports the following configuration keys: * ``mobileSizeThreshold``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases or release candidates). Defaults to ``false``. * ``sizeThreshold``: Unique instance identifier, auto generated on first activation + * ``skipUntilthis``: If this string is provided the GCode Viewer will search for this string, and if found, skip all gcode up until this string. This can be used to skip prime nozzle gcode in the preview .. _sec-bundledplugins-gcodeviewer-sourcecode: diff --git a/src/octoprint/plugins/gcodeviewer/__init__.py b/src/octoprint/plugins/gcodeviewer/__init__.py index a7331b0ca..7622ee710 100644 --- a/src/octoprint/plugins/gcodeviewer/__init__.py +++ b/src/octoprint/plugins/gcodeviewer/__init__.py @@ -48,8 +48,9 @@ class GcodeviewerPlugin( def get_settings_defaults(self): return { "mobileSizeThreshold": 2 * 1024 * 1024, # 2MB - "sizeThreshold": 20 * 1024 * 1024, - } # 20MB + "sizeThreshold": 20 * 1024 * 1024, # 20MB + "skipUntilthis": None, + } def get_settings_version(self): return 1 diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index 6fb9ba4e3..261851798 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -475,6 +475,21 @@ $(function () { }; self.showGCodeViewer = function (response, rstatus) { + // Slice of the gcode + if (self.settings.settings.plugins.gcodeviewer.skipUntilthis() != "") { + var findThis = + self.settings.settings.plugins.gcodeviewer.skipUntilthis() + ""; + var indexPos = response.indexOf("\n" + findThis); + // Try windows newlines if not found + if (indexPos == -1) { + indexPos = response.indexOf("\r" + findThis); + } + if (indexPos != -1) { + // Slice and make sure we comment out any string left back after slicing - so if a user configures something like "G1" we dont end up with a snippet of gcode commands + // Yes it would be prettier to parse it line by line and remove the entire line, that is very slow and uses mem - this way we find the string, and remove it + response = ";" + response.slice(indexPos + findThis.length + 1); + } + } var par = { target: { result: response @@ -879,8 +894,8 @@ $(function () { self.resetOptions(); var current = loadFromLocalStorage(optionsLocalStorageKey); - if (current["centerViewport"] !== undefined) - self.renderer_centerViewport(current["centerViewport"]); + if (current["centerViewPort"] !== undefined) + self.renderer_centerViewport(current["centerViewPort"]); if (current["zoomOnModel"] !== undefined) self.renderer_zoomOnModel(current["zoomOnModel"]); if (current["showMoves"] !== undefined) diff --git a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 index f61067956..b6e485083 100644 --- a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 +++ b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 @@ -19,4 +19,15 @@ +
+ +
+ +
+
+ + {% trans %}If provided, the GCode Viewer will search for a line beginning with this string. If found, all GCode up to that point will be skipped. This can be used to skip "purge/nozzle wipe" GCode in the viewer. Note the search is case sensitive. Example: ; layer 1{% endtrans %} + +
+
From ac2e25f6d62a68872cd5139807312d49e6c19b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 23 Feb 2021 16:23:55 +0100 Subject: [PATCH 13/13] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20skipUntilthis=20=3D>?= =?UTF-8?q?=20skipUntilThis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also made some comparisons a bit more resilient. --- docs/bundledplugins/gcodeviewer.rst | 2 +- src/octoprint/plugins/gcodeviewer/__init__.py | 2 +- .../plugins/gcodeviewer/static/js/gcodeviewer.js | 9 ++++----- .../gcodeviewer/templates/gcodeviewer_settings.jinja2 | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/bundledplugins/gcodeviewer.rst b/docs/bundledplugins/gcodeviewer.rst index 8af5f971c..b112a22c7 100644 --- a/docs/bundledplugins/gcodeviewer.rst +++ b/docs/bundledplugins/gcodeviewer.rst @@ -27,7 +27,7 @@ The plugin supports the following configuration keys: * ``mobileSizeThreshold``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases or release candidates). Defaults to ``false``. * ``sizeThreshold``: Unique instance identifier, auto generated on first activation - * ``skipUntilthis``: If this string is provided the GCode Viewer will search for this string, and if found, skip all gcode up until this string. This can be used to skip prime nozzle gcode in the preview + * ``skipUntilThis``: If this string is provided the GCode Viewer will search for this string, and if found, skip all gcode up until this string. This can be used to skip prime nozzle gcode in the preview .. _sec-bundledplugins-gcodeviewer-sourcecode: diff --git a/src/octoprint/plugins/gcodeviewer/__init__.py b/src/octoprint/plugins/gcodeviewer/__init__.py index 7622ee710..7bc359016 100644 --- a/src/octoprint/plugins/gcodeviewer/__init__.py +++ b/src/octoprint/plugins/gcodeviewer/__init__.py @@ -49,7 +49,7 @@ class GcodeviewerPlugin( return { "mobileSizeThreshold": 2 * 1024 * 1024, # 2MB "sizeThreshold": 20 * 1024 * 1024, # 20MB - "skipUntilthis": None, + "skipUntilThis": None, } def get_settings_version(self): diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index 261851798..5f194574a 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -476,15 +476,14 @@ $(function () { self.showGCodeViewer = function (response, rstatus) { // Slice of the gcode - if (self.settings.settings.plugins.gcodeviewer.skipUntilthis() != "") { - var findThis = - self.settings.settings.plugins.gcodeviewer.skipUntilthis() + ""; + var findThis = self.settings.settings.plugins.gcodeviewer.skipUntilThis(); + if (findThis && findThis !== "") { var indexPos = response.indexOf("\n" + findThis); // Try windows newlines if not found - if (indexPos == -1) { + if (indexPos === -1) { indexPos = response.indexOf("\r" + findThis); } - if (indexPos != -1) { + if (indexPos !== -1) { // Slice and make sure we comment out any string left back after slicing - so if a user configures something like "G1" we dont end up with a snippet of gcode commands // Yes it would be prettier to parse it line by line and remove the entire line, that is very slow and uses mem - this way we find the string, and remove it response = ";" + response.slice(indexPos + findThis.length + 1); diff --git a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 index b6e485083..1520023a1 100644 --- a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 +++ b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 @@ -20,9 +20,9 @@
- +
- +