From da6f3a2ebb6782d89cb36c66ca682c8cfeaadec8 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Sun, 24 Oct 2021 01:59:41 +0200 Subject: [PATCH 01/41] test against python 3.10 --- .github/workflows/build.yml | 4 ++-- .github/workflows/test_install.yml | 4 ++-- setup.py | 25 +++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc97af96e..dabbb701a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: name: 🧪 Unit tests strategy: matrix: - python: ["2.7", "3.7", "3.8", "3.9"] + python: ["2.7", "3.7", "3.8", "3.9", "3.10"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -70,7 +70,7 @@ jobs: needs: build strategy: matrix: - python: ["2.7", "3.7", "3.8", "3.9"] + python: ["2.7", "3.7", "3.8", "3.9", "3.10"] installable: ["wheel", "sdist"] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index ba2dc5875..8a848511c 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python: ["2.7", "3.7", "3.8", "3.9"] + python: ["2.7", "3.7", "3.8", "3.9", "3.10"] branch: ["master"] runs-on: ${{ matrix.os }} steps: @@ -49,7 +49,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python: ["2.7", "3.7", "3.8", "3.9"] + python: ["2.7", "3.7", "3.8", "3.9", "3.10"] runs-on: ${{ matrix.os }} steps: - name: 👀 Determine latest release diff --git a/setup.py b/setup.py index 73b89f827..29476a968 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- import os +import re import sys from distutils.command.build_py import build_py as _build_py @@ -102,8 +103,10 @@ INSTALL_REQUIRES_OSX = [ EXTRA_REQUIRES = { "develop": [ # Testing dependencies - "mock>=3.0.5,<4", - "pytest==4.6.10", + "mock>=3.0.5,<4 ; python_version < '3'", + "pytest==4.6.10 ; python_version < '3'", + "mock>=4,<5 ; python_version >= '3'", + "pytest>=6.2.5,<7 ; python_version >= '3'", "pytest-doctest-custom>=1.0.0,<2", "ddt", # pre-commit @@ -133,6 +136,22 @@ if int(setuptools.__version__.split(".", 1)[0]) < 18: assert "bdist_wheel" not in sys.argv # add optional dependencies for setuptools versions < 18 that don't yet support environment markers + def _filter_by_python_version_marker(requirements): + for requirement in requirements: + req_match = re.match( + r"^(?P.+);\s*(?Ppython_version.+)$", requirement + ) + if not req_match: + yield requirement + else: + if eval(req_match.group("marker"), {}, {"python_version": sys.version}): + yield req_match.group("req") + + EXTRA_REQUIRES = { + extra: list(_filter_by_python_version_marker(extra_requirements)) + for extra, extra_requirements in EXTRA_REQUIRES.items() + } + if sys.version_info[0] < 3: INSTALL_REQUIRES += INSTALL_REQUIRES_PYTHON2 else: @@ -273,6 +292,8 @@ def params(): "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: JavaScript", "Topic :: Printing", From 1212c00bba75de3d46282b905472c45d0838eac2 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Sun, 24 Oct 2021 02:02:59 +0200 Subject: [PATCH 02/41] added rooter authors --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 47e1237dd..44931beb9 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -154,6 +154,7 @@ date of first contribution): * [Bryan Kenote](https://github.com/bryankenote) * [Sven Samoray](https://github.com/thelastWallE) * [Quinn Damerell](https://github.com/QuinnDamerell) + * [Maciej Urbański](https://github.com/rooterkyberian) 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 From 270cb4f9dea2aaa3327d0bca3ffd461bcbee823b Mon Sep 17 00:00:00 2001 From: Shawn Bruce Date: Wed, 3 Nov 2021 05:16:06 -0400 Subject: [PATCH 03/41] =?UTF-8?q?=F0=9F=90=9B=20Fix=20blacklist=20processi?= =?UTF-8?q?ng=20(#4296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4294 --- src/octoprint/plugin/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index f60908d31..500cc0ca9 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -854,7 +854,7 @@ class PluginManager(object): key, version = entry try: processed_blacklist.append( - (key, pkg_resources.Requirement.parse(version)) + (key, pkg_resources.Requirement.parse(key + version)) ) except Exception: self.logger.warning( @@ -1340,7 +1340,7 @@ class PluginManager(object): return entry_key == key and version in entry_version return False - return any(map(lambda entry: matches_plugin(entry), self.plugin_blacklist)) + return any(map(matches_plugin, self.plugin_blacklist)) def reload_plugins( self, startup=False, initialize_implementations=True, force_reload=None From 56e81d5ea0a1b18ae0127cf6b0ff84a8f32afadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 3 Nov 2021 16:07:00 +0100 Subject: [PATCH 04/41] =?UTF-8?q?=F0=9F=90=9B=20entry=20can=20be=20list=20?= =?UTF-8?q?or=20tuple?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also part of #4294 --- src/octoprint/plugin/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 500cc0ca9..a194e5b3b 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -850,7 +850,7 @@ class PluginManager(object): processed_blacklist = [] for entry in plugin_blacklist: - if isinstance(entry, tuple): + if isinstance(entry, (tuple, list)): key, version = entry try: processed_blacklist.append( From f4d7cb93262f44b5adab130698c15bedb3c7877e Mon Sep 17 00:00:00 2001 From: thelastWallE <12502210+thelastWallE@users.noreply.github.com> Date: Sun, 31 Oct 2021 14:19:23 +0100 Subject: [PATCH 05/41] :globe_with_meridians: change "Restart" to "Neustart" --- .../translations/de/LC_MESSAGES/messages.mo | Bin 197572 -> 197573 bytes .../translations/de/LC_MESSAGES/messages.po | 2 +- translations/de/LC_MESSAGES/messages.mo | Bin 197572 -> 197573 bytes translations/de/LC_MESSAGES/messages.po | 3 +-- 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/octoprint/translations/de/LC_MESSAGES/messages.mo b/src/octoprint/translations/de/LC_MESSAGES/messages.mo index 157cef660c39b98685a5e86fcd0640e5875da3c3..9fff0edd267a1cb2fbc011bc4d3846bba70fc92c 100644 GIT binary patch delta 4266 zcmYk=dtBGm9mny*K@?50@-meY@YYPx)R0i7V9sr#Y&DIva3gj5LnLRKw$yKCKCo#D zh?_v!FNY?Cx4fV$@{-pTiWj_uQ$&TlwbZ7wq3-qOeE-OQp67FZ-|zXJ^EsdM{qk^k zX7fFn&DYlt_d<;^BeSe&g{k;coPs~W0&I;N@nJlG$ynvbPh?wDL>!MDuofS}kQ{5m zu?C1*bKkGCU_9_fa9ov>QD=4pX(;t z3AK30_8MegoT+ftEBgM+Xy9>Mn5_^=f7FChP#Mj@Se%AgxCWIWZ(yD^3u%nUXuOV^Kt#T?H!4-nptd3f z7vam;39q9v)w;kvXfrh)*hMGtvYMiU637PjAChnOgG#XNl?dTtb18_8IOO~Qm zxEVEYg&&{6=EQgKL2UfKTTyH5PCNj6;2%-r=lZ{Iz(nE`IKX(uv|H|0ItmkX11eRk zQ4^>}rPh4l;*R(j;b2rz{T@|RS*QmEPzxwSP2djp#I6BX8>4U_@kEU0`KFkLs%Qy0I8F&{kBjRiai{i>L4wUd4*PThld&l@_|KyRg!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+)b_f7{g`0XH`YucPAuU~@i_hsM;~%0=Ke$Me{F+OI#j*qP}}bo>cp#e z*j0B6RFQSXRv3+u_yRV>`QGnosHIzn+7(Ao2hsO939GR)PB`Lr)e=9AP&zVE#g&5# z@HW=&(^9wZlTZ^{hiozczNa@6O$@fEj=9>YlDKG+kV!!Y~@>i#rrjyb4e+;)ZiuT<`!Ljxa1rSv5F z@EU6E>R)x=YadP|9*8;zR-!&qr%>DO5^6#Xu32*uJK}k~huY?4*WJgh0@oA!e`Npv zK^IoK)K16w#1%LlC;#OB+C7Skh$sBprMd$3`=p<(A+x3w^`^&AMO)_eU-kO0d;L|Y zA~rYNi#GJrU};T9R3TW}BKuz!{N>@LD5hk@mYW)>DYtau+eR|t)elScqZyEmaRAhE3pT5xnoTd zj>j%|2DQc^|8={i4NfK=fPcaOF2tWPUi*LcU29g;@ilJ2X}`GQY570*kr;;S=ugFW zG3uT*tFRO|;mm4RE3NOl`vzkg{WDN+UW5ATMg8hBG#|SY@5FK1|5s>eZDVSz$-@0u zf#a!Bt!+$DaP8X0qSkg8Y7NKXLpT++zhC!UjH-nU48dGf^#@Qzn1`zV?HH>4Ur0ko z;}_l!rKp-X;l-y>4?Kr@U?pmxYSgX?vu?l!sDr4HX9sLc+}Ha(-s^uJ8_+);{hG-e zG_+=Z)WF%OKaba<{1Rm#d;V(y?H+BqxLcCxJ1d9Lw diff --git a/src/octoprint/translations/de/LC_MESSAGES/messages.po b/src/octoprint/translations/de/LC_MESSAGES/messages.po index 15a701c8c..7ac7d10e5 100644 --- a/src/octoprint/translations/de/LC_MESSAGES/messages.po +++ b/src/octoprint/translations/de/LC_MESSAGES/messages.po @@ -7881,7 +7881,7 @@ msgstr "Gedruckt" #: src/octoprint/templates/sidebar/state.jinja2:29 msgid "Restart" -msgstr "Restart" +msgstr "Neustart" #: src/octoprint/templates/sidebar/state.jinja2:29 msgid "Print" diff --git a/translations/de/LC_MESSAGES/messages.mo b/translations/de/LC_MESSAGES/messages.mo index 157cef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=fPcaOF2tWPUi*LcU29g;@ilJ2X}`GQY570*kr;;S=ugFW zG3uT*tFRO|;mm4RE3NOl`vzkg{WDN+UW5ATMg8hBG#|SY@5FK1|5s>eZDVSz$-@0u zf#a!Bt!+$DaP8X0qSkg8Y7NKXLpT++zhC!UjH-nU48dGf^#@Qzn1`zV?HH>4Ur0ko z;}_l!rKp-X;l-y>4?Kr@U?pmxYSgX?vu?l!sDr4HX9sLc+}Ha(-s^uJ8_+);{hG-e zG_+=Z)WF%OKaba<{1Rm#d;V(y?H+BqxLcCxJ1d9Lw diff --git a/translations/de/LC_MESSAGES/messages.po b/translations/de/LC_MESSAGES/messages.po index 106033e94..7ac7d10e5 100644 --- a/translations/de/LC_MESSAGES/messages.po +++ b/translations/de/LC_MESSAGES/messages.po @@ -7881,7 +7881,7 @@ msgstr "Gedruckt" #: src/octoprint/templates/sidebar/state.jinja2:29 msgid "Restart" -msgstr "Restart" +msgstr "Neustart" #: src/octoprint/templates/sidebar/state.jinja2:29 msgid "Print" @@ -8998,4 +8998,3 @@ msgstr "Ungerenderte Zeitrafferaufnahme löschen" #: src/octoprint/templates/tabs/timelapse.jinja2:201 msgid "Render timelapse" msgstr "Zeitrafferaufnahme rendern" - From 686eda353603cddaa096dacab58e12ce195b7f2e Mon Sep 17 00:00:00 2001 From: thelastWallE <12502210+thelastWallE@users.noreply.github.com> Date: Fri, 29 Oct 2021 22:42:55 +0200 Subject: [PATCH 06/41] :pencil: use slash in git bash - changed backslashes to normal slashes for the creation of the venv. --- docs/development/environment.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/development/environment.rst b/docs/development/environment.rst index 144e37e71..b8d989ae3 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -180,7 +180,7 @@ Open the Git Bash you just installed and in that: cd /c/Devel git clone https://github.com/OctoPrint/OctoPrint.git cd OctoPrint - virtualenv --python=C:\Python3\python.exe venv3 + virtualenv --python=C:/Python3/python.exe venv3 source ./venv3/Scripts/activate pip install --upgrade pip python -m pip install -e '.[develop,plugins,docs]' @@ -207,7 +207,7 @@ Then: .. code-block:: none cd /c/Devel/OctoPrint - virtualenv --python=C:\Python27\python.exe venv2 + virtualenv --python=C:/Python27/python.exe venv2 source ./venv2/Scripts/activate python -m pip install --upgrade pip pip install -e '.[develop,plugins]' From f5304abbe20267c627c047a9d6c924527796e1a0 Mon Sep 17 00:00:00 2001 From: Adam Wolf Date: Thu, 4 Nov 2021 05:01:12 -0500 Subject: [PATCH 07/41] =?UTF-8?q?=F0=9F=9A=B8=20Highlight=20every=20fifth?= =?UTF-8?q?=20grid=20line=20in=20GCode=20Viewer=20(#4287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By highlighting every fifth grid line in the GCode Viewer, people can better see spatial relations. Plus, it looks a bit like engineering grid paper! For #4179 Co-authored-by: Adam Wolf Co-authored-by: Gina Häußge --- AUTHORS.md | 1 + .../gcodeviewer/static/js/viewer/renderer.js | 30 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 38309b09e..858771efd 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -155,6 +155,7 @@ date of first contribution): * [Quinn Damerell](https://github.com/QuinnDamerell) * [Sven Samoray](https://github.com/thelastWallE) * [Maciej Urbański](https://github.com/rooterkyberian) + * [Adam Wolf](https://github.com/adamwolf) 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/plugins/gcodeviewer/static/js/viewer/renderer.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/renderer.js index 3946f17d2..6dfd2a047 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/renderer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/renderer.js @@ -617,12 +617,19 @@ GCODE.renderer = (function () { ctx.circle(0, 0, 2); ctx.stroke(); - ctx.strokeStyle = renderOptions["colorGrid"]; - ctx.lineWidth = lineWidthFactor; - //~~ grid starting from origin - ctx.beginPath(); + ctx.strokeStyle = renderOptions["colorGrid"]; + var gridline = 0; for (x = 0; x <= maxX; x += gridStep) { + ctx.beginPath(); + if (gridline % 5 === 0) { + // every fifth line, including the center + ctx.lineWidth = 1.5 * lineWidthFactor; + } else { + ctx.lineWidth = lineWidthFactor; + } + gridline += 1; + ctx.moveTo(x, minY); ctx.lineTo(x, maxY); @@ -630,11 +637,20 @@ GCODE.renderer = (function () { ctx.moveTo(-1 * x, minY); ctx.lineTo(-1 * x, maxY); } + ctx.stroke(); } - ctx.stroke(); - ctx.beginPath(); + gridline = 0; for (y = 0; y <= maxY; y += gridStep) { + ctx.beginPath(); + if (gridline % 5 === 0) { + // every fifth line, including the center + ctx.lineWidth = 1.5 * lineWidthFactor; + } else { + ctx.lineWidth = lineWidthFactor; + } + gridline += 1; + ctx.moveTo(minX, y); ctx.lineTo(maxX, y); @@ -642,8 +658,8 @@ GCODE.renderer = (function () { ctx.moveTo(minX, -1 * y); ctx.lineTo(maxX, -1 * y); } + ctx.stroke(); } - ctx.stroke(); }; var drawCircularGrid = function () { From 3c094f55852f322e22f8446b61caebee6f30ddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 8 Nov 2021 14:54:29 +0100 Subject: [PATCH 08/41] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=82=EF=B8=8F?= =?UTF-8?q?=20Fix=20comment=20detection=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/issue_automation.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/issue_automation.yml b/.github/workflows/issue_automation.yml index 40a89ba60..3e5b9e016 100644 --- a/.github/workflows/issue_automation.yml +++ b/.github/workflows/issue_automation.yml @@ -109,6 +109,11 @@ jobs: issue_number: context.issue.number, }) const comment = comments.data.find(c => c.user.login === "github-actions[bot]" && c.body.includes(marker)); + if (comment) { + console.log("Found comment, id=" + comment.id); + } else { + console.log("No comment found"); + } if (!labels.includes("triage") || labels.includes("approved")) { console.log("Deleting comment if it exists..."); @@ -127,20 +132,20 @@ jobs: if (!found) { console.log("No bundle found, posting/updating reminder"); const text = REMINDER + "\n" + marker; - if (comment && comment.body !== text) { - await github.rest.issues.updateComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: comment.id, - body: text - }); - } else { + if (!comment) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: text }); + } else if (comment.body !== text) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + body: text + }); } } else if (found && comment) { console.log("Bundle found, saying thanks"); From 526a8e9a9f49221041bcbc3a2708810f8324ec1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Nov 2021 13:57:38 +0100 Subject: [PATCH 09/41] =?UTF-8?q?=E2=9C=A8=20Add=20last=20safe=20mode=20da?= =?UTF-8?q?te=20&=20reason=20to=20sys=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That will allow us to determine if a user *actually* recently launched in safe mode when reporting an issue. I wish this wasn't necessary, but as House always said, everybody lies. --- src/octoprint/cli/systeminfo.py | 30 +++++++++++++++++++++++++--- src/octoprint/server/__init__.py | 15 ++++++++++++++ src/octoprint/server/api/system.py | 1 + src/octoprint/server/util/tornado.py | 1 + 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/octoprint/cli/systeminfo.py b/src/octoprint/cli/systeminfo.py index 76678375c..42a2b11d9 100644 --- a/src/octoprint/cli/systeminfo.py +++ b/src/octoprint/cli/systeminfo.py @@ -2,9 +2,11 @@ from __future__ import absolute_import, division, print_function, unicode_literals __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" -__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" +__copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License" +import datetime +import io import logging import os @@ -16,7 +18,9 @@ from octoprint.cli import init_platform_for_cli, standard_options click.disable_unicode_literals_warning = True -def get_systeminfo(environment_detector, connectivity_checker, additional_fields=None): +def get_systeminfo( + environment_detector, connectivity_checker, settings, additional_fields=None +): from octoprint import __version__ from octoprint.util import dict_flatten @@ -25,10 +29,30 @@ def get_systeminfo(environment_detector, connectivity_checker, additional_fields environment_detector.run_detection(notify_plugins=False) + safe_mode_file = os.path.join(settings.getBaseFolder("data"), "last_safe_mode") + last_safe_mode = {"date": "unknown", "reason": "unknown"} + try: + if os.path.exists(safe_mode_file): + with io.open(safe_mode_file, "r") as f: + last_safe_mode["reason"] = f.readline().strip() + last_safe_mode["date"] = ( + datetime.datetime.utcfromtimestamp( + os.path.getmtime(safe_mode_file) + ).isoformat()[:19] + + "Z" + ) + except Exception as ex: + logging.getLogger(__name__).error( + "Error while retrieving last safe mode information from {}: {}".format( + safe_mode_file, ex + ) + ) + systeminfo = { - "octoprint": {"version": __version__}, + "octoprint": {"version": __version__, "last_safe_mode": last_safe_mode}, "connectivity": connectivity_checker.as_dict(), "env": environment_detector.environment, + "systeminfo": {"generated": datetime.datetime.utcnow().isoformat()[:19] + "Z"}, } # flatten and filter diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index bb3e468f1..fdf5eec8f 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -303,6 +303,9 @@ class Server(object): debug = self._debug safe_mode = self._safe_mode + if safe_mode: + self._log_safe_mode_start(safe_mode) + if self._v6_only and not octoprint.util.net.HAS_V6: raise RuntimeError( "IPv6 only mode configured but system doesn't support IPv6" @@ -1277,6 +1280,18 @@ class Server(object): ) self._logger.exception("Stacktrace follows:") + def _log_safe_mode_start(self, self_mode): + self_mode_file = os.path.join( + self._settings.getBaseFolder("data"), "last_safe_mode" + ) + try: + with io.open(self_mode_file, "w+", encoding="utf-8") as f: + f.write(self_mode) + except Exception as ex: + self._logger.warn( + "Could not write safe mode file {}: {}".format(self_mode_file, ex) + ) + def _create_socket_connection(self, session): global printer, fileManager, analysisQueue, userManager, eventManager, connectivityChecker return util.sockjs.PrinterStateConnection( diff --git a/src/octoprint/server/api/system.py b/src/octoprint/server/api/system.py index a3e3dcab8..7863a9c01 100644 --- a/src/octoprint/server/api/system.py +++ b/src/octoprint/server/api/system.py @@ -47,6 +47,7 @@ def getSystemInfo(): systeminfo = get_systeminfo( environmentDetector, connectivityChecker, + s(), { "browser.user_agent": request.headers.get("User-Agent"), "octoprint.safe_mode": safe_mode is not None, diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index 00aca1d23..d74169cfb 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -1580,6 +1580,7 @@ class SystemInfoBundleHandler(CorsSupportMixin, tornado.web.RequestHandler): systeminfo = get_systeminfo( environmentDetector, connectivityChecker, + settings(), { "browser.user_agent": self.request.headers.get("User-Agent"), "octoprint.safe_mode": safe_mode is not None, From d4fc7e940fa69ea28df41bf1e39ce2e8a5b81953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 9 Nov 2021 14:31:50 +0100 Subject: [PATCH 10/41] =?UTF-8?q?=F0=9F=92=AC=20Rephrase=20systeminfo=20bu?= =?UTF-8?q?ndle=20instructions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/dialogs/about/systeminfo.jinja2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/octoprint/templates/dialogs/about/systeminfo.jinja2 b/src/octoprint/templates/dialogs/about/systeminfo.jinja2 index 9eb51ad74..d13a7e210 100644 --- a/src/octoprint/templates/dialogs/about/systeminfo.jinja2 +++ b/src/octoprint/templates/dialogs/about/systeminfo.jinja2 @@ -1,11 +1,14 @@

{{ _('System Information') }}

-

{% trans %}Please always share a Systeminfo Bundle when requesting support on the forums or - when opening a new bug report:{% endtrans %}

+

{% trans %}Sharing a Systeminfo Bundle when requesting support on the forums or + when opening a new bug report is mandatory!{% endtrans %}

+ +

{% trans %}Download the bundle and share as provided. Do not rename, unpack, + repack or otherwise modify, provide exactly as downloaded.{% endtrans %}

{{ _('Download Systeminfo Bundle') }}

-

{% trans %}You can view Systeminfo Bundles at bundleviewer.octoprint.org{% endtrans %}

+

{% trans %}You can view Systeminfo Bundles at bundleviewer.octoprint.org{% endtrans %}

@@ -13,7 +16,5 @@

:

- - {{ _('Copy') }}
From 1627b8627b184c6d80ec51f9b08fd3883ec89065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20W=C3=BCrthner?= Date: Wed, 10 Nov 2021 12:01:02 +0100 Subject: [PATCH 11/41] =?UTF-8?q?=E2=9C=A8=20Websocket:=20Allow=20clients?= =?UTF-8?q?=20to=20selectively=20subscribe=20to=20messages=20(#4280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a `subscribe` message to allow clients to reduce websocket traffic. Docs updated accordingly. Co-authored-by: Gina Häußge --- AUTHORS.md | 1 + docs/api/push.rst | 65 +++++++++++++++- src/octoprint/server/util/sockjs.py | 115 +++++++++++++++++++++++++++- 3 files changed, 177 insertions(+), 4 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 858771efd..55974884f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -154,6 +154,7 @@ date of first contribution): * [Bryan Kenote](https://github.com/bryankenote) * [Quinn Damerell](https://github.com/QuinnDamerell) * [Sven Samoray](https://github.com/thelastWallE) + * [Christian Würthner](https://github.com/crysxd) * [Maciej Urbański](https://github.com/rooterkyberian) * [Adam Wolf](https://github.com/adamwolf) diff --git a/docs/api/push.rst b/docs/api/push.rst index 5210ad599..a9796b663 100644 --- a/docs/api/push.rst +++ b/docs/api/push.rst @@ -50,7 +50,70 @@ Clients must ignore any unknown messages. The data model of the attached payloads is described further below. -OctoPrint's SockJS socket also accepts two commands from the client to the server. +OctoPrint's SockJS socket also accepts three commands from the client to the server. + + * ``subscribe`` (since 1.8.0): With the ``subscribe`` message, clients may selectively + subscribe to certain message types. The payload should be a dict of message types with + supported keys as follows: + + * ``state``: Either a boolean value indicating whether to generally receive state updates (``current`` and ``history``) + or not, or a dict with further options for received state updates. Currently the following options are recognized here: + + * ``logs``: A boolean value whether to include all log lines (``True``, default) or not (``False``). Alternatively a string with + a regex pattern can be provided, in which case only log lines matching the pattern will be returned. + * ``messages``: Like ``logs`` but for the returned message lines. + + * ``plugins``: Either a boolean value indicating whether to generally receive plugin messages, or a list of plugin + identifiers to receive plugin messages for. + * ``events``: Either a boolean value indicating whether to generally receive event messages, or a list of event + types to receive event messages for. + + If you send a ``subscribe`` message, OctoPrint will default the connection to not subscribe you to anything you did't explicitly + request. ``subscribe`` messages do replace previous ones. + + Example for a ``subscribe`` message subscribing only to updates from plugin ``example`` but neither state nor events: + + .. sourcecode:: javascript + + { + "subscribe": { + "plugins": ["example"] + } + } + + Example for a ``subscribe`` message subscribing to state, event and plugin updates, + but filtering logs in state updates to only contain lines matching ``^Recv: Cap`` and also + filtering out all messages: + + .. sourcecode:: javascript + + { + "subscribe": { + "state": { + "logs": "^Recv: Cap", + "messages": false + }, + "events": true, + "plugins": true + } + } + + Example for a ``subscribe`` message subscribing only to events of type ``PrintFailed``: + + .. sourcecode:: javascript + + { + "subscribe": { + "events": ["PrintFailed"] + } + } + + .. note:: + + Per default, OctoPrint will subscribe connecting clients to all state, event and plugin updates + without any filtering in place. If you wish to have your more selective subscription active + right from the start of your socket session, be sure to send the ``subscribe`` message + **before** the ``auth`` message. * ``auth`` (since 1.3.10): With the ``auth`` message, clients may associate an existing user session with the socket. That is of special importance to receive diff --git a/src/octoprint/server/util/sockjs.py b/src/octoprint/server/util/sockjs.py index 57ca4de52..4fb257a73 100644 --- a/src/octoprint/server/util/sockjs.py +++ b/src/octoprint/server/util/sockjs.py @@ -6,10 +6,12 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" import logging +import re import threading import time import wrapt +from past.builtins import basestring import octoprint.access.users import octoprint.events @@ -170,6 +172,10 @@ class PrinterStateConnection( self._registered = False self._authed = False + self._initial_data_sent = False + + self._subscriptions_active = False + self._subscriptions = {"state": False, "plugins": [], "events": []} @staticmethod def _get_remote_address(info): @@ -313,10 +319,77 @@ class PrinterStateConnection( ) ) + elif "subscribe" in message: + if not self._subscriptions_active: + self._subscriptions_active = True + self._logger.debug("Client makes use of subscriptions") + + def list_or_boolean(value): + if isinstance(value, list): + return value + elif isinstance(value, bool): + return [] if not value else None + else: + raise ValueError("value must be a list or boolean") + + def regex_or_boolean(value): + if isinstance(value, basestring): + try: + return re.compile(value) + except Exception: + raise ValueError("value must be a valid regex") + elif isinstance(value, bool): + return value + else: + raise ValueError("value must be a string or boolean") + + try: + subscribe = message["subscribe"] + + state = subscribe.get("state", False) + if isinstance(state, bool): + if state: + state = {"logs": True, "messages": False} + elif isinstance(state, dict): + logs = regex_or_boolean(state.get("logs", False)) + messages = regex_or_boolean(state.get("messages", False)) + state = { + "logs": logs, + "messages": messages, + } + + plugins = list_or_boolean(subscribe.get("plugins", [])) + events = list_or_boolean(subscribe.get("events", [])) + + except ValueError as e: + self._logger.warning( + "Got invalid subscription message from client {}, ignoring: {!r} ({}) ".format( + self._remoteAddress, message["subscribe"], str(e) + ) + ) + else: + old_state = self._subscriptions["state"] + self._subscriptions["state"] = state + self._subscriptions["plugins"] = plugins + self._subscriptions["events"] = events + + if state and not old_state: + # trigger initial data + self._printer.send_initial_callback(self) + elif old_state and not state: + self._initial_data_sent = False + def on_printer_send_current_data(self, data): if not self._user.has_permission(Permissions.STATUS): return + if self._subscriptions_active and not self._subscriptions["state"]: + return + + if not self._initial_data_sent: + self._logger.debug("Initial data not yet send, dropping current message") + return + # make sure we rate limit the updates according to our throttle factor with self._held_back_mutex: if self._held_back_current is not None: @@ -342,11 +415,11 @@ class PrinterStateConnection( self._temperatureBacklog = [] with self._logBacklogMutex: - logs = self._logBacklog + logs = self._filter_logs(self._logBacklog) self._logBacklog = [] with self._messageBacklogMutex: - messages = self._messageBacklog + messages = self._filter_messages(self._messageBacklog) self._messageBacklog = [] busy_files = [ @@ -373,7 +446,7 @@ class PrinterStateConnection( { "serverTime": time.time(), "temps": temperatures, - "logs": logs, + "logs": self._filter_logs(logs), "messages": messages, "busyFiles": busy_files, } @@ -381,10 +454,32 @@ class PrinterStateConnection( self._emit("current", payload=data) def on_printer_send_initial_data(self, data): + self._initial_data_sent = True + if self._subscriptions_active and not self._subscriptions["state"]: + self._logger.debug("Not subscribed to state, dropping history") + return + data_to_send = dict(data) + data_to_send["logs"] = self._filter_logs(data_to_send.get("logs", [])) + data_to_send["messages"] = self._filter_messages(data_to_send.get("messages", [])) data_to_send["serverTime"] = time.time() self._emit("history", payload=data_to_send) + def _filter_state_subscription(self, sub, values): + if not self._subscriptions_active or self._subscriptions["state"][sub] is True: + return values + + if self._subscriptions["state"][sub] is False: + return [] + + return [line for line in values if self._subscriptions["state"][sub].search(line)] + + def _filter_logs(self, logs): + return self._filter_state_subscription("logs", logs) + + def _filter_messages(self, messages): + return self._filter_state_subscription("messages", messages) + def sendEvent(self, type, payload=None): permissions = self._event_permissions.get(type, self._event_permissions["*"]) permissions = [x(self._user) if callable(x) else x for x in permissions] @@ -423,6 +518,13 @@ class PrinterStateConnection( self._emit("renderProgress", {"progress": progress}) def on_plugin_message(self, plugin, data, permissions=None): + if ( + self._subscriptions_active + and self._subscriptions["plugins"] is not None + and plugin not in self._subscriptions["plugins"] + ): + return + self._emit( "plugin", payload={"plugin": plugin, "data": data}, permissions=permissions ) @@ -475,6 +577,13 @@ class PrinterStateConnection( self._sendReauthRequired("modified") def _onEvent(self, event, payload): + if ( + self._subscriptions_active + and self._subscriptions["events"] is not None + and event not in self._subscriptions["events"] + ): + return + self.sendEvent(event, payload) def _register(self): From 8b3a51c1a0f39844189780f15e843154b7ee7e0c Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Wed, 10 Nov 2021 12:49:14 +0100 Subject: [PATCH 12/41] =?UTF-8?q?=E2=8F=AA=20Back=20to=20frozendict=20(#42?= =?UTF-8?q?44)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original frozendict module is maintained again and has not removed setup.py from the repository to make packaging harder. Also the 2.x releases have added native code to speed it up. We need to however stick to older versions for Python 2 and can only pull in newer versions under Python 3. Co-authored-by: Gina Häußge --- setup.py | 4 ++-- src/octoprint/printer/standard.py | 15 +++++---------- src/octoprint/util/__init__.py | 23 +++++++++-------------- src/octoprint/util/json/__init__.py | 8 ++------ tests/util/test_misc.py | 23 +++++++++-------------- 5 files changed, 27 insertions(+), 46 deletions(-) diff --git a/setup.py b/setup.py index 4b5c1c8bd..c17440333 100644 --- a/setup.py +++ b/setup.py @@ -76,7 +76,7 @@ INSTALL_REQUIRES_PYTHON2 = [ "chainmap>=1.0.3,<2", "typing>=3.10.0.0,<4", "enum34>=1.1.10,<1.2", - "frozendict==1.2", # newer versions from different maintainer require Python 3 + "frozendict==1.2", # newer versions require Python 3 "colorlog<5", # newer versions require Python 3 # vendor bundled dependencies "unidecode<1.3", # dependency of awesome-slugify, newer versions require Python 3 @@ -87,7 +87,7 @@ INSTALL_REQUIRES_PYTHON3 = [ "feedparser>=6.0.8,<7", "tornado>=6,<7", # tornado < 6 is incompatible with Python 3.10 "zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases - "immutabledict>=2.1,<3", + "frozendict>=2.0,<3", "pathvalidate>=2.4.1,<3", "colorlog>=5.0.1,<6", # vendor bundled dependencies diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 7b8912d66..66b55ed4f 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -15,12 +15,7 @@ import os import threading import time -try: - from immutabledict import immutabledict -except ImportError: - # Python 2 - from frozendict import frozendict as immutabledict - +from frozendict import frozendict from past.builtins import basestring, long import octoprint.util.json @@ -56,7 +51,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._logger_job = logging.getLogger("{}.job".format(__name__)) self._dict = ( - immutabledict + frozendict if settings().getBoolean(["devel", "useFrozenDictForPrinterState"]) else dict ) @@ -203,7 +198,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): @property def firmware_info(self): - return immutabledict(self._firmware_info) if self._firmware_info else None + return frozendict(self._firmware_info) if self._firmware_info else None # ~~ handling of PrinterCallbacks @@ -844,11 +839,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): return self._comm.getErrorString() def get_current_data(self, *args, **kwargs): - return util.thaw_immutabledict(self._stateMonitor.get_current_data()) + return util.thaw_frozendict(self._stateMonitor.get_current_data()) def get_current_job(self, *args, **kwargs): currentData = self._stateMonitor.get_current_data() - return util.thaw_immutabledict(currentData["job"]) + return util.thaw_frozendict(currentData["job"]) def get_current_temperatures(self, *args, **kwargs): if self._comm is not None: diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 0a1f4c271..1233e1f5a 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -33,13 +33,8 @@ except ImportError: # Python 2.7 from collections import Iterable, MutableMapping, Set -try: - from immutabledict import immutabledict -except ImportError: - # Python 2 - from frozendict import frozendict as immutabledict - import past.builtins +from frozendict import frozendict try: import queue @@ -1214,23 +1209,23 @@ except ImportError: monotonic_time = time.time -def thaw_immutabledict(obj): - if not isinstance(obj, (dict, immutabledict)): - raise ValueError("obj must be a dict or immutabledict instance") +def thaw_frozendict(obj): + if not isinstance(obj, (dict, frozendict)): + raise ValueError("obj must be a dict or frozendict instance") # only true love can thaw a frozen dict letitgo = {} for key, value in obj.items(): - if isinstance(value, (dict, immutabledict)): - letitgo[key] = thaw_immutabledict(value) + if isinstance(value, (dict, frozendict)): + letitgo[key] = thaw_frozendict(value) else: letitgo[key] = copy.deepcopy(value) return letitgo -thaw_frozendict = deprecated( - "thaw_frozendict has been renamed to thaw_immutabledict", since="1.6.0" -)(thaw_immutabledict) +thaw_immutabledict = deprecated( + "thaw_immutabledict has been renamed back to thaw_frozendict", since="1.8.0" +)(thaw_frozendict) def utmify(link, source=None, medium=None, name=None, term=None, content=None): diff --git a/src/octoprint/util/json/__init__.py b/src/octoprint/util/json/__init__.py index 41a8f30c1..4fe7be597 100644 --- a/src/octoprint/util/json/__init__.py +++ b/src/octoprint/util/json/__init__.py @@ -8,11 +8,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms import collections import json -try: - from immutabledict import immutabledict -except ImportError: - # Python 2 - from frozendict import frozendict as immutabledict +from frozendict import frozendict from octoprint.util import to_unicode @@ -49,5 +45,5 @@ class JsonEncoding(object): raise TypeError -JsonEncoding.add_encoder(immutabledict, lambda obj: dict(obj)) +JsonEncoding.add_encoder(frozendict, lambda obj: dict(obj)) JsonEncoding.add_encoder(bytes, lambda obj: to_unicode(obj)) diff --git a/tests/util/test_misc.py b/tests/util/test_misc.py index 64de26908..86c195b3e 100644 --- a/tests/util/test_misc.py +++ b/tests/util/test_misc.py @@ -8,12 +8,7 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms import unittest import ddt - -try: - from immutabledict import immutabledict -except ImportError: - # Python 2 - from frozendict import frozendict as immutabledict +from frozendict import frozendict import octoprint.util @@ -71,35 +66,35 @@ class MiscTestCase(unittest.TestCase): self.assertEqual(actual, expected) @ddt.data( - (immutabledict(a=1, b=2, c=3), {"a": 1, "b": 2, "c": 3}), + (frozendict(a=1, b=2, c=3), {"a": 1, "b": 2, "c": 3}), ( - immutabledict(a=1, b=2, c=immutabledict(c1=1, c2=2)), + frozendict(a=1, b=2, c=frozendict(c1=1, c2=2)), {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2}}, ), ({"a": 1, "b": 2, "c": 3}, {"a": 1, "b": 2, "c": 3}), ( - {"a": 1, "b": 2, "c": immutabledict(c1=1, c2=2)}, + {"a": 1, "b": 2, "c": frozendict(c1=1, c2=2)}, {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2}}, ), ( { "a": 1, "b": 2, - "c": {"c1": 1, "c2": 2, "c3": immutabledict(c11=11, c12=12)}, + "c": {"c1": 1, "c2": 2, "c3": frozendict(c11=11, c12=12)}, }, {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2, "c3": {"c11": 11, "c12": 12}}}, ), ) @ddt.unpack - def test_unfreeze_immutabledict(self, input, expected): - result = octoprint.util.thaw_immutabledict(input) + def test_unfreeze_frozendict(self, input, expected): + result = octoprint.util.thaw_frozendict(input) self.assertIsInstance(result, dict) self.assertDictEqual(result, expected) @ddt.data(None, "invalid", 3, [1, 2], (3, 4)) - def test_unfreeze_immutabledict_invalid(self, input): + def test_unfreeze_frozendict_invalid(self, input): try: - octoprint.util.thaw_immutabledict(input) + octoprint.util.thaw_frozendict(input) self.fail("expected ValueError") except ValueError: # expected From 28ae00d9defb70ff65e0fcaf5d13ace7c72a5497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 10 Nov 2021 16:08:13 +0100 Subject: [PATCH 13/41] =?UTF-8?q?=F0=9F=90=9B=20Ignore=20checks=20w/o=20ty?= =?UTF-8?q?pe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we disabled some checks in the past, and their providing plugins are currently disabled, we will have checks configured that only consist of a "disabled" key. That will cause a warning to be logged as there's no type defined. So we now simply ignore entries without a type altogether. --- src/octoprint/plugins/softwareupdate/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 1dfde6b31..ff30b19f7 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -1543,6 +1543,9 @@ class SoftwareUpdatePlugin( if not check: continue + if "type" not in check: + continue + try: populated_check = self._populated_check(target, check) future = executor.submit( From bc85a0d02aaf812acab3e9e9dec636aef2556449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 11 Nov 2021 15:35:27 +0100 Subject: [PATCH 14/41] =?UTF-8?q?=E2=9C=A8=20pgmr:=20Bulk=20plugin=20manag?= =?UTF-8?q?ement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now restricted to third party plugins. Allows bulk enabling and disabling. Should help with debugging and also general maintenance. Implements #4314 --- .../static/css/pluginmanager.css | 2 +- .../pluginmanager/static/js/pluginmanager.js | 185 +++++++++++++++++- .../static/less/pluginmanager.less | 9 + .../templates/pluginmanager_settings.jinja2 | 16 ++ 4 files changed, 209 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css b/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css index 4525678b4..ea8c55eea 100644 --- a/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css +++ b/src/octoprint/plugins/pluginmanager/static/css/pluginmanager.css @@ -1 +1 @@ -#settings_plugin_pluginmanager_pluginlist{height:calc(100vh - 450px);display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em;position:relative;border-top:1px solid #eee;padding-top:6px}#settings_plugin_pluginmanager_pluginlist>table{margin-top:0}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name .prop,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name .prop{white-space:nowrap}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:400px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .meta{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .stats .prop{white-space:nowrap}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009} \ No newline at end of file +#settings_plugin_pluginmanager_pluginlist{height:calc(100vh - 450px);display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em;position:relative;border-top:1px solid #eee;padding-top:6px}#settings_plugin_pluginmanager_pluginlist>table{margin-top:0}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_checkbox,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_checkbox{text-align:center;width:10px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_checkbox input[type=checkbox],#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_checkbox input[type=checkbox]{margin-top:0}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name .prop,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name .prop{white-space:nowrap}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:400px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .meta{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .stats .prop{white-space:nowrap}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009} \ No newline at end of file diff --git a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js index 28f515056..4381e7d4c 100644 --- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js +++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js @@ -58,6 +58,10 @@ $(function () { ], 0 ); + self.plugins.currentFilters.subscribe(function () { + self.clearPluginsSelection(); + }); + self.pluginLookup = {}; self.repositoryplugins = new ItemListHelper( "plugin.pluginmanager.repositoryplugins", @@ -169,6 +173,8 @@ $(function () { 0 ); + self.selectedPlugins = ko.observableArray([]); + self.uploadElement = $("#settings_plugin_pluginmanager_repositorydialog_upload"); self.uploadButton = $( "#settings_plugin_pluginmanager_repositorydialog_upload_start" @@ -274,14 +280,21 @@ $(function () { return !self.printerState.isBusy(); }); - self.enableToggle = function (data) { + self.enableBulk = function (data) { + return self.enableToggle(data, true) && !data.bundled; + }; + + self.enableToggle = function (data, ignoreToggling) { var command = self._getToggleCommand(data); var not_safemode_victim = !data.safe_mode_victim; var not_blacklisted = !data.blacklisted; var not_incompatible = !data.incompatible; + + ignoreToggling = !!ignoreToggling; + return ( self.enableManagement() && - !self.toggling() && + (ignoreToggling || !self.toggling()) && (command === "disable" || (not_safemode_victim && not_blacklisted && not_incompatible)) && data.key !== "pluginmanager" @@ -508,7 +521,9 @@ $(function () { var installedPlugins = []; var noticeCount = 0; + var lookup = {}; _.each(data, function (plugin) { + lookup[plugin.key] = plugin; installedPlugins.push(plugin.key); if (evalNotices && plugin.notifications && plugin.notifications.length) { @@ -537,6 +552,7 @@ $(function () { if (evalNotices) self.noticeCount(noticeCount); self.installedPlugins(installedPlugins); self.plugins.updateItems(data); + self.pluginLookup = lookup; }; self.fromOrphanResponse = function (data) { @@ -802,6 +818,171 @@ $(function () { } }; + self._bulkOperation = function ( + plugins, + title, + message, + successText, + failureText, + statusText, + callback, + alreadyCheck + ) { + var deferred = $.Deferred(); + var promise = deferred.promise(); + var options = { + title: title, + message: _.sprintf(message, {count: plugins.length}), + max: plugins.length, + output: true + }; + showProgressModal(options, promise); + + var handle = function (key) { + var d = $.Deferred(); + + var plugin = self.pluginLookup[key]; + if (!plugin) { + deferred.notify( + _.sprintf( + gettext("Can't resolve plugin with key %(key)s, skipping..."), + {key: key} + ), + false + ); + d.reject(); + return d.promise(); + } + if (!self.enableBulk(plugin)) { + deferred.notify( + _.sprintf( + gettext( + "Plugin %(plugin)s doesn't support bulk operations, skipping..." + ), + {plugin: plugin.name || key} + ), + false + ); + d.reject(); + return d.promise(); + } + if (alreadyCheck(plugin)) { + deferred.notify( + _.sprintf( + gettext( + "Plugin %(plugin)s is already %(status)s (or pending), skipping..." + ), + { + plugin: plugin.name || key, + status: statusText + } + ), + true + ); + d.reject(); + return d.promise(); + } + + callback(plugin) + .done(function () { + deferred.notify( + _.sprintf(successText, {plugin: plugin.name || key}), + true + ); + d.resolve(); + }) + .fail(function () { + deferred.notify( + _.sprintf(failureText, {plugin: plugin.name || key}), + false + ); + d.reject(); + }); + return d.promise(); + }; + + var operations = []; + _.each(plugins, function (key) { + operations.push(handle(key)); + }); + $.when.apply($, _.map(operations, wrapPromiseWithAlways)).done(function () { + deferred.resolve(); + self.requestPluginData(); + }); + return promise; + }; + + self.enableSelectedPlugins = function () { + if (self.selectedPlugins().length === 0) return; + + var callback = function (plugin) { + return OctoPrint.plugins.pluginmanager.enable(plugin.key); + }; + var check = function (plugin) { + return plugin.enabled || plugin.pending_enable; + }; + + self.toggling(true); + self._bulkOperation( + self.selectedPlugins(), + gettext("Enabling plugins"), + gettext("Enabling %(count)i plugins"), + gettext("Enabled plugin %(plugin)s..."), + gettext("Enabling plugin %(plugin)s failed, continuing..."), + gettext("enabled"), + callback, + check + ) + .done(function () { + self.selectedPlugins([]); + }) + .always(function () { + self.toggling(false); + }); + }; + + self.disableSelectedPlugins = function () { + if (self.selectedPlugins().length === 0) return; + + var callback = function (plugin) { + return OctoPrint.plugins.pluginmanager.disable(plugin.key); + }; + var check = function (plugin) { + return !plugin.enabled || plugin.pending_disable; + }; + + self.toggling(true); + self._bulkOperation( + self.selectedPlugins(), + gettext("Disabling plugins"), + gettext("Disabling %(count)i plugins"), + gettext("Disabled plugin %(plugin)s..."), + gettext("Disabling plugin %(plugin)s failed, continuing..."), + gettext("disabled"), + callback, + check + ) + .done(function () { + self.selectedPlugins([]); + }) + .always(function () { + self.toggling(false); + }); + }; + + self.selectAllVisiblePlugins = function () { + var selection = []; + _.each(self.plugins.paginatedItems(), function (plugin) { + if (!self.enableBulk(plugin)) return; + selection.push(plugin.key); + }); + self.selectedPlugins(selection); + }; + + self.clearPluginsSelection = function () { + self.selectedPlugins([]); + }; + self.showRepository = function () { self.repositoryDialog.modal({ minHeight: function () { diff --git a/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less b/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less index 5ddbbc00d..70b30f573 100644 --- a/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less +++ b/src/octoprint/plugins/pluginmanager/static/less/pluginmanager.less @@ -19,6 +19,15 @@ table { th, td { + &.settings_plugin_plugin_manager_plugins_checkbox { + text-align: center; + width: 10px; + + input[type="checkbox"] { + margin-top: 0; + } + } + &.settings_plugin_plugin_manager_plugins_name { text-overflow: ellipsis; text-align: left; diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index ea2ff3f15..e9b201ea9 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -107,6 +107,16 @@
+
@@ -124,12 +134,17 @@ + +
+ {{ _('Name') }} {{ _('Actions') }}
+ +
()
@@ -151,6 +166,7 @@
+ {{ _('Please note that bundled plugins do not support bulk operations.') }}
From e2f1fc64ae13375e63ba3054e5d0946aac36982b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 11 Nov 2021 15:44:42 +0100 Subject: [PATCH 15/41] =?UTF-8?q?=F0=9F=92=AC=20pmgr:=20Slight=20rephrasin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pluginmanager/templates/pluginmanager_settings.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index e9b201ea9..9c4568bdc 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -166,7 +166,7 @@
- {{ _('Please note that bundled plugins do not support bulk operations.') }} + {{ _('Please note that bundled and incompatible plugins do not support bulk operations.') }}
From 737d7e017ea1b507f307c7053e5598e60b44e92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 11 Nov 2021 16:18:01 +0100 Subject: [PATCH 16/41] =?UTF-8?q?=F0=9F=9A=B8=20pmgr:=20tooltip=20for=20di?= =?UTF-8?q?sabled=20checkboxes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pluginmanager/templates/pluginmanager_settings.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index 9c4568bdc..8f536a848 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -143,7 +143,7 @@ - +
()
From ae32445fea900f5092380f547ef5d0480b08aa86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 11 Nov 2021 19:57:53 +0100 Subject: [PATCH 17/41] =?UTF-8?q?=E2=9C=A8=20login:=20Support=20to=20reque?= =?UTF-8?q?st=20specific=20user=20to=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/server/util/__init__.py | 37 ++++++++++++++++++++++++++ src/octoprint/server/views.py | 19 ++++++++----- src/octoprint/static/js/login/login.js | 9 +++++-- src/octoprint/templates/login.jinja2 | 7 +++-- 4 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/octoprint/server/util/__init__.py b/src/octoprint/server/util/__init__.py index f92d153c3..5568d36cc 100644 --- a/src/octoprint/server/util/__init__.py +++ b/src/octoprint/server/util/__init__.py @@ -361,6 +361,43 @@ def has_permissions(*permissions): return all(map(lambda p: p.can(), permissions)) +def require_login_with(permissions=None, user_id=None): + """ + Requires a login with the given permissions and/or user id. + + Args: + permissions: list of all permissions required to pass the check + user_id: required user to pass the check + + Returns: a flask redirect response to return if a login is required, or None + """ + + from octoprint.server import current_user, userManager + + login_kwargs = {"redirect": _flask.request.script_root + _flask.request.full_path} + if ( + _flask.request.headers.get("X-Preemptive-Recording", "no") == "no" + and userManager.has_been_customized() + ): + requires_login = False + + if current_user.is_anonymous: + requires_login = True + + if permissions is not None and not has_permissions(*permissions): + requires_login = True + login_kwargs["permissions"] = ",".join([x.key for x in permissions]) + + if user_id is not None and current_user.get_id() != user_id: + requires_login = True + login_kwargs["user_id"] = user_id + + if requires_login: + return _flask.redirect(_flask.url_for("login", **login_kwargs)) + + return None + + def require_login(*permissions): """ Returns a redirect response to the login view if the permission requirements are diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index 8804c8815..56b5ce61a 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -43,7 +43,7 @@ from octoprint.server import ( # noqa: F401 preemptiveCache, userManager, ) -from octoprint.server.util import has_permissions, require_login +from octoprint.server.util import has_permissions, require_login_with from octoprint.settings import settings from octoprint.util import sv, to_bytes, to_unicode from octoprint.util.version import get_python_version_string @@ -189,13 +189,18 @@ def login(): if not permissions: permissions = [Permissions.STATUS, Permissions.SETTINGS_READ] - if has_permissions(*permissions): + user_id = request.args.get("user_id", "") + + if (not user_id or current_user.get_id() == user_id) and has_permissions( + *permissions + ): return redirect(redirect_url) render_kwargs = { "theming": [], "redirect_url": redirect_url, "permission_names": map(lambda x: x.get_name(), permissions), + "user_id": user_id, "logged_in": not current_user.is_anonymous, } @@ -216,7 +221,7 @@ def login(): @app.route("/recovery") @app.route("/recovery/") def recovery(): - response = require_login(Permissions.ADMIN) + response = require_login_with(permissions=[Permissions.ADMIN]) if response: return response @@ -632,7 +637,7 @@ def index(): plugin.implementation, octoprint.plugin.UiPlugin ): permissions = plugin.implementation.get_ui_permissions() - response = require_login(*permissions) + response = require_login_with(permissions=permissions) if not response: response = plugin_view(plugin.implementation) if _logger.isEnabledFor(logging.DEBUG) and isinstance( @@ -642,7 +647,7 @@ def index(): "X-Ui-Plugin" ] = plugin.implementation._identifier else: - response = require_login(*default_permissions) + response = require_login_with(permissions=default_permissions) if not response: response = default_view() if _logger.isEnabledFor(logging.DEBUG) and isinstance(response, Response): @@ -658,7 +663,7 @@ def index(): if plugin.will_handle_ui(request): # plugin claims responsibility, let it render the UI permissions = plugin.get_ui_permissions() - response = require_login(*permissions) + response = require_login_with(permissions=permissions) if not response: response = plugin_view(plugin) if response is not None: @@ -681,7 +686,7 @@ def index(): extra={"plugin": plugin._identifier}, ) else: - response = require_login(*default_permissions) + response = require_login_with(permissions=default_permissions) if not response: response = default_view() if _logger.isEnabledFor(logging.DEBUG) and isinstance(response, Response): diff --git a/src/octoprint/static/js/login/login.js b/src/octoprint/static/js/login/login.js index afc60e873..61a881723 100644 --- a/src/octoprint/static/js/login/login.js +++ b/src/octoprint/static/js/login/login.js @@ -37,9 +37,14 @@ $(function () { window.location.href = REDIRECT_URL; }) .fail(function () { - usernameElement.val(""); + usernameElement.val(USER_ID); passwordElement.val(""); - usernameElement.focus(); + + if (USER_ID) { + passwordElement.focus(); + } else { + usernameElement.focus(); + } overlayElement.removeClass("in"); errorElement.addClass("in"); diff --git a/src/octoprint/templates/login.jinja2 b/src/octoprint/templates/login.jinja2 index 5582b64cf..14d48cf7a 100644 --- a/src/octoprint/templates/login.jinja2 +++ b/src/octoprint/templates/login.jinja2 @@ -26,6 +26,7 @@ @@ -46,11 +47,13 @@
{{ _('Incorrect username or password. Hint: Both are case sensitive!') }}
{{ _('Server is currently offline.') }} {{ _('Reconnect...') }}
- {% if logged_in %}

+ {% if user_id %}

+ {{ _('The following account is required:') }} {{ user_id }} +

{% elif logged_in %}

{{ _('An account with the following permissions is required:') }} {{ permission_names|join(", ") }}

{% endif %} - + {{ _('Forgot password?') }}
+
+
+ +
+