diff --git a/.github/pr-validation.yml b/.github/pr-validation.yml index b6644f25c..b44ba7855 100644 --- a/.github/pr-validation.yml +++ b/.github/pr-validation.yml @@ -1,5 +1,6 @@ approve_label: "approved" problem_label: "needs some work" +ignore_label: "skip validation" allowed_targets: ["maintenance", "devel", "staging/maintenance", "staging/devel"] forbidden_sources: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3a1111546..4a219563a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: name: 🧪 Unit tests strategy: matrix: - python: ["3.7", "3.8", "3.9"] + python: ["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: ["3.7", "3.8", "3.9"] + python: ["3.7", "3.8", "3.9", "3.10"] installable: ["wheel", "sdist"] runs-on: ubuntu-latest steps: @@ -95,7 +95,7 @@ jobs: test-e2e: name: 🧪 E2E tests needs: build - runs-on: ubuntu-16.04 + runs-on: ubuntu-latest steps: - name: ⬇ Checkout code uses: actions/checkout@v2 @@ -183,10 +183,14 @@ jobs: needs: publish-on-pypi runs-on: ubuntu-latest steps: + - name: 👀 Determine version + run: | + OCTOPRINT_VERSION=$(echo $GITHUB_REF | cut -d/ -f3) + echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV - name: 🚀 Repository Dispatch uses: peter-evans/repository-dispatch@v1 with: token: ${{ secrets.REPODISPATCH_TOKEN }} repository: OctoPrint/OctoPi-UpToDate event-type: octoprint_release - client-payload: '{"version": "${{ github.ref }}"}' + client-payload: '{"version": "${{ env.OCTOPRINT_VERSION }}"}' diff --git a/.github/workflows/issue_automation.yml b/.github/workflows/issue_automation.yml index fb59a7d97..3e5b9e016 100644 --- a/.github/workflows/issue_automation.yml +++ b/.github/workflows/issue_automation.yml @@ -1,19 +1,18 @@ name: "Issue Automation" on: issues: - types: [opened, edited, closed, reopened] + types: [opened, edited, closed, reopened, labeled, unlabeled] jobs: issue-automation: runs-on: ubuntu-latest steps: - - uses: actions/github-script@v2 + - uses: actions/github-script@v5 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - let labels = []; + let labels = context.payload.issue.labels.map(label => label.name); let setLabels = false; - context.payload.issue.labels.forEach(label => { labels.push(label.name) }); switch (context.payload.action) { @@ -55,7 +54,7 @@ jobs: } if (setLabels) { - github.issues.setLabels({ + github.rest.issues.setLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, @@ -67,3 +66,96 @@ jobs: # if: github.event_name == 'issues' && (github.event.action == 'opened' || github.event.action == 'edited') # with: # repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/github-script@v5 + env: + REMINDER: > + Hi @${{ github.event.issue.user.login }}! + + + It looks like you didn't upload a [system info bundle](https://community.octoprint.org/t/29887) as requested by the template. + A bundle is required to further process your issue. It contains important logs and + system information to be able to put your issue into context and give pointers as to + what has happened. + + + Please **edit your original post above** and upload **a bundle zip file**. Actually upload the file please and + do not paste some link to a cloud provider, we want to have everything in one place here. Also do + not unpack, repack or otherwise modify the bundle or its name, share it **exactly** like you get it from OctoPrint. + + + Without the availability of a bundle, your issue will have to be closed. + + + Thank you for your collaboration. + THANKYOU: > + Thank you @${{ github.event.issue.user.login }} for adding a bundle! Now this can actually get looked at. + with: + script: | + const { REMINDER, THANKYOU } = process.env; + const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g; + const marker = ""; + + const issueLabels = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + let labels = issueLabels.data.map(label => label.name); + + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + 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..."); + if (comment) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + }) + } + return; + } + + const found = !!context.payload.issue.body.match(bundleRegex); + + if (!found) { + console.log("No bundle found, posting/updating reminder"); + const text = REMINDER + "\n" + marker; + 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"); + const text = REMINDER.split("\n\n").map(line => `~~${line.trim()}~~`).join("\n\n") + "\n\n" + THANKYOU + "\n" + marker; + if (comment.body !== text) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment.id, + body: text + }); + } + } diff --git a/.github/workflows/pr_automation.yml b/.github/workflows/pr_automation.yml index 659733438..cc411d121 100644 --- a/.github/workflows/pr_automation.yml +++ b/.github/workflows/pr_automation.yml @@ -1,7 +1,8 @@ name: "Pull Request Automation" on: pull_request_target: - types: ["opened", "synchronize", "reopened", "edited", "labeled", "unlabeled"] + #types: ["opened", "synchronize", "reopened", "edited", "labeled", "unlabeled"] + types: ["opened"] jobs: pr-automation: @@ -11,6 +12,34 @@ jobs: with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // fetch a fresh set of labels, they might have changed earlier + const issueLabels = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + let labels = issueLabels.data.map(label => label.name); + let setLabels = false; + + let target = context.payload.pull_request.base.ref; + if (["maintenance", "devel", "staging/maintenance", "staging/devel", "master"].includes(target)) { + labels.push(`targets ${target}`); + setLabels = true; + } + + if (setLabels) { + github.rest.issues.setLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: labels + }) + } + - uses: OctoPrint/actions/pr-validation@main with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index aae343c08..37e64bc49 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python: ["3.7", "3.8", "3.9"] + python: ["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: ["3.7", "3.8", "3.9"] + python: ["3.7", "3.8", "3.9", "3.10"] runs-on: ${{ matrix.os }} steps: - name: 👀 Determine latest release diff --git a/.ignore b/.ignore new file mode 100644 index 000000000..c4d12f75e --- /dev/null +++ b/.ignore @@ -0,0 +1,4 @@ +# ripgrep ignore file + +src/octoprint/static/vendor/ +src/octoprint/vendor/ diff --git a/.versioneer-lookup b/.versioneer-lookup index 6075a0bba..b3586a09a 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -18,21 +18,21 @@ prerelease HEAD \(detached.* -# maintenance is currently the branch for preparation of maintenance release 1.7.0 +# maintenance is currently the branch for preparation of maintenance release 1.8.0 # so are any fix/... and improve/... branches -maintenance 1.7.0 07c4630d126617c2ae98a9c23ad49facf7bf0bbd pep440-dev -fix/.* 1.7.0 07c4630d126617c2ae98a9c23ad49facf7bf0bbd pep440-dev -improve/.* 1.7.0 07c4630d126617c2ae98a9c23ad49facf7bf0bbd pep440-dev +maintenance 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev +fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev +improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev -# staging/bugfix is the branch for preparation of the 1.6.1 bugfix release +# staging/bugfix is the branch for preparation of the 1.7.3 bugfix release # so are any bug/... branches -staging/bugfix 1.6.1 29484fb2926960279e62881d6ee073c374a2a5fe pep440-dev -bug/.* 1.6.1 29484fb2926960279e62881d6ee073c374a2a5fe pep440-dev +staging/bugfix 1.7.2 d60c5a631aedf2328e4492125d9b86f595e43d00 pep440-dev +bug/.* 1.7.2 d60c5a631aedf2328e4492125d9b86f595e43d00 pep440-dev -# staging/maintenance is currently the branch for preparation of 1.6.0rc4 +# staging/maintenance is currently the branch for preparation of 1.7.0rc4 # so is regressionfix/... -staging/maintenance 1.6.0rc4 7054a726bb3dc363a98ec6944b24e07879bb389b pep440-dev -regressionfix/.* 1.6.0rc4 7054a726bb3dc363a98ec6944b24e07879bb389b pep440-dev +staging/maintenance 1.7.0rc4 f31194f75365787f3eb5da61a24f2f8620111f4f pep440-dev +regressionfix/.* 1.7.0rc4 f31194f75365787f3eb5da61a24f2f8620111f4f pep440-dev # staging/devel is currently inactive (but has the 1.4.1rc4 namespace) staging/devel 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev diff --git a/AUTHORS.md b/AUTHORS.md index 25fca2f57..16a42ce8d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -146,6 +146,18 @@ date of first contribution): * ["sparxooo"](https://github.com/sparxooo) * ["Stevil Knevil"](https://github.com/StevilKnevil) * [ldursw](https://github.com/ldursw) + * [Ian Wilt](https://github.com/ianwiltdotcom) + * [Ben Sycha](https://github.com/Sycha) + * [John Boiles](https://github.com/johnboiles) + * [Adam DeMuri](https://github.com/ademuri) + * [Daniel Shenkle](https://github.com/DShenkle) + * [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) + * [Carey Metcalfe](https://github.com/pR0Ps) 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/CONTRIBUTING.md b/CONTRIBUTING.md index 51c1e7d19..89706c7cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,7 +97,7 @@ following section *completely* and also follow the instructions in the **safe mode**, either by selecting "Restart OctoPrint in safe mode" from the "System" menu, or by starting OctoPrint from the command line with `octoprint serve --safe`. Then try to reproduce your issue. Find out - more about safe mode in the [docs](http://docs.octoprint.org/en/master/features/safemode.html). + more about safe mode in the [docs](https://docs.octoprint.org/en/master/features/safemode.html). You might also want to try the current development version of OctoPrint (if you aren't already). Refer to the [FAQ](https://faq.octoprint.org) diff --git a/README.md b/README.md index 62cd644d9..e4ade6a0c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@

OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software -and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html). +and released under the [GNU Affero General Public License V3](https://www.gnu.org/licenses/agpl-3.0.html). Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme). @@ -27,7 +27,7 @@ An invite to the Discord server can be found at [discord.octoprint.org](https:// The FAQ can be accessed by following [faq.octoprint.org](https://faq.octoprint.org/?utm_source=github&utm_medium=readme). -The documentation is located at [docs.octoprint.org](http://docs.octoprint.org). +The documentation is located at [docs.octoprint.org](https://docs.octoprint.org). The official plugin repository can be reached at [plugins.octoprint.org](https://plugins.octoprint.org/?utm_source=github&utm_medium=readme). @@ -38,14 +38,14 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!** You are currently looking at the source code repository of OctoPrint. If you already installed it (e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only -want to find out how to use it, [the documentation](http://docs.octoprint.org/) might be of more interest for you. You might also want to subscribe to join +want to find out how to use it, [the documentation](https://docs.octoprint.org/) might be of more interest for you. You might also want to subscribe to join [the community forum at community.octoprint.org](https://community.octoprint.org) where there are other active users who might be able to help you with any questions you might have. ## Contributing Contributions of all kinds are welcome, not only in the form of code but also with regards to the -[official documentation](http://docs.octoprint.org/), debugging help +[official documentation](https://docs.octoprint.org/), debugging help in the [bug tracker](https://github.com/OctoPrint/OctoPrint/issues), support of other users on [the community forum at community.octoprint.org](https://community.octoprint.org) or [the official discord at discord.octoprint.org](https://discord.octoprint.org) @@ -140,7 +140,7 @@ which is located at `~/.octoprint` on Linux, at `%APPDATA%/OctoPrint` on Windows at `~/Library/Application Support/OctoPrint` on MacOS. A comprehensive overview of all available configuration settings can be found -[in the docs](http://docs.octoprint.org/en/master/configuration/config_yaml.html). +[in the docs](https://docs.octoprint.org/en/master/configuration/config_yaml.html). Please note that the most commonly used configuration settings can also easily be edited from OctoPrint's settings dialog. diff --git a/SUPPORTERS.md b/SUPPORTERS.md index dcdf69cf9..36ef22907 100644 --- a/SUPPORTERS.md +++ b/SUPPORTERS.md @@ -9,6 +9,7 @@ thanks to everyone who contributed! * 3D-TECH * 3DPrinterOS * Arnljot Arntsen + * Artillery 3D * Ash King * BigTreeTech * Boris Hussein @@ -18,56 +19,56 @@ thanks to everyone who contributed! * Chris Lynch * Christian Petropolis * Christian Wolf + * Christian Würthner * Christoph Sigrist * Creality3D - * D Brian Kimmel - * Dana Voigt + * David Bounds * DeltaMaker 3D Printers * Dennis Breining - * Dennis Christilaw - * Douglas Floyd + * Dr. Frank Wester * Eric Betts * Ernesto Martinez * Franziska Kunsmann * George Robles * Greg Holloway * Hog Duske - * Hopewell Medical Acupuncture Center + * Itay Shem-tov + * Jeff Moe * Jeremy Cole * Joshua Wills * Julian Melo * Justin Kaufman * Kaile Riser - * Kale Stedman * Kazuhiro Ogura * Kelly C McNiece * Kenneth Jiang * Kurt Wubbels * Kyle Menigoz * LA 3D Printer Repair + * Lachlan Bell * Lee Dohm + * Lefteris Lertas + * LulzBot * Makespace Madrid * Mark Walker * Michael Aumock + * Mike Kershaw * Miles Flavel * Mosaic Manufacturing * Nat Friedman * Neil R. Goldberg * Norman Jaffe * Ory Weaver - * Patrick Glyré + * Peopoly * Pete Barnwell - * Prof Yuh Wen Chen * Raise3D * Randy C. Will * Ranjib Dey * Richard McGuire * Richard Michaud * Richard Stocks - * Rigid3D * Robert Gusek * Ronald Griehsler - * Sacha Telgenhof * Sebastien Andrivet * Stefan Krister * Steve Thompson @@ -77,4 +78,4 @@ thanks to everyone who contributed! * Ulderico Cirello * Ulrich Kempken -and 2350 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! +and 2247 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! diff --git a/THIRDPARTYLICENSES.md b/THIRDPARTYLICENSES.md index 395dc3262..91bb0b73c 100644 --- a/THIRDPARTYLICENSES.md +++ b/THIRDPARTYLICENSES.md @@ -76,6 +76,7 @@ * [watchdog](http://github.com/gorakhargosh/watchdog): Apache License 2.0 * [websocket-client](https://github.com/liris/websocket-client): LGPLv3 * [wrapt](http://wrapt.readthedocs.org/): BSD + * [zipstream-ng](https://github.com/pR0Ps/zipstream-ng): LGPLv3 ## Development (testing, documentation generation, etc) diff --git a/docs/api/datamodel.rst b/docs/api/datamodel.rst index 514631c74..24a10f904 100644 --- a/docs/api/datamodel.rst +++ b/docs/api/datamodel.rst @@ -365,6 +365,14 @@ Files - 0..1 - :ref:`GCODE analysis information ` - Information from the analysis of the GCODE file, if available. Left out in abridged version. + * - ``prints`` + - 0..1 + - :ref:`Print history information ` + - Information about previous prints of the file. Left out if the file has never been printed. + * - ``statistics`` + - 0..1 + - :ref:`Print statistics information ` + - Statistics about the file, based on the previous print times. Left out if the file has never been printed. .. _sec-api-datamodel-files-fileabridged: @@ -506,6 +514,62 @@ References - The model from which this file was generated (e.g. an STL, currently not used). Never present for folders. +.. _sec-api-datamodel-files-prints: + +Print History +------------- + +.. list-table:: + :widths: 15 5 10 30 + :header-rows: 1 + + * - Name + - Multiplicity + - Type + - Description + * - ``success`` + - 1 + - Number + - Number of successful prints + * - ``failure`` + - 1 + - Number + - Number of failed prints + * - ``last.date`` + - 1 + - Unix Timestamp + - Last date this file was printed + * - ``last.printTime`` + - 1 + - Float + - Last print time in seconds + * - ``last.success`` + - 1 + - Boolean + - Whether the last print was a success or not + +.. _sec-api-datamodel-files-stats: + +Print Statistics +---------------- + +.. list-table:: + :widths: 15 5 10 30 + :header-rows: 1 + + * - Name + - Multiplicity + - Type + - Description + * - ``averagePrintTime`` + - 1 + - Object + - Object that maps printer profile names to the last print time of the file, in seconds + * - ``lastPrintTime`` + - 1 + - Object + - Object that maps printer profile names to the average print time of the file, in seconds + .. _sec-api-datamodel-access: Access control 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/docs/api/timelapse.rst b/docs/api/timelapse.rst index 000a8190f..66e0bb72e 100644 --- a/docs/api/timelapse.rst +++ b/docs/api/timelapse.rst @@ -226,6 +226,10 @@ For timelapse type ``zchange``. - 1 - float - Size of retraction Z hop to detect and ignore for z-based snapshots + * - ``minDelay`` + - 1 + - int + - Snapshots will be rate limited against this interval, to prevent performance issues with vase mode/continuous z prints .. _sec-api-timelapse-datamodel-config-timed: diff --git a/docs/development/environment.rst b/docs/development/environment.rst index d0bab6915..4234cbed5 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -134,7 +134,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:\Python38\python.exe venv + virtualenv --python=C:/Python3/python.exe venv3 source ./venv/Scripts/activate python -m pip install --upgrade pip python -m pip install -e '.[develop,plugins,docs]' @@ -199,6 +199,10 @@ You'll need a user account with administrator privileges. * ``ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` * ``brew install python`` + * Install `pip `_ + + * ``python -m ensurepip --upgrade`` + * Install `virtualenv `_ * ``pip install virtualenv`` @@ -315,3 +319,102 @@ Otherwise go through Settings. Make sure you are running a PyCharm version of 2016.1 or later, or manually fix `a debugger bug contained in earlier versions `_ or plugin management will not work in your developer install when running OctoPrint from PyCharm in debug mode. + +Visual Studio Code (vscode) +--------------------------- + + - Install Visual Studio Code from `code.visualstudio.com `_ + - Open folder select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) + + - Create a directory ``.vscode`` if not already present in the root of the project + + - Create the following files inside the ``.vscode`` directory + + settings.json + .. code-block:: json + + { + "python.defaultInterpreterPath": "venv3/bin/python", + "python.formatting.provider": "black", + "python.formatting.blackArgs": [ + "--config", + "black.toml" + ], + "editor.formatOnSave": true, + "python.sortImports.args": [ + "--profile=black", + ], + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true + } + + tasks.json + .. code-block:: json + + { + "version": "2.0.0", + "tasks": [ + { + "label": "clean build artifacts", + "type": "shell", + "command": "python ./setup.py clean" + }, + { + "label": "build docs", + "type": "shell", + "command": "sphinx-build -b html ./docs ./docs/_build" + } + ] + } + + + launch.json + .. code-block:: json + + { + "version": "0.2.0", + "configurations": [ + { + "name": "OctoPrint", + "type": "python", + "request": "launch", + "module": "octoprint", + "args": [ + "serve", + "--debug" + ], + "cwd": "${workspaceFolder}/src", + "preLaunchTask": "clean build artifacts" + } + ] + } + + In the terminal install the python extension by running this command: + + .. code-block:: bash + + code --install-extension ms-python.python + + In vscode terminal, or with venv active install code formatter black and linter flake8 by running: + + .. code-block:: bash + + python -m pip install -U black flake8 flake8-bugbear + + Summary of vscode config: + + * Pressing ``F5`` will now start OctoPrint in debug mode + + * Your terminal inside vscode uses the virtual python environment + + * Saving a file will run an auto formatter and import sort + + * ``Ctrl+Shift+B`` can be used to run the ``build docs`` task to rebuild the documentation + + diff --git a/docs/events/index.rst b/docs/events/index.rst index 71a55d68e..a9b030095 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -607,6 +607,11 @@ Eject EStop An ``M112`` was sent to the printer through OctoPrint (not triggered when printing from SD!) +FilamentChange + An ``M600``, ``M701`` or ``M702`` was sent to the printer through OctoPrint (not triggered when printing from SD!) + + .. versionadded:: 1.7.0 + PositionUpdate The response to an ``M114`` was received by OctoPrint. The payload contains the current position information parsed from the response and (in the case of the selected tool ``t`` and the current feedrate ``f``) tracked diff --git a/docs/features/accesscontrol.rst b/docs/features/accesscontrol.rst index 62a548768..1c3ee2583 100644 --- a/docs/features/accesscontrol.rst +++ b/docs/features/accesscontrol.rst @@ -184,6 +184,7 @@ further down there's also a dedicated list of steps for OctoPi specifically. autologinAs: "" localNetworks: - "127.0.0.0/8" + - "::1/128" - "" 4. Restart OctoPrint, check that everything works. diff --git a/docs/features/gcode_scripts.rst b/docs/features/gcode_scripts.rst index d836d3fad..aa8fb1329 100644 --- a/docs/features/gcode_scripts.rst +++ b/docs/features/gcode_scripts.rst @@ -38,6 +38,8 @@ The following GCODE scripts are sent by OctoPrint automatically: * ``afterPrintDone``: Sent just after a print job finished. Defaults to an empty script. * ``afterPrintPaused``: Sent just after a print job was paused. Defaults to an empty script. * ``beforePrintResumed``: Sent just before a print job is resumed. Defaults to an empty script. + * ``beforeToolChange``: Sent just before a tool change command (``Tn``) is issued. + * ``afterToolChange``: Sent just after a tool change command (``Tn``) is issued .. note:: @@ -70,7 +72,8 @@ Context All GCODE scripts have access to the following template variables through the template context: * ``printer_profile``: The currently selected :ref:`Printer Profile `, including - information such as the extruder count, the build volume size, the filament diameter etc. + information such as the extruder count, the build volume size, the filament diameter etc. The individual properties + follow the common data model for :ref:`printer profiles `. * ``last_position``: Last position reported by the printer via `M114` (might be unset if no `M114` was sent so far!). Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and current tool ``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no @@ -107,6 +110,11 @@ There are a few additional template variables available for the following specif * ``cancel_temperature``: Last known temperature values when the print was cancelled. See ``last_temperature`` above for the structure to expect here. + * ``beforeToolChange`` and ``afterToolChange`` + + * ``tool.old``: The number of the previous tool + * ``tool.new``: The number of the new tool + .. warning:: diff --git a/docs/images/plugins_lifecycle.png b/docs/images/plugins_lifecycle.png deleted file mode 100644 index f0fe1e2d6..000000000 Binary files a/docs/images/plugins_lifecycle.png and /dev/null differ diff --git a/docs/images/plugins_lifecycle.svg b/docs/images/plugins_lifecycle.svg new file mode 100644 index 000000000..785e984e9 --- /dev/null +++ b/docs/images/plugins_lifecycle.svg @@ -0,0 +1,4 @@ + + + +
load
load
disabled
disabled
enabled
enabled
enable
enable
disable
disable
plugin_manager.plugins
plugin_manager.plugins
plugin.disable
deregister hooks
deregister implementation
plugin.implementation.on_plugin_disabled
plugin.disable...
plugin.enable
register hooks
register implementation
plugin.implementation.on_plugin_enabled

If/as soon as framework has started up:
inject dependencies into implementation
plugin.implementation.initialize

plugin.enable...
plugin.load
plugin.load
unload
unload
plugin.unload
plugin.unload
plugin_manager.enabled_plugins
plug...
plugin_manager.disabled_plugins
plug...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index cdfa4b217..91643ca58 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,7 +7,7 @@ Welcome to OctoPrint's documentation! :align: right OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software -and released under the `GNU Affero General Public License V3 `_. +and released under the `GNU Affero General Public License V3 `_. Its website can be found at `octoprint.org `_. diff --git a/docs/plugins/concepts.rst b/docs/plugins/concepts.rst index 5e1c624cf..4019164dc 100644 --- a/docs/plugins/concepts.rst +++ b/docs/plugins/concepts.rst @@ -35,10 +35,23 @@ any :ref:`settings overlays =2021.2.23", - "OctoPrint-FirmwareCheck>=2021.2.4", - "OctoPrint-PiSupport>=2021.3.26", + "OctoPrint-FirmwareCheck>=2021.10.11", + "OctoPrint-PiSupport>=2021.10.28", # the following dependencies are non trivial to update since later versions # introduce backwards incompatible changes that might affect plugins, or due to # other observed problems "regex!=2018.11.6", # avoid broken 2018.11.6. See #2874 + "wrapt>=1.12.1,<1.13", # newer versions fail to build on OctoPi 0.15 # anything below this should be checked on releases for new versions "tornado>=6.0.4,<7", "markdown>=3.2.2,<4", - "flask>=1.1.2,<2", - "Jinja2>=2.11.2,<3", + "flask>=2,<3", "Flask-Login>=0.5,<0.6", # flask-login doesn't use semver & breaks stuff on minor version increases - "Flask-Babel>=1.0,<2", + "Flask-Babel>=2.0,<3", "Flask-Assets>=2.0,<3", - "werkzeug>=1.0.1,<2", - "itsdangerous>=1.1.0,<2", - "cachelib>=0.1,<1", - "PyYAML>=5.3.1,<6", + "cachelib>=0.2,<0.3", + "PyYAML>=5.4.1,<6", "pyserial>=3.4,<4", "netaddr>=0.7.19,<1", "watchdog==1.0.0", @@ -51,30 +49,30 @@ INSTALL_REQUIRES = [ "pkginfo>=1.5.0.1,<2", "requests>=2.23.0,<3", "semantic_version>=2.8.5,<3", - "psutil>=5.7,<6", - "Click>=7.1.2,<8", - "feedparser>=6.0.2,<7", + "psutil>=5.8,<6", + "Click>=8.0.3,<9", + "feedparser>=6.0.8,<7", "future>=0.18.2,<1", # not really needed anymore, but leaving in for py2/3 compat plugins - "websocket-client>=0.57,<1", + "websocket-client>=1.2.1,<2", "wrapt>=1.12.1,<2", - "emoji>=0.5.4,<1", - "immutabledict>=1.2.0,<2", - "sentry-sdk>=0.15.1,<1", + "emoji>=1.4.2,<2", + "sentry-sdk>=1.5.0,<2", "filetype>=1.0.7,<2", - "zeroconf>=0.24,<0.25", - "zipstream-new>=1.1.8,<1.2", + "zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases + "zipstream-ng>=1.3.1,<2.0.0", "pathvalidate>=2.4.1,<3", "colorlog>=5.0.1,<6", # vendor bundled dependencies - "unidecode>=0.04.14,<0.05", # dependency of awesome-slugify "blinker>=1.4,<2", # dependency of flask_principal + "unidecode", # dependency of awesome-slugify, leave w/o range to not cause dependency hell w/ Octolapse deps ] # Additional requirements for optional install options EXTRA_REQUIRES = { "develop": [ # Testing dependencies - "pytest>=5.4.3,<6", + "mock>=4,<5", + "pytest>=6.2.5,<7", "pytest-doctest-custom>=1.0.0,<2", "ddt", # pre-commit @@ -230,6 +228,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", diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index e77c8a03d..b6cefcd7c 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -266,16 +266,16 @@ def init_logging( "formatters": { "simple": {"format": simple_format}, "colored": { - "class": "colorlog.ColoredFormatter", - "format": "%(log_color)s" + simple_format, + "()": "colorlog.ColoredFormatter", + "format": "%(log_color)s" + simple_format + "%(reset)s", + "reset": True, "log_colors": { - "DEBUG": "light_white", + "DEBUG": "cyan", "INFO": "white", "WARNING": "yellow", "ERROR": "red", "CRITICAL": "bold_red", }, - "reset": True, }, "serial": {"format": "%(asctime)s - %(message)s"}, "timings": {"format": "%(asctime)s - %(message)s"}, @@ -381,10 +381,9 @@ def init_logging( config_from_file = {} if os.path.exists(logging_file) and os.path.isfile(logging_file): - import yaml + from octoprint.util import yaml - with open(logging_file, encoding="utf-8") as f: - config_from_file = yaml.safe_load(f) + config_from_file = yaml.load_from_file(path=logging_file) # we merge that with the default config if config_from_file is not None and isinstance(config_from_file, dict): @@ -730,9 +729,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None): import time import requests - import yaml - from octoprint.util import bom_aware_open from octoprint.util.version import is_octoprint_compatible, is_python_compatible logger = log.getLogger(__name__ + ".startup") @@ -798,8 +795,9 @@ def get_plugin_blacklist(settings, connectivity_checker=None): if os.stat(path).st_mtime + ttl < time.time(): return None - with bom_aware_open(path, encoding="utf-8", mode="rt") as f: - result = yaml.safe_load(f) + from octoprint.util import yaml + + result = yaml.load_from_file(path=path) if isinstance(result, list): return result @@ -812,8 +810,9 @@ def get_plugin_blacklist(settings, connectivity_checker=None): if cache is not None: try: - with bom_aware_open(cache, encoding="utf-8", mode="wt") as f: - yaml.safe_dump(result, f) + from octoprint.util import yaml + + yaml.save_to_file(result, path=cache) except Exception as e: logger.info( "Fetched plugin blacklist but couldn't write it to its cache file: %s", diff --git a/src/octoprint/access/groups.py b/src/octoprint/access/groups.py index 00c6f0d41..9265798e0 100644 --- a/src/octoprint/access/groups.py +++ b/src/octoprint/access/groups.py @@ -6,12 +6,10 @@ import logging import os from functools import partial -import yaml - from octoprint.access import ADMIN_GROUP, GUEST_GROUP, READONLY_GROUP, USER_GROUP from octoprint.access.permissions import OctoPrintPermission, Permissions from octoprint.settings import settings -from octoprint.util import atomic_write +from octoprint.util import atomic_write, yaml from octoprint.vendor.flask_principal import Need, Permission GroupNeed = partial(Need, "group") @@ -226,8 +224,7 @@ class FilebasedGroupManager(GroupManager): def _load(self): if os.path.exists(self._groupfile) and os.path.isfile(self._groupfile): try: - with open(self._groupfile, encoding="utf-8") as f: - data = yaml.safe_load(f) + data = yaml.load_from_file(path=self._groupfile) if "groups" not in data: groups = data @@ -343,11 +340,7 @@ class FilebasedGroupManager(GroupManager): with atomic_write( self._groupfile, mode="wt", permissions=0o600, max_permissions=0o666 ) as f: - import yaml - - yaml.safe_dump( - data, f, default_flow_style=False, indent=2, allow_unicode=True - ) + yaml.save_to_file(data, file=f, pretty=True) self._dirty = False self._load() diff --git a/src/octoprint/access/users.py b/src/octoprint/access/users.py index a327bf22f..7717d743c 100644 --- a/src/octoprint/access/users.py +++ b/src/octoprint/access/users.py @@ -8,7 +8,6 @@ import time import uuid import wrapt -import yaml from flask_login import AnonymousUserMixin, UserMixin from werkzeug.local import LocalProxy @@ -17,7 +16,7 @@ from octoprint.access.permissions import OctoPrintPermission, Permissions from octoprint.settings import settings as s from octoprint.util import atomic_write, deprecated, generate_api_key from octoprint.util import get_fully_qualified_classname as fqcn -from octoprint.util import to_bytes +from octoprint.util import to_bytes, yaml class UserManager(GroupChangeListener): @@ -512,64 +511,60 @@ class FilebasedUserManager(UserManager): def _load(self): if os.path.exists(self._userfile) and os.path.isfile(self._userfile): - # noinspection PyBroadException - with open(self._userfile, encoding="utf-8") as f: - data = yaml.safe_load(f) + data = yaml.load_from_file(path=self._userfile) - if not data or not isinstance(data, dict): - self._logger.fatal( - "{} does not contain a valid map of users. Fix " - "the file, or remove it, then restart OctoPrint.".format( - self._userfile - ) + if not data or not isinstance(data, dict): + self._logger.fatal( + "{} does not contain a valid map of users. Fix " + "the file, or remove it, then restart OctoPrint.".format( + self._userfile ) - raise CorruptUserStorage() + ) + raise CorruptUserStorage() - for name, attributes in data.items(): - if not isinstance(attributes, dict): - continue + for name, attributes in data.items(): + if not isinstance(attributes, dict): + continue - permissions = [] - if "permissions" in attributes: - permissions = attributes["permissions"] + permissions = [] + if "permissions" in attributes: + permissions = attributes["permissions"] - if "groups" in attributes: - groups = set(attributes["groups"]) - else: - groups = {self._group_manager.user_group} + if "groups" in attributes: + groups = set(attributes["groups"]) + else: + groups = {self._group_manager.user_group} - # migrate from roles to permissions - if "roles" in attributes and "permissions" not in attributes: - self._logger.info( - "Migrating user {} to new granular permission system".format( - name - ) - ) - - groups |= set(self._migrate_roles_to_groups(attributes["roles"])) - self._dirty = True - - apikey = None - if "apikey" in attributes: - apikey = attributes["apikey"] - settings = {} - if "settings" in attributes: - settings = attributes["settings"] - - self._users[name] = User( - username=name, - passwordHash=attributes["password"], - active=attributes["active"], - permissions=self._to_permissions(*permissions), - groups=self._to_groups(*groups), - apikey=apikey, - settings=settings, + # migrate from roles to permissions + if "roles" in attributes and "permissions" not in attributes: + self._logger.info( + f"Migrating user {name} to new granular permission system" ) - for sessionid in self._sessionids_by_userid.get(name, set()): - if sessionid in self._session_users_by_session: - self._session_users_by_session[sessionid].update_user( - self._users[name] - ) + + groups |= set(self._migrate_roles_to_groups(attributes["roles"])) + self._dirty = True + + apikey = None + if "apikey" in attributes: + apikey = attributes["apikey"] + settings = {} + if "settings" in attributes: + settings = attributes["settings"] + + self._users[name] = User( + username=name, + passwordHash=attributes["password"], + active=attributes["active"], + permissions=self._to_permissions(*permissions), + groups=self._to_groups(*groups), + apikey=apikey, + settings=settings, + ) + for sessionid in self._sessionids_by_userid.get(name, set()): + if sessionid in self._session_users_by_session: + self._session_users_by_session[sessionid].update_user( + self._users[name] + ) if self._dirty: self._save() @@ -601,9 +596,7 @@ class FilebasedUserManager(UserManager): with atomic_write( self._userfile, mode="wt", permissions=0o600, max_permissions=0o666 ) as f: - yaml.safe_dump( - data, f, default_flow_style=False, indent=2, allow_unicode=True - ) + yaml.save_to_file(data, file=f, pretty=True) self._dirty = False self._load() diff --git a/src/octoprint/cli/analysis.py b/src/octoprint/cli/analysis.py index 94d7fa28d..f2d93b4a9 100644 --- a/src/octoprint/cli/analysis.py +++ b/src/octoprint/cli/analysis.py @@ -5,6 +5,8 @@ import sys import click +from octoprint.util import yaml + click.disable_unicode_literals_warning = True # ~~ "octoprint util" commands @@ -94,8 +96,6 @@ def gcode_command( import time - import yaml - from octoprint.util.gcodeInterpreter import gcode throttle_callback = None @@ -151,14 +151,7 @@ def gcode_command( ) sys.exit(-1) click.echo("RESULTS:") - click.echo( - yaml.safe_dump( - interpreter.get_result(), - default_flow_style=False, - indent=2, - allow_unicode=True, - ) - ) + click.echo(yaml.dump(interpreter.get_result(), pretty=True)) if __name__ == "__main__": diff --git a/src/octoprint/cli/client.py b/src/octoprint/cli/client.py index 212485e66..d3739fc6a 100644 --- a/src/octoprint/cli/client.py +++ b/src/octoprint/cli/client.py @@ -9,6 +9,7 @@ import click import octoprint_client from octoprint import FatalStartupError, init_settings from octoprint.cli import bulk_options, get_ctx_obj_option +from octoprint.util import yaml click.disable_unicode_literals_warning = True @@ -171,10 +172,7 @@ def post_from_file(ctx, path, file_path, json_flag, yaml_flag, timeout): with open(file_path) as fp: data = json.load(fp) else: - import yaml - - with open(file_path) as fp: - data = yaml.safe_load(fp) + data = yaml.load_from_file(path=file_path) r = ctx.obj.client.post_json(path, data, timeout=timeout) else: diff --git a/src/octoprint/cli/config.py b/src/octoprint/cli/config.py index 7af142247..b7fd050bc 100644 --- a/src/octoprint/cli/config.py +++ b/src/octoprint/cli/config.py @@ -7,10 +7,10 @@ import logging import pprint import click -import yaml from octoprint import FatalStartupError, init_settings from octoprint.cli import get_ctx_obj_option, standard_options +from octoprint.util import yaml click.disable_unicode_literals_warning = True @@ -214,9 +214,7 @@ def get_command(ctx, path, as_json=False, as_yaml=False, as_raw=False): if as_json: output = json.dumps(value) elif as_yaml: - output = yaml.safe_dump( - value, default_flow_style=False, indent=2, allow_unicode=True - ) + output = yaml.dump(value, pretty=True) elif as_raw: output = value else: @@ -240,9 +238,7 @@ def effective_command(ctx, as_json=False, as_yaml=False, as_raw=False): if as_json: output = json.dumps(value) elif as_yaml: - output = yaml.safe_dump( - value, default_flow_style=False, indent=2, allow_unicode=True - ) + output = yaml.dump(value, pretty=True) elif as_raw: output = value else: diff --git a/src/octoprint/cli/systeminfo.py b/src/octoprint/cli/systeminfo.py index f069120c9..cb5e2d107 100644 --- a/src/octoprint/cli/systeminfo.py +++ b/src/octoprint/cli/systeminfo.py @@ -1,19 +1,22 @@ __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 logging import os import click -import zipstream +from zipstream.ng import ZIP_DEFLATED, ZipStream 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 @@ -22,10 +25,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 open(safe_mode_file) 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 @@ -42,39 +65,28 @@ def get_systeminfo(environment_detector, connectivity_checker, additional_fields def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None): from octoprint.util import to_bytes + try: + z = ZipStream(compress_type=ZIP_DEFLATED) + except RuntimeError: + # no zlib support + z = ZipStream(sized=True) + + if printer and printer.is_operational(): + firmware_info = printer.firmware_info + if firmware_info: + # add firmware to systeminfo so it's included in systeminfo.txt + systeminfo["printer.firmware"] = firmware_info["name"] + + # Add printer log, if available + if hasattr(printer, "_log"): + z.add(to_bytes("\n".join(printer._log)), "terminal.txt") + + # add systeminfo systeminfotxt = [] for k in sorted(systeminfo.keys()): systeminfotxt.append("{}: {}".format(k, systeminfo[k])) - terminaltxt = None - if printer and printer.is_operational(): - firmware_info = printer.firmware_info - if firmware_info: - systeminfo["printer.firmware"] = firmware_info["name"] - - if hasattr(printer, "_log"): - terminaltxt = list(printer._log) - - try: - import zlib # noqa: F401 - - compress_type = zipstream.ZIP_DEFLATED - except ImportError: - # no zlib, no compression - compress_type = zipstream.ZIP_STORED - - z = zipstream.ZipFile() - - # add systeminfo - z.writestr( - "systeminfo.txt", to_bytes("\n".join(systeminfotxt)), compress_type=compress_type - ) - - # add terminal.txt, if available - if terminaltxt: - z.writestr( - "terminal.txt", to_bytes("\n".join(terminaltxt)), compress_type=compress_type - ) + z.add(to_bytes("\n".join(systeminfotxt)), arcname="systeminfo.txt") # add logs for log in ( @@ -83,7 +95,7 @@ def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None ): logpath = os.path.join(logbase, log) if os.path.exists(logpath): - z.write(logpath, arcname=log, compress_type=compress_type) + z.add_path(logpath, arcname=log) # add additional bundle contents from bundled plugins if plugin_manager: @@ -103,10 +115,10 @@ def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None if isinstance(content, str): # log path if os.path.exists(content) and os.access(content, os.R_OK): - z.write(content, arcname=log, compress_type=compress_type) + z.add_path(content, arcname=log) elif callable(content): # content generating callable - z.writestr(log, to_bytes(content()), compress_type=compress_type) + z.add(to_bytes(content()), arcname=log) except Exception: logging.getLogger(__name__).exception( "Error while retrieving additional bundle contents for plugin {}".format( @@ -170,8 +182,7 @@ def systeminfo_command(ctx, path, **kwargs): ) try: with open(zipfilename, "wb") as f: - for data in z: - f.write(data) + f.writelines(z) except Exception as e: click.echo(str(e), err=True) click.echo(f"There was an error writing to {zipfilename}.", err=True) diff --git a/src/octoprint/environment.py b/src/octoprint/environment.py index 6711dc02b..fd4f0053f 100644 --- a/src/octoprint/environment.py +++ b/src/octoprint/environment.py @@ -8,9 +8,9 @@ import sys import threading import psutil -import yaml from octoprint.plugin import EnvironmentDetectionPlugin +from octoprint.util import yaml from octoprint.util.platform import get_os from octoprint.util.version import get_python_version_string @@ -165,9 +165,7 @@ class EnvironmentDetector: self.run_detection() environment = copy.deepcopy(self._cache) - dumped_environment = yaml.safe_dump( - environment, default_flow_style=False, indent=2, allow_unicode=True - ).strip() + dumped_environment = yaml.dump(environment, pretty=True).strip() environment_lines = "\n".join( map(lambda l: f"| {l}", dumped_environment.split("\n")) ) diff --git a/src/octoprint/events.py b/src/octoprint/events.py index f93553ee9..17ed69b1e 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -98,6 +98,7 @@ class Events: REGISTERED_MESSAGE_RECEIVED = "RegisteredMessageReceived" COMMAND_SUPPRESSED = "CommandSuppressed" INVALID_TOOL_REPORTED = "InvalidToolReported" + FILAMENT_CHANGE = "FilamentChange" # Timelapse CAPTURE_START = "CaptureStart" diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index d4b561ec5..ad8260b21 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -12,6 +12,7 @@ import octoprint.plugin import octoprint.util from octoprint.events import Events, eventManager from octoprint.util import get_fully_qualified_classname as fqcn +from octoprint.util import yaml from .analysis import AnalysisQueue, QueueEntry # noqa: F401 from .destinations import FileDestinations # noqa: F401 @@ -941,8 +942,6 @@ class FileManager: def save_recovery_data(self, origin, path, pos): import time - import yaml - from octoprint.util import atomic_write data = { @@ -953,9 +952,7 @@ class FileManager: } try: with atomic_write(self._recovery_file, mode="wt", max_permissions=0o666) as f: - yaml.safe_dump( - data, stream=f, default_flow_style=False, indent=2, allow_unicode=True - ) + yaml.save_to_file(data, file=f, pretty=True) except Exception: self._logger.exception( f"Could not write recovery data to file {self._recovery_file}" @@ -976,11 +973,9 @@ class FileManager: if not os.path.isfile(self._recovery_file): return None - import yaml - try: - with open(self._recovery_file, encoding="utf-8") as f: - data = yaml.safe_load(f) + data = yaml.load_from_file(path=self._recovery_file) + if not isinstance(data, dict) or not all( map(lambda x: x in data, ("origin", "path", "pos", "date")) ): diff --git a/src/octoprint/filemanager/analysis.py b/src/octoprint/filemanager/analysis.py index fedcca891..b6c01de93 100644 --- a/src/octoprint/filemanager/analysis.py +++ b/src/octoprint/filemanager/analysis.py @@ -14,6 +14,7 @@ from octoprint.events import Events, eventManager from octoprint.settings import settings from octoprint.util import dict_merge from octoprint.util import get_fully_qualified_classname as fqcn +from octoprint.util import yaml from octoprint.util.platform import CLOSE_FDS EMPTY_RESULT = { @@ -401,7 +402,6 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): import sys import sarge - import yaml if self._current.analysis and all( map( @@ -495,7 +495,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): raise RuntimeError("No analysis result found") else: _, output = output.split("RESULTS:") - analysis = yaml.safe_load(output) + analysis = yaml.load_from_file(file=output) result["printingArea"] = analysis["printing_area"] result["dimensions"] = analysis["dimensions"] diff --git a/src/octoprint/filemanager/storage/local.py b/src/octoprint/filemanager/storage/local.py index 5d752ae38..c3522bd2f 100644 --- a/src/octoprint/filemanager/storage/local.py +++ b/src/octoprint/filemanager/storage/local.py @@ -12,7 +12,14 @@ from os import scandir, walk import pylru import octoprint.filemanager -from octoprint.util import atomic_write, is_hidden_path, time_this, to_bytes, to_unicode +from octoprint.util import ( + atomic_write, + is_hidden_path, + time_this, + to_bytes, + to_unicode, + yaml, +) from octoprint.util.files import sanitize_filename from . import Storage, StorageError @@ -73,10 +80,7 @@ class LocalFileStorage(Storage): if os.path.exists(old_metadata_path): # load the old metadata file try: - with open(old_metadata_path, encoding="utf-8") as f: - import yaml - - self._old_metadata = yaml.safe_load(f) + self._old_metadata = yaml.load_from_file(path=old_metadata_path) except Exception: self._logger.exception("Error while loading old metadata file") @@ -1474,8 +1478,6 @@ class LocalFileStorage(Storage): # we switched to json in 1.3.9 - if we still have yaml here, migrate it now import json - import yaml - with self._get_persisted_metadata_lock(path): metadata_path_yaml = os.path.join(path, ".metadata.yaml") metadata_path_json = os.path.join(path, ".metadata.json") @@ -1496,16 +1498,13 @@ class LocalFileStorage(Storage): ) return - with open(metadata_path_yaml, encoding="utf-8") as f: - try: - metadata = yaml.safe_load(f) - except Exception: - self._logger.exception( - "Error while reading .metadata.yaml from {path}".format( - **locals() - ) - ) - return + try: + metadata = yaml.load_from_file(path=metadata_path_yaml) + except Exception: + self._logger.exception( + "Error while reading .metadata.yaml from {path}".format(**locals()) + ) + return if not isinstance(metadata, dict): # looks invalid, ignore it diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 1c4d63dd5..979769cc6 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -834,11 +834,11 @@ class PluginManager: processed_blacklist = [] for entry in plugin_blacklist: - if isinstance(entry, tuple): + if isinstance(entry, (tuple, list)): 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( @@ -1324,7 +1324,7 @@ class PluginManager: 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 @@ -2385,9 +2385,15 @@ class Plugin: pass def on_plugin_enabled(self): + """ + Called by the plugin core when the plugin was enabled. Override this to react to the event. + """ pass def on_plugin_disabled(self): + """ + Called by the plugin core when the plugin was disabled. Override this to react to the event. + """ pass diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index b3be4b0cb..bea482ed1 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -123,6 +123,14 @@ class OctoPrintPlugin(Plugin): os.makedirs(self._data_folder) return self._data_folder + def on_plugin_pending_uninstall(self): + """ + Called by the plugin manager when the plugin is pending uninstall. Override this to react to the event. + + NOT called during plugin uninstalls triggered outside of OctoPrint! + """ + pass + class ReloadNeedingPlugin(Plugin): """ @@ -390,6 +398,10 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin): ``TemplatePlugin`` is a :class:`~octoprint.plugin.core.ReloadNeedingPlugin`. """ + @property + def template_folder_key(self): + return f"plugin_{self._identifier}" + def get_template_configs(self): """ Allows configuration of injected navbar, sidebar, tab and settings templates (and also additional templates of diff --git a/src/octoprint/plugins/announcements/static/js/announcements.js b/src/octoprint/plugins/announcements/static/js/announcements.js index 75720f39a..dccf4e953 100644 --- a/src/octoprint/plugins/announcements/static/js/announcements.js +++ b/src/octoprint/plugins/announcements/static/js/announcements.js @@ -209,7 +209,6 @@ $(function () { } }) .css({ - "width": "auto", "margin-left": function () { return -($(this).width() / 2); } diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py index ca8ff3024..270926d94 100644 --- a/src/octoprint/plugins/appkeys/__init__.py +++ b/src/octoprint/plugins/appkeys/__init__.py @@ -4,16 +4,20 @@ import time from collections import defaultdict import flask -import yaml from flask_babel import gettext import octoprint.plugin -from octoprint.access import ADMIN_GROUP +from octoprint.access import ADMIN_GROUP, USER_GROUP from octoprint.access.permissions import Permissions from octoprint.server import NO_CONTENT, admin_permission, current_user -from octoprint.server.util.flask import no_firstrun_access, restricted_access +from octoprint.server.util import require_login_with +from octoprint.server.util.flask import ( + add_non_caching_response_headers, + no_firstrun_access, + restricted_access, +) from octoprint.settings import valid_boolean_trues -from octoprint.util import ResettableTimer, atomic_write, generate_api_key +from octoprint.util import ResettableTimer, atomic_write, generate_api_key, yaml CUTOFF_TIME = 10 * 60 # 10min POLL_TIMEOUT = 5 # 5 seconds @@ -121,7 +125,14 @@ class AppKeysPlugin( "roles": ["admin"], "dangerous": True, "default_groups": [ADMIN_GROUP], - } + }, + { + "key": "GRANT", + "name": "Grant access", + "description": gettext("Allows to grant app access"), + "roles": ["user"], + "default_groups": [USER_GROUP], + }, ] ##~~ TemplatePlugin @@ -165,6 +176,9 @@ class AppKeysPlugin( user_id = data["user"] app_token, user_token = self._add_pending_decision(app_name, user_id=user_id) + auth_dialog = flask.url_for( + "plugin.appkeys.handle_auth_dialog", app_token=app_token, _external=True + ) + (f"?user={user_id}" if user_id else "") self._plugin_manager.send_plugin_message( self._identifier, @@ -175,7 +189,7 @@ class AppKeysPlugin( "user_id": user_id, }, ) - response = flask.jsonify(app_token=app_token) + response = flask.jsonify(app_token=app_token, auth_dialog=auth_dialog) response.status_code = 201 response.headers["Location"] = flask.url_for( ".handle_decision_poll", app_token=app_token, _external=True @@ -200,12 +214,59 @@ class AppKeysPlugin( return flask.abort(404) + @octoprint.plugin.BlueprintPlugin.route("/auth/") + @no_firstrun_access + def handle_auth_dialog(self, app_token): + user_id = current_user.get_name() + required_user = flask.request.args.get("user", None) + + pendings = self._get_pending_by_app_token(app_token) + if not pendings: + return flask.abort(404) + + response = require_login_with( + permissions=[Permissions.PLUGIN_APPKEYS_GRANT], user_id=required_user + ) + if response: + return response + + pending = None + for p in pendings: + if p.user_id == required_user or (not required_user and p.user_id == user_id): + pending = p + break + else: + return flask.abort(404) + + app_id = pending.app_id + user_token = pending.user_token + redirect_url = flask.request.args.get("redirect", "") + + response = flask.make_response( + flask.render_template( + "plugin_appkeys/appkeys_authdialog.jinja2", + app=app_id, + user=user_id, + user_token=user_token, + redirect_url=redirect_url, + theming=[], + request_text=gettext( + '"%(app)s" has requested access to control OctoPrint through the API.' + ).replace("%(app)s", app_id), + ) + ) + return add_non_caching_response_headers(response) + @octoprint.plugin.BlueprintPlugin.route("/decision/", methods=["POST"]) @restricted_access def handle_decision(self, user_token): data = flask.request.json if "decision" not in data: flask.abort(400, description="No decision provided") + + if not Permissions.PLUGIN_APPKEYS_GRANT.can(): + flask.abort(403, description="No permission to grant app access") + decision = data["decision"] in valid_boolean_trues user_id = current_user.get_name() @@ -438,8 +499,7 @@ class AppKeysPlugin( return try: - with open(self._key_path, encoding="utf-8", errors="strict") as f: - persisted = yaml.safe_load(f) + persisted = yaml.load_from_file(path=self._key_path) except Exception: self._logger.exception( f"Could not load application keys from {self._key_path}" @@ -464,7 +524,7 @@ class AppKeysPlugin( try: with atomic_write(self._key_path, mode="wt") as f: - yaml.safe_dump(to_persist, f, allow_unicode=True) + yaml.save_to_file(to_persist, file=f) except Exception: self._logger.exception( f"Could not write application keys to {self._key_path}" diff --git a/src/octoprint/plugins/appkeys/static/css/authdialog.css b/src/octoprint/plugins/appkeys/static/css/authdialog.css new file mode 100644 index 000000000..0a3363f17 --- /dev/null +++ b/src/octoprint/plugins/appkeys/static/css/authdialog.css @@ -0,0 +1 @@ +body{padding-top:40px;padding-bottom:40px;background-color:#f5f5f5}#auth-choice,#auth-done,#auth-error,#auth-offline{max-width:300px;padding:19px 29px 29px;margin:0 auto 20px;background-color:#fff;border:1px solid #e5e5e5;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05);text-align:center}.form-auth-heading{margin-bottom:10px} \ No newline at end of file diff --git a/src/octoprint/plugins/appkeys/static/js/authdialog.js b/src/octoprint/plugins/appkeys/static/js/authdialog.js new file mode 100644 index 000000000..25fac9ed0 --- /dev/null +++ b/src/octoprint/plugins/appkeys/static/js/authdialog.js @@ -0,0 +1,91 @@ +/* + * Will get included into the auth dialog, NOT into the regular OctoPrint + * web application. + */ + +$(function () { + var OctoPrint = window.OctoPrint; + + OctoPrint.authui = { + startedUp: false + }; + + var offlineElement = $("#auth-offline"); + var grantButtonElement = $("#auth-grant"); + var rejectButtonElement = $("#auth-reject"); + + var choiceElement = $("#auth-choice"); + var doneElement = $("#auth-done"); + var errorElement = $("#auth-error"); + + var showDone = function () { + choiceElement.hide(); + doneElement.show(); + }; + var showError = function () { + choiceElement.hide(); + errorElement.show(); + }; + var showOffline = function () { + choiceElement.hide(); + offlineElement.show(); + }; + + grantButtonElement.click(function () { + errorElement.removeClass("in"); + + OctoPrint.plugins.appkeys + .decide(USER_TOKEN, true) + .done(function () { + if (REDIRECT_URL) { + window.location.href = REDIRECT_URL; + } else { + showDone(); + } + }) + .fail(showError); + + return false; + }); + rejectButtonElement.click(function () { + OctoPrint.plugins.appkeys + .decide(USER_TOKEN, false) + .done(function () { + if (REDIRECT_URL) { + window.location.href = REDIRECT_URL; + } else { + showDone(); + } + }) + .fail(showError); + + return false; + }); + + OctoPrint.options.baseurl = BASE_URL; + + OctoPrint.socket.onConnected = function () { + OctoPrint.browser.passiveLogin().done(function (login) { + OctoPrint.socket.sendAuth(login.name, login.session); + OctoPrint.authui.startedUp = true; + }); + }; + + OctoPrint.socket.onDisconnected = function () { + showOffline(); + }; + + OctoPrint.socket.onMessage("plugin", function (event) { + if (event.data.plugin !== "appkeys") return; + + var type = event.data.data.type; + if (type !== "end_request") return; + + var token = event.data.data.user_token; + if (token !== USER_TOKEN) return; + + showDone(); + }); + + OctoPrint.socket.connect(); +}); diff --git a/src/octoprint/plugins/appkeys/static/less/authdialog.less b/src/octoprint/plugins/appkeys/static/less/authdialog.less new file mode 100644 index 000000000..4f2fe4eea --- /dev/null +++ b/src/octoprint/plugins/appkeys/static/less/authdialog.less @@ -0,0 +1,27 @@ +body { + padding-top: 40px; + padding-bottom: 40px; + background-color: #f5f5f5; +} + +#auth-choice, +#auth-done, +#auth-error, +#auth-offline { + max-width: 300px; + padding: 19px 29px 29px; + margin: 0 auto 20px; + background-color: #fff; + border: 1px solid #e5e5e5; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + text-align: center; +} + +.form-auth-heading { + margin-bottom: 10px; +} diff --git a/src/octoprint/plugins/appkeys/templates/appkeys_authdialog.jinja2 b/src/octoprint/plugins/appkeys/templates/appkeys_authdialog.jinja2 new file mode 100644 index 000000000..b043fe74d --- /dev/null +++ b/src/octoprint/plugins/appkeys/templates/appkeys_authdialog.jinja2 @@ -0,0 +1,77 @@ + + + + OctoPrint App Authentication + + + + + + + + + + + + + + + + {% for url in theming %} + + {% endfor %} + + + + + + + + + + {% assets "js_client" %} + + {% endassets %} + + + + +
+
+

{{ _('Access Request') }}

+ +

{% trans %}Hello {{ user }}!{% endtrans %}

+

{{ request_text }}

+

{% trans %} + Do you want to allow access to this application with your user account? + {% endtrans %}

+ + + +
+ +
+

{% trans %} + The access request has been processed. You may now close this tab. + {% endtrans %}

+
+ +
+

{% trans %} + Something went wrong while processing the access request. You may now close this tab. + {% endtrans %}

+
+ +
+

{% trans %} + The server has gone offline. You may now close this tab. + {% endtrans %}

+
+
+ + diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 13174e9d8..1072ac691 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -10,7 +10,7 @@ from octoprint.events import Events from octoprint.server import NO_CONTENT from octoprint.server.util.flask import no_firstrun_access from octoprint.settings import default_settings -from octoprint.util import is_hidden_path, to_bytes +from octoprint.util import is_hidden_path, to_bytes, yaml from octoprint.util.pip import create_pip_caller from octoprint.util.platform import is_os_compatible from octoprint.util.version import ( @@ -1190,10 +1190,7 @@ class BackupPlugin( on_restore_failed(path) return False - import yaml - - with open(configfile, encoding="utf-8") as f: - configdata = yaml.safe_load(f) + configdata = yaml.load_from_file(path=configfile) userfile = os.path.join(temp, "basedir", "users.yaml") if not os.path.exists(userfile): diff --git a/src/octoprint/plugins/backup/templates/backup_settings.jinja2 b/src/octoprint/plugins/backup/templates/backup_settings.jinja2 index 0d2fd81fe..d65bab106 100644 --- a/src/octoprint/plugins/backup/templates/backup_settings.jinja2 +++ b/src/octoprint/plugins/backup/templates/backup_settings.jinja2 @@ -108,7 +108,7 @@

{{ _('Restore settings & files from an uploaded backup archive.') }}

{% set plugin_backup_upload_form_id='settings-backup-upload' %} - {% include "snippets/plugin/backup/backup_plugin_upload_form.jinja2" %} + {% include "snippets/backup_plugin_upload_form.jinja2" %}
diff --git a/src/octoprint/plugins/backup/templates/backup_wizard.jinja2 b/src/octoprint/plugins/backup/templates/backup_wizard.jinja2 index 8ba4f479c..f1f4c2c87 100644 --- a/src/octoprint/plugins/backup/templates/backup_wizard.jinja2 +++ b/src/octoprint/plugins/backup/templates/backup_wizard.jinja2 @@ -5,4 +5,4 @@

{% endtrans %} {% set plugin_backup_upload_form_id='wizard-backup-upload' %} -{% include "snippets/plugin/backup/backup_plugin_upload_form.jinja2" %} +{% include "snippets/backup_plugin_upload_form.jinja2" %} diff --git a/src/octoprint/plugins/backup/templates/snippets/plugin/backup/backup_plugin_upload_form.jinja2 b/src/octoprint/plugins/backup/templates/snippets/backup_plugin_upload_form.jinja2 similarity index 100% rename from src/octoprint/plugins/backup/templates/snippets/plugin/backup/backup_plugin_upload_form.jinja2 rename to src/octoprint/plugins/backup/templates/snippets/backup_plugin_upload_form.jinja2 diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py index 28d0e5fab..f8b6c4432 100644 --- a/src/octoprint/plugins/discovery/__init__.py +++ b/src/octoprint/plugins/discovery/__init__.py @@ -786,7 +786,7 @@ class DiscoveryPlugin( __plugin_name__ = "Discovery" __plugin_author__ = "Gina Häußge" -__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/discovery.html" +__plugin_url__ = "https://docs.octoprint.org/en/master/bundledplugins/discovery.html" __plugin_description__ = ( "Makes the OctoPrint instance discoverable via Bonjour/Avahi/Zeroconf and uPnP" ) diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index 9d2975d7e..e6319f4b6 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -18,10 +18,10 @@ from octoprint.util.version import ( ) SENTRY_URL_SERVER = ( - "https://6a544965fe6c4c6eb96f7e39352b2924@o118517.ingest.sentry.io/1373987" + "https://690e174698034bcc95928e6bfa8573f7@o118517.ingest.sentry.io/1373987" ) SENTRY_URL_COREUI = ( - "https://840570e9555741bcb82bd56a084fb46e@o118517.ingest.sentry.io/1374096" + "https://186f1dc5da7d46ab9d6b6de564d839bb@o118517.ingest.sentry.io/1374096" ) SETTINGS_DEFAULTS = { diff --git a/src/octoprint/plugins/eventmanager/__init__.py b/src/octoprint/plugins/eventmanager/__init__.py new file mode 100644 index 000000000..bda534ce2 --- /dev/null +++ b/src/octoprint/plugins/eventmanager/__init__.py @@ -0,0 +1,62 @@ +from flask_babel import gettext + +import octoprint.events +import octoprint.plugin +from octoprint.access import ADMIN_GROUP + + +class EventManagerPlugin( + octoprint.plugin.SettingsPlugin, + octoprint.plugin.AssetPlugin, + octoprint.plugin.TemplatePlugin, +): + def on_settings_load(self): + my_settings = { + "availableEvents": octoprint.events.all_events(), + "subscriptions": [], + } + events = self._settings.global_get(["events"]) + if events: + my_settings["subscriptions"] = events.get("subscriptions", []) + return my_settings + + def on_settings_save(self, data): + if type(data.get("subscriptions")) == list: + self._settings.global_set( + ["events", "subscriptions"], data.get("subscriptions", []) + ) + + def get_assets(self): + return {"js": ["js/events.js"]} + + def get_template_configs(self): + return [ + { + "type": "settings", + "custom_bindings": True, + "name": gettext("Event Manager"), + } + ] + + def get_additional_permissions(self): + return [ + { + "key": "MANAGE", + "name": "Event management", + "description": gettext( + "Allows for the management of event subscriptions." + ), + "default_groups": [ADMIN_GROUP], + "roles": ["manage"], + } + ] + + +__plugin_name__ = gettext("Event Manager") +__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_author__ = "jneilliii" +__plugin_license__ = "AGPLv3" +__plugin_description__ = gettext( + "Plugin to configure event subscriptions available in config.yaml." +) +__plugin_implementation__ = EventManagerPlugin() diff --git a/src/octoprint/plugins/eventmanager/static/js/events.js b/src/octoprint/plugins/eventmanager/static/js/events.js new file mode 100644 index 000000000..f30e4972f --- /dev/null +++ b/src/octoprint/plugins/eventmanager/static/js/events.js @@ -0,0 +1,59 @@ +/* + * View model for OctoPrint-EventCoordinator + * + * Author: jneilliii + * License: AGPLv3 + */ +$(function () { + function eventManagerViewModel(parameters) { + var self = this; + + self.settingsViewModel = parameters[0]; + self.selectedCommand = ko.observable(); + + self.eventDetails = function (data) { + if (data === false) { + return { + event: ko.observable(""), + command: ko.observable(""), + type: ko.observable(""), + enabled: ko.observable(true), + debug: ko.observable(false) + }; + } else { + if (!data.hasOwnProperty("enabled")) { + data["enabled"] = ko.observable(true); + } + if (!data.hasOwnProperty("debug")) { + data["debug"] = ko.observable(false); + } + return data; + } + }; + + self.addEvent = function () { + self.selectedCommand(self.eventDetails(false)); + self.settingsViewModel.settings.plugins.eventmanager.subscriptions.push( + self.selectedCommand() + ); + $("#EventManagerEditor").modal("show"); + }; + + self.editEvent = function (data) { + self.selectedCommand(self.eventDetails(data)); + $("#EventManagerEditor").modal("show"); + }; + + self.removeEvent = function (data) { + self.settingsViewModel.settings.plugins.eventmanager.subscriptions.remove( + data + ); + }; + } + + OCTOPRINT_VIEWMODELS.push({ + construct: eventManagerViewModel, + dependencies: ["settingsViewModel"], + elements: ["#settings_plugin_eventmanager"] + }); +}); diff --git a/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 b/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 new file mode 100644 index 000000000..414c51078 --- /dev/null +++ b/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 @@ -0,0 +1,65 @@ +
+

{{ _('For additional information on OctoPrint events please see the official documentation.', url='https://docs.octoprint.org/en/master/events/index.html') }}

+

{{ _('Warning:') }} {{ _('For changes to take effect you must restart OctoPrint after saving.') }}

+
+
+
{{ _('Event') }}
+
{{ _('Command') }}
+
+ +
+
+
+
+
+
+
+ + +
+
+
+ + diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index fcf717b8a..b2ae6fdfe 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -371,6 +371,7 @@ $(function () { self._configureLayerSlider(layerSliderElement); self._configureLayerCommandSlider(commandSliderElement); + self._configureContainerElement(containerElement); self.settings.firstRequest.done(function () { var initResult = GCODE.ui.init({ @@ -475,6 +476,18 @@ $(function () { .on("slide", self.changeCommandRange); }; + self._configureContainerElement = function (containerElement) { + // Prevent the default browser action for the mouse wheel down event. The desired behavor is to have the + // gocde canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser + // will also scroll the entire page. + containerElement.mousedown(function (event) { + // Middle mouse button + if (event.which === 2) { + event.preventDefault(); + } + }); + }; + self.loadFile = function (path, date) { self.enableReload(false); self.needsLoad = false; 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 () { diff --git a/src/octoprint/plugins/logging/__init__.py b/src/octoprint/plugins/logging/__init__.py index a27da578c..344be014b 100644 --- a/src/octoprint/plugins/logging/__init__.py +++ b/src/octoprint/plugins/logging/__init__.py @@ -4,7 +4,6 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms import os from os import scandir -import yaml from flask import abort, jsonify, request, url_for from flask_babel import gettext from werkzeug.exceptions import BadRequest @@ -16,7 +15,7 @@ from octoprint.access.permissions import Permissions from octoprint.server import NO_CONTENT from octoprint.server.util.flask import no_firstrun_access, redirect_to_tornado from octoprint.settings import settings -from octoprint.util import is_hidden_path +from octoprint.util import is_hidden_path, yaml class LoggingPlugin( @@ -180,10 +179,7 @@ class LoggingPlugin( config_from_file = {} if os.path.exists(logging_file) and os.path.isfile(logging_file): - import yaml - - with open(logging_file, encoding="utf-8") as f: - config_from_file = yaml.safe_load(f) + config_from_file = yaml.load_from_file(path=logging_file) return config_from_file def _get_logging_levels(self): @@ -233,9 +229,7 @@ class LoggingPlugin( with octoprint.util.atomic_write( self._get_logging_file(), mode="wt", max_permissions=0o666 ) as f: - yaml.safe_dump( - config, f, default_flow_style=False, indent=2, allow_unicode=True - ) + yaml.save_to_file(config, file=f, pretty=True) # set runtime logging levels now for logger, level in new_levels.items(): diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 912f99249..8dc5b1303 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -1251,6 +1251,14 @@ class PluginManagerPlugin( ) abort(500, description="Could not uninstall plugin, its origin is unknown") + if plugin.implementation: + try: + plugin.implementation.on_plugin_pending_uninstall() + except Exception: + self._logger.exception( + "Error while calling on_plugin_pending_uninstall on the plugin, proceeding regardless" + ) + if plugin.origin.type == "entry_point": # plugin is installed through entry point, need to use pip to uninstall it origin = plugin.origin[3] @@ -2113,7 +2121,7 @@ def _register_custom_events(*args, **kwargs): __plugin_name__ = "Plugin Manager" __plugin_author__ = "Gina Häußge" -__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html" +__plugin_url__ = "https://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html" __plugin_description__ = "Allows installing and managing OctoPrint plugins" __plugin_license__ = "AGPLv3" __plugin_pythoncompat__ = ">=2.7,<4" 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 4d1276b33..4381e7d4c 100644 --- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js +++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js @@ -50,7 +50,7 @@ $(function () { return !item.enabled; } }, - "popularity", + "name", [], [ ["bundled", "3rdparty"], @@ -58,6 +58,10 @@ $(function () { ], 0 ); + self.plugins.currentFilters.subscribe(function () { + self.clearPluginsSelection(); + }); + self.pluginLookup = {}; self.repositoryplugins = new ItemListHelper( "plugin.pluginmanager.repositoryplugins", @@ -138,7 +142,7 @@ $(function () { return !plugin.abandoned; } }, - "title", + "popularity", ["filter_installed", "filter_incompatible"], [], 0 @@ -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 7c1008606..8f536a848 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -62,7 +62,7 @@
- {{ _('Export') }} + {{ _('Export') }}
@@ -107,6 +107,16 @@
+
@@ -124,12 +134,17 @@ + +
+ {{ _('Name') }} {{ _('Actions') }}
+ +
()
@@ -151,6 +166,7 @@
+ {{ _('Please note that bundled and incompatible plugins do not support bulk operations.') }}
diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 9b79bf63a..cae6e5984 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -27,20 +27,22 @@ from octoprint.server.util.flask import ( no_firstrun_access, with_revalidation_checking, ) -from octoprint.util import dict_merge, get_formatted_size, to_unicode +from octoprint.util import dict_merge, get_formatted_size, to_unicode, yaml from octoprint.util.pip import create_pip_caller from octoprint.util.version import ( get_comparable_version, get_python_version_string, is_python_compatible, + is_released_octoprint_version, + is_stable, ) from . import cli, exceptions, updaters, util, version_checks -# OctoPi 0.15+ -MINIMUM_PYTHON = "2.7.9" -MINIMUM_SETUPTOOLS = "39.0.1" -MINIMUM_PIP = "9.0.3" +# OctoPi 0.16+ +MINIMUM_PYTHON = "2.7.13" +MINIMUM_SETUPTOOLS = "40.7.1" +MINIMUM_PIP = "19.0.1" DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" @@ -60,9 +62,12 @@ class SoftwareUpdatePlugin( COMMIT_TRACKING_TYPES = ("github_commit", "bitbucket_commit") CURRENT_TRACKING_TYPES = COMMIT_TRACKING_TYPES + ("etag", "lastmodified", "jsondata") + RELEASE_TRACKING_TYPES = ("github_release",) OCTOPRINT_RESTART_TYPES = ("pip", "single_file_plugin") + VALID_RESTART_TYPES = ("octoprint", "environment") + DATA_FORMAT_VERSION = "v4" CHECK_OVERLAY_KEY = "softwareupdate_check_overlay" @@ -463,11 +468,8 @@ class SoftwareUpdatePlugin( if not os.path.isfile(self._version_cache_path): return - import yaml - try: - with open(self._version_cache_path, encoding="utf-8") as f: - data = yaml.safe_load(f) + data = yaml.load_from_file(path=self._version_cache_path) timestamp = os.stat(self._version_cache_path).st_mtime except Exception: self._logger.exception("Error while loading version cache from disk") @@ -504,8 +506,6 @@ class SoftwareUpdatePlugin( self._logger.exception("Error parsing in version cache data") def _save_version_cache(self): - import yaml - from octoprint._version import get_versions from octoprint.util import atomic_write @@ -515,13 +515,7 @@ class SoftwareUpdatePlugin( with atomic_write( self._version_cache_path, mode="wt", max_permissions=0o666 ) as file_obj: - yaml.safe_dump( - self._version_cache, - stream=file_obj, - default_flow_style=False, - indent=2, - allow_unicode=True, - ) + yaml.save_to_file(self._version_cache, file=file_obj, pretty=True) self._version_cache_dirty = False self._version_cache_timestamp = time.time() @@ -539,11 +533,8 @@ class SoftwareUpdatePlugin( if not os.path.isfile(self._update_log_path): return - import yaml - try: - with open(self._update_log_path, encoding="utf-8") as f: - data = yaml.safe_load(f) + data = yaml.load_from_file(path=self._update_log_path) except Exception: self._logger.exception("Error while loading update log from disk") else: @@ -573,20 +564,16 @@ class SoftwareUpdatePlugin( self._logger.info("Loaded update log from disk") def _save_update_log(self): - import yaml - from octoprint.util import atomic_write with self._update_log_mutex: with atomic_write( self._update_log_path, mode="wt", max_permissions=0o666 ) as file_obj: - yaml.safe_dump( + yaml.save_to_file( sorted(self._update_log, key=lambda x: x["datetime"]), - stream=file_obj, - default_flow_style=False, - indent=2, - allow_unicode=True, + file=file_obj, + pretty=True, ) self._update_log_dirty = False @@ -625,15 +612,45 @@ class SoftwareUpdatePlugin( self._save_update_log() def _is_octoprint_outdated_and_can_update(self): - information, update_available, update_possible = self.get_current_versions() - if not update_available or not update_possible or "octoprint" not in information: + checks = self._get_configured_checks() + check = checks.get("octoprint", None) + if not check: return False - octoprint_information = information["octoprint"] - return ( - octoprint_information["updateAvailable"] - and octoprint_information["updatePossible"] + check = self._populated_check("octoprint", check) + credentials = self._settings.get(["credentials"], merged=True) + + _, update_available, update_possible, _, _ = self._get_current_version( + "octoprint", check, credentials=credentials ) + if not update_available or not update_possible: + return False + + restart_type = self._get_restart_type(check) + restart_command = self._get_restart_command(restart_type) + return restart_command is not None + + def _get_restart_type(self, check): + if check.get("restart") in self.VALID_RESTART_TYPES: + return check["restart"] + elif "pip" in check or check.get("method") in self.OCTOPRINT_RESTART_TYPES: + return "octoprint" + else: + target_restart_type = None + + return target_restart_type + + def _get_restart_command(self, restart_type): + if restart_type == "octoprint": + return self._settings.global_get( + ["server", "commands", "serverRestartCommand"] + ) + elif restart_type == "environment": + return self._settings.global_get( + ["server", "commands", "systemRestartCommand"] + ) + else: + return None # ~~ SettingsPlugin API @@ -1087,6 +1104,8 @@ class SoftwareUpdatePlugin( )(view)() @octoprint.plugin.BlueprintPlugin.route("/check", methods=["GET"]) + @no_firstrun_access + @Permissions.PLUGIN_SOFTWAREUPDATE_CHECK.require(403) def check_for_update(self): if ( not Permissions.PLUGIN_SOFTWAREUPDATE_CHECK.can() @@ -1428,7 +1447,11 @@ class SoftwareUpdatePlugin( def _is_wizard_update_required(self): firstrun = self._settings.global_get(["server", "firstRun"]) - return firstrun and self._is_octoprint_outdated_and_can_update() + return ( + firstrun + and self._is_octoprint_outdated_and_can_update() + and not self._is_settings_wizard_required() + ) def _is_settings_wizard_required(self): checks = self._get_configured_checks() @@ -1442,6 +1465,14 @@ class SoftwareUpdatePlugin( def get_wizard_version(self): return 1 + def get_wizard_details(self): + result = {} + if self._is_wizard_update_required(): + information, _, _ = self.get_current_versions() + data = information.get("octoprint", {}) + result["update"] = data + return result + ##~~ EventHandlerPlugin API def on_event(self, event, payload): @@ -1501,6 +1532,9 @@ class SoftwareUpdatePlugin( if not check: continue + if "type" not in check: + continue + try: populated_check = self._populated_check(target, check) future = executor.submit( @@ -1881,15 +1915,7 @@ class SoftwareUpdatePlugin( if target_result is not None: target_results[target] = target_result - if "restart" in check: - target_restart_type = check["restart"] - elif ( - "pip" in check - or check.get("method") in self.OCTOPRINT_RESTART_TYPES - ): - target_restart_type = "octoprint" - else: - target_restart_type = None + target_restart_type = self._get_restart_type(check) # if our update requires a restart we have to determine which type if restart_type is None or ( @@ -1920,16 +1946,7 @@ class SoftwareUpdatePlugin( # one of our updates requires a restart of either type "octoprint" or "environment". Let's see if # we can actually perform that - restart_command = None - if restart_type == "octoprint": - restart_command = self._settings.global_get( - ["server", "commands", "serverRestartCommand"] - ) - elif restart_type == "environment": - restart_command = self._settings.global_get( - ["server", "commands", "systemRestartCommand"] - ) - + restart_command = self._get_restart_command(restart_type) if restart_command: self._send_client_message( "restarting", @@ -2166,12 +2183,6 @@ class SoftwareUpdatePlugin( result = dict(check) if target == "octoprint": - - from octoprint.util.version import ( - is_released_octoprint_version, - is_stable_octoprint_version, - ) - displayName = check.get("displayName") if displayName is None: # displayName missing or set to None @@ -2184,13 +2195,6 @@ class SoftwareUpdatePlugin( displayVersion = "{octoprint_version}" result["displayVersion"] = to_unicode(displayVersion, errors="replace") - stable_branch = "master" - release_branches = [] - if "stable_branch" in check: - release_branches.append(check["stable_branch"]["branch"]) - stable_branch = check["stable_branch"]["branch"] - if "prerelease_branches" in check: - release_branches += [x["branch"] for x in check["prerelease_branches"]] result["released_version"] = is_released_octoprint_version() if check["type"] in self.COMMIT_TRACKING_TYPES: @@ -2198,39 +2202,6 @@ class SoftwareUpdatePlugin( else: result["current"] = VERSION - if check["type"] == "github_release" and ( - check.get("prerelease", None) or not is_stable_octoprint_version() - ): - # we are tracking github releases and are either also tracking prerelease OR are currently running - # a non stable version => we need to change some parameters - - # we compare versions fully, not just the base so that we see a difference - # between RCs + stable for the same version release - result["force_base"] = False - - if check.get("prerelease", None): - # we are tracking prereleases => we want to be on the correct prerelease channel/branch - channel = check.get("prerelease_channel", None) - if channel: - # if we have a release channel, we also set our update_branch here to our release channel - # in case it's not already set - result["update_branch"] = check.get("update_branch", channel) - - else: - # we are not tracking prereleases, but aren't on the stable branch either => switch back - # to stable branch on update - result["update_branch"] = check.get( - "update_branch", stable_branch - ) - - if check.get("update_script", None): - # we force an exact version & python unequality check, to be able to downgrade - result["force_exact_version"] = True - result["release_compare"] = "python_unequal" - elif check.get("pip", None): - # we force python unequality check for pip installs, to be able to downgrade - result["release_compare"] = "python_unequal" - elif target == "pip": import pkg_resources @@ -2273,6 +2244,43 @@ class SoftwareUpdatePlugin( "current", check.get("displayVersion", None) ) + if ( + check["type"] in self.RELEASE_TRACKING_TYPES + and result["current"] + and (check.get("prerelease", None) or not is_stable(result["current"])) + ): + # we are tracking releases and are either also tracking prerelease OR are currently running + # a non stable version => we need to change some parameters + + # we compare versions fully, not just the base so that we see a difference + # between RCs + stable for the same version release + result["force_base"] = False + + if check["type"] == "github_release": + if check.get("prerelease", None): + # we are tracking prereleases => we want to be on the correct prerelease channel/branch + channel = check.get("prerelease_channel", None) + if channel: + # if we have a release channel, we also set our update_branch here to our release channel + # in case it's not already set + result["update_branch"] = check.get("update_branch", channel) + + else: + # we are not tracking prereleases, but aren't on the stable branch either => switch back + # to stable branch on update + result["update_branch"] = check.get( + "update_branch", + check.get("stable_branch", {"branch": "main"})["branch"], + ) + + if check.get("update_script", None): + # we force an exact version & python unequality check, to be able to downgrade + result["force_exact_version"] = True + result["release_compare"] = "python_unequal" + elif check.get("pip", None): + # we force python unequality check for pip installs, to be able to downgrade + result["release_compare"] = "python_unequal" + if result.get("pip", None): if "pip_command" not in result: local_pip_command = self._settings.global_get( @@ -2397,7 +2405,7 @@ def _register_custom_events(*args, **kwargs): __plugin_name__ = "Software Update" __plugin_author__ = "Gina Häußge" -__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html" +__plugin_url__ = "https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html" __plugin_description__ = "Allows receiving update notifications and performing updates of OctoPrint and plugins" __plugin_disabling_discouraged__ = gettext( "Without this plugin OctoPrint will no longer be able to " diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 11eee8226..d98069c23 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -82,6 +82,10 @@ $(function () { }); self.enableUpdateAll = ko.pureComputed(function () { + return self.enableUpdate() && self.availableAndPossible().length > 0; + }); + + self.enableUpdateEnabled = ko.pureComputed(function () { return ( self.enableUpdate() && self.availableAndPossibleAndEnabled().length > 0 ); @@ -306,74 +310,90 @@ $(function () { ); }; + self._enrichInformation = function (key, information) { + information["key"] = key; + + if ( + !information.hasOwnProperty("displayName") || + information.displayName === "" + ) { + information.displayName = information.key; + } + if ( + !information.hasOwnProperty("displayVersion") || + information.displayVersion === "" + ) { + information.displayVersion = information.information.local.name; + } + if ( + !information.hasOwnProperty("releaseNotes") || + information.releaseNotes === "" + ) { + information.releaseNotes = undefined; + } + + var fullNameTemplate = gettext("%(name)s: %(version)s"); + information.fullNameLocal = _.sprintf(fullNameTemplate, { + name: _.escape(information.displayName), + version: _.escape(information.displayVersion) + }); + + var fullNameRemoteVars = { + name: _.escape(information.displayName), + version: gettext("unknown") + }; + if ( + information.hasOwnProperty("information") && + information.information.hasOwnProperty("remote") && + information.information.remote.hasOwnProperty("name") + ) { + fullNameRemoteVars.version = _.escape( + information.information.remote.name + ); + } + information.fullNameRemote = _.sprintf(fullNameTemplate, fullNameRemoteVars); + + if (information.releaseChannels && information.releaseChannels.current) { + information.releaseChannels.current = ko.observable( + information.releaseChannels.current + ); + information.releaseChannels.current.subscribe(function (selected) { + var patch = {}; + patch[key] = {channel: selected}; + OctoPrint.plugins.softwareupdate.configure(patch).done(function () { + self.performCheck(false, false, false, [key]); + }); + }); + } + + information.toggleDisabled = function () { + var patch = {}; + patch[key] = {disabled: !information.disabled}; + OctoPrint.plugins.softwareupdate.configure(patch).done(function () { + self.performCheck(false, false, false, [key]); + }); + }; + + information.notificationIconTitle = function () { + var update = information.updateAvailable + ? gettext("Update available") + : gettext("Up-to-date"); + var notifications = information.disabled + ? gettext("notifications are muted") + : gettext("notifications are enabled"); + + return update + " (" + notifications + ")"; + }; + + return information; + }; + self.fromCheckResponse = function (data, ignoreSeen, showIfNothingNew) { self.cacheTimestamp(data.timestamp); var versions = []; _.each(data.information, function (value, key) { - value["key"] = key; - - if (!value.hasOwnProperty("displayName") || value.displayName === "") { - value.displayName = value.key; - } - if ( - !value.hasOwnProperty("displayVersion") || - value.displayVersion === "" - ) { - value.displayVersion = value.information.local.name; - } - if (!value.hasOwnProperty("releaseNotes") || value.releaseNotes === "") { - value.releaseNotes = undefined; - } - - var fullNameTemplate = gettext("%(name)s: %(version)s"); - value.fullNameLocal = _.sprintf(fullNameTemplate, { - name: _.escape(value.displayName), - version: _.escape(value.displayVersion) - }); - - var fullNameRemoteVars = { - name: _.escape(value.displayName), - version: gettext("unknown") - }; - if ( - value.hasOwnProperty("information") && - value.information.hasOwnProperty("remote") && - value.information.remote.hasOwnProperty("name") - ) { - fullNameRemoteVars.version = _.escape(value.information.remote.name); - } - value.fullNameRemote = _.sprintf(fullNameTemplate, fullNameRemoteVars); - - if (value.releaseChannels && value.releaseChannels.current) { - value.releaseChannels.current = ko.observable( - value.releaseChannels.current - ); - value.releaseChannels.current.subscribe(function (selected) { - var patch = {}; - patch[key] = {channel: selected}; - OctoPrint.plugins.softwareupdate - .configure(patch) - .done(function () { - self.performCheck(false, false, false, [key]); - }); - }); - } - - value.toggleDisabled = function () { - var patch = {}; - patch[key] = {disabled: !value.disabled}; - OctoPrint.plugins.softwareupdate.configure(patch).done(function () { - self.performCheck(false, false, false, [key]); - }); - }; - - if (key === "octoprint") { - self.octoprintData.item = value; - self.octoprintData.current(value.information.local.name); - self.octoprintData.available(value.information.remote.name); - } - + self._enrichInformation(key, value); versions.push(value); }); self.versions.updateItems(versions); @@ -683,14 +703,7 @@ $(function () { }; self.performUpdate = function (force, items) { - if ( - !( - self.loginState.hasPermission( - self.access.permissions.PLUGIN_SOFTWAREUPDATE_UPDATE - ) || CONFIG_FIRST_RUN - ) - ) - return; + if (!self.updateAccess()) return; if (self.printerState.isPrinting()) return; self.updateInProgress = true; @@ -747,15 +760,16 @@ $(function () { return self.update(force, self.availableAndPossibleAndEnabled()); }; + self.updateAccess = function () { + return ( + self.loginState.hasPermission( + self.access.permissions.PLUGIN_SOFTWAREUPDATE_UPDATE + ) || CONFIG_FIRST_RUN + ); + }; + self.update = function (force, items) { - if ( - self.updateInProgress || - !( - self.loginState.hasPermission( - self.access.permissions.PLUGIN_SOFTWAREUPDATE_UPDATE - ) || CONFIG_FIRST_RUN - ) - ) { + if (self.updateInProgress || !self.updateAccess()) { self._updateClicked = false; return; } @@ -851,8 +865,10 @@ $(function () { self._showWorkingDialog = function (title) { if ( - !self.loginState.hasPermission( - self.access.permissions.PLUGIN_SOFTWAREUPDATE_CHECK + !( + self.loginState.hasPermission( + self.access.permissions.PLUGIN_SOFTWAREUPDATE_CHECK + ) || CONFIG_FIRST_RUN ) ) { return; @@ -929,6 +945,21 @@ $(function () { self.performCheck(); }; + self.onWizardDetails = function (data) { + if ( + data.softwareupdate && + data.softwareupdate.details && + data.softwareupdate.details.update + ) { + var value = data.softwareupdate.details.update; + self._enrichInformation("octoprint", value); + + self.octoprintData.item = value; + self.octoprintData.current(value.information.local.name); + self.octoprintData.available(value.information.remote.name); + } + }; + self.onDataUpdaterReconnect = function () { if (self.waitingForRestart) { self.waitingForRestart = false; diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/checkoutFolder.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/checkoutFolder.jinja2 similarity index 100% rename from src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/checkoutFolder.jinja2 rename to src/octoprint/plugins/softwareupdate/templates/snippets/checkoutFolder.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/pipEnableCheck.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/pipEnableCheck.jinja2 similarity index 100% rename from src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/pipEnableCheck.jinja2 rename to src/octoprint/plugins/softwareupdate/templates/snippets/pipEnableCheck.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/pipTarget.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/pipTarget.jinja2 similarity index 100% rename from src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/pipTarget.jinja2 rename to src/octoprint/plugins/softwareupdate/templates/snippets/pipTarget.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/releaseChannel.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/releaseChannel.jinja2 similarity index 100% rename from src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/releaseChannel.jinja2 rename to src/octoprint/plugins/softwareupdate/templates/snippets/releaseChannel.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/trackedBranch.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/trackedBranch.jinja2 similarity index 100% rename from src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/trackedBranch.jinja2 rename to src/octoprint/plugins/softwareupdate/templates/snippets/trackedBranch.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/versionTracking.jinja2 b/src/octoprint/plugins/softwareupdate/templates/snippets/versionTracking.jinja2 similarity index 100% rename from src/octoprint/plugins/softwareupdate/templates/snippets/plugins/softwareupdate/versionTracking.jinja2 rename to src/octoprint/plugins/softwareupdate/templates/snippets/versionTracking.jinja2 diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 index 0efe80cfd..0e3056f59 100644 --- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 +++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 @@ -12,7 +12,7 @@ If you have a local OctoPrint checkout folder switched to another branch, simply switching over to "Commit" tracking will already take care of that. Otherwise please take a look at the - Documentation. + Documentation.

{% endtrans %}
{% trans %} @@ -85,28 +85,31 @@
- - +
+ + + +
+
+ + + +

{{ _('Current versions') }}

-
- -
- {{ _('Last cache refresh:') }} - - -
-
-
- +
- + @@ -126,9 +129,20 @@
+ + = {{ _('Update notifications enabled') }}, + = {{ _('Update notifications muted') }}, + {{ _('click to toggle') }}. + {% trans %} + "Update all" will update all items for which updates are availalbe & + update notifications are enabled as well, "Update all available" will + update all items for which updates are available regardless of update + notifications being enabled or muted. + {% endtrans %} +
-
+

{{ _('Update log') }}

@@ -158,11 +172,11 @@
+
+
+ +
+
diff --git a/src/octoprint/templates/login.jinja2 b/src/octoprint/templates/login.jinja2 index 175738b6b..14d48cf7a 100644 --- a/src/octoprint/templates/login.jinja2 +++ b/src/octoprint/templates/login.jinja2 @@ -26,6 +26,7 @@ @@ -43,14 +44,16 @@