Compare commits
102
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a42f02aec | ||
|
|
7c48cfd0f7 | ||
|
|
bba796d551 | ||
|
|
a855f3e62c | ||
|
|
5079e7e891 | ||
|
|
ddc948fa94 | ||
|
|
f88f2b25ea | ||
|
|
ea59dab7ab | ||
|
|
f0914c2214 | ||
|
|
b3e76c3ecc | ||
|
|
a4d5acb0b8 | ||
|
|
79b66f17b6 | ||
|
|
36198c684f | ||
|
|
a3a60c5967 | ||
|
|
6df3cb5c12 | ||
|
|
0611329a6d | ||
|
|
2f90fca5ce | ||
|
|
e4e97190da | ||
|
|
9c748a85b4 | ||
|
|
78c2199d89 | ||
|
|
0e67906d1e | ||
|
|
4c602cba2e | ||
|
|
89255e2ec9 | ||
|
|
372b3662e9 | ||
|
|
e007dbaf4c | ||
|
|
f67f9b9399 | ||
|
|
c6c5328418 | ||
|
|
accbfc2b45 | ||
|
|
9976f2b7a3 | ||
|
|
f249563b2c | ||
|
|
09e023917c | ||
|
|
799b86b287 | ||
|
|
ea1bcf8e5d | ||
|
|
ee93e25ffd | ||
|
|
d25f664be3 | ||
|
|
3bffe4f7cb | ||
|
|
f140dd9d44 | ||
|
|
d44747b39a | ||
|
|
f2da9d8d7d | ||
|
|
5483ef7cd4 | ||
|
|
85d212ba97 | ||
|
|
44af09580a | ||
|
|
530fca95e4 | ||
|
|
59ae7e39f2 | ||
|
|
72167d14d2 | ||
|
|
2c6568acd1 | ||
|
|
e27c216a05 | ||
|
|
7b4c148dd7 | ||
|
|
a924520dd6 | ||
|
|
e88eb6dd85 | ||
|
|
59dfa994bd | ||
|
|
6959ce4d38 | ||
|
|
08bc0082cf | ||
|
|
6069d74a54 | ||
|
|
68ee7030f1 | ||
|
|
81342acccc | ||
|
|
e029f33901 | ||
|
|
7bd8cff137 | ||
|
|
055dcfa0e1 | ||
|
|
8acf417383 | ||
|
|
b50e1aee8a | ||
|
|
c714bce17e | ||
|
|
a9a8e48489 | ||
|
|
9dec840818 | ||
|
|
9af125ca6d | ||
|
|
1f4fabe6ef | ||
|
|
121f36704d | ||
|
|
85ff545c07 | ||
|
|
3662c84de5 | ||
|
|
79558fdfbf | ||
|
|
11040f272a | ||
|
|
fa2716c65c | ||
|
|
768b06e35a | ||
|
|
0820c23aea | ||
|
|
361fbaa366 | ||
|
|
a91359f2af | ||
|
|
4bfabf82ae | ||
|
|
c90f556fe9 | ||
|
|
352b190a72 | ||
|
|
e9b0bd9e65 | ||
|
|
c8ea808d93 | ||
|
|
d40c3e6241 | ||
|
|
e94f789b72 | ||
|
|
9ff44c49a6 | ||
|
|
c7b933ba00 | ||
|
|
6765b25803 | ||
|
|
59b60f5dad | ||
|
|
2822992843 | ||
|
|
1b82aa859f | ||
|
|
12be637f85 | ||
|
|
3bd9d11fc3 | ||
|
|
e864d6b03e | ||
|
|
547db7c1f5 | ||
|
|
d6516e4a4c | ||
|
|
2387b4a771 | ||
|
|
b03d43156d | ||
|
|
07423712a6 | ||
|
|
81735d07c9 | ||
|
|
03e328fd13 | ||
|
|
7efcf00baf | ||
|
|
a3254466f7 | ||
|
|
f8dc504773 |
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: [foosel]
|
||||||
|
patreon: foosel
|
||||||
|
custom: https://octoprint.org/support-octoprint/
|
||||||
@@ -16,8 +16,9 @@ checklist:
|
|||||||
made sure your changes don't interfere with current development by
|
made sure your changes don't interfere with current development by
|
||||||
talking it through with the maintainers, e.g. through a
|
talking it through with the maintainers, e.g. through a
|
||||||
Brainstorming ticket
|
Brainstorming ticket
|
||||||
* [ ] Your PR targets OctoPrint's devel branch, or maintenance if it's
|
* [ ] Your PR targets OctoPrint's devel branch if it's a completely
|
||||||
a bug fix for an issue present in the current stable version (no PRs
|
new feature, or maintenance if it's a bug fix or improvement of
|
||||||
|
existing functionality for the current stable version (no PRs
|
||||||
against master or anything else please)
|
against master or anything else please)
|
||||||
* [ ] Your PR was opened from a custom branch on your repository
|
* [ ] Your PR was opened from a custom branch on your repository
|
||||||
(no PRs from your version of master, maintenance or devel please),
|
(no PRs from your version of master, maintenance or devel please),
|
||||||
|
|||||||
@@ -102,6 +102,12 @@ date of first contribution):
|
|||||||
* [Jack Wilsdon](https://github.com/jackwilsdon)
|
* [Jack Wilsdon](https://github.com/jackwilsdon)
|
||||||
* [Ryan Finnie](https://github.com/rfinnie)
|
* [Ryan Finnie](https://github.com/rfinnie)
|
||||||
* [Timur Duehr](https://github.com/tduehr)
|
* [Timur Duehr](https://github.com/tduehr)
|
||||||
|
* [Nicolai Nielsen](https://github.com/dovecode)
|
||||||
|
* [Janne Mäntyharju](https://github.com/JanneMantyharju)
|
||||||
|
* [Steven Spungin](https://github.com/flamenco)
|
||||||
|
* [Piotr Usewicz](https://github.com/pusewicz)
|
||||||
|
* [Aliaksei Pilko](https://github.com/aliaksei135)
|
||||||
|
* [Ben Yarmis](https://github.com/byarmis)
|
||||||
|
|
||||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
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
|
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||||
|
|||||||
@@ -1,5 +1,91 @@
|
|||||||
# OctoPrint Changelog
|
# OctoPrint Changelog
|
||||||
|
|
||||||
|
## 1.3.12rc1 (2019-09-10)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* [#1239](https://github.com/foosel/OctoPrint/issues/1239) & [#3227](https://github.com/foosel/OctoPrint/pull/3227) - Add command line interface for user management. Via `octoprint user [add_user|remove_user|change_password]` it is now possible to add & remove users or change their passwords right from the command line instead of just through the web interface. That should also make password recovery easier and as simple as `octoprint user change_password username`.
|
||||||
|
* [#2896](https://github.com/foosel/OctoPrint/issues/2896) - Add confirmation dialog when removing a plugin (see also [#3179](https://github.com/foosel/OctoPrint/pull/3179)).
|
||||||
|
* [#3075](https://github.com/foosel/OctoPrint/issues/3075) - Calculate filament usage for all extruders in `M605` duplicate/mirror setup (see also [#3181](https://github.com/foosel/OctoPrint/pull/3181)).
|
||||||
|
* [#3101](https://github.com/foosel/OctoPrint/issues/3101) - Support tags on GCODE script hook and add `plugin:<plugin id>` to script parts from plugins.
|
||||||
|
* [#2669](https://github.com/foosel/OctoPrint/issues/2669) - Add option for disabling filters on search results in the file list (see also [#3126](https://github.com/foosel/OctoPrint/pull/3126)).
|
||||||
|
* [#3131](https://github.com/foosel/OctoPrint/pull/3131) - Allow subscribing to multiple events in one yaml based event subscription.
|
||||||
|
* [#3133](https://github.com/foosel/OctoPrint/issues/3133) - Adjust wording in case of file upload errors to also hint at permission problems.
|
||||||
|
* [#3134](https://github.com/foosel/OctoPrint/pull/3134) - Add support for logging in (and creating users) through `REMOTE_USER` header supplied by a reverse proxy in front of OctoPrint.
|
||||||
|
* [#3147](https://github.com/foosel/OctoPrint/pull/3147) - Forcelogin: Add autofocus to the username
|
||||||
|
* [#3161](https://github.com/foosel/OctoPrint/issues/3161) - Plugin manager: Reduce height of plugin list.
|
||||||
|
* [#3162](https://github.com/foosel/OctoPrint/issues/3162) - Make closing behaviour of dialogs adjustable: default behaviour is to close on click outside of dialog, this can now be disabled.
|
||||||
|
* [#3167](https://github.com/foosel/OctoPrint/pull/3167) - Make it configurable whether to perform the parity double open workaround on serial needed for (some?) debian based systems. Solves issues for FreeBSD systems & Klipper.
|
||||||
|
* [#3180](https://github.com/foosel/OctoPrint/pull/3180) - Add button to terminal tab to clear the log.
|
||||||
|
* [#3188](https://github.com/foosel/OctoPrint/issues/3188) - Suppress scary `WebSocketClosedError` messages in the log simply caused by closing the browser.
|
||||||
|
* [#3171](https://github.com/foosel/OctoPrint/issues/3171) & [#3204](https://github.com/foosel/OctoPrint/issues/3204) - Action command prompts: Add close button to prompts triggered through action commands by the firmware. Wouldn't have been necessary if firmware wasn't already abusing this feature created for *interactive prompts* as non interactive fire&forget notification dialogs 🙄
|
||||||
|
* [#3174](https://github.com/foosel/OctoPrint/issues/3174) - Include upload date & time in State panel to make file refreshs clearer.
|
||||||
|
* [#3191](https://github.com/foosel/OctoPrint/pull/3191) - Docs: Clarify that a target temperature value of 0 turns heaters off.
|
||||||
|
* [#3198](https://github.com/foosel/OctoPrint/issues/3198) - Clarify execution order of GCODE scripts.
|
||||||
|
* [#3199](https://github.com/foosel/OctoPrint/issues/3199) - Hardening against corrupt print recovery data.
|
||||||
|
* [#3203](https://github.com/foosel/OctoPrint/issues/3203) - Add documentation for `printTimeLeftOrigin` field.
|
||||||
|
* [#3206](https://github.com/foosel/OctoPrint/issues/3206) - Better resilience against garbage on the line on initial connect to the printer due to more handshake attempts.
|
||||||
|
* [#3207](https://github.com/foosel/OctoPrint/issues/3207) - Try to guess the mimetype if there is none during the webcam stream test.
|
||||||
|
* [#3218](https://github.com/foosel/OctoPrint/pull/3218) - Small refactoring in comm layer
|
||||||
|
* [#3225](https://github.com/foosel/OctoPrint/pull/3225) - Quote arguments in `pip install` to avoid issues with shells other than bash.
|
||||||
|
* [#3249](https://github.com/foosel/OctoPrint/pull/3249) & [#3263](https://github.com/foosel/OctoPrint/pull/3263) - Printer profile events are now properly triggered.
|
||||||
|
* [#3250](https://github.com/foosel/OctoPrint/issues/3250) - Add optional confirmation dialog for starting a print.
|
||||||
|
* Make emergency codes configurable.
|
||||||
|
* Detect endless resend requests of the same line. If the printer keeps requesting the same line over and over again, something is either seriously wrong with the line or with the connection. In any case, log an error and disconnect.
|
||||||
|
* Send `M112` on disconnect due to an error (configurable) to try to disable heaters and such.
|
||||||
|
* More type annotations throughout the code.
|
||||||
|
* Re-add missing `minHeight` support to modals.
|
||||||
|
* Ensure line breaks on copy of terminal contents.
|
||||||
|
* Error Tracking: Further limit events that go out, this time by fqcn of callback methods, if needed.
|
||||||
|
* GCODE viewer: Increase logging.
|
||||||
|
* Plugin Manager: Prevent plugin installs while throttled due to undervoltage or overheating.
|
||||||
|
* Software Update: Consider an empty restart command an unset one.
|
||||||
|
* Software Update: Prevent updates while throttled due to undervoltage or overheating.
|
||||||
|
* Tracking: Track plugins & versions once every 24h. This is a feature requested repeatedly by plugin developers and will also allow the compilation of something like a Top-10-list.
|
||||||
|
* Tracking: Track slicing events
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* [#3022](https://github.com/foosel/OctoPrint/issues/3022) & [#3236](https://github.com/foosel/OctoPrint/issues/3236) - Ignore `NaN` and `Inf` values in GCODE analysis result, don't allow `NaN` on APIs.
|
||||||
|
* [#3095](https://github.com/foosel/OctoPrint/issues/3095) - Fix a small error in the frontend through bootstrap update.
|
||||||
|
* [#3096](https://github.com/foosel/OctoPrint/issues/3096) - Fix handling of `Empty` exception in send loop.
|
||||||
|
* [#3104](https://github.com/foosel/OctoPrint/issues/3104) - `M112` and other emergency codes must *always* jump the internal command queue even when printing and be sent immediately.
|
||||||
|
* [#3107](https://github.com/foosel/OctoPrint/issues/3107) - Prevent issues if `hash` field on file metadata is unset.
|
||||||
|
* [#3109](https://github.com/foosel/OctoPrint/issues/3109) - Fix some unicode issues on the API.
|
||||||
|
* [#3114](https://github.com/foosel/OctoPrint/issues/3114) - Virtual printer: Fix handling of closed connection.
|
||||||
|
* [#3137](https://github.com/foosel/OctoPrint/issues/3137) - Do not invert axes in GCODE viewer. The axis inversion is only relevant to the control panel (depends on how the print head is positioned), NOT the rendition of the GCODE.
|
||||||
|
* [#3142](https://github.com/foosel/OctoPrint/issues/3142) - Only do autologin if not actively logged out.
|
||||||
|
* [#3143](https://github.com/foosel/OctoPrint/issues/3143) - Fix layers vanishing from GCODE viewer on settings access.
|
||||||
|
* [#3153](https://github.com/foosel/OctoPrint/issues/3153) - Fix wrong variable name in an exception handler.
|
||||||
|
* [#3154](https://github.com/foosel/OctoPrint/issues/3154) - Strip interface tags from IPv6 addresses in local address check.
|
||||||
|
* [#3155](https://github.com/foosel/OctoPrint/issues/3155) - Backup: Make sure `exclude` is always a list.
|
||||||
|
* [#3156](https://github.com/foosel/OctoPrint/issues/3156) - Tracking: Fix error if tracked time is `None`.
|
||||||
|
* [#3157](https://github.com/foosel/OctoPrint/issues/3157) - Plugin manager: Better handling of unexpected repository format (e.g. in case of a misconfigured repository URL).
|
||||||
|
* [#3166](https://github.com/foosel/OctoPrint/issues/3166) & [#3211](https://github.com/foosel/OctoPrint/issues/3211) - Fix caching behaviour in case of active wizards.
|
||||||
|
* [#3171](https://github.com/foosel/OctoPrint/issues/3171) - Action command prompts: Remove prompts on disconnect from the printer.
|
||||||
|
* [#3176](https://github.com/foosel/OctoPrint/issues/3176) - Forcelogin: Don't touch static endpoints.
|
||||||
|
* [#3177](https://github.com/foosel/OctoPrint/issues/3177) - Always report all tools in shared nozzle setups to avoid inconsistencies.
|
||||||
|
* [#3190](https://github.com/foosel/OctoPrint/issues/3190) - Plugin Manager: Refresh the repository list on cache timeout, not just on server restart and/or connectivity events.
|
||||||
|
* [#3194](https://github.com/foosel/OctoPrint/issues/3194) & [#3196](https://github.com/foosel/OctoPrint/issues/3196) - Fix typo causing a `KeyError` on starting a second consecutive print of a file (see also [#3195](https://github.com/foosel/OctoPrint/pull/3195)).
|
||||||
|
* [#3217](https://github.com/foosel/OctoPrint/pull/3217) - Docs: Fix typo in chambers documentation
|
||||||
|
* [#3220](https://github.com/foosel/OctoPrint/issues/3220) - Fix `_long_running_command` flag for `M191` on comm layer.
|
||||||
|
* [#3224](https://github.com/foosel/OctoPrint/issues/3224) - Fix file selection not being cleared in the frontend on printer disconnect.
|
||||||
|
* [#3247](https://github.com/foosel/OctoPrint/issues/3247) - Fix scoping issue in JavaScript for custom commands with `javascript`/`enabled` fields.
|
||||||
|
* [#3253](https://github.com/foosel/OctoPrint/issues/3253) - Software Update: Fix error in python version detection (see also [#3256](https://github.com/foosel/OctoPrint/pull/3256)).
|
||||||
|
* [#3257](https://github.com/foosel/OctoPrint/issues/3257) - Appkeys: Ignore empty username on `request` endpoint to avoid later issues.
|
||||||
|
* Fix broken filtering of valid tools
|
||||||
|
* Properly clear out user data from user management dialogs
|
||||||
|
* Appkeys: Fix handling of empty request body, should return `400 Bad Request` instead of `500 Internal Server Error`.
|
||||||
|
* Printer safety: Anycubic 1.1.2 is already safe (off by one error, used to only detect >1.1.2 instead of >=1.1.2)
|
||||||
|
|
||||||
|
### Special thanks to all the contributors!
|
||||||
|
|
||||||
|
Special thanks to everyone who contributed to this release candidate and provided full, analyzable bug reports and pull requests, especially [@aliaksei135](https://github.com/aliaksei135), [@AndyQ](https://github.com/AndyQ), [@dmweis](https://github.com/dmweis), [@esver](https://github.com/esver), [@gdombiak](https://github.com/gdombiak), [@jackwilsdon](https://github.com/jackwilsdon), [@JanneMantyharju](https://github.com/JanneMantyharju), [@kevans91](https://github.com/kevans91), [@pusewicz](https://github.com/pusewicz), [@rfinnie](https://github.com/rfinnie) and [@tduehr](https://github.com/tduehr) for their PRs.
|
||||||
|
|
||||||
|
### More information
|
||||||
|
|
||||||
|
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.11...1.3.12rc1)
|
||||||
|
|
||||||
## 1.3.11 (2019-05-14)
|
## 1.3.11 (2019-05-14)
|
||||||
|
|
||||||
### Heads-up: 1.3.11 unbundles the Cura plugin
|
### Heads-up: 1.3.11 unbundles the Cura plugin
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!**
|
|||||||
You are currently looking at the source code repository of OctoPrint. If you already installed it
|
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
|
(e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only
|
||||||
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
|
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
|
||||||
might be of more interest for you. You might also want to subscribe to join
|
might be of more interest for you. You might also want to subscribe to join
|
||||||
[the community forum at community.octoprint.org](https://community.octoprint.org) where there are other active users who might be
|
[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.
|
able to help you with any questions you might have.
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ able to help you with any questions you might have.
|
|||||||
|
|
||||||
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
|
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
|
||||||
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), debugging help
|
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), debugging help
|
||||||
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
|
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
|
||||||
[the community forum at community.octoprint.org](https://community.octoprint.org)
|
[the community forum at community.octoprint.org](https://community.octoprint.org)
|
||||||
and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
|
and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
|
||||||
|
|
||||||
@@ -65,14 +65,15 @@ you already have Python 2.7, pip and virtualenv set up on your system:
|
|||||||
|
|
||||||
1. Checkout OctoPrint: `git clone https://github.com/foosel/OctoPrint.git`
|
1. Checkout OctoPrint: `git clone https://github.com/foosel/OctoPrint.git`
|
||||||
2. Change into the OctoPrint folder: `cd OctoPrint`
|
2. Change into the OctoPrint folder: `cd OctoPrint`
|
||||||
3. Create a user-owned virtual environment therein: `virtualenv venv`
|
3. Create a user-owned virtual environment therein: `virtualenv venv` if your system default python version is
|
||||||
|
python 2.7, otherwise you need to specify the version explicitly, e.g. `virtualenv --python=python2.7 venv`.
|
||||||
4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .`
|
4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .`
|
||||||
|
|
||||||
You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage)
|
You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage)
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
After installation, please make sure you follow the first-run wizard and set up
|
After installation, please make sure you follow the first-run wizard and set up
|
||||||
access control as necessary.
|
access control as necessary.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -8,8 +8,8 @@ thanks to everyone who contributed!
|
|||||||
|
|
||||||
* Andre Bubel
|
* Andre Bubel
|
||||||
* Andrew Moorby
|
* Andrew Moorby
|
||||||
|
* ANTONIO AUGUSTO DE LIMA PONTES
|
||||||
* Arnljot Arntsen
|
* Arnljot Arntsen
|
||||||
* Bjorn Breckenridge
|
|
||||||
* Boris Hussein
|
* Boris Hussein
|
||||||
* Brad Jackson
|
* Brad Jackson
|
||||||
* Christian Petropolis
|
* Christian Petropolis
|
||||||
@@ -27,7 +27,6 @@ thanks to everyone who contributed!
|
|||||||
* Jeff Renfer
|
* Jeff Renfer
|
||||||
* Jefferson Hunt
|
* Jefferson Hunt
|
||||||
* Jeremiah Avery
|
* Jeremiah Avery
|
||||||
* Joseph Payne
|
|
||||||
* Joshua Wills
|
* Joshua Wills
|
||||||
* Justin Kaufman
|
* Justin Kaufman
|
||||||
* Kaile Riser
|
* Kaile Riser
|
||||||
@@ -41,9 +40,11 @@ thanks to everyone who contributed!
|
|||||||
* Miles Flavel
|
* Miles Flavel
|
||||||
* Mosaic Manufacturing
|
* Mosaic Manufacturing
|
||||||
* OMER MEHMET SUTAS
|
* OMER MEHMET SUTAS
|
||||||
|
* Patrick Glyré
|
||||||
* Patrick McGinnis
|
* Patrick McGinnis
|
||||||
* Prof Yuh Wen Chen
|
* Prof Yuh Wen Chen
|
||||||
* Randy C. Will
|
* Randy C. Will
|
||||||
|
* Ranjib Dey
|
||||||
* Robert Gusek
|
* Robert Gusek
|
||||||
* Samer Najia
|
* Samer Najia
|
||||||
* Shawn Lewis
|
* Shawn Lewis
|
||||||
@@ -53,5 +54,6 @@ thanks to everyone who contributed!
|
|||||||
* TEVO 3D Printers
|
* TEVO 3D Printers
|
||||||
* Trent Shumay
|
* Trent Shumay
|
||||||
* Ulrich Kempken
|
* Ulrich Kempken
|
||||||
|
* Vladislav Kuzemchik
|
||||||
|
|
||||||
and 1544 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
and 1587 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||||
@@ -218,6 +218,17 @@ Progress information
|
|||||||
- 1
|
- 1
|
||||||
- Integer
|
- Integer
|
||||||
- Estimate of time left to print, in seconds
|
- Estimate of time left to print, in seconds
|
||||||
|
* - ``printTimeLeftOrigin``
|
||||||
|
- 1
|
||||||
|
- String
|
||||||
|
- Origin of the current time left estimate. Can currently be either of:
|
||||||
|
|
||||||
|
* ``linear``: based on an linear approximation of the progress in file in bytes vs time
|
||||||
|
* ``analysis``: based on an analysis of the file
|
||||||
|
* ``estimate``: calculated estimate after stabilization of linear estimation
|
||||||
|
* ``average``: based on the average total from past prints of the same model against the same printer profile
|
||||||
|
* ``mixed-analysis``: mixture of ``estimate`` and ``analysis``
|
||||||
|
* ``mixed-average``: mixture of ``estimate`` and ``average``
|
||||||
|
|
||||||
.. _sec-api-datamodel-files:
|
.. _sec-api-datamodel-files:
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ Issue a tool command
|
|||||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
Sets the given target temperature on the printer's tools. Additional parameters:
|
||||||
|
|
||||||
* ``targets``: Target temperature(s) to set, properties must match the format ``tool{n}`` with ``n`` being the
|
* ``targets``: Target temperature(s) to set, properties must match the format ``tool{n}`` with ``n`` being the
|
||||||
tool's index starting with 0.
|
tool's index starting with 0. A value of `0` will turn the heater off.
|
||||||
|
|
||||||
offset
|
offset
|
||||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
Sets the given temperature offset on the printer's tools. Additional parameters:
|
||||||
@@ -630,7 +630,7 @@ Issue a bed command
|
|||||||
target
|
target
|
||||||
Sets the given target temperature on the printer's bed. Additional parameters:
|
Sets the given target temperature on the printer's bed. Additional parameters:
|
||||||
|
|
||||||
* ``target``: Target temperature to set.
|
* ``target``: Target temperature to set. A value of `0` will turn the heater off.
|
||||||
|
|
||||||
offset
|
offset
|
||||||
Sets the given temperature offset on the printer's bed. Additional parameters:
|
Sets the given temperature offset on the printer's bed. Additional parameters:
|
||||||
@@ -770,7 +770,7 @@ Retrieve the current bed state
|
|||||||
Issue a chamber command
|
Issue a chamber command
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
.. http:post:: /api/printer/bed
|
.. http:post:: /api/printer/chamber
|
||||||
|
|
||||||
Chamber commands allow setting the temperature and temperature offsets for the printer's heated chamber. Available commands
|
Chamber commands allow setting the temperature and temperature offsets for the printer's heated chamber. Available commands
|
||||||
are:
|
are:
|
||||||
@@ -778,7 +778,7 @@ Issue a chamber command
|
|||||||
target
|
target
|
||||||
Sets the given target temperature on the printer's chamber. Additional parameters:
|
Sets the given target temperature on the printer's chamber. Additional parameters:
|
||||||
|
|
||||||
* ``target``: Target temperature to set.
|
* ``target``: Target temperature to set. A value of `0` will turn the heater off.
|
||||||
|
|
||||||
offset
|
offset
|
||||||
Sets the given temperature offset on the printer's chamber. Additional parameters:
|
Sets the given temperature offset on the printer's chamber. Additional parameters:
|
||||||
@@ -790,7 +790,7 @@ Issue a chamber command
|
|||||||
|
|
||||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||||
|
|
||||||
If no heated chambed is configured for the currently selected printer profile, the resource will return
|
If no heated chamber is configured for the currently selected printer profile, the resource will return
|
||||||
an :http:statuscode:`409`.
|
an :http:statuscode:`409`.
|
||||||
|
|
||||||
Requires user rights.
|
Requires user rights.
|
||||||
|
|||||||
@@ -425,8 +425,7 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
|||||||
# Lines to send on simulated reset
|
# Lines to send on simulated reset
|
||||||
resetLines:
|
resetLines:
|
||||||
- start
|
- start
|
||||||
- Marlin: Virtual Marlin!
|
- "Marlin: Virtual Marlin!"
|
||||||
- "\x80"
|
|
||||||
- "SD card ok"
|
- "SD card ok"
|
||||||
|
|
||||||
# Initial set of prepared oks to use instead of regular ok (e.g. to simulate
|
# Initial set of prepared oks to use instead of regular ok (e.g. to simulate
|
||||||
|
|||||||
+17
-1
@@ -588,6 +588,7 @@ SlicingStarted
|
|||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
|
* ``slicer``: the used slicer
|
||||||
* ``stl``: the STL's filename
|
* ``stl``: the STL's filename
|
||||||
* ``stl_location``: the STL's location
|
* ``stl_location``: the STL's location
|
||||||
* ``gcode``: the sliced GCODE's filename
|
* ``gcode``: the sliced GCODE's filename
|
||||||
@@ -599,6 +600,7 @@ SlicingDone
|
|||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
|
* ``slicer``: the used slicer
|
||||||
* ``stl``: the STL's filename
|
* ``stl``: the STL's filename
|
||||||
* ``stl_location``: the STL's location
|
* ``stl_location``: the STL's location
|
||||||
* ``gcode``: the sliced GCODE's filename
|
* ``gcode``: the sliced GCODE's filename
|
||||||
@@ -611,6 +613,7 @@ SlicingCancelled
|
|||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
|
* ``slicer``: the used slicer
|
||||||
* ``stl``: the STL's filename
|
* ``stl``: the STL's filename
|
||||||
* ``stl_location``: the STL's location
|
* ``stl_location``: the STL's location
|
||||||
* ``gcode``: the sliced GCODE's filename
|
* ``gcode``: the sliced GCODE's filename
|
||||||
@@ -621,6 +624,7 @@ SlicingFailed
|
|||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
|
* ``slicer``: the used slicer
|
||||||
* ``stl``: the STL's filename
|
* ``stl``: the STL's filename
|
||||||
* ``stl_location``: the STL's location
|
* ``stl_location``: the STL's location
|
||||||
* ``gcode``: the sliced GCODE's filename
|
* ``gcode``: the sliced GCODE's filename
|
||||||
@@ -636,7 +640,7 @@ SlicingProfileAdded
|
|||||||
* ``profile``: the profile that was added
|
* ``profile``: the profile that was added
|
||||||
|
|
||||||
SlicingProfileModified
|
SlicingProfileModified
|
||||||
A new slicing profile was modified.
|
A slicing profile was modified.
|
||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
@@ -661,3 +665,15 @@ SettingsUpdated
|
|||||||
|
|
||||||
This event may also be triggered if calling code of :py:class:`octoprint.settings.Settings.save` or
|
This event may also be triggered if calling code of :py:class:`octoprint.settings.Settings.save` or
|
||||||
:py:class:`octoprint.plugin.PluginSettings.save` sets the ``trigger_event`` parameter to ``True``.
|
:py:class:`octoprint.plugin.PluginSettings.save` sets the ``trigger_event`` parameter to ``True``.
|
||||||
|
|
||||||
|
.. _sec-events-available_events-printer_profile:
|
||||||
|
|
||||||
|
Printer Profile
|
||||||
|
--------
|
||||||
|
|
||||||
|
PrinterProfileModified
|
||||||
|
A printer profile was modified.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``identifier``: the identifier of the modified printer profile
|
||||||
@@ -61,7 +61,8 @@ INSTALL_REQUIRES = [
|
|||||||
"monotonic>=1.5,<1.6",
|
"monotonic>=1.5,<1.6",
|
||||||
"frozendict>=1.2,<1.3",
|
"frozendict>=1.2,<1.3",
|
||||||
"sentry-sdk==0.7.7",
|
"sentry-sdk==0.7.7",
|
||||||
"typing>=3.6.6,<4"
|
"typing>=3.6.6,<4",
|
||||||
|
"filetype>=1.0.5,<2"
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
@@ -81,6 +82,7 @@ EXTRA_REQUIRES = dict(
|
|||||||
"sphinxcontrib-httpdomain",
|
"sphinxcontrib-httpdomain",
|
||||||
"sphinxcontrib-mermaid>=0.3",
|
"sphinxcontrib-mermaid>=0.3",
|
||||||
"sphinx_rtd_theme",
|
"sphinx_rtd_theme",
|
||||||
|
"readthedocs-sphinx-ext==0.5.7"
|
||||||
],
|
],
|
||||||
|
|
||||||
# Dependencies for developing OctoPrint plugins
|
# Dependencies for developing OctoPrint plugins
|
||||||
|
|||||||
@@ -137,9 +137,10 @@ from .dev import dev_commands
|
|||||||
from .client import client_commands
|
from .client import client_commands
|
||||||
from .config import config_commands
|
from .config import config_commands
|
||||||
from .analysis import analysis_commands
|
from .analysis import analysis_commands
|
||||||
|
from .user import user_commands
|
||||||
|
|
||||||
@click.group(name="octoprint", invoke_without_command=True, cls=click.CommandCollection,
|
@click.group(name="octoprint", invoke_without_command=True, cls=click.CommandCollection,
|
||||||
sources=[server_commands, plugin_commands, dev_commands, client_commands, config_commands, analysis_commands])
|
sources=[server_commands, plugin_commands, dev_commands, client_commands, config_commands, analysis_commands, user_commands])
|
||||||
@standard_options()
|
@standard_options()
|
||||||
@legacy_options
|
@legacy_options
|
||||||
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
|
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
|
import click
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from octoprint import init_settings
|
||||||
|
from octoprint.cli import get_ctx_obj_option
|
||||||
|
from octoprint.users import FilebasedUserManager, UnknownUser, UserAlreadyExists
|
||||||
|
from octoprint.util import get_class
|
||||||
|
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
|
|
||||||
|
#~~ "octoprint user" commands
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
def user_commands():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@user_commands.group(name="user")
|
||||||
|
@click.pass_context
|
||||||
|
def user(ctx):
|
||||||
|
"""
|
||||||
|
User management.
|
||||||
|
|
||||||
|
Note that this currently only supports managing user accounts stored in the configured user manager, not any
|
||||||
|
user managers added through plugins and the "octoprint.users.factory" hook.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
logging.basicConfig(level=logging.DEBUG if get_ctx_obj_option(ctx, "verbosity", 0) > 0 else logging.WARN)
|
||||||
|
settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None))
|
||||||
|
|
||||||
|
name = settings.get(["accessControl", "userManager"])
|
||||||
|
try:
|
||||||
|
clazz = get_class(name)
|
||||||
|
manager = clazz(settings=settings)
|
||||||
|
except Exception:
|
||||||
|
click.echo("Could not instantiate user manager {}, falling back to FilebasedUserManager!".format(name), err=True)
|
||||||
|
manager = FilebasedUserManager(settings=settings)
|
||||||
|
finally:
|
||||||
|
manager.enabled = settings.getBoolean(["accessControl", "enabled"])
|
||||||
|
|
||||||
|
ctx.obj.user_manager = manager
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
click.echo("Could not instantiate user manager", err=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@user.command(name="list")
|
||||||
|
@click.pass_context
|
||||||
|
def list_users_command(ctx):
|
||||||
|
"""Lists user information"""
|
||||||
|
users = ctx.obj.user_manager.getAllUsers()
|
||||||
|
_print_list(users)
|
||||||
|
|
||||||
|
|
||||||
|
@user.command(name="add")
|
||||||
|
@click.argument("username", type=click.STRING, required=True)
|
||||||
|
@click.password_option("--password", "password", help="Password for user")
|
||||||
|
@click.option("--admin", "is_admin", type=click.BOOL, is_flag=True, default=False,
|
||||||
|
help="Sets admin role on user")
|
||||||
|
@click.pass_context
|
||||||
|
def add_user_command(ctx, username, password, is_admin):
|
||||||
|
"""Add a new user."""
|
||||||
|
try:
|
||||||
|
ctx.obj.user_manager.addUser(username,
|
||||||
|
password,
|
||||||
|
roles=(("user", "admin") if is_admin else ("user",)),
|
||||||
|
active=True)
|
||||||
|
|
||||||
|
user = ctx.obj.user_manager.findUser(username)
|
||||||
|
if user:
|
||||||
|
click.echo("User created:")
|
||||||
|
click.echo("\t{}".format(_user_to_line(user.asDict())))
|
||||||
|
except UserAlreadyExists:
|
||||||
|
click.echo("A user with the name {} does already exist!".format(username), err=True)
|
||||||
|
|
||||||
|
|
||||||
|
@user.command(name="remove")
|
||||||
|
@click.argument("username", type=click.STRING)
|
||||||
|
@click.pass_context
|
||||||
|
def remove_user_command(ctx, username):
|
||||||
|
"""Remove an existing user."""
|
||||||
|
confirm = click.prompt("This is will irreversibly destroy the user account! Enter 'yes' to confirm",
|
||||||
|
type=click.STRING)
|
||||||
|
|
||||||
|
if confirm.lower() == "yes":
|
||||||
|
ctx.obj.user_manager.removeUser(username)
|
||||||
|
click.echo("User {} removed.".format(username))
|
||||||
|
else:
|
||||||
|
click.echo("User {} not removed.".format(username))
|
||||||
|
|
||||||
|
|
||||||
|
@user.command(name="password")
|
||||||
|
@click.argument("username", type=click.STRING)
|
||||||
|
@click.password_option("--password", "password", help="New password for user")
|
||||||
|
@click.pass_context
|
||||||
|
def change_password_command(ctx, username, password):
|
||||||
|
"""Change an existing user's password."""
|
||||||
|
try:
|
||||||
|
ctx.obj.user_manager.changeUserPassword(username, password)
|
||||||
|
click.echo("Password changed for user {}.".format(username))
|
||||||
|
except UnknownUser:
|
||||||
|
click.echo("User {} does not exist!".format(username), err=True)
|
||||||
|
|
||||||
|
|
||||||
|
@user.command(name="activate")
|
||||||
|
@click.argument("username", type=click.STRING)
|
||||||
|
@click.pass_context
|
||||||
|
def activate_command(ctx, username):
|
||||||
|
"""Activate a user account."""
|
||||||
|
try:
|
||||||
|
ctx.obj.user_manager.changeUserActivation(username, True)
|
||||||
|
click.echo("User {} activated.".format(username))
|
||||||
|
|
||||||
|
user = ctx.obj.user_manager.findUser(username)
|
||||||
|
if user:
|
||||||
|
click.echo("User created:")
|
||||||
|
click.echo("\t{}".format(_user_to_line(user.asDict())))
|
||||||
|
except UnknownUser:
|
||||||
|
click.echo("User {} does not exist!".format(username), err=True)
|
||||||
|
|
||||||
|
|
||||||
|
@user.command(name="deactivate")
|
||||||
|
@click.argument("username", type=click.STRING)
|
||||||
|
@click.pass_context
|
||||||
|
def deactivate_command(ctx, username):
|
||||||
|
"""Activate a user account."""
|
||||||
|
try:
|
||||||
|
ctx.obj.user_manager.changeUserActivation(username, False)
|
||||||
|
click.echo("User {} activated.".format(username))
|
||||||
|
|
||||||
|
user = ctx.obj.user_manager.findUser(username)
|
||||||
|
if user:
|
||||||
|
click.echo("User created:")
|
||||||
|
click.echo("\t{}".format(_user_to_line(user.asDict())))
|
||||||
|
except UnknownUser:
|
||||||
|
click.echo("User {} does not exist!".format(username), err=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _print_list(users):
|
||||||
|
click.echo("{} users registered in the system:".format(len(users)))
|
||||||
|
for user in sorted(users, key=lambda x: x.get("name")):
|
||||||
|
click.echo("\t{}".format(_user_to_line(user)))
|
||||||
|
|
||||||
|
|
||||||
|
def _user_to_line(user):
|
||||||
|
return "{} (active: {}, admin: {})".format(user.get("name"),
|
||||||
|
"yes" if user.get("active", False) else "no",
|
||||||
|
"yes" if user.get("admin", False) else "no")
|
||||||
@@ -17,6 +17,7 @@ from .destinations import FileDestinations
|
|||||||
from .analysis import QueueEntry, AnalysisQueue
|
from .analysis import QueueEntry, AnalysisQueue
|
||||||
from .storage import LocalFileStorage
|
from .storage import LocalFileStorage
|
||||||
from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
|
from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
|
||||||
|
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
@@ -329,16 +330,18 @@ class FileManager(object):
|
|||||||
printer_profile_id, callback, callback_args, _error=None, _cancelled=False, _analysis=None):
|
printer_profile_id, callback, callback_args, _error=None, _cancelled=False, _analysis=None):
|
||||||
try:
|
try:
|
||||||
if _error:
|
if _error:
|
||||||
eventManager().fire(Events.SLICING_FAILED, dict(stl=source_path,
|
eventManager().fire(Events.SLICING_FAILED, dict(slicer=slicer_name,
|
||||||
stl_location=source_location,
|
stl=source_path,
|
||||||
gcode=dest_path,
|
stl_location=source_location,
|
||||||
gcode_location=dest_location,
|
gcode=dest_path,
|
||||||
reason=_error))
|
gcode_location=dest_location,
|
||||||
|
reason=_error))
|
||||||
elif _cancelled:
|
elif _cancelled:
|
||||||
eventManager().fire(Events.SLICING_CANCELLED, dict(stl=source_path,
|
eventManager().fire(Events.SLICING_CANCELLED, dict(slicer=slicer_name,
|
||||||
stl_location=source_location,
|
stl=source_path,
|
||||||
gcode=dest_path,
|
stl_location=source_location,
|
||||||
gcode_location=dest_location))
|
gcode=dest_path,
|
||||||
|
gcode_location=dest_location))
|
||||||
else:
|
else:
|
||||||
source_meta = self.get_metadata(source_location, source_path)
|
source_meta = self.get_metadata(source_location, source_path)
|
||||||
hash = source_meta.get("hash", "n/a")
|
hash = source_meta.get("hash", "n/a")
|
||||||
@@ -356,11 +359,12 @@ class FileManager(object):
|
|||||||
printer_profile=printer_profile, analysis=_analysis)
|
printer_profile=printer_profile, analysis=_analysis)
|
||||||
|
|
||||||
end_time = octoprint.util.monotonic_time()
|
end_time = octoprint.util.monotonic_time()
|
||||||
eventManager().fire(Events.SLICING_DONE, dict(stl=source_path,
|
eventManager().fire(Events.SLICING_DONE, dict(slicer=slicer_name,
|
||||||
stl_location=source_location,
|
stl=source_path,
|
||||||
gcode=dest_path,
|
stl_location=source_location,
|
||||||
gcode_location=dest_location,
|
gcode=dest_path,
|
||||||
time=end_time - start_time))
|
gcode_location=dest_location,
|
||||||
|
time=end_time - start_time))
|
||||||
|
|
||||||
if callback is not None:
|
if callback is not None:
|
||||||
if callback_args is None:
|
if callback_args is None:
|
||||||
@@ -381,7 +385,8 @@ class FileManager(object):
|
|||||||
slicer = self._slicing_manager.get_slicer(slicer_name)
|
slicer = self._slicing_manager.get_slicer(slicer_name)
|
||||||
|
|
||||||
start_time = octoprint.util.monotonic_time()
|
start_time = octoprint.util.monotonic_time()
|
||||||
eventManager().fire(Events.SLICING_STARTED, {"stl": source_path,
|
eventManager().fire(Events.SLICING_STARTED, {"slicer": slicer_name,
|
||||||
|
"stl": source_path,
|
||||||
"stl_location": source_location,
|
"stl_location": source_location,
|
||||||
"gcode": dest_path,
|
"gcode": dest_path,
|
||||||
"gcode_location": dest_location,
|
"gcode_location": dest_location,
|
||||||
@@ -425,7 +430,8 @@ class FileManager(object):
|
|||||||
self._last_slicing_progress = progress_int
|
self._last_slicing_progress = progress_int
|
||||||
for callback in self._slicing_progress_callbacks:
|
for callback in self._slicing_progress_callbacks:
|
||||||
try: callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
try: callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
||||||
except: self._logger.exception("Exception while pushing slicing progress")
|
except: self._logger.exception("Exception while pushing slicing progress",
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
if progress_int:
|
if progress_int:
|
||||||
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
|
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
|
||||||
@@ -654,6 +660,8 @@ class FileManager(object):
|
|||||||
try:
|
try:
|
||||||
with open(self._recovery_file) as f:
|
with open(self._recovery_file) as f:
|
||||||
data = yaml.safe_load(f)
|
data = yaml.safe_load(f)
|
||||||
|
if not isinstance(data, dict) or not all(map(lambda x: x in data, ("origin", "path", "pos", "date"))):
|
||||||
|
raise ValueError("Invalid recovery data structure")
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Could not read recovery data from file {}".format(self._recovery_file))
|
self._logger.exception("Could not read recovery data from file {}".format(self._recovery_file))
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import time
|
|||||||
from octoprint.events import Events, eventManager
|
from octoprint.events import Events, eventManager
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings
|
||||||
from octoprint.util import monotonic_time
|
from octoprint.util import monotonic_time
|
||||||
|
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||||
|
|
||||||
|
|
||||||
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
|
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
|
||||||
@@ -109,7 +110,11 @@ class AnalysisQueue(object):
|
|||||||
|
|
||||||
def _analysis_finished(self, entry, result):
|
def _analysis_finished(self, entry, result):
|
||||||
for callback in self._callbacks:
|
for callback in self._callbacks:
|
||||||
callback(entry, result)
|
try:
|
||||||
|
callback(entry, result)
|
||||||
|
except:
|
||||||
|
self._logger.exception(u"Error while pushing analysis data to callback {}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
eventManager().fire(Events.METADATA_ANALYSIS_FINISHED, {"name": entry.name,
|
eventManager().fire(Events.METADATA_ANALYSIS_FINISHED, {"name": entry.name,
|
||||||
"path": entry.path,
|
"path": entry.path,
|
||||||
"origin": entry.location,
|
"origin": entry.location,
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
|
|||||||
def on_event(self, event, payload):
|
def on_event(self, event, payload):
|
||||||
if event == Events.CONNECTED and self._enable == "always" and self._enable_signal_support:
|
if event == Events.CONNECTED and self._enable == "always" and self._enable_signal_support:
|
||||||
self._printer.commands(["{command} P1".format(command=self._command)])
|
self._printer.commands(["{command} P1".format(command=self._command)])
|
||||||
|
elif event == Events.DISCONNECTED:
|
||||||
|
self._close_prompt()
|
||||||
|
|
||||||
#~ SettingsPlugin
|
#~ SettingsPlugin
|
||||||
|
|
||||||
@@ -213,7 +215,7 @@ __plugin_name__ = "Action Command Prompt Support"
|
|||||||
__plugin_description__ = "Allows your printer to trigger prompts via action commands on the connection"
|
__plugin_description__ = "Allows your printer to trigger prompts via action commands on the connection"
|
||||||
__plugin_author__ = "Gina Häußge"
|
__plugin_author__ = "Gina Häußge"
|
||||||
__plugin_disabling_discouraged__ = gettext("Without this plugin your printer will no longer be able to trigger"
|
__plugin_disabling_discouraged__ = gettext("Without this plugin your printer will no longer be able to trigger"
|
||||||
"confirmation or selection prompts in OctoPrint")
|
" confirmation or selection prompts in OctoPrint")
|
||||||
__plugin_license__ = "AGPLv3"
|
__plugin_license__ = "AGPLv3"
|
||||||
__plugin_implementation__ = ActionCommandPromptPlugin()
|
__plugin_implementation__ = ActionCommandPromptPlugin()
|
||||||
__plugin_hooks__ = {
|
__plugin_hooks__ = {
|
||||||
|
|||||||
@@ -4,7 +4,17 @@ $(function() {
|
|||||||
|
|
||||||
self.loginState = parameters[0];
|
self.loginState = parameters[0];
|
||||||
|
|
||||||
self._modal = undefined;
|
self.modal = ko.observable(undefined);
|
||||||
|
|
||||||
|
self.text = ko.observable();
|
||||||
|
self.buttons = ko.observableArray([]);
|
||||||
|
|
||||||
|
self.active = ko.pureComputed(function() {
|
||||||
|
return self.text() !== undefined;
|
||||||
|
});
|
||||||
|
self.visible = ko.pureComputed(function() {
|
||||||
|
return self.modal() !== undefined;
|
||||||
|
});
|
||||||
|
|
||||||
self.requestData = function() {
|
self.requestData = function() {
|
||||||
if (!self.loginState.isUser()) return;
|
if (!self.loginState.isUser()) return;
|
||||||
@@ -15,26 +25,35 @@ $(function() {
|
|||||||
|
|
||||||
self.fromResponse = function(data) {
|
self.fromResponse = function(data) {
|
||||||
if (data.hasOwnProperty("text") && data.hasOwnProperty("choices")) {
|
if (data.hasOwnProperty("text") && data.hasOwnProperty("choices")) {
|
||||||
self._showPrompt(data.text, data.choices);
|
self.text(data.text);
|
||||||
|
self.buttons(data.choices);
|
||||||
|
self.showPrompt();
|
||||||
|
} else {
|
||||||
|
self.text(undefined);
|
||||||
|
self.buttons([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self._showPrompt = function(text, buttons) {
|
self.showPrompt = function() {
|
||||||
|
var text = self.text();
|
||||||
|
var buttons = self.buttons();
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
title: gettext("Message from your printer"),
|
title: gettext("Message from your printer"),
|
||||||
message: text,
|
message: text,
|
||||||
selections: buttons,
|
selections: buttons,
|
||||||
|
maycancel: true, // see #3171
|
||||||
onselect: function(index) {
|
onselect: function(index) {
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
self._select(index);
|
self._select(index);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onclose: function() {
|
onclose: function() {
|
||||||
self._modal = undefined;
|
self.modal(undefined);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self._modal = showSelectionDialog(opts)
|
self.modal(showSelectionDialog(opts));
|
||||||
};
|
};
|
||||||
|
|
||||||
self._select = function(index) {
|
self._select = function(index) {
|
||||||
@@ -42,8 +61,9 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self._closePrompt = function() {
|
self._closePrompt = function() {
|
||||||
if (self._modal) {
|
var modal = self.modal();
|
||||||
self._modal.modal("hide");
|
if (modal) {
|
||||||
|
modal.modal("hide");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,10 +79,14 @@ $(function() {
|
|||||||
|
|
||||||
switch (data.action) {
|
switch (data.action) {
|
||||||
case "show": {
|
case "show": {
|
||||||
self._showPrompt(data.text, data.choices);
|
self.text(data.text);
|
||||||
|
self.buttons(data.choices);
|
||||||
|
self.showPrompt();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "close": {
|
case "close": {
|
||||||
|
self.text(undefined);
|
||||||
|
self.buttons([]);
|
||||||
self._closePrompt();
|
self._closePrompt();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -73,6 +97,7 @@ $(function() {
|
|||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push({
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
construct: ActionCommandPromptViewModel,
|
construct: ActionCommandPromptViewModel,
|
||||||
dependencies: ["loginStateViewModel"]
|
dependencies: ["loginStateViewModel"],
|
||||||
|
elements: ["#navbar_plugin_action_command_prompt"]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<a id="navbar_show_prompt" class="pull-right" style="display: none" href="javascript:void(0)" data-bind="click: function() { showPrompt(); }, visible: active() && !visible()" title="{{ _('Message from your printer') }}">
|
||||||
|
<i class="fa fa-commenting-o"></i>
|
||||||
|
</a>
|
||||||
@@ -43,6 +43,12 @@ class PendingDecision(object):
|
|||||||
user_id=self.user_id,
|
user_id=self.user_id,
|
||||||
user_token=self.user_token)
|
user_token=self.user_token)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return u"PendingDecision({!r}, {!r}, {!r}, {!r}, timeout_callback=...)".format(self.app_id,
|
||||||
|
self.app_token,
|
||||||
|
self.user_id,
|
||||||
|
self.user_token)
|
||||||
|
|
||||||
|
|
||||||
class ReadyDecision(object):
|
class ReadyDecision(object):
|
||||||
def __init__(self, app_id, app_token, user_id):
|
def __init__(self, app_id, app_token, user_id):
|
||||||
@@ -54,6 +60,11 @@ class ReadyDecision(object):
|
|||||||
def for_pending(cls, pending, user_id):
|
def for_pending(cls, pending, user_id):
|
||||||
return cls(pending.app_id, pending.app_token, user_id)
|
return cls(pending.app_id, pending.app_token, user_id)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return u"ReadyDecision({!r}, {!r}, {!r})".format(self.app_id,
|
||||||
|
self.app_token,
|
||||||
|
self.user_id)
|
||||||
|
|
||||||
|
|
||||||
class ActiveKey(object):
|
class ActiveKey(object):
|
||||||
def __init__(self, app_id, api_key, user_id):
|
def __init__(self, app_id, api_key, user_id):
|
||||||
@@ -74,6 +85,11 @@ class ActiveKey(object):
|
|||||||
def for_internal(cls, internal, user_id):
|
def for_internal(cls, internal, user_id):
|
||||||
return cls(internal["app_id"], internal["api_key"], user_id)
|
return cls(internal["app_id"], internal["api_key"], user_id)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return u"ActiveKey({!r}, {!r}, {!r})".format(self.app_id,
|
||||||
|
self.api_key,
|
||||||
|
self.user_id)
|
||||||
|
|
||||||
|
|
||||||
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
||||||
octoprint.plugin.BlueprintPlugin,
|
octoprint.plugin.BlueprintPlugin,
|
||||||
@@ -121,12 +137,15 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
|||||||
@no_firstrun_access
|
@no_firstrun_access
|
||||||
def handle_request(self):
|
def handle_request(self):
|
||||||
data = flask.request.json
|
data = flask.request.json
|
||||||
|
if data is None:
|
||||||
|
return flask.make_response("Missing key request", 400)
|
||||||
|
|
||||||
if not "app" in data:
|
if not "app" in data:
|
||||||
return flask.make_response("No app name provided", 400)
|
return flask.make_response("No app name provided", 400)
|
||||||
|
|
||||||
app_name = data["app"]
|
app_name = data["app"]
|
||||||
user_id = None
|
user_id = None
|
||||||
if "user" in data:
|
if "user" in data and data["user"]:
|
||||||
user_id = data["user"]
|
user_id = data["user"]
|
||||||
|
|
||||||
app_token, user_token = self._add_pending_decision(app_name, user_id=user_id)
|
app_token, user_token = self._add_pending_decision(app_name, user_id=user_id)
|
||||||
|
|||||||
@@ -619,6 +619,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
try:
|
try:
|
||||||
if exclude is None:
|
if exclude is None:
|
||||||
exclude = []
|
exclude = []
|
||||||
|
if not isinstance(exclude, list):
|
||||||
|
exclude = list(exclude)
|
||||||
|
|
||||||
if "timelapse" in exclude:
|
if "timelapse" in exclude:
|
||||||
exclude.append("timelapse_tmp")
|
exclude.append("timelapse_tmp")
|
||||||
|
|||||||
@@ -197,10 +197,10 @@ $(function() {
|
|||||||
self.loglines.push({line: " ", stream: "message"});
|
self.loglines.push({line: " ", stream: "message"});
|
||||||
self.loglines.push({line: gettext("Restore successful! The server will now be restarted!"), stream: "message"});
|
self.loglines.push({line: gettext("Restore successful! The server will now be restarted!"), stream: "message"});
|
||||||
self.restoreInProgress(false);
|
self.restoreInProgress(false);
|
||||||
} else if (data.type === "install_plugin") {
|
} else if (data.type === "installing_plugin") {
|
||||||
self.loglines.push({line: " ", stream: "message"});
|
self.loglines.push({line: " ", stream: "message"});
|
||||||
self.loglines.push({
|
self.loglines.push({
|
||||||
line: _.sprintf(gettext("Installing plugin \"%(plugin)s}\"..."), {plugin: data.plugin.name}),
|
line: _.sprintf(gettext("Installing plugin \"%(plugin)s\"..."), {plugin: data.plugin}),
|
||||||
stream: "message"
|
stream: "message"
|
||||||
});
|
});
|
||||||
} else if (data.type === "plugin_incompatible") {
|
} else if (data.type === "plugin_incompatible") {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<p>{% trans %}
|
<p>{% trans %}
|
||||||
Finally, please decide on whether to enable or disable the connectivity check. You may change the configuration at
|
Finally, please decide on whether to enable or disable the connectivity check. You may change the configuration at
|
||||||
any time to a later date through Settings > Server right from within OctoPrint.
|
any time through Settings > Server right from within OctoPrint.
|
||||||
{% endtrans %}</p>
|
{% endtrans %}</p>
|
||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ __copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms
|
|||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||||
from octoprint.util.version import get_octoprint_version_string, is_released_octoprint_version
|
from octoprint.util.version import get_octoprint_version_string, is_released_octoprint_version
|
||||||
|
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
from flask_babel import gettext
|
from flask_babel import gettext
|
||||||
|
|
||||||
SENTRY_URL_SERVER = "https://4069187705ab4e76921eb19db2e9ccbb@sentry.io/1373987"
|
SENTRY_URL_SERVER = "https://f13023e873e644b2b0ac8e69eabcdb6c@sentry.io/1373987"
|
||||||
SENTRY_URL_COREUI = "https://a4ab48f27daf4c129392b78be15412b8@sentry.io/1374096"
|
SENTRY_URL_COREUI = "https://fa2cf38446664da6a5a7d03ad9b4485b@sentry.io/1374096"
|
||||||
|
|
||||||
SETTINGS_DEFAULTS = dict(enabled=False,
|
SETTINGS_DEFAULTS = dict(enabled=False,
|
||||||
enabled_unreleased=False,
|
enabled_unreleased=False,
|
||||||
@@ -29,19 +30,24 @@ import tornado.websocket
|
|||||||
|
|
||||||
IGNORED_EXCEPTIONS = [
|
IGNORED_EXCEPTIONS = [
|
||||||
# serial exceptions in octoprint.util.comm
|
# serial exceptions in octoprint.util.comm
|
||||||
(serial.SerialException, lambda exc, logger, plugin: logger == "octoprint.util.comm"),
|
(serial.SerialException, lambda exc, logger, plugin, cb: logger == "octoprint.util.comm"),
|
||||||
|
|
||||||
# isp errors during port auto detection in octoprint.util.comm
|
# isp errors during port auto detection in octoprint.util.comm
|
||||||
(octoprint.util.avr_isp.ispBase.IspError, lambda exc, logger, plugin: logger == "octoprint.util.comm"),
|
(octoprint.util.avr_isp.ispBase.IspError, lambda exc, logger, plugin, cb: logger == "octoprint.util.comm"),
|
||||||
|
|
||||||
# IOErrors of any kind due to a full file system
|
# IOErrors of any kind due to a full file system
|
||||||
(IOError, lambda exc, logger, plugin: getattr(exc, "errno") and exc.errno in (getattr(errno, "ENOSPC"),)),
|
(IOError, lambda exc, logger, plugin, cb: getattr(exc, "errno") and exc.errno in (getattr(errno, "ENOSPC"),)),
|
||||||
|
|
||||||
# RequestExceptions of any kind
|
# RequestExceptions of any kind
|
||||||
requests.exceptions.RequestException,
|
requests.exceptions.RequestException,
|
||||||
|
|
||||||
# Tornado WebSocketErrors of any kind
|
# Tornado WebSocketErrors of any kind
|
||||||
tornado.websocket.WebSocketError
|
tornado.websocket.WebSocketError,
|
||||||
|
|
||||||
|
# Anything triggered by or in third party plugin Astroprint
|
||||||
|
(Exception, lambda exc, logger, plugin, cb: logger.startswith("octoprint.plugins.astroprint")
|
||||||
|
or plugin == "astroprint"
|
||||||
|
or cb.startswith("octoprint_astroprint."))
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -138,6 +144,7 @@ def _enable_errortracking():
|
|||||||
handled = True
|
handled = True
|
||||||
logger = event.get("logger", "")
|
logger = event.get("logger", "")
|
||||||
plugin = event.get("extra", dict()).get("plugin", None)
|
plugin = event.get("extra", dict()).get("plugin", None)
|
||||||
|
callback = event.get("extra", dict()).get("callback", None)
|
||||||
|
|
||||||
for ignore in IGNORED_EXCEPTIONS:
|
for ignore in IGNORED_EXCEPTIONS:
|
||||||
if isinstance(ignore, tuple):
|
if isinstance(ignore, tuple):
|
||||||
@@ -147,8 +154,8 @@ def _enable_errortracking():
|
|||||||
matcher = lambda *args: True
|
matcher = lambda *args: True
|
||||||
|
|
||||||
exc = hint["exc_info"][1]
|
exc = hint["exc_info"][1]
|
||||||
if isinstance(exc, ignored_exc) and matcher(exc, logger, plugin):
|
if isinstance(exc, ignored_exc) and matcher(exc, logger, plugin, callback):
|
||||||
# exception ignored for logger
|
# exception ignored for logger, plugin and/or callback
|
||||||
return None
|
return None
|
||||||
|
|
||||||
elif isinstance(ignore, type):
|
elif isinstance(ignore, type):
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin,
|
|||||||
# not active, no handling
|
# not active, no handling
|
||||||
return
|
return
|
||||||
|
|
||||||
if flask.request.endpoint in ("api.login",):
|
if flask.request.endpoint in ("api.login",) or flask.request.endpoint.endswith(".static"):
|
||||||
return
|
return
|
||||||
|
|
||||||
if plugin is not None and not plugin.is_blueprint_protected():
|
if plugin is not None and not plugin.is_blueprint_protected():
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
<input type="text" id="login-user" class="input-block-level" placeholder="{{ _('Username') }}" autofocus>
|
<input type="text" id="login-user" class="input-block-level" placeholder="{{ _('Username') }}" autofocus>
|
||||||
<input type="password" id="login-password" class="input-block-level" placeholder="{{ _('Password') }}">
|
<input type="password" id="login-password" class="input-block-level" placeholder="{{ _('Password') }}">
|
||||||
|
<span class="pull-right"><small><a href="https://faq.octoprint.org/forgotten-password" id="login-forgotpassword" target="_blank" tabindex="-1">{{ _('Forgot password?') }}</a></small></span>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="login-remember"> {{ _('Remember me') }}
|
<input type="checkbox" id="login-remember"> {{ _('Remember me') }}
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ __plugin_name__ = "Pi Support Plugin"
|
|||||||
__plugin_author__ = "Gina Häußge"
|
__plugin_author__ = "Gina Häußge"
|
||||||
__plugin_description__ = "Provides additional information about your Pi in the UI."
|
__plugin_description__ = "Provides additional information about your Pi in the UI."
|
||||||
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
||||||
"provide additional information about your Pi,"
|
"provide additional information about your Pi, "
|
||||||
"which will make it more tricky to help you if you need support.")
|
"which will make it more tricky to help you if you need support.")
|
||||||
__plugin_license__ = "AGPLv3"
|
__plugin_license__ = "AGPLv3"
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ _DATA_FORMAT_VERSION = "v2"
|
|||||||
|
|
||||||
|
|
||||||
def map_repository_entry(entry):
|
def map_repository_entry(entry):
|
||||||
|
if not isinstance(entry, dict):
|
||||||
|
return None
|
||||||
|
|
||||||
result = copy.deepcopy(entry)
|
result = copy.deepcopy(entry)
|
||||||
|
|
||||||
if not "follow_dependency_links" in result:
|
if not "follow_dependency_links" in result:
|
||||||
@@ -103,20 +106,26 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
self._repository_plugins = []
|
self._repository_plugins = []
|
||||||
self._repository_cache_path = None
|
self._repository_cache_path = None
|
||||||
self._repository_cache_ttl = 0
|
self._repository_cache_ttl = 0
|
||||||
|
self._repository_mtime = None
|
||||||
|
|
||||||
self._notices = dict()
|
self._notices = dict()
|
||||||
self._notices_available = False
|
self._notices_available = False
|
||||||
self._notices_cache_path = None
|
self._notices_cache_path = None
|
||||||
self._notices_cache_ttl = 0
|
self._notices_cache_ttl = 0
|
||||||
|
self._notices_mtime = None
|
||||||
|
|
||||||
self._console_logger = None
|
self._console_logger = None
|
||||||
|
|
||||||
|
self._get_throttled = lambda: False
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self._console_logger = logging.getLogger("octoprint.plugins.pluginmanager.console")
|
self._console_logger = logging.getLogger("octoprint.plugins.pluginmanager.console")
|
||||||
self._repository_cache_path = os.path.join(self.get_plugin_data_folder(), "plugins.json")
|
self._repository_cache_path = os.path.join(self.get_plugin_data_folder(), "plugins.json")
|
||||||
self._repository_cache_ttl = self._settings.get_int(["repository_ttl"]) * 60
|
self._repository_cache_ttl = self._settings.get_int(["repository_ttl"]) * 60
|
||||||
self._notices_cache_path = os.path.join(self.get_plugin_data_folder(), "notices.json")
|
self._notices_cache_path = os.path.join(self.get_plugin_data_folder(), "notices.json")
|
||||||
self._notices_cache_ttl = self._settings.get_int(["notices_ttl"]) * 60
|
self._notices_cache_ttl = self._settings.get_int(["notices_ttl"]) * 60
|
||||||
|
self._confirm_uninstall = self._settings.global_get_boolean(["confirm_uninstall"])
|
||||||
|
self._confirm_disable = self._settings.global_get_boolean(["confirm_disable"])
|
||||||
|
|
||||||
self._pip_caller = LocalPipCaller(force_user=self._settings.get_boolean(["pip_force_user"]))
|
self._pip_caller = LocalPipCaller(force_user=self._settings.get_boolean(["pip_force_user"]))
|
||||||
self._pip_caller.on_log_call = self._log_call
|
self._pip_caller.on_log_call = self._log_call
|
||||||
@@ -141,6 +150,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
self._console_logger.setLevel(logging.DEBUG)
|
self._console_logger.setLevel(logging.DEBUG)
|
||||||
self._console_logger.propagate = False
|
self._console_logger.propagate = False
|
||||||
|
|
||||||
|
helpers = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
||||||
|
if helpers and "get_throttled" in helpers:
|
||||||
|
self._get_throttled = helpers["get_throttled"]
|
||||||
|
|
||||||
# decouple repository fetching from server startup
|
# decouple repository fetching from server startup
|
||||||
self._fetch_all_data(do_async=True)
|
self._fetch_all_data(do_async=True)
|
||||||
|
|
||||||
@@ -154,6 +167,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
notices_ttl=6*60,
|
notices_ttl=6*60,
|
||||||
pip_args=None,
|
pip_args=None,
|
||||||
pip_force_user=False,
|
pip_force_user=False,
|
||||||
|
confirm_uninstall=True,
|
||||||
|
confirm_disable=False,
|
||||||
dependency_links=False,
|
dependency_links=False,
|
||||||
hidden=[]
|
hidden=[]
|
||||||
)
|
)
|
||||||
@@ -164,6 +179,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
self._repository_cache_ttl = self._settings.get_int(["repository_ttl"]) * 60
|
self._repository_cache_ttl = self._settings.get_int(["repository_ttl"]) * 60
|
||||||
self._notices_cache_ttl = self._settings.get_int(["notices_ttl"]) * 60
|
self._notices_cache_ttl = self._settings.get_int(["notices_ttl"]) * 60
|
||||||
self._pip_caller.force_user = self._settings.get_boolean(["pip_force_user"])
|
self._pip_caller.force_user = self._settings.get_boolean(["pip_force_user"])
|
||||||
|
self._confirm_uninstall = self._settings.global_get_boolean(["confirm_uninstall"])
|
||||||
|
self._confirm_disable = self._settings.global_get_boolean(["confirm_disable"])
|
||||||
|
|
||||||
##~~ AssetPlugin
|
##~~ AssetPlugin
|
||||||
|
|
||||||
@@ -260,11 +277,11 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
from octoprint.server import safe_mode
|
from octoprint.server import safe_mode
|
||||||
|
|
||||||
refresh_repository = request.values.get("refresh_repository", "false") in valid_boolean_trues
|
refresh_repository = request.values.get("refresh_repository", "false") in valid_boolean_trues
|
||||||
if refresh_repository:
|
if refresh_repository or not self._is_repository_cache_valid():
|
||||||
self._repository_available = self._refresh_repository()
|
self._repository_available = self._refresh_repository()
|
||||||
|
|
||||||
refresh_notices = request.values.get("refresh_notices", "false") in valid_boolean_trues
|
refresh_notices = request.values.get("refresh_notices", "false") in valid_boolean_trues
|
||||||
if refresh_notices:
|
if refresh_notices or not self._is_notices_cache_valid():
|
||||||
self._notices_available = self._refresh_notices()
|
self._notices_available = self._refresh_notices()
|
||||||
|
|
||||||
def view():
|
def view():
|
||||||
@@ -341,6 +358,12 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
return self.command_toggle(plugin, command)
|
return self.command_toggle(plugin, command)
|
||||||
|
|
||||||
def command_install(self, url=None, path=None, force=False, reinstall=None, dependency_links=False):
|
def command_install(self, url=None, path=None, force=False, reinstall=None, dependency_links=False):
|
||||||
|
throttled = self._get_throttled()
|
||||||
|
if throttled and isinstance(throttled, dict) and throttled.get("current_issue", False):
|
||||||
|
# currently throttled, we refuse to run
|
||||||
|
return make_response("System is currently throttled, refusing to install "
|
||||||
|
"anything due to possible stability issues", 409)
|
||||||
|
|
||||||
if url is not None:
|
if url is not None:
|
||||||
if not any(map(lambda scheme: url.startswith(scheme + "://"), self.URL_SCHEMES)):
|
if not any(map(lambda scheme: url.startswith(scheme + "://"), self.URL_SCHEMES)):
|
||||||
raise ValueError("Invalid URL to pip install from")
|
raise ValueError("Invalid URL to pip install from")
|
||||||
@@ -767,16 +790,23 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
else:
|
else:
|
||||||
run()
|
run()
|
||||||
|
|
||||||
|
def _is_repository_cache_valid(self, mtime=None):
|
||||||
|
import time
|
||||||
|
if mtime is None:
|
||||||
|
mtime = self._repository_mtime
|
||||||
|
return mtime + self._repository_cache_ttl >= time.time() > mtime
|
||||||
|
|
||||||
def _fetch_repository_from_disk(self):
|
def _fetch_repository_from_disk(self):
|
||||||
repo_data = None
|
repo_data = None
|
||||||
if os.path.isfile(self._repository_cache_path):
|
if os.path.isfile(self._repository_cache_path):
|
||||||
import time
|
import time
|
||||||
mtime = os.path.getmtime(self._repository_cache_path)
|
mtime = os.path.getmtime(self._repository_cache_path)
|
||||||
if mtime + self._repository_cache_ttl >= time.time() > mtime:
|
if self._is_repository_cache_valid(mtime=mtime):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
with open(self._repository_cache_path) as f:
|
with open(self._repository_cache_path) as f:
|
||||||
repo_data = json.load(f)
|
repo_data = json.load(f)
|
||||||
|
self._repository_mtime = mtime
|
||||||
self._logger.info("Loaded plugin repository data from disk, was still valid")
|
self._logger.info("Loaded plugin repository data from disk, was still valid")
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Error while loading repository data from {}".format(self._repository_cache_path))
|
self._logger.exception("Error while loading repository data from {}".format(self._repository_cache_path))
|
||||||
@@ -797,12 +827,22 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
self._logger.exception("Could not fetch plugins from repository at {repository_url}: {message}".format(repository_url=repository_url, message=str(e)))
|
self._logger.exception("Could not fetch plugins from repository at {repository_url}: {message}".format(repository_url=repository_url, message=str(e)))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
repo_data = r.json()
|
try:
|
||||||
|
repo_data = r.json()
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.exception("Error while reading repository data")
|
||||||
|
return None
|
||||||
|
|
||||||
|
# validation
|
||||||
|
if not isinstance(repo_data, (list, tuple)):
|
||||||
|
self._logger.warn("Invalid repository data: expected a list, got {!r}".format(repo_data))
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
with octoprint.util.atomic_write(self._repository_cache_path, "wb") as f:
|
with octoprint.util.atomic_write(self._repository_cache_path, "wb") as f:
|
||||||
json.dump(repo_data, f)
|
json.dump(repo_data, f)
|
||||||
|
self._repository_mtime = os.path.getmtime(self._repository_cache_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.exception("Error while saving repository data to {}: {}".format(self._repository_cache_path, str(e)))
|
self._logger.exception("Error while saving repository data to {}: {}".format(self._repository_cache_path, str(e)))
|
||||||
|
|
||||||
@@ -814,19 +854,27 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
if repo_data is None:
|
if repo_data is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self._repository_plugins = map(map_repository_entry, repo_data)
|
self._repository_plugins = filter(lambda x: x is not None,
|
||||||
|
map(map_repository_entry, repo_data))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _is_notices_cache_valid(self, mtime=None):
|
||||||
|
import time
|
||||||
|
if mtime is None:
|
||||||
|
mtime = self._notices_mtime
|
||||||
|
return mtime + self._notices_cache_ttl >= time.time() > mtime
|
||||||
|
|
||||||
def _fetch_notices_from_disk(self):
|
def _fetch_notices_from_disk(self):
|
||||||
notice_data = None
|
notice_data = None
|
||||||
if os.path.isfile(self._notices_cache_path):
|
if os.path.isfile(self._notices_cache_path):
|
||||||
import time
|
import time
|
||||||
mtime = os.path.getmtime(self._notices_cache_path)
|
mtime = os.path.getmtime(self._notices_cache_path)
|
||||||
if mtime + self._notices_cache_ttl >= time.time() > mtime:
|
if self._is_notices_cache_valid(mtime=mtime):
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
with open(self._notices_cache_path) as f:
|
with open(self._notices_cache_path) as f:
|
||||||
notice_data = json.load(f)
|
notice_data = json.load(f)
|
||||||
|
self._notices_mtime = mtime
|
||||||
self._logger.info("Loaded notice data from disk, was still valid")
|
self._logger.info("Loaded notice data from disk, was still valid")
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Error while loading notices from {}".format(self._notices_cache_path))
|
self._logger.exception("Error while loading notices from {}".format(self._notices_cache_path))
|
||||||
@@ -853,6 +901,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
import json
|
import json
|
||||||
with octoprint.util.atomic_write(self._notices_cache_path, "wb") as f:
|
with octoprint.util.atomic_write(self._notices_cache_path, "wb") as f:
|
||||||
json.dump(notice_data, f)
|
json.dump(notice_data, f)
|
||||||
|
self._notices_mtime = os.path.getmtime(self._notices_cache_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.exception("Error while saving notices to {}: {}".format(self._notices_cache_path, str(e)))
|
self._logger.exception("Error while saving notices to {}: {}".format(self._notices_cache_path, str(e)))
|
||||||
return notice_data
|
return notice_data
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;height:500px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#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_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_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_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#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:300px;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_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}
|
#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#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_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_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_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#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:300px;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_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}
|
||||||
@@ -7,12 +7,17 @@ $(function() {
|
|||||||
self.printerState = parameters[2];
|
self.printerState = parameters[2];
|
||||||
self.systemViewModel = parameters[3];
|
self.systemViewModel = parameters[3];
|
||||||
|
|
||||||
|
// optional
|
||||||
|
self.piSupport = parameters[4];
|
||||||
|
|
||||||
self.config_repositoryUrl = ko.observable();
|
self.config_repositoryUrl = ko.observable();
|
||||||
self.config_repositoryTtl = ko.observable();
|
self.config_repositoryTtl = ko.observable();
|
||||||
self.config_noticesUrl = ko.observable();
|
self.config_noticesUrl = ko.observable();
|
||||||
self.config_noticesTtl = ko.observable();
|
self.config_noticesTtl = ko.observable();
|
||||||
self.config_pipAdditionalArgs = ko.observable();
|
self.config_pipAdditionalArgs = ko.observable();
|
||||||
self.config_pipForceUser = ko.observable();
|
self.config_pipForceUser = ko.observable();
|
||||||
|
self.config_confirmUninstall = ko.observable();
|
||||||
|
self.config_confirmDisable = ko.observable();
|
||||||
|
|
||||||
self.configurationDialog = $("#settings_plugin_pluginmanager_configurationdialog");
|
self.configurationDialog = $("#settings_plugin_pluginmanager_configurationdialog");
|
||||||
|
|
||||||
@@ -164,9 +169,13 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.enableRepoInstall = function(data) {
|
self.enableRepoInstall = function(data) {
|
||||||
return self.enableManagement() && self.pipAvailable() && !self.safeMode() && self.online() && self.isCompatible(data);
|
return self.enableManagement() && self.pipAvailable() && !self.safeMode() && !self.throttled() && self.online() && self.isCompatible(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.throttled = ko.pureComputed(function() {
|
||||||
|
return self.piSupport && self.piSupport.currentIssue();
|
||||||
|
});
|
||||||
|
|
||||||
self.invalidUrl = ko.pureComputed(function() {
|
self.invalidUrl = ko.pureComputed(function() {
|
||||||
// supported pip install URL schemes, according to https://pip.pypa.io/en/stable/reference/pip_install/
|
// supported pip install URL schemes, according to https://pip.pypa.io/en/stable/reference/pip_install/
|
||||||
var allowedUrlSchemes = ["http", "https",
|
var allowedUrlSchemes = ["http", "https",
|
||||||
@@ -191,6 +200,7 @@ $(function() {
|
|||||||
return self.enableManagement()
|
return self.enableManagement()
|
||||||
&& self.pipAvailable()
|
&& self.pipAvailable()
|
||||||
&& !self.safeMode()
|
&& !self.safeMode()
|
||||||
|
&& !self.throttled()
|
||||||
&& self.online()
|
&& self.online()
|
||||||
&& url !== undefined
|
&& url !== undefined
|
||||||
&& url.trim() !== ""
|
&& url.trim() !== ""
|
||||||
@@ -216,6 +226,7 @@ $(function() {
|
|||||||
return self.enableManagement()
|
return self.enableManagement()
|
||||||
&& self.pipAvailable()
|
&& self.pipAvailable()
|
||||||
&& !self.safeMode()
|
&& !self.safeMode()
|
||||||
|
&& !self.throttled()
|
||||||
&& name !== undefined
|
&& name !== undefined
|
||||||
&& name.trim() !== ""
|
&& name.trim() !== ""
|
||||||
&& !self.invalidArchive();
|
&& !self.invalidArchive();
|
||||||
@@ -394,12 +405,13 @@ $(function() {
|
|||||||
.done(onSuccess)
|
.done(onSuccess)
|
||||||
.fail(onError);
|
.fail(onError);
|
||||||
} else {
|
} else {
|
||||||
var perform = function() {
|
var performDisabling = function() {
|
||||||
OctoPrint.plugins.pluginmanager.disable(data.key)
|
OctoPrint.plugins.pluginmanager.disable(data.key)
|
||||||
.done(onSuccess)
|
.done(onSuccess)
|
||||||
.fail(onError);
|
.fail(onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// always warn if plugin is marked "disabling discouraged"
|
||||||
if (data.disabling_discouraged) {
|
if (data.disabling_discouraged) {
|
||||||
var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: data.name})
|
var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: data.name})
|
||||||
+ "</p><p>" + data.disabling_discouraged;
|
+ "</p><p>" + data.disabling_discouraged;
|
||||||
@@ -409,10 +421,21 @@ $(function() {
|
|||||||
question: gettext("Do you still want to disable it?"),
|
question: gettext("Do you still want to disable it?"),
|
||||||
cancel: gettext("Keep enabled"),
|
cancel: gettext("Keep enabled"),
|
||||||
proceed: gettext("Disable anyway"),
|
proceed: gettext("Disable anyway"),
|
||||||
onproceed: perform
|
onproceed: performDisabling
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
// warn if global "warn disabling" setting is set"
|
||||||
|
else if (self.settingsViewModel.settings.plugins.pluginmanager.confirm_disable()) {
|
||||||
|
showConfirmationDialog({
|
||||||
|
message: _.sprintf(gettext("You are about to disable \"%(name)s\""), {name: data.name}),
|
||||||
|
cancel: gettext("Keep enabled"),
|
||||||
|
proceed: gettext("Disable plugin"),
|
||||||
|
onproceed: performDisabling,
|
||||||
|
nofade: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
perform();
|
// otherwise just go ahead and disable...
|
||||||
|
performDisabling();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -446,6 +469,10 @@ $(function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.throttled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (url === undefined) {
|
if (url === undefined) {
|
||||||
url = self.installUrl();
|
url = self.installUrl();
|
||||||
}
|
}
|
||||||
@@ -511,23 +538,41 @@ $(function() {
|
|||||||
if (data.bundled) return;
|
if (data.bundled) return;
|
||||||
if (data.key == "pluginmanager") return;
|
if (data.key == "pluginmanager") return;
|
||||||
|
|
||||||
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name}));
|
// defining actual uninstall logic as functor in order to handle
|
||||||
|
// the confirm/no-confirm logic without duplication of logic
|
||||||
|
var performUninstall = function() {
|
||||||
|
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name}));
|
||||||
|
|
||||||
OctoPrint.plugins.pluginmanager.uninstall(data.key)
|
OctoPrint.plugins.pluginmanager.uninstall(data.key)
|
||||||
.done(function() {
|
.done(function() {
|
||||||
self.requestData();
|
self.requestData();
|
||||||
})
|
})
|
||||||
.fail(function() {
|
.fail(function() {
|
||||||
new PNotify({
|
new PNotify({
|
||||||
title: gettext("Something went wrong"),
|
title: gettext("Something went wrong"),
|
||||||
text: gettext("Please consult octoprint.log for details"),
|
text: gettext("Please consult octoprint.log for details"),
|
||||||
type: "error",
|
type: "error",
|
||||||
hide: false
|
hide: false
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.always(function() {
|
||||||
|
self._markDone();
|
||||||
});
|
});
|
||||||
})
|
};
|
||||||
.always(function() {
|
|
||||||
self._markDone();
|
if (self.settingsViewModel.settings.plugins.pluginmanager.confirm_uninstall()) {
|
||||||
|
// confirmation needed. Show confirmation dialog and call performUninstall if user clicks Yes
|
||||||
|
showConfirmationDialog({
|
||||||
|
message: _.sprintf(gettext("You are about to uninstall the plugin \"%(name)s\""), {name: data.name}),
|
||||||
|
cancel: gettext("Keep installed"),
|
||||||
|
proceed: gettext("Uninstall"),
|
||||||
|
onproceed: performUninstall,
|
||||||
|
nofade: true
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// no confirmation needed, just go ahead and uninstall
|
||||||
|
performUninstall();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.refreshRepository = function() {
|
self.refreshRepository = function() {
|
||||||
@@ -596,7 +641,9 @@ $(function() {
|
|||||||
notices: notices,
|
notices: notices,
|
||||||
notices_ttl: noticesTtl,
|
notices_ttl: noticesTtl,
|
||||||
pip_args: pipArgs,
|
pip_args: pipArgs,
|
||||||
pip_force_user: self.config_pipForceUser()
|
pip_force_user: self.config_pipForceUser(),
|
||||||
|
confirm_uninstall: self.config_confirmUninstall(),
|
||||||
|
confirm_disable: self.config_confirmDisable(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -614,6 +661,8 @@ $(function() {
|
|||||||
self.config_noticesTtl(self.settingsViewModel.settings.plugins.pluginmanager.notices_ttl());
|
self.config_noticesTtl(self.settingsViewModel.settings.plugins.pluginmanager.notices_ttl());
|
||||||
self.config_pipAdditionalArgs(self.settingsViewModel.settings.plugins.pluginmanager.pip_args());
|
self.config_pipAdditionalArgs(self.settingsViewModel.settings.plugins.pluginmanager.pip_args());
|
||||||
self.config_pipForceUser(self.settingsViewModel.settings.plugins.pluginmanager.pip_force_user());
|
self.config_pipForceUser(self.settingsViewModel.settings.plugins.pluginmanager.pip_force_user());
|
||||||
|
self.config_confirmUninstall(self.settingsViewModel.settings.plugins.pluginmanager.confirm_uninstall());
|
||||||
|
self.config_confirmDisable(self.settingsViewModel.settings.plugins.pluginmanager.confirm_disable());
|
||||||
};
|
};
|
||||||
|
|
||||||
self.installed = function(data) {
|
self.installed = function(data) {
|
||||||
@@ -1083,7 +1132,8 @@ $(function() {
|
|||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push({
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
construct: PluginManagerViewModel,
|
construct: PluginManagerViewModel,
|
||||||
dependencies: ["loginStateViewModel", "settingsViewModel", "printerStateViewModel", "systemViewModel"],
|
dependencies: ["loginStateViewModel", "settingsViewModel", "printerStateViewModel", "systemViewModel", "piSupportViewModel"],
|
||||||
|
optional: ["piSupportViewModel"],
|
||||||
elements: ["#settings_plugin_pluginmanager"]
|
elements: ["#settings_plugin_pluginmanager"]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#settings_plugin_pluginmanager_pluginlist {
|
#settings_plugin_pluginmanager_pluginlist {
|
||||||
display: block;
|
display: block;
|
||||||
width: auto;
|
width: auto;
|
||||||
height: 500px;
|
height: 400px;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
|
|||||||
@@ -20,6 +20,13 @@
|
|||||||
{% endtrans %}</div>
|
{% endtrans %}</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro pluginmanager_throttled() %}
|
||||||
|
<div class="alert" data-bind="visible: throttled">{% trans %}
|
||||||
|
The system OctoPrint is running on is currently throttled. Due to that it's not possible to install new
|
||||||
|
plugins in order to avoid possible issues caused by system instability.
|
||||||
|
{% endtrans %}</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro pluginmanager_offline() %}
|
{% macro pluginmanager_offline() %}
|
||||||
<div class="alert" data-bind="visible: !online()">{% trans %}
|
<div class="alert" data-bind="visible: !online()">{% trans %}
|
||||||
It looks like OctoPrint has currently no connection to the internet. Due to that it's not possible
|
It looks like OctoPrint has currently no connection to the internet. Due to that it's not possible
|
||||||
@@ -30,6 +37,7 @@
|
|||||||
{{ pluginmanager_printing() }}
|
{{ pluginmanager_printing() }}
|
||||||
{{ pluginmanager_nopip() }}
|
{{ pluginmanager_nopip() }}
|
||||||
{{ pluginmanager_safemode() }}
|
{{ pluginmanager_safemode() }}
|
||||||
|
{{ pluginmanager_throttled() }}
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
||||||
@@ -122,6 +130,7 @@
|
|||||||
{{ pluginmanager_printing() }}
|
{{ pluginmanager_printing() }}
|
||||||
{{ pluginmanager_nopip() }}
|
{{ pluginmanager_nopip() }}
|
||||||
{{ pluginmanager_safemode() }}
|
{{ pluginmanager_safemode() }}
|
||||||
|
{{ pluginmanager_throttled() }}
|
||||||
{{ pluginmanager_offline() }}
|
{{ pluginmanager_offline() }}
|
||||||
<h4 style="position: relative">
|
<h4 style="position: relative">
|
||||||
{{ _('... from the <a href="%(url)s" target="_blank">Plugin Repository</a>', url='https://plugins.octoprint.org') }}
|
{{ _('... from the <a href="%(url)s" target="_blank">Plugin Repository</a>', url='https://plugins.octoprint.org') }}
|
||||||
@@ -234,6 +243,25 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ _('Confirmations') }}</legend>
|
||||||
|
|
||||||
|
<div class="control-group" title="{{ _('Confirm before uninstalling a plugin') }}">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: config_confirmUninstall"> {{ _('Confirm before uninstalling a plugin') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group" title="{{ _('Confirm before disabling a plugin') }}">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: config_confirmDisable"> {{ _('Confirm before disabling a plugin') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<p>{% trans %}You should normally <strong>not</strong> have to change <strong>any</strong> of the following settings, they are purely provided for convenience here.{% endtrans %}</p>
|
<p>{% trans %}You should normally <strong>not</strong> have to change <strong>any</strong> of the following settings, they are purely provided for convenience here.{% endtrans %}</p>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ __plugin_author__ = "Gina Häußge"
|
|||||||
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/printer_safety_check.html"
|
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/printer_safety_check.html"
|
||||||
__plugin_description__ = "Checks for unsafe printers/printer firmwares"
|
__plugin_description__ = "Checks for unsafe printers/printer firmwares"
|
||||||
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
||||||
"check if the printer it is connected to has a known safety"
|
"check if the printer it is connected to has a known safety "
|
||||||
"issue and inform you about that fact.")
|
"issue and inform you about that fact.")
|
||||||
__plugin_license__ = "AGPLv3"
|
__plugin_license__ = "AGPLv3"
|
||||||
__plugin_implementation__ = PrinterSafetyCheckPlugin()
|
__plugin_implementation__ = PrinterSafetyCheckPlugin()
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class AnycubicCheck(Check):
|
|||||||
def _broken_version(self, line):
|
def _broken_version(self, line):
|
||||||
version_str = line[len(self.VERSION):]
|
version_str = line[len(self.VERSION):]
|
||||||
version = get_comparable_version(version_str, base=True)
|
version = get_comparable_version(version_str, base=True)
|
||||||
if version is not None and version <= self.FIXED_VERSION:
|
if version is not None and version < self.FIXED_VERSION:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -32,9 +32,10 @@ from octoprint.util.pip import LocalPipCaller
|
|||||||
import octoprint.settings
|
import octoprint.settings
|
||||||
|
|
||||||
|
|
||||||
|
# OctoPi 0.15+
|
||||||
MINIMUM_PYTHON = "2.7.9"
|
MINIMUM_PYTHON = "2.7.9"
|
||||||
MINIMUM_SETUPTOOLS = "5.5.1"
|
MINIMUM_SETUPTOOLS = "39.0.1"
|
||||||
MINIMUM_PIP = "9.0.1"
|
MINIMUM_PIP = "10.0.1"
|
||||||
|
|
||||||
|
|
||||||
##~~ Plugin
|
##~~ Plugin
|
||||||
@@ -75,6 +76,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
|
|
||||||
self._console_logger = None
|
self._console_logger = None
|
||||||
|
|
||||||
|
self._get_throttled = lambda: False
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self._console_logger = logging.getLogger("octoprint.plugins.softwareupdate.console")
|
self._console_logger = logging.getLogger("octoprint.plugins.softwareupdate.console")
|
||||||
|
|
||||||
@@ -98,6 +101,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
self._console_logger.setLevel(logging.DEBUG)
|
self._console_logger.setLevel(logging.DEBUG)
|
||||||
self._console_logger.propagate = False
|
self._console_logger.propagate = False
|
||||||
|
|
||||||
|
helpers = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
||||||
|
if helpers and "get_throttled" in helpers:
|
||||||
|
self._get_throttled = helpers["get_throttled"]
|
||||||
|
|
||||||
def on_after_startup(self):
|
def on_after_startup(self):
|
||||||
self._check_environment()
|
self._check_environment()
|
||||||
self.get_current_versions()
|
self.get_current_versions()
|
||||||
@@ -567,6 +574,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
@restricted_access
|
@restricted_access
|
||||||
@admin_permission.require(403)
|
@admin_permission.require(403)
|
||||||
def perform_update(self):
|
def perform_update(self):
|
||||||
|
throttled = self._get_throttled()
|
||||||
|
if throttled and isinstance(throttled, dict) and throttled.get("current_issue", False):
|
||||||
|
# currently throttled, we refuse to run
|
||||||
|
return flask.make_response("System is currently throttled, refusing to update "
|
||||||
|
"anything due to possible stability issues", 409)
|
||||||
|
|
||||||
if self._printer.is_printing() or self._printer.is_paused():
|
if self._printer.is_printing() or self._printer.is_paused():
|
||||||
# do not update while a print job is running
|
# do not update while a print job is running
|
||||||
return flask.make_response("Printer is currently printing or paused", 409)
|
return flask.make_response("Printer is currently printing or paused", 409)
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ $(function() {
|
|||||||
self.loginState = parameters[0];
|
self.loginState = parameters[0];
|
||||||
self.printerState = parameters[1];
|
self.printerState = parameters[1];
|
||||||
self.settings = parameters[2];
|
self.settings = parameters[2];
|
||||||
|
|
||||||
|
// optional
|
||||||
|
|
||||||
|
self.piSupport = parameters[3]; // might be null!
|
||||||
|
|
||||||
self.popup = undefined;
|
self.popup = undefined;
|
||||||
|
|
||||||
self.updateInProgress = false;
|
self.updateInProgress = false;
|
||||||
@@ -51,7 +56,7 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.enableUpdate = ko.pureComputed(function() {
|
self.enableUpdate = ko.pureComputed(function() {
|
||||||
return !self.updateInProgress && self.environmentSupported();
|
return !self.updateInProgress && self.environmentSupported() && !self.printerState.isPrinting() && !self.throttled();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.enable_configSave = ko.pureComputed(function() {
|
self.enable_configSave = ko.pureComputed(function() {
|
||||||
@@ -91,6 +96,10 @@ $(function() {
|
|||||||
return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible; });
|
return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible; });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.throttled = ko.pureComputed(function() {
|
||||||
|
return self.piSupport && self.piSupport.currentIssue();
|
||||||
|
});
|
||||||
|
|
||||||
self.onUserLoggedIn = function() {
|
self.onUserLoggedIn = function() {
|
||||||
self.performCheck();
|
self.performCheck();
|
||||||
};
|
};
|
||||||
@@ -484,36 +493,46 @@ $(function() {
|
|||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
self._updateClicked = false;
|
self._updateClicked = false;
|
||||||
} else {
|
return;
|
||||||
var html = "<p>" + gettext("This will update the following components and restart the server:") + "</p>";
|
|
||||||
html += "<ul>";
|
|
||||||
_.each(items, function(item) {
|
|
||||||
html += "<li>"
|
|
||||||
+ "<span class=\"name\" title=\"" + item.fullNameRemote + "\">" + item.fullNameRemote + "</span>";
|
|
||||||
if (item.releaseNotes) {
|
|
||||||
html += "<br><a href=\"" + item.releaseNotes + "\" target=\"_blank\" rel=\"noreferrer noopener\">" + gettext("Release Notes") + "</a>"
|
|
||||||
}
|
|
||||||
html += "</li>";
|
|
||||||
});
|
|
||||||
html += "</ul>";
|
|
||||||
html += "<p>" + gettext("Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know <strong>before</strong> upgrading.") + "</p>"
|
|
||||||
+ "<p><strong>" + gettext("This action may disrupt any ongoing print jobs.") + "</strong></p>"
|
|
||||||
+ "<p>" + gettext("Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset.") + "</p>"
|
|
||||||
+ "<p>" + gettext("Are you sure you want to proceed?") + "</p>";
|
|
||||||
showConfirmationDialog({
|
|
||||||
title: gettext("Are you sure you want to update now?"),
|
|
||||||
html: html,
|
|
||||||
proceed: gettext("Proceed"),
|
|
||||||
onproceed: function() {
|
|
||||||
self.performUpdate((force === true),
|
|
||||||
_.map(items, function(info) { return info.key }));
|
|
||||||
},
|
|
||||||
onclose: function() {
|
|
||||||
self._updateClicked = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.piSupport && self.piSupport.currentIssue()) {
|
||||||
|
self._showPopup({
|
||||||
|
title: gettext("Can't update while throttled"),
|
||||||
|
text: gettext("Your system is currently throttled. OctoPrint refuses to run updates while in this state due to possible stability issues."),
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
self._updateClicked = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = "<p>" + gettext("This will update the following components and restart the server:") + "</p>";
|
||||||
|
html += "<ul>";
|
||||||
|
_.each(items, function(item) {
|
||||||
|
html += "<li>"
|
||||||
|
+ "<span class=\"name\" title=\"" + item.fullNameRemote + "\">" + item.fullNameRemote + "</span>";
|
||||||
|
if (item.releaseNotes) {
|
||||||
|
html += "<br><a href=\"" + item.releaseNotes + "\" target=\"_blank\" rel=\"noreferrer noopener\">" + gettext("Release Notes") + "</a>"
|
||||||
|
}
|
||||||
|
html += "</li>";
|
||||||
|
});
|
||||||
|
html += "</ul>";
|
||||||
|
html += "<p>" + gettext("Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know <strong>before</strong> upgrading.") + "</p>"
|
||||||
|
+ "<p><strong>" + gettext("This action may disrupt any ongoing print jobs.") + "</strong></p>"
|
||||||
|
+ "<p>" + gettext("Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset.") + "</p>"
|
||||||
|
+ "<p>" + gettext("Are you sure you want to proceed?") + "</p>";
|
||||||
|
showConfirmationDialog({
|
||||||
|
title: gettext("Are you sure you want to update now?"),
|
||||||
|
html: html,
|
||||||
|
proceed: gettext("Proceed"),
|
||||||
|
onproceed: function() {
|
||||||
|
self.performUpdate((force === true),
|
||||||
|
_.map(items, function(info) { return info.key }));
|
||||||
|
},
|
||||||
|
onclose: function() {
|
||||||
|
self._updateClicked = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self._showWorkingDialog = function(title) {
|
self._showWorkingDialog = function(title) {
|
||||||
@@ -795,7 +814,8 @@ $(function() {
|
|||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push({
|
OCTOPRINT_VIEWMODELS.push({
|
||||||
construct: SoftwareUpdateViewModel,
|
construct: SoftwareUpdateViewModel,
|
||||||
dependencies: ["loginStateViewModel", "printerStateViewModel", "settingsViewModel"],
|
dependencies: ["loginStateViewModel", "printerStateViewModel", "settingsViewModel", "piSupportViewModel"],
|
||||||
|
optional: ["piSupportViewModel"],
|
||||||
elements: ["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"]
|
elements: ["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -32,6 +32,26 @@
|
|||||||
Please take a look at <a href="https://faq.octoprint.org/unsupported-python-environment" target="_blank">this FAQ entry on how to proceed</a>.
|
Please take a look at <a href="https://faq.octoprint.org/unsupported-python-environment" target="_blank">this FAQ entry on how to proceed</a>.
|
||||||
</p>
|
</p>
|
||||||
{% endtrans %}</div>
|
{% endtrans %}</div>
|
||||||
|
<div class="alert" data-bind="visible: throttled()">{% trans %}
|
||||||
|
<p>
|
||||||
|
<strong>OctoPrint is running on a throttled system, updates are disabled.</strong>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To reduce the likelihood of running into update problems on throttled and hence potentially unstable systems
|
||||||
|
as seen in the past, OctoPrint doesn't support updating under such conditions. Please fix the current issue
|
||||||
|
before trying to update. Take a look at the displayed warning in the navigation bar to learn about what is
|
||||||
|
wrong and to get hints on how to solve the problem.
|
||||||
|
</p>
|
||||||
|
{% endtrans %}</div>
|
||||||
|
<div class="alert" data-bind="visible: printerState.isPrinting()">{% trans %}
|
||||||
|
<p>
|
||||||
|
<strong>OctoPrint is currently printing, updates are disabled.</strong>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Running updates is not supported while printing in order to not risk any kind of disruption to the print job.
|
||||||
|
Please let the print finish before trying to update.
|
||||||
|
</p>
|
||||||
|
{% endtrans %}</div>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
||||||
@@ -47,7 +67,7 @@
|
|||||||
<span data-bind="invisible: !updateAvailable"><i class="fa fa-bell-o" title="{{ _('Update available') }}"></i></span>
|
<span data-bind="invisible: !updateAvailable"><i class="fa fa-bell-o" title="{{ _('Update available') }}"></i></span>
|
||||||
</td>
|
</td>
|
||||||
<td class="settings_plugin_softwareupdate_column_information">
|
<td class="settings_plugin_softwareupdate_column_information">
|
||||||
<a href="javascript:void(0)" data-bind="click: function() { $root.update(false, [$data]) }, visible: updateAvailable && updatePossible" class="btn btn-primary pull-right">{{ _('Update') }}</a>
|
<a href="javascript:void(0)" data-bind="click: function() { $root.update(false, [$data]) }, visible: $root.enableUpdate() && updateAvailable && updatePossible" class="btn btn-primary pull-right">{{ _('Update') }}</a>
|
||||||
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="fa fa-exclamation-triangle" data-bind="css: {'fa-unlink': !online && information && information.needs_online, 'fa-exclamation-triangle': !(!online && information && information.needs_online)}, attr: {title: $root.iconTitleForEntry($data)}"></i></span><br>
|
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="fa fa-exclamation-triangle" data-bind="css: {'fa-unlink': !online && information && information.needs_online, 'fa-exclamation-triangle': !(!online && information && information.needs_online)}, attr: {title: $root.iconTitleForEntry($data)}"></i></span><br>
|
||||||
<small class="muted">
|
<small class="muted">
|
||||||
<span class="line">{{ _('Installed:') }} <span data-bind="text: information.local.name"></span></span>
|
<span class="line">{{ _('Installed:') }} <span data-bind="text: information.local.name"></span></span>
|
||||||
@@ -69,7 +89,7 @@
|
|||||||
<div class="hide">
|
<div class="hide">
|
||||||
<small class="muted" style="display: block">{{ _('Last cache refresh:') }} <span data-bind="text: cacheTimestampText"></span></small>
|
<small class="muted" style="display: block">{{ _('Last cache refresh:') }} <span data-bind="text: cacheTimestampText"></span></small>
|
||||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
||||||
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.update(true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update now (even if no new versions are available)') }}</button>
|
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.update(true); }, enable: enableUpdate() && !checking(), css: {disabled: !enableUpdate() || checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update now (even if no new versions are available)') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
self._printer_connection_parameters = None
|
self._printer_connection_parameters = None
|
||||||
self._url = None
|
self._url = None
|
||||||
self._ping_worker = None
|
self._ping_worker = None
|
||||||
|
self._pong_worker = None
|
||||||
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
|
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
|
||||||
|
|
||||||
self._record_next_firmware_info = False
|
self._record_next_firmware_info = False
|
||||||
@@ -60,14 +61,17 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
unique_id=None,
|
unique_id=None,
|
||||||
server=TRACKING_URL,
|
server=TRACKING_URL,
|
||||||
ping=15*60,
|
ping=15*60,
|
||||||
events=dict(startup=True,
|
pong=24*60*60,
|
||||||
|
events=dict(pong=True,
|
||||||
|
startup=True,
|
||||||
printjob=True,
|
printjob=True,
|
||||||
commerror=True,
|
commerror=True,
|
||||||
plugin=True,
|
plugin=True,
|
||||||
update=True,
|
update=True,
|
||||||
printer=True,
|
printer=True,
|
||||||
printer_safety_check=True,
|
printer_safety_check=True,
|
||||||
throttled=True))
|
throttled=True,
|
||||||
|
slicing=True))
|
||||||
|
|
||||||
def get_settings_restricted_paths(self):
|
def get_settings_restricted_paths(self):
|
||||||
return dict(admin=[["enabled"], ["unique_id"], ["events"]],
|
return dict(admin=[["enabled"], ["unique_id"], ["events"]],
|
||||||
@@ -121,6 +125,9 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
self._record_next_firmware_info = False
|
self._record_next_firmware_info = False
|
||||||
self._track_printer_event(event, payload)
|
self._track_printer_event(event, payload)
|
||||||
|
|
||||||
|
elif event in (Events.SLICING_STARTED,):
|
||||||
|
self._track_slicing_event(event, payload)
|
||||||
|
|
||||||
elif hasattr(Events, "PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN") and \
|
elif hasattr(Events, "PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN") and \
|
||||||
event in (Events.PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN, Events.PLUGIN_PLUGINMANAGER_UNINSTALL_PLUGIN,
|
event in (Events.PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN, Events.PLUGIN_PLUGINMANAGER_UNINSTALL_PLUGIN,
|
||||||
Events.PLUGIN_PLUGINMANAGER_ENABLE_PLUGIN, Events.PLUGIN_PLUGINMANAGER_DISABLE_PLUGIN):
|
Events.PLUGIN_PLUGINMANAGER_ENABLE_PLUGIN, Events.PLUGIN_PLUGINMANAGER_DISABLE_PLUGIN):
|
||||||
@@ -168,11 +175,17 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
return
|
return
|
||||||
|
|
||||||
if self._ping_worker is None:
|
if self._ping_worker is None:
|
||||||
ping = self._settings.get_int(["ping"])
|
ping_interval = self._settings.get_int(["ping"])
|
||||||
if ping:
|
if ping_interval:
|
||||||
self._ping_worker = RepeatedTimer(ping, self._track_ping, run_first=True)
|
self._ping_worker = RepeatedTimer(ping_interval, self._track_ping, run_first=True)
|
||||||
self._ping_worker.start()
|
self._ping_worker.start()
|
||||||
|
|
||||||
|
if self._pong_worker is None:
|
||||||
|
pong_interval = self._settings.get(["pong"])
|
||||||
|
if pong_interval:
|
||||||
|
self._pong_worker = RepeatedTimer(pong_interval, self._track_pong, run_first=True)
|
||||||
|
self._pong_worker.start()
|
||||||
|
|
||||||
if self._helpers_get_throttle_state is None:
|
if self._helpers_get_throttle_state is None:
|
||||||
# cautiously look for the get_throttled helper from pi_support
|
# cautiously look for the get_throttled helper from pi_support
|
||||||
pi_helper = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
pi_helper = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
||||||
@@ -189,6 +202,18 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
uptime = int(monotonic_time() - self._startup_time)
|
uptime = int(monotonic_time() - self._startup_time)
|
||||||
self._track("ping", octoprint_uptime=uptime)
|
self._track("ping", octoprint_uptime=uptime)
|
||||||
|
|
||||||
|
def _track_pong(self):
|
||||||
|
if not self._settings.get_boolean(["events", "pong"]):
|
||||||
|
return
|
||||||
|
|
||||||
|
plugins = self._plugin_manager.enabled_plugins
|
||||||
|
plugins_thirdparty = [plugin for plugin in plugins.values() if not plugin.bundled]
|
||||||
|
payload = dict(plugins=",".join(map(lambda x: "{}:{}".format(x.key.lower(),
|
||||||
|
x.version.lower() if x.version else "?"),
|
||||||
|
plugins_thirdparty)))
|
||||||
|
|
||||||
|
self._track("pong", body=True, **payload)
|
||||||
|
|
||||||
def _track_startup(self):
|
def _track_startup(self):
|
||||||
if not self._settings.get_boolean(["events", "startup"]):
|
if not self._settings.get_boolean(["events", "startup"]):
|
||||||
return
|
return
|
||||||
@@ -305,7 +330,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
elapsed = int(payload.get(b"time", 0))
|
elapsed = int(payload.get(b"time", 0))
|
||||||
if elapsed:
|
if elapsed:
|
||||||
args[b"elapsed"] = elapsed
|
args[b"elapsed"] = elapsed
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
track_event = "print_done"
|
track_event = "print_done"
|
||||||
elif event == Events.PRINT_FAILED:
|
elif event == Events.PRINT_FAILED:
|
||||||
@@ -313,7 +338,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
elapsed = int(payload.get(b"time", 0))
|
elapsed = int(payload.get(b"time", 0))
|
||||||
if elapsed:
|
if elapsed:
|
||||||
args[b"elapsed"] = elapsed
|
args[b"elapsed"] = elapsed
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
args[b"reason"] = payload.get(b"reason", "unknown")
|
args[b"reason"] = payload.get(b"reason", "unknown")
|
||||||
|
|
||||||
@@ -326,7 +351,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
elapsed = int(payload.get(b"time", 0))
|
elapsed = int(payload.get(b"time", 0))
|
||||||
if elapsed:
|
if elapsed:
|
||||||
args[b"elapsed"] = elapsed
|
args[b"elapsed"] = elapsed
|
||||||
except ValueError:
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
track_event = "print_cancelled"
|
track_event = "print_cancelled"
|
||||||
|
|
||||||
@@ -363,13 +388,20 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
printer_safety_warning_type=payload.get(b"warning_type", "unknown"),
|
printer_safety_warning_type=payload.get(b"warning_type", "unknown"),
|
||||||
printer_safety_check_name=payload.get(b"check_name", "unknown"))
|
printer_safety_check_name=payload.get(b"check_name", "unknown"))
|
||||||
|
|
||||||
|
def _track_slicing_event(self, event, payload):
|
||||||
|
if not self._settings.get_boolean(["events", "slicing"]):
|
||||||
|
return
|
||||||
|
|
||||||
|
self._track("slicing_started",
|
||||||
|
slicer=payload.get(b"slicer", "unknown"))
|
||||||
|
|
||||||
def _track(self, event, **kwargs):
|
def _track(self, event, **kwargs):
|
||||||
if not self._settings.get_boolean([b"enabled"]):
|
if not self._settings.get_boolean([b"enabled"]):
|
||||||
return
|
return
|
||||||
|
|
||||||
self._executor.submit(self._do_track, event, **kwargs)
|
self._executor.submit(self._do_track, event, **kwargs)
|
||||||
|
|
||||||
def _do_track(self, event, **kwargs):
|
def _do_track(self, event, body=False, **kwargs):
|
||||||
if not self._connectivity_checker.online:
|
if not self._connectivity_checker.online:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -389,10 +421,17 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
|||||||
try:
|
try:
|
||||||
params = urlencode(kwargs, doseq=True).replace("+", "%20")
|
params = urlencode(kwargs, doseq=True).replace("+", "%20")
|
||||||
|
|
||||||
requests.get(url,
|
if body:
|
||||||
params=params,
|
requests.post(url,
|
||||||
timeout=3.1,
|
data=params,
|
||||||
headers=headers)
|
timeout=3.1,
|
||||||
|
headers=headers)
|
||||||
|
else:
|
||||||
|
requests.get(url,
|
||||||
|
params=params,
|
||||||
|
timeout=3.1,
|
||||||
|
headers=headers)
|
||||||
|
|
||||||
self._logger.info("Sent tracking event {}, payload: {!r}".format(event, kwargs))
|
self._logger.info("Sent tracking event {}, payload: {!r}".format(event, kwargs))
|
||||||
except:
|
except:
|
||||||
if self._logger.isEnabledFor(logging.DEBUG):
|
if self._logger.isEnabledFor(logging.DEBUG):
|
||||||
|
|||||||
@@ -20,7 +20,10 @@
|
|||||||
<label class="control-label" title="{{ _('Events to track. The ping is mandatory.') }}">{{ _('Tracked events') }}</label>
|
<label class="control-label" title="{{ _('Events to track. The ping is mandatory.') }}">{{ _('Tracked events') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" checked="checked" disabled="disabled"> {{ _('Regular ping') }}
|
<input type="checkbox" checked="checked" disabled="disabled"> {{ _('Regular ping every 15min (incl. uptime)') }}
|
||||||
|
</label>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.pong"> {{ _('Regular pong every 24h (incl. plugin list)') }}
|
||||||
</label>
|
</label>
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.startup"> {{ _('Server startup & shutdown') }}
|
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.startup"> {{ _('Server startup & shutdown') }}
|
||||||
@@ -46,6 +49,9 @@
|
|||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.throttled"> {{ _('System got throttled/unthrottled (currently only detected on RPis)') }}
|
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.throttled"> {{ _('System got throttled/unthrottled (currently only detected on RPis)') }}
|
||||||
</label>
|
</label>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.slicing"> {{ _('Onboard slicing actions') }}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class VirtualPrinter(object):
|
|||||||
self._temperature_reporter = None
|
self._temperature_reporter = None
|
||||||
self._sdstatus_reporter = None
|
self._sdstatus_reporter = None
|
||||||
|
|
||||||
self.currentLine = 0
|
self.current_line = 0
|
||||||
self.lastN = 0
|
self.lastN = 0
|
||||||
|
|
||||||
self._incoming_lock = threading.RLock()
|
self._incoming_lock = threading.RLock()
|
||||||
@@ -146,6 +146,7 @@ class VirtualPrinter(object):
|
|||||||
self._debug_sleep = None
|
self._debug_sleep = None
|
||||||
self._sleepAfterNext = dict()
|
self._sleepAfterNext = dict()
|
||||||
self._sleepAfter = dict()
|
self._sleepAfter = dict()
|
||||||
|
self._rerequest_last = False
|
||||||
|
|
||||||
self._dont_answer = False
|
self._dont_answer = False
|
||||||
|
|
||||||
@@ -204,7 +205,7 @@ class VirtualPrinter(object):
|
|||||||
|
|
||||||
self._heatingUp = False
|
self._heatingUp = False
|
||||||
|
|
||||||
self.currentLine = 0
|
self.current_line = 0
|
||||||
self.lastN = 0
|
self.lastN = 0
|
||||||
|
|
||||||
self._debug_awol = False
|
self._debug_awol = False
|
||||||
@@ -311,10 +312,10 @@ class VirtualPrinter(object):
|
|||||||
checksum = int(data[data.rfind("*") + 1:])
|
checksum = int(data[data.rfind("*") + 1:])
|
||||||
data = data[:data.rfind("*")]
|
data = data[:data.rfind("*")]
|
||||||
if not checksum == self._calculate_checksum(data):
|
if not checksum == self._calculate_checksum(data):
|
||||||
self._triggerResend(expected=self.currentLine + 1)
|
self._triggerResend(expected=self.current_line + 1)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.currentLine += 1
|
self.current_line += 1
|
||||||
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
|
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
|
||||||
self._send(self._error("checksum_missing"))
|
self._send(self._error("checksum_missing"))
|
||||||
continue
|
continue
|
||||||
@@ -323,7 +324,7 @@ class VirtualPrinter(object):
|
|||||||
if data.startswith("N") and "M110" in data:
|
if data.startswith("N") and "M110" in data:
|
||||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||||
self.lastN = linenumber
|
self.lastN = linenumber
|
||||||
self.currentLine = linenumber
|
self.current_line = linenumber
|
||||||
|
|
||||||
self._triggerResendAt100 = True
|
self._triggerResendAt100 = True
|
||||||
self._triggerResendWithTimeoutAt105 = True
|
self._triggerResendWithTimeoutAt105 = True
|
||||||
@@ -364,6 +365,9 @@ class VirtualPrinter(object):
|
|||||||
elif isinstance(prepared, basestring):
|
elif isinstance(prepared, basestring):
|
||||||
self._send(prepared)
|
self._send(prepared)
|
||||||
continue
|
continue
|
||||||
|
elif self._rerequest_last:
|
||||||
|
self._triggerResend(actual=linenumber)
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
self.lastN = linenumber
|
self.lastN = linenumber
|
||||||
data = data.split(None, 1)[1].strip()
|
data = data.split(None, 1)[1].strip()
|
||||||
@@ -753,6 +757,8 @@ class VirtualPrinter(object):
|
|||||||
prepare_ok <broken ok>
|
prepare_ok <broken ok>
|
||||||
| Will cause <broken ok> to be enqueued for use,
|
| Will cause <broken ok> to be enqueued for use,
|
||||||
| will be used instead of actual "ok"
|
| will be used instead of actual "ok"
|
||||||
|
rerequest_last
|
||||||
|
| Will cause the last line number + 1 to be rerequest add infinitum
|
||||||
|
|
||||||
# Reply Timing / Sleeping
|
# Reply Timing / Sleeping
|
||||||
|
|
||||||
@@ -814,6 +820,9 @@ class VirtualPrinter(object):
|
|||||||
elif data == "go_awol":
|
elif data == "go_awol":
|
||||||
self._send("// Going AWOL")
|
self._send("// Going AWOL")
|
||||||
self._debug_awol = True
|
self._debug_awol = True
|
||||||
|
elif data == "rerequest_last":
|
||||||
|
self._send("// Entering rerequest loop")
|
||||||
|
self._rerequest_last = True
|
||||||
elif data == "cancel_sd":
|
elif data == "cancel_sd":
|
||||||
if self._sdPrinting and self._sdPrinter:
|
if self._sdPrinting and self._sdPrinter:
|
||||||
self._pauseSdPrint()
|
self._pauseSdPrint()
|
||||||
|
|||||||
@@ -319,14 +319,21 @@ class PrinterProfileManager(object):
|
|||||||
except InvalidProfileError:
|
except InvalidProfileError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def remove(self, identifier):
|
def remove(self, identifier, trigger_event=False):
|
||||||
if self._current is not None and self._current["id"] == identifier:
|
if self._current is not None and self._current["id"] == identifier:
|
||||||
return False
|
return False
|
||||||
elif settings().get(["printerProfiles", "default"]) == identifier:
|
elif settings().get(["printerProfiles", "default"]) == identifier:
|
||||||
return False
|
return False
|
||||||
return self._remove_from_path(self._get_profile_path(identifier))
|
|
||||||
|
|
||||||
def save(self, profile, allow_overwrite=False, make_default=False):
|
removed = self._remove_from_path(self._get_profile_path(identifier))
|
||||||
|
if removed and trigger_event:
|
||||||
|
from octoprint.events import eventManager, Events
|
||||||
|
payload = dict(identifier=identifier)
|
||||||
|
eventManager().fire(Events.PRINTER_PROFILE_DELETED, payload=payload)
|
||||||
|
|
||||||
|
return removed
|
||||||
|
|
||||||
|
def save(self, profile, allow_overwrite=False, make_default=False, trigger_event=False):
|
||||||
if "id" in profile:
|
if "id" in profile:
|
||||||
identifier = profile["id"]
|
identifier = profile["id"]
|
||||||
elif "name" in profile:
|
elif "name" in profile:
|
||||||
@@ -341,7 +348,10 @@ class PrinterProfileManager(object):
|
|||||||
profile = dict_sanitize(profile, self.__class__.default)
|
profile = dict_sanitize(profile, self.__class__.default)
|
||||||
profile = dict_merge(self.__class__.default, profile)
|
profile = dict_merge(self.__class__.default, profile)
|
||||||
|
|
||||||
self._save_to_path(self._get_profile_path(identifier), profile, allow_overwrite=allow_overwrite)
|
path = self._get_profile_path(identifier)
|
||||||
|
is_overwrite = os.path.exists(path)
|
||||||
|
|
||||||
|
self._save_to_path(path, profile, allow_overwrite=allow_overwrite)
|
||||||
|
|
||||||
if make_default:
|
if make_default:
|
||||||
settings().set(["printerProfiles", "default"], identifier)
|
settings().set(["printerProfiles", "default"], identifier)
|
||||||
@@ -349,6 +359,13 @@ class PrinterProfileManager(object):
|
|||||||
|
|
||||||
if self._current is not None and self._current["id"] == identifier:
|
if self._current is not None and self._current["id"] == identifier:
|
||||||
self.select(identifier)
|
self.select(identifier)
|
||||||
|
|
||||||
|
from octoprint.events import eventManager, Events
|
||||||
|
if trigger_event:
|
||||||
|
payload = dict(identifier=identifier)
|
||||||
|
event = Events.PRINTER_PROFILE_MODIFIED if is_overwrite else Events.PRINTER_PROFILE_ADDED
|
||||||
|
eventManager().fire(event, payload=payload)
|
||||||
|
|
||||||
return self.get(identifier)
|
return self.get(identifier)
|
||||||
|
|
||||||
def is_default_unmodified(self):
|
def is_default_unmodified(self):
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from octoprint.util import comm as comm
|
|||||||
from octoprint.util import InvariantContainer
|
from octoprint.util import InvariantContainer
|
||||||
from octoprint.util import to_unicode
|
from octoprint.util import to_unicode
|
||||||
from octoprint.util import monotonic_time
|
from octoprint.util import monotonic_time
|
||||||
|
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||||
|
|
||||||
|
|
||||||
class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||||
@@ -174,28 +175,32 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||||||
try:
|
try:
|
||||||
callback.on_printer_add_temperature(data)
|
callback.on_printer_add_temperature(data)
|
||||||
except:
|
except:
|
||||||
self._logger.exception(u"Exception while adding temperature data point to callback {}".format(callback))
|
self._logger.exception(u"Exception while adding temperature data point to callback {}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
def _sendAddLogCallbacks(self, data):
|
def _sendAddLogCallbacks(self, data):
|
||||||
for callback in self._callbacks:
|
for callback in self._callbacks:
|
||||||
try:
|
try:
|
||||||
callback.on_printer_add_log(data)
|
callback.on_printer_add_log(data)
|
||||||
except:
|
except:
|
||||||
self._logger.exception(u"Exception while adding communication log entry to callback {}".format(callback))
|
self._logger.exception(u"Exception while adding communication log entry to callback {}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
def _sendAddMessageCallbacks(self, data):
|
def _sendAddMessageCallbacks(self, data):
|
||||||
for callback in self._callbacks:
|
for callback in self._callbacks:
|
||||||
try:
|
try:
|
||||||
callback.on_printer_add_message(data)
|
callback.on_printer_add_message(data)
|
||||||
except:
|
except:
|
||||||
self._logger.exception(u"Exception while adding printer message to callback {}".format(callback))
|
self._logger.exception(u"Exception while adding printer message to callback {}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
def _sendCurrentDataCallbacks(self, data):
|
def _sendCurrentDataCallbacks(self, data):
|
||||||
for callback in self._callbacks:
|
for callback in self._callbacks:
|
||||||
try:
|
try:
|
||||||
callback.on_printer_send_current_data(copy.deepcopy(data))
|
callback.on_printer_send_current_data(copy.deepcopy(data))
|
||||||
except:
|
except:
|
||||||
self._logger.exception(u"Exception while pushing current data to callback {}".format(callback))
|
self._logger.exception(u"Exception while pushing current data to callback {}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
#~~ callback from metadata analysis event
|
#~~ callback from metadata analysis event
|
||||||
|
|
||||||
@@ -483,14 +488,18 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||||||
path_on_disk = self._fileManager.path_on_disk(origin, path)
|
path_on_disk = self._fileManager.path_on_disk(origin, path)
|
||||||
path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk)
|
path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk)
|
||||||
|
|
||||||
recovery_data = self._fileManager.get_recovery_data()
|
try:
|
||||||
if recovery_data:
|
recovery_data = self._fileManager.get_recovery_data()
|
||||||
# clean up recovery data if we just selected a different file than is logged in that
|
if recovery_data:
|
||||||
actual_origin = recovery_data.get("origin", None)
|
# clean up recovery data if we just selected a different file
|
||||||
actual_path = recovery_data.get("path", None)
|
actual_origin = recovery_data.get("origin", None)
|
||||||
|
actual_path = recovery_data.get("path", None)
|
||||||
|
|
||||||
if actual_origin is None or actual_path is None or actual_origin != origin or actual_path != path_in_storage:
|
if actual_origin is None or actual_path is None or actual_origin != origin or actual_path != path_in_storage:
|
||||||
self._fileManager.delete_recovery_data()
|
self._fileManager.delete_recovery_data()
|
||||||
|
except Exception:
|
||||||
|
# anything goes wrong with the recovery data, we ignore it
|
||||||
|
self._logger.exception("Something was wrong with processing the recovery data")
|
||||||
|
|
||||||
self._printAfterSelect = printAfterSelect
|
self._printAfterSelect = printAfterSelect
|
||||||
self._posAfterSelect = pos
|
self._posAfterSelect = pos
|
||||||
@@ -1002,7 +1011,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||||||
self._stateMonitor.set_job_data(self._dict(file=job_data["file"],
|
self._stateMonitor.set_job_data(self._dict(file=job_data["file"],
|
||||||
estimatedPrintTime=job_data["estimatedPrintTime"],
|
estimatedPrintTime=job_data["estimatedPrintTime"],
|
||||||
averagePrintTime=job_data["averagePrintTime"],
|
averagePrintTime=job_data["averagePrintTime"],
|
||||||
lastPrintTIme=job_data["lastPrintTime"],
|
lastPrintTime=job_data["lastPrintTime"],
|
||||||
filament=job_data["filament"],
|
filament=job_data["filament"],
|
||||||
user=user))
|
user=user))
|
||||||
|
|
||||||
@@ -1016,7 +1025,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||||||
})
|
})
|
||||||
callback.on_printer_send_initial_data(data)
|
callback.on_printer_send_initial_data(data)
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Error while trying to send initial state update")
|
self._logger.exception(u"Error while pushing initial state update to callback {}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
def _getStateFlags(self):
|
def _getStateFlags(self):
|
||||||
return self._dict(operational=self.is_operational(),
|
return self._dict(operational=self.is_operational(),
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ class Server(object):
|
|||||||
except:
|
except:
|
||||||
self._logger.exception("Error while trying to migrate settings for "
|
self._logger.exception("Error while trying to migrate settings for "
|
||||||
"plugin {}, ignoring it".format(implementation._identifier),
|
"plugin {}, ignoring it".format(implementation._identifier),
|
||||||
extra=dict(plugin=plugin._identifier))
|
extra=dict(plugin=implementation._identifier))
|
||||||
|
|
||||||
pluginManager.implementation_post_inits=[settings_plugin_config_migration_and_cleanup]
|
pluginManager.implementation_post_inits=[settings_plugin_config_migration_and_cleanup]
|
||||||
|
|
||||||
|
|||||||
@@ -464,7 +464,17 @@ def _test_url(data):
|
|||||||
response_result = dict(headers=dict(response.headers),
|
response_result = dict(headers=dict(response.headers),
|
||||||
content_type=content_type)
|
content_type=content_type)
|
||||||
|
|
||||||
|
if not content_type and data.get("content_type_guess") in valid_boolean_trues:
|
||||||
|
content = response.content
|
||||||
|
content_type = util.guess_mime_type(bytearray(content))
|
||||||
|
|
||||||
|
if not content_type:
|
||||||
|
content_type = "application/octet-stream"
|
||||||
|
|
||||||
|
response_result = dict(assumed_content_type=content_type)
|
||||||
|
|
||||||
parsed_content_type = util.parse_mime_type(content_type)
|
parsed_content_type = util.parse_mime_type(content_type)
|
||||||
|
|
||||||
in_whitelist = content_type_whitelist is None or any(
|
in_whitelist = content_type_whitelist is None or any(
|
||||||
map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_whitelist))
|
map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_whitelist))
|
||||||
in_blacklist = content_type_blacklist is not None and any(
|
in_blacklist = content_type_blacklist is not None and any(
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ def printerProfilesAdd():
|
|||||||
return make_response("Profile does not contain mandatory 'name' field", 400)
|
return make_response("Profile does not contain mandatory 'name' field", 400)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
saved_profile = printerProfileManager.save(profile, allow_overwrite=False, make_default=make_default)
|
saved_profile = printerProfileManager.save(profile, allow_overwrite=False, make_default=make_default,
|
||||||
|
trigger_event=True)
|
||||||
except InvalidProfileError:
|
except InvalidProfileError:
|
||||||
return make_response("Profile is invalid", 400)
|
return make_response("Profile is invalid", 400)
|
||||||
except CouldNotOverwriteError:
|
except CouldNotOverwriteError:
|
||||||
@@ -114,7 +115,7 @@ def printerProfilesDelete(identifier):
|
|||||||
if default_profile and default_profile["id"] == identifier:
|
if default_profile and default_profile["id"] == identifier:
|
||||||
return make_response("Cannot delete default profile: {}".format(identifier), 409)
|
return make_response("Cannot delete default profile: {}".format(identifier), 409)
|
||||||
|
|
||||||
printerProfileManager.remove(identifier)
|
printerProfileManager.remove(identifier, trigger_event=True)
|
||||||
return NO_CONTENT
|
return NO_CONTENT
|
||||||
|
|
||||||
@api.route("/printerprofiles/<string:identifier>", methods=["PATCH"])
|
@api.route("/printerprofiles/<string:identifier>", methods=["PATCH"])
|
||||||
@@ -146,7 +147,8 @@ def printerProfilesUpdate(identifier):
|
|||||||
merged_profile["id"] = identifier
|
merged_profile["id"] = identifier
|
||||||
|
|
||||||
try:
|
try:
|
||||||
saved_profile = printerProfileManager.save(merged_profile, allow_overwrite=True, make_default=make_default)
|
saved_profile = printerProfileManager.save(merged_profile, allow_overwrite=True, make_default=make_default,
|
||||||
|
trigger_event=True)
|
||||||
except InvalidProfileError:
|
except InvalidProfileError:
|
||||||
return make_response("Profile is invalid", 400)
|
return make_response("Profile is invalid", 400)
|
||||||
except CouldNotOverwriteError:
|
except CouldNotOverwriteError:
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ def getSettings():
|
|||||||
"colorIcon": s.getBoolean(["appearance", "colorIcon"]),
|
"colorIcon": s.getBoolean(["appearance", "colorIcon"]),
|
||||||
"defaultLanguage": s.get(["appearance", "defaultLanguage"]),
|
"defaultLanguage": s.get(["appearance", "defaultLanguage"]),
|
||||||
"showFahrenheitAlso": s.getBoolean(["appearance", "showFahrenheitAlso"]),
|
"showFahrenheitAlso": s.getBoolean(["appearance", "showFahrenheitAlso"]),
|
||||||
"fuzzyTimes": s.getBoolean(["appearance", "fuzzyTimes"])
|
"fuzzyTimes": s.getBoolean(["appearance", "fuzzyTimes"]),
|
||||||
|
"closeModalsWithClick": s.getBoolean(["appearance", "closeModalsWithClick"])
|
||||||
},
|
},
|
||||||
"printer": {
|
"printer": {
|
||||||
"defaultExtrusionLength": s.getInt(["printerParameters", "defaultExtrusionLength"])
|
"defaultExtrusionLength": s.getInt(["printerParameters", "defaultExtrusionLength"])
|
||||||
@@ -123,6 +124,7 @@ def getSettings():
|
|||||||
"keyboardControl": s.getBoolean(["feature", "keyboardControl"]),
|
"keyboardControl": s.getBoolean(["feature", "keyboardControl"]),
|
||||||
"pollWatched": s.getBoolean(["feature", "pollWatched"]),
|
"pollWatched": s.getBoolean(["feature", "pollWatched"]),
|
||||||
"modelSizeDetection": s.getBoolean(["feature", "modelSizeDetection"]),
|
"modelSizeDetection": s.getBoolean(["feature", "modelSizeDetection"]),
|
||||||
|
"printStartConfirmation": s.getBoolean(["feature", "printStartConfirmation"]),
|
||||||
"printCancelConfirmation": s.getBoolean(["feature", "printCancelConfirmation"]),
|
"printCancelConfirmation": s.getBoolean(["feature", "printCancelConfirmation"]),
|
||||||
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
|
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
|
||||||
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"])
|
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"])
|
||||||
@@ -172,6 +174,8 @@ def getSettings():
|
|||||||
"ignoreIdenticalResends": s.getBoolean(["serial", "ignoreIdenticalResends"]),
|
"ignoreIdenticalResends": s.getBoolean(["serial", "ignoreIdenticalResends"]),
|
||||||
"firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]),
|
"firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]),
|
||||||
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
||||||
|
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
|
||||||
|
"sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]),
|
||||||
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
|
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
|
||||||
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
||||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
||||||
@@ -383,6 +387,7 @@ def _saveSettings(data):
|
|||||||
if "defaultLanguage" in data["appearance"]: s.set(["appearance", "defaultLanguage"], data["appearance"]["defaultLanguage"])
|
if "defaultLanguage" in data["appearance"]: s.set(["appearance", "defaultLanguage"], data["appearance"]["defaultLanguage"])
|
||||||
if "showFahrenheitAlso" in data["appearance"]: s.setBoolean(["appearance", "showFahrenheitAlso"], data["appearance"]["showFahrenheitAlso"])
|
if "showFahrenheitAlso" in data["appearance"]: s.setBoolean(["appearance", "showFahrenheitAlso"], data["appearance"]["showFahrenheitAlso"])
|
||||||
if "fuzzyTimes" in data["appearance"]: s.setBoolean(["appearance", "fuzzyTimes"], data["appearance"]["fuzzyTimes"])
|
if "fuzzyTimes" in data["appearance"]: s.setBoolean(["appearance", "fuzzyTimes"], data["appearance"]["fuzzyTimes"])
|
||||||
|
if "closeModalsWithClick" in data["appearance"]: s.setBoolean(["appearance", "closeModalsWithClick"], data["appearance"]["closeModalsWithClick"])
|
||||||
|
|
||||||
if "printer" in data.keys():
|
if "printer" in data.keys():
|
||||||
if "defaultExtrusionLength" in data["printer"]: s.setInt(["printerParameters", "defaultExtrusionLength"], data["printer"]["defaultExtrusionLength"])
|
if "defaultExtrusionLength" in data["printer"]: s.setInt(["printerParameters", "defaultExtrusionLength"], data["printer"]["defaultExtrusionLength"])
|
||||||
@@ -413,6 +418,7 @@ def _saveSettings(data):
|
|||||||
if "keyboardControl" in data["feature"]: s.setBoolean(["feature", "keyboardControl"], data["feature"]["keyboardControl"])
|
if "keyboardControl" in data["feature"]: s.setBoolean(["feature", "keyboardControl"], data["feature"]["keyboardControl"])
|
||||||
if "pollWatched" in data["feature"]: s.setBoolean(["feature", "pollWatched"], data["feature"]["pollWatched"])
|
if "pollWatched" in data["feature"]: s.setBoolean(["feature", "pollWatched"], data["feature"]["pollWatched"])
|
||||||
if "modelSizeDetection" in data["feature"]: s.setBoolean(["feature", "modelSizeDetection"], data["feature"]["modelSizeDetection"])
|
if "modelSizeDetection" in data["feature"]: s.setBoolean(["feature", "modelSizeDetection"], data["feature"]["modelSizeDetection"])
|
||||||
|
if "printStartConfirmation" in data["feature"]: s.setBoolean(["feature", "printStartConfirmation"], data["feature"]["printStartConfirmation"])
|
||||||
if "printCancelConfirmation" in data["feature"]: s.setBoolean(["feature", "printCancelConfirmation"], data["feature"]["printCancelConfirmation"])
|
if "printCancelConfirmation" in data["feature"]: s.setBoolean(["feature", "printCancelConfirmation"], data["feature"]["printCancelConfirmation"])
|
||||||
if "g90InfluencesExtruder" in data["feature"]: s.setBoolean(["feature", "g90InfluencesExtruder"], data["feature"]["g90InfluencesExtruder"])
|
if "g90InfluencesExtruder" in data["feature"]: s.setBoolean(["feature", "g90InfluencesExtruder"], data["feature"]["g90InfluencesExtruder"])
|
||||||
if "autoUppercaseBlacklist" in data["feature"] and isinstance(data["feature"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["feature", "autoUppercaseBlacklist"], data["feature"]["autoUppercaseBlacklist"])
|
if "autoUppercaseBlacklist" in data["feature"] and isinstance(data["feature"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["feature", "autoUppercaseBlacklist"], data["feature"]["autoUppercaseBlacklist"])
|
||||||
@@ -459,6 +465,11 @@ def _saveSettings(data):
|
|||||||
if "ignoreIdenticalResends" in data["serial"]: s.setBoolean(["serial", "ignoreIdenticalResends"], data["serial"]["ignoreIdenticalResends"])
|
if "ignoreIdenticalResends" in data["serial"]: s.setBoolean(["serial", "ignoreIdenticalResends"], data["serial"]["ignoreIdenticalResends"])
|
||||||
if "firmwareDetection" in data["serial"]: s.setBoolean(["serial", "firmwareDetection"], data["serial"]["firmwareDetection"])
|
if "firmwareDetection" in data["serial"]: s.setBoolean(["serial", "firmwareDetection"], data["serial"]["firmwareDetection"])
|
||||||
if "blockWhileDwelling" in data["serial"]: s.setBoolean(["serial", "blockWhileDwelling"], data["serial"]["blockWhileDwelling"])
|
if "blockWhileDwelling" in data["serial"]: s.setBoolean(["serial", "blockWhileDwelling"], data["serial"]["blockWhileDwelling"])
|
||||||
|
if "useParityWorkaround" in data["serial"]:
|
||||||
|
value = data["serial"]["useParityWorkaround"]
|
||||||
|
if value in ("always", "detect", "never"):
|
||||||
|
s.set(["serial", "useParityWorkaround"], value)
|
||||||
|
if "sendM112OnError" in data["serial"]: s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"])
|
||||||
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
|
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
|
||||||
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
|
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
|
||||||
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
|
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
|
||||||
|
|||||||
@@ -1143,19 +1143,49 @@ def check_lastmodified(lastmodified):
|
|||||||
|
|
||||||
|
|
||||||
def add_revalidation_response_headers(response):
|
def add_revalidation_response_headers(response):
|
||||||
response.headers["Cache-Control"] = "no-cache, must-revalidate"
|
import werkzeug.http
|
||||||
|
|
||||||
|
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
|
||||||
|
if "no-cache" not in cache_control:
|
||||||
|
cache_control["no-cache"] = None
|
||||||
|
if "must-revalidate" not in cache_control:
|
||||||
|
cache_control["must-revalidate"] = None
|
||||||
|
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def add_non_caching_response_headers(response):
|
def add_non_caching_response_headers(response):
|
||||||
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0"
|
import werkzeug.http
|
||||||
|
|
||||||
|
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
|
||||||
|
if "no-store" not in cache_control:
|
||||||
|
cache_control["no-store"] = None
|
||||||
|
if "no-cache" not in cache_control:
|
||||||
|
cache_control["no-cache"] = None
|
||||||
|
if "must-revalidate" not in cache_control:
|
||||||
|
cache_control["must-revalidate"] = None
|
||||||
|
if "post-check" not in cache_control or cache_control["post-check"] != "0":
|
||||||
|
cache_control["post-check"] = "0"
|
||||||
|
if "pre-check" not in cache_control or cache_control["pre-check"] != "0":
|
||||||
|
cache_control["pre-check"] = "0"
|
||||||
|
if "max-age" not in cache_control or cache_control["max-age"] != "0":
|
||||||
|
cache_control["max-age"] = "0"
|
||||||
|
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
|
||||||
|
|
||||||
response.headers["Pragma"] = "no-cache"
|
response.headers["Pragma"] = "no-cache"
|
||||||
response.headers["Expires"] = "-1"
|
response.headers["Expires"] = "-1"
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def add_no_max_age_response_headers(response):
|
def add_no_max_age_response_headers(response):
|
||||||
response.headers["Cache-Control"] = "max-age=0"
|
import werkzeug.http
|
||||||
|
|
||||||
|
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
|
||||||
|
if "max-age" not in cache_control or cache_control["max-age"] != "0":
|
||||||
|
cache_control["max-age"] = "0"
|
||||||
|
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -200,9 +200,10 @@ def index():
|
|||||||
|
|
||||||
default_additional_etag = [enable_accesscontrol,
|
default_additional_etag = [enable_accesscontrol,
|
||||||
enable_gcodeviewer,
|
enable_gcodeviewer,
|
||||||
enable_timelapse] + sorted(["{}:{}".format(to_bytes(k, errors="replace"),
|
enable_timelapse,
|
||||||
to_bytes(v, errors="replace"))
|
wizard_active(_templates.get(locale))] + sorted(["{}:{}".format(to_bytes(k, errors="replace"),
|
||||||
for k, v in _plugin_vars.items()])
|
to_bytes(v, errors="replace"))
|
||||||
|
for k, v in _plugin_vars.items()])
|
||||||
|
|
||||||
def get_preemptively_cached_view(key, view, data=None, additional_request_data=None, additional_unless=None):
|
def get_preemptively_cached_view(key, view, data=None, additional_request_data=None, additional_unless=None):
|
||||||
if (data is None and additional_request_data is None) or g.locale is None:
|
if (data is None and additional_request_data is None) or g.locale is None:
|
||||||
|
|||||||
@@ -144,6 +144,9 @@ default_settings = {
|
|||||||
"supportFAsCommand": False,
|
"supportFAsCommand": False,
|
||||||
"firmwareDetection": True,
|
"firmwareDetection": True,
|
||||||
"blockWhileDwelling": False,
|
"blockWhileDwelling": False,
|
||||||
|
"useParityWorkaround": "detect",
|
||||||
|
"maxConsecutiveResends": 10,
|
||||||
|
"sendM112OnError": True,
|
||||||
|
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"autoreport_temp": True,
|
"autoreport_temp": True,
|
||||||
@@ -254,6 +257,7 @@ default_settings = {
|
|||||||
"keyboardControl": True,
|
"keyboardControl": True,
|
||||||
"pollWatched": False,
|
"pollWatched": False,
|
||||||
"modelSizeDetection": True,
|
"modelSizeDetection": True,
|
||||||
|
"printStartConfirmation": False,
|
||||||
"printCancelConfirmation": True,
|
"printCancelConfirmation": True,
|
||||||
"autoUppercaseBlacklist": ["M117", "M118"],
|
"autoUppercaseBlacklist": ["M117", "M118"],
|
||||||
"g90InfluencesExtruder": False
|
"g90InfluencesExtruder": False
|
||||||
@@ -297,6 +301,7 @@ default_settings = {
|
|||||||
"defaultLanguage": "_default",
|
"defaultLanguage": "_default",
|
||||||
"showFahrenheitAlso": False,
|
"showFahrenheitAlso": False,
|
||||||
"fuzzyTimes": True,
|
"fuzzyTimes": True,
|
||||||
|
"closeModalsWithClick": True,
|
||||||
"components": {
|
"components": {
|
||||||
"order": {
|
"order": {
|
||||||
"navbar": ["settings", "systemmenu", "plugin_announcements", "plugin_pi_support", "login"],
|
"navbar": ["settings", "systemmenu", "plugin_announcements", "plugin_pi_support", "login"],
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "resend":
|
case "resend":
|
||||||
|
case "resend_loop":
|
||||||
case "timeout": {
|
case "timeout": {
|
||||||
title = gettext("Communication error");
|
title = gettext("Communication error");
|
||||||
text = _.sprintf(gettext("There was a communication error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), payload);
|
text = _.sprintf(gettext("There was a communication error while talking to your printer. Please consult the terminal output and octoprint.log for details. Error: %(error)s"), payload);
|
||||||
|
|||||||
@@ -576,9 +576,19 @@ function formatFuzzyPrintTime(totalSeconds) {
|
|||||||
return _.sprintf(text, replacements);
|
return _.sprintf(text, replacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(unixTimestamp) {
|
function formatDate(unixTimestamp, options) {
|
||||||
|
if (!options) {
|
||||||
|
options = { seconds: false };
|
||||||
|
}
|
||||||
|
|
||||||
if (!unixTimestamp) return "-";
|
if (!unixTimestamp) return "-";
|
||||||
return moment.unix(unixTimestamp).format(gettext(/* L10N: Date format */ "YYYY-MM-DD HH:mm"));
|
|
||||||
|
var format = gettext(/* L10N: Date format */ "YYYY-MM-DD HH:mm");
|
||||||
|
if (options.seconds) {
|
||||||
|
format = gettext(/* L10N: Date format with seconds */ "YYYY-MM-DD HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
return moment.unix(unixTimestamp).format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTimeAgo(unixTimestamp) {
|
function formatTimeAgo(unixTimestamp) {
|
||||||
|
|||||||
@@ -708,6 +708,16 @@ $(function() {
|
|||||||
|
|
||||||
viewModelMap["settingsViewModel"].requestData()
|
viewModelMap["settingsViewModel"].requestData()
|
||||||
.done(function() {
|
.done(function() {
|
||||||
|
var adjustModalDefaultBehaviour = function() {
|
||||||
|
if (viewModelMap["settingsViewModel"].appearance_closeModalsWithClick()) {
|
||||||
|
$.fn.modal.defaults.backdrop = true;
|
||||||
|
} else {
|
||||||
|
$.fn.modal.defaults.backdrop = "static";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
adjustModalDefaultBehaviour();
|
||||||
|
viewModelMap["settingsViewModel"].appearance_closeModalsWithClick.subscribe(adjustModalDefaultBehaviour);
|
||||||
|
|
||||||
// There appears to be an odd race condition either in JQuery's AJAX implementation or
|
// There appears to be an odd race condition either in JQuery's AJAX implementation or
|
||||||
// the browser's implementation of XHR, causing a second GET request from inside the
|
// the browser's implementation of XHR, causing a second GET request from inside the
|
||||||
// completion handler of the very same request to never get its completion handler called
|
// completion handler of the very same request to never get its completion handler called
|
||||||
|
|||||||
@@ -203,9 +203,8 @@ $(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var js;
|
|
||||||
if (control.hasOwnProperty("javascript")) {
|
if (control.hasOwnProperty("javascript")) {
|
||||||
js = control.javascript;
|
var js = control.javascript;
|
||||||
|
|
||||||
// if js is a function everything's fine already, but if it's a string we need to eval that first
|
// if js is a function everything's fine already, but if it's a string we need to eval that first
|
||||||
if (!_.isFunction(js)) {
|
if (!_.isFunction(js)) {
|
||||||
@@ -216,12 +215,12 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (control.hasOwnProperty("enabled")) {
|
if (control.hasOwnProperty("enabled")) {
|
||||||
js = control.enabled;
|
var enabled = control.enabled;
|
||||||
|
|
||||||
// if js is a function everything's fine already, but if it's a string we need to eval that first
|
// if js is a function everything's fine already, but if it's a string we need to eval that first
|
||||||
if (!_.isFunction(js)) {
|
if (!_.isFunction(enabled)) {
|
||||||
control.enabled = function (data) {
|
control.enabled = function (data) {
|
||||||
return eval(js);
|
return eval(enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.highlightFilename = function(filename) {
|
self.highlightFilename = function(filename) {
|
||||||
if (filename === undefined) {
|
if (filename === undefined || filename === null) {
|
||||||
self.listHelper.selectNone();
|
self.listHelper.selectNone();
|
||||||
} else {
|
} else {
|
||||||
self.listHelper.selectItem(function(item) {
|
self.listHelper.selectItem(function(item) {
|
||||||
@@ -460,7 +460,20 @@ $(function() {
|
|||||||
var withinPrintDimensions = self.evaluatePrintDimensions(data, true);
|
var withinPrintDimensions = self.evaluatePrintDimensions(data, true);
|
||||||
var print = printAfterLoad && withinPrintDimensions;
|
var print = printAfterLoad && withinPrintDimensions;
|
||||||
|
|
||||||
OctoPrint.files.select(data.origin, data.path, print);
|
if (print && self.settingsViewModel.feature_printStartConfirmation()) {
|
||||||
|
showConfirmationDialog({
|
||||||
|
message: gettext("This will start a new print job. Please check that the print bed is clear."),
|
||||||
|
question: gettext("Do you want to start the print job now?"),
|
||||||
|
cancel: gettext("No"),
|
||||||
|
proceed: gettext("Yes"),
|
||||||
|
onproceed: function() {
|
||||||
|
OctoPrint.files.select(data.origin, data.path, print);
|
||||||
|
},
|
||||||
|
nofade: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
OctoPrint.files.select(data.origin, data.path, print);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,10 @@ $(function() {
|
|||||||
self.filename = ko.observable(undefined);
|
self.filename = ko.observable(undefined);
|
||||||
self.filepath = ko.observable(undefined);
|
self.filepath = ko.observable(undefined);
|
||||||
self.filedisplay = ko.observable(undefined);
|
self.filedisplay = ko.observable(undefined);
|
||||||
self.progress = ko.observable(undefined);
|
|
||||||
self.filesize = ko.observable(undefined);
|
self.filesize = ko.observable(undefined);
|
||||||
self.filepos = ko.observable(undefined);
|
self.filepos = ko.observable(undefined);
|
||||||
|
self.filedate = ko.observable(undefined);
|
||||||
|
self.progress = ko.observable(undefined);
|
||||||
self.printTime = ko.observable(undefined);
|
self.printTime = ko.observable(undefined);
|
||||||
self.printTimeLeft = ko.observable(undefined);
|
self.printTimeLeft = ko.observable(undefined);
|
||||||
self.printTimeLeftOrigin = ko.observable(undefined);
|
self.printTimeLeftOrigin = ko.observable(undefined);
|
||||||
@@ -62,7 +63,7 @@ $(function() {
|
|||||||
if (self.estimatedPrintTime())
|
if (self.estimatedPrintTime())
|
||||||
return fmt(self.estimatedPrintTime());
|
return fmt(self.estimatedPrintTime());
|
||||||
return "-";
|
return "-";
|
||||||
}
|
};
|
||||||
self.estimatedPrintTimeString = ko.pureComputed(function() {
|
self.estimatedPrintTimeString = ko.pureComputed(function() {
|
||||||
return estimatedPrintTimeStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration);
|
return estimatedPrintTimeStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration);
|
||||||
});
|
});
|
||||||
@@ -95,7 +96,7 @@ $(function() {
|
|||||||
} else {
|
} else {
|
||||||
return fmt(self.printTimeLeft());
|
return fmt(self.printTimeLeft());
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
self.printTimeLeftString = ko.pureComputed(function() {
|
self.printTimeLeftString = ko.pureComputed(function() {
|
||||||
return printTimeLeftStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration);
|
return printTimeLeftStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration);
|
||||||
});
|
});
|
||||||
@@ -194,6 +195,15 @@ $(function() {
|
|||||||
return (user ? user : (file ? "-" : ""));
|
return (user ? user : (file ? "-" : ""));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.dateString = ko.pureComputed(function() {
|
||||||
|
var date = self.filedate();
|
||||||
|
if (!date) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatDate(date, {seconds:true});
|
||||||
|
});
|
||||||
|
|
||||||
self.fromCurrentData = function(data) {
|
self.fromCurrentData = function(data) {
|
||||||
self._fromData(data);
|
self._fromData(data);
|
||||||
};
|
};
|
||||||
@@ -228,7 +238,7 @@ $(function() {
|
|||||||
self.isReady(data.flags.ready);
|
self.isReady(data.flags.ready);
|
||||||
self.isSdReady(data.flags.sdReady);
|
self.isSdReady(data.flags.sdReady);
|
||||||
|
|
||||||
if (self.isPaused() != prevPaused) {
|
if (self.isPaused() !== prevPaused) {
|
||||||
if (self.isPaused()) {
|
if (self.isPaused()) {
|
||||||
self.titlePrintButton(self.TITLE_PRINT_BUTTON_PAUSED);
|
self.titlePrintButton(self.TITLE_PRINT_BUTTON_PAUSED);
|
||||||
self.titlePauseButton(self.TITLE_PAUSE_BUTTON_PAUSED);
|
self.titlePauseButton(self.TITLE_PAUSE_BUTTON_PAUSED);
|
||||||
@@ -245,12 +255,14 @@ $(function() {
|
|||||||
self.filepath(data.file.path);
|
self.filepath(data.file.path);
|
||||||
self.filesize(data.file.size);
|
self.filesize(data.file.size);
|
||||||
self.filedisplay(data.file.display);
|
self.filedisplay(data.file.display);
|
||||||
self.sd(data.file.origin == "sdcard");
|
self.filedate(data.file.date);
|
||||||
|
self.sd(data.file.origin === "sdcard");
|
||||||
} else {
|
} else {
|
||||||
self.filename(undefined);
|
self.filename(undefined);
|
||||||
self.filepath(undefined);
|
self.filepath(undefined);
|
||||||
self.filesize(undefined);
|
self.filesize(undefined);
|
||||||
self.filedisplay(undefined);
|
self.filedisplay(undefined);
|
||||||
|
self.filedate(undefined);
|
||||||
self.sd(undefined);
|
self.sd(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +270,7 @@ $(function() {
|
|||||||
self.lastPrintTime(data.lastPrintTime);
|
self.lastPrintTime(data.lastPrintTime);
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
if (data.filament && typeof(data.filament) == "object" && _.keys(data.filament).length > 0) {
|
if (data.filament && typeof(data.filament) === "object" && _.keys(data.filament).length > 0) {
|
||||||
var keys = _.keys(data.filament);
|
var keys = _.keys(data.filament);
|
||||||
keys.sort();
|
keys.sort();
|
||||||
_.each(keys, function(key) {
|
_.each(keys, function(key) {
|
||||||
@@ -310,7 +322,21 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
OctoPrint.job.start();
|
if (!self.settings.feature_printStartConfirmation()) {
|
||||||
|
OctoPrint.job.start();
|
||||||
|
} else {
|
||||||
|
showConfirmationDialog({
|
||||||
|
message: gettext("This will start a new print job. Please check that the print bed is clear."),
|
||||||
|
question: gettext("Do you want to start the print job now?"),
|
||||||
|
cancel: gettext("No"),
|
||||||
|
proceed: gettext("Yes"),
|
||||||
|
onproceed: function() {
|
||||||
|
OctoPrint.job.start();
|
||||||
|
},
|
||||||
|
nofade: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ $(function() {
|
|||||||
self.appearance_defaultLanguage = ko.observable();
|
self.appearance_defaultLanguage = ko.observable();
|
||||||
self.appearance_showFahrenheitAlso = ko.observable(undefined);
|
self.appearance_showFahrenheitAlso = ko.observable(undefined);
|
||||||
self.appearance_fuzzyTimes = ko.observable(undefined);
|
self.appearance_fuzzyTimes = ko.observable(undefined);
|
||||||
|
self.appearance_closeModalsWithClick = ko.observable(undefined);
|
||||||
|
|
||||||
self.printer_defaultExtrusionLength = ko.observable(undefined);
|
self.printer_defaultExtrusionLength = ko.observable(undefined);
|
||||||
|
|
||||||
@@ -143,6 +144,7 @@ $(function() {
|
|||||||
self.feature_keyboardControl = ko.observable(undefined);
|
self.feature_keyboardControl = ko.observable(undefined);
|
||||||
self.feature_pollWatched = ko.observable(undefined);
|
self.feature_pollWatched = ko.observable(undefined);
|
||||||
self.feature_modelSizeDetection = ko.observable(undefined);
|
self.feature_modelSizeDetection = ko.observable(undefined);
|
||||||
|
self.feature_printStartConfirmation = ko.observable(undefined);
|
||||||
self.feature_printCancelConfirmation = ko.observable(undefined);
|
self.feature_printCancelConfirmation = ko.observable(undefined);
|
||||||
self.feature_g90InfluencesExtruder = ko.observable(undefined);
|
self.feature_g90InfluencesExtruder = ko.observable(undefined);
|
||||||
self.feature_autoUppercaseBlacklist = ko.observable(undefined);
|
self.feature_autoUppercaseBlacklist = ko.observable(undefined);
|
||||||
@@ -185,6 +187,7 @@ $(function() {
|
|||||||
self.serial_ignoreIdenticalResends = ko.observable(undefined);
|
self.serial_ignoreIdenticalResends = ko.observable(undefined);
|
||||||
self.serial_firmwareDetection = ko.observable(undefined);
|
self.serial_firmwareDetection = ko.observable(undefined);
|
||||||
self.serial_blockWhileDwelling = ko.observable(undefined);
|
self.serial_blockWhileDwelling = ko.observable(undefined);
|
||||||
|
self.serial_useParityWorkaround = ko.observable(undefined);
|
||||||
self.serial_supportResendsWithoutOk = ko.observable(undefined);
|
self.serial_supportResendsWithoutOk = ko.observable(undefined);
|
||||||
self.serial_logPositionOnPause = ko.observable(undefined);
|
self.serial_logPositionOnPause = ko.observable(undefined);
|
||||||
self.serial_logPositionOnCancel = ko.observable(undefined);
|
self.serial_logPositionOnCancel = ko.observable(undefined);
|
||||||
@@ -196,6 +199,7 @@ $(function() {
|
|||||||
self.serial_capAutoreportSdStatus = ko.observable(undefined);
|
self.serial_capAutoreportSdStatus = ko.observable(undefined);
|
||||||
self.serial_capBusyProtocol = ko.observable(undefined);
|
self.serial_capBusyProtocol = ko.observable(undefined);
|
||||||
self.serial_capEmergencyParser = ko.observable(undefined);
|
self.serial_capEmergencyParser = ko.observable(undefined);
|
||||||
|
self.serial_sendM112OnError = ko.observable(undefined);
|
||||||
|
|
||||||
self.folder_uploads = ko.observable(undefined);
|
self.folder_uploads = ko.observable(undefined);
|
||||||
self.folder_timelapse = ko.observable(undefined);
|
self.folder_timelapse = ko.observable(undefined);
|
||||||
@@ -358,7 +362,8 @@ $(function() {
|
|||||||
response: "bytes",
|
response: "bytes",
|
||||||
timeout: self.webcam_snapshotTimeout(),
|
timeout: self.webcam_snapshotTimeout(),
|
||||||
validSsl: self.webcam_snapshotSslValidation(),
|
validSsl: self.webcam_snapshotSslValidation(),
|
||||||
content_type_whitelist: ["image/*"]
|
content_type_whitelist: ["image/*"],
|
||||||
|
content_type_guess: true
|
||||||
})
|
})
|
||||||
.done(function(response) {
|
.done(function(response) {
|
||||||
if (!response.result) {
|
if (!response.result) {
|
||||||
@@ -382,7 +387,7 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var content = response.response.content;
|
var content = response.response.content;
|
||||||
var contentType = response.response.content_type
|
var contentType = response.response.assumed_content_type;
|
||||||
|
|
||||||
var mimeType = "image/jpeg";
|
var mimeType = "image/jpeg";
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
@@ -392,7 +397,7 @@ $(function() {
|
|||||||
var text = gettext("If you see your webcam snapshot picture below, the entered snapshot URL is ok.");
|
var text = gettext("If you see your webcam snapshot picture below, the entered snapshot URL is ok.");
|
||||||
showMessageDialog({
|
showMessageDialog({
|
||||||
title: gettext("Snapshot test"),
|
title: gettext("Snapshot test"),
|
||||||
message: $('<p>' + text + '</p><p><img src="data:' + mimeType + ';base64,' + content + '" /></p>'),
|
message: $('<p>' + text + '</p><p><img src="data:' + mimeType + ';base64,' + content + '" style="border: 1px solid black" /></p>'),
|
||||||
onclose: function() {
|
onclose: function() {
|
||||||
self.testWebcamSnapshotUrlBusy(false);
|
self.testWebcamSnapshotUrlBusy(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,6 +338,10 @@ $(function() {
|
|||||||
copyToClipboard(lines.join("\n"));
|
copyToClipboard(lines.join("\n"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.clearAllLogs = function() {
|
||||||
|
self.log([]);
|
||||||
|
self.plainLogLines([]);
|
||||||
|
};
|
||||||
// command matching regex
|
// command matching regex
|
||||||
// (Example output for inputs G0, G1, G28.1, M117 test)
|
// (Example output for inputs G0, G1, G28.1, M117 test)
|
||||||
// - 1: code including optional subcode. Example: G0, G1, G28.1, M117
|
// - 1: code including optional subcode. Example: G0, G1, G28.1, M117
|
||||||
|
|||||||
@@ -38,25 +38,28 @@ $(function() {
|
|||||||
self.changePasswordDialog = undefined;
|
self.changePasswordDialog = undefined;
|
||||||
|
|
||||||
self.currentUser.subscribe(function(newValue) {
|
self.currentUser.subscribe(function(newValue) {
|
||||||
if (newValue === undefined) {
|
self.resetEditUser();
|
||||||
self.editorUsername(undefined);
|
if (newValue !== undefined) {
|
||||||
self.editorAdmin(undefined);
|
|
||||||
self.editorActive(undefined);
|
|
||||||
self.editorApikey(undefined);
|
|
||||||
} else {
|
|
||||||
self.editorUsername(newValue.name);
|
self.editorUsername(newValue.name);
|
||||||
self.editorAdmin(newValue.admin);
|
self.editorAdmin(newValue.admin);
|
||||||
self.editorActive(newValue.active);
|
self.editorActive(newValue.active);
|
||||||
self.editorApikey(newValue.apikey);
|
self.editorApikey(newValue.apikey);
|
||||||
}
|
}
|
||||||
self.editorPassword(undefined);
|
|
||||||
self.editorRepeatedPassword(undefined);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
self.editorPasswordMismatch = ko.pureComputed(function() {
|
self.editorPasswordMismatch = ko.pureComputed(function() {
|
||||||
return self.editorPassword() !== self.editorRepeatedPassword();
|
return self.editorPassword() !== self.editorRepeatedPassword();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.resetEditUser = function() {
|
||||||
|
self.editorUsername(undefined);
|
||||||
|
self.editorAdmin(undefined);
|
||||||
|
self.editorActive(undefined);
|
||||||
|
self.editorApikey(undefined);
|
||||||
|
self.editorPassword(undefined);
|
||||||
|
self.editorRepeatedPassword(undefined);
|
||||||
|
};
|
||||||
|
|
||||||
self.requestData = function() {
|
self.requestData = function() {
|
||||||
if (!CONFIG_ACCESS_CONTROL) return;
|
if (!CONFIG_ACCESS_CONTROL) return;
|
||||||
if (!self.loginState.isAdmin()) return;
|
if (!self.loginState.isAdmin()) return;
|
||||||
@@ -178,8 +181,19 @@ $(function() {
|
|||||||
|
|
||||||
self.onStartup = function() {
|
self.onStartup = function() {
|
||||||
self.addUserDialog = $("#settings-usersDialogAddUser");
|
self.addUserDialog = $("#settings-usersDialogAddUser");
|
||||||
|
self.addUserDialog.on("hidden", function() {
|
||||||
|
self.resetEditUser();
|
||||||
|
});
|
||||||
|
|
||||||
self.editUserDialog = $("#settings-usersDialogEditUser");
|
self.editUserDialog = $("#settings-usersDialogEditUser");
|
||||||
|
self.editUserDialog.on("hidden", function() {
|
||||||
|
self.resetEditUser();
|
||||||
|
});
|
||||||
|
|
||||||
self.changePasswordDialog = $("#settings-usersDialogChangePassword");
|
self.changePasswordDialog = $("#settings-usersDialogChangePassword");
|
||||||
|
self.changePasswordDialog.on("hidden", function() {
|
||||||
|
self.resetEditUser();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//~~ API calls
|
//~~ API calls
|
||||||
|
|||||||
@@ -57,6 +57,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: appearance_closeModalsWithClick" id="settings-appearanceCloseModalsWithClick"> {{ _('Close dialogs by clicking outside') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div id="settings_appearance_managelanguagesdialog" class="modal hide fade">
|
<div id="settings_appearance_managelanguagesdialog" class="modal hide fade">
|
||||||
|
|||||||
@@ -13,6 +13,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: feature_printStartConfirmation" id="settings-printStartConfirmation"> {{ _('Confirm before starting a print') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
|
|||||||
@@ -3,42 +3,49 @@
|
|||||||
<label class="control-label">{{ _('Before print job starts') }}</label>
|
<label class="control-label">{{ _('Before print job starts') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforePrintStarted"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforePrintStarted"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>before</em> any lines in your files.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('After print job completes') }}</label>
|
<label class="control-label">{{ _('After print job completes') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterPrintDone"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterPrintDone"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>after</em> any lines in your files.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('After print job is cancelled') }}</label>
|
<label class="control-label">{{ _('After print job is cancelled') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterPrintCancelled"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterPrintCancelled"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>after</em> any lines in your files.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('After print job is paused') }}</label>
|
<label class="control-label">{{ _('After print job is paused') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterPrintPaused"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterPrintPaused"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>after</em> any lines in your files.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('Before print job is resumed') }}</label>
|
<label class="control-label">{{ _('Before print job is resumed') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforePrintResumed"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforePrintResumed"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>before</em> any lines in your files.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('Before tool change') }}</label>
|
<label class="control-label">{{ _('Before tool change') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforeToolChange"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforeToolChange"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>before</em> any tool change commands <code>Tn</code>.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('After tool change') }}</label>
|
<label class="control-label">{{ _('After tool change') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterToolChange"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_afterToolChange"></textarea>
|
||||||
|
<small>{{ _('Anything you put here will be executed <em>after</em> any tool change commands <code>Tn</code>.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
@@ -51,7 +58,7 @@
|
|||||||
<label class="control-label">{{ _('Before connection to printer is closed') }}</label>
|
<label class="control-label">{{ _('Before connection to printer is closed') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforePrinterDisconnected"></textarea>
|
<textarea rows="4" class="block" data-bind="value: scripts_gcode_beforePrinterDisconnected"></textarea>
|
||||||
<small>{{ _('This will only be executed when closing the connection actively. If the connection to the printer is suddenly lost nothing will be sent.') }}</small>
|
<small>{{ _('Anything you put here will only be executed when closing the connection actively. If the connection to the printer is suddenly lost nothing will be sent.') }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
<label class="control-label" for="settings-serialAdditionalPorts">{{ _('Additional serial ports') }}</label>
|
<label class="control-label" for="settings-serialAdditionalPorts">{{ _('Additional serial ports') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea rows="4" class="block" id="settings-serialAdditionalPorts" data-bind="value: serial_additionalPorts"></textarea>
|
<textarea rows="4" class="block" id="settings-serialAdditionalPorts" data-bind="value: serial_additionalPorts"></textarea>
|
||||||
<span class="help-inline">{{ _('Use this to define additional <a href="%%(glob_url)s">glob patterns</a> matching serial ports to list for connecting against, e.g. <code>/dev/ttyAMA*</code>. One entry per line.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
|
<span class="help-inline">{{ _('Use this to define additional <a href="%%(glob_url)s">glob patterns</a> matching serial ports to list for connecting against, e.g. <code>/dev/ttyAMA*</code>. One entry per line. Please note that ports will only be offered to connect to if they get also detected by the <em>operating system</em>. Adding a port here will not make it magically appear in OctoPrint. If the operating system doesn\'t see your printer you need to solve this first.')|format(glob_url="http://docs.python.org/2/library/glob.html") }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
@@ -51,6 +51,22 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label">{{ _('Apply parity double open workaround')}}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<label class="radio">
|
||||||
|
<input type="radio" name="useParityWorkaroundGroup" value="always" data-bind="checked: serial_useParityWorkaround" id="settings-serialUseParityWorkaroundAlways"> {{ _('Always') }}
|
||||||
|
<span class="help-block">{{ _('Use this if you are running into <a href="%%(url)s" target="_blank" rel="noopener noreferer">this problem</a>.')|format(url="https://forum.arduino.cc/index.php?topic=91291.0") }}</span>
|
||||||
|
</label>
|
||||||
|
<label class="radio">
|
||||||
|
<input type="radio" name="useParityWorkaroundGroup" value="detect" data-bind="checked: serial_useParityWorkaround" id="settings-serialUseParityWorkaroundPrint"> {{ _('If detected as potentially needed') }}
|
||||||
|
</label>
|
||||||
|
<label class="radio">
|
||||||
|
<input type="radio" name="useParityWorkaroundGroup" value="never" data-bind="checked: serial_useParityWorkaround" id="settings-serialUseParityWorkaroundNever"> {{ _('Never') }}
|
||||||
|
<span class="help-block">{{ _('Use this if connecting to your printer fails with <code>(22, \'Invalid argument\')</code>.') }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset id="settings_serial_general_logging">
|
<fieldset id="settings_serial_general_logging">
|
||||||
<legend>{{ _('Serial logging') }}</legend>
|
<legend>{{ _('Serial logging') }}</legend>
|
||||||
@@ -405,6 +421,12 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: serial_sendM112OnError" id="settings-serialSendM112OnError"> {{ _('Send <code>M112</code> on disconnect due to error') }}
|
||||||
|
<span class="help-block">{{ _('If this is checked, OctoPrint will try to send an <code>M112</code> prior to a disconnect due to a (fatal) error in order to disable heaters and motors.') }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{{ _('Pausing') }}</legend>
|
<legend>{{ _('Pausing') }}</legend>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<span title="{{ _('Current printer state') }}">{{ _('State') }}</span>: <strong data-bind="text: stateString"></strong><br>
|
<span title="{{ _('Current printer state') }}">{{ _('State') }}</span>: <strong data-bind="text: stateString"></strong><br>
|
||||||
<hr>
|
<hr>
|
||||||
<span title="{{ _('Name of file currently selected for printing') }}">{{ _('File') }}</span>: <strong data-bind="text: filedisplay, attr: {title: filepath}"></strong> <strong data-bind="visible: sd">(SD)</strong><br>
|
<span title="{{ _('Name of file currently selected for printing') }}">{{ _('File') }}</span>: <strong data-bind="text: filedisplay, attr: {title: filepath}"></strong> <strong data-bind="visible: sd">(SD)</strong><br>
|
||||||
|
<span title="{{ _('Upload date of the file currently selected or printing') }}">{{ _('Uploaded') }}</span>: <strong data-bind="text: dateString"></strong><br>
|
||||||
<!-- ko if: userString -->
|
<!-- ko if: userString -->
|
||||||
<span title="{{ _('User who selected this file for printing') }}">{{ _('User') }}</span>: <strong data-bind="text: userString"></strong><br>
|
<span title="{{ _('User who selected this file for printing') }}">{{ _('User') }}</span>: <strong data-bind="text: userString"></strong><br>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="terminal">
|
<div class="terminal">
|
||||||
<pre id="terminal-output" class="pre-scrollable pre-output" data-bind="foreach: displayedLines, visible: fancyFunctionality(), click: function(){ gotoTerminalCommand(); }, event: { scroll: terminalScrollEvent }"><span data-bind="text: line, css: {muted: type == 'filtered' || type == 'cut'}"></span></pre>
|
<pre id="terminal-output" class="pre-scrollable pre-output" data-bind="foreach: displayedLines, visible: fancyFunctionality(), click: function(){ gotoTerminalCommand(); }, event: { scroll: terminalScrollEvent }"><span data-bind="text: line + '\n', css: {muted: type == 'filtered' || type == 'cut'}"></span></pre>
|
||||||
<pre id="terminal-output-lowfi" style="display: none" class="pre-scrollable" data-bind="text: plainLogOutput, visible: !fancyFunctionality()"></pre>
|
<pre id="terminal-output-lowfi" style="display: none" class="pre-scrollable" data-bind="text: plainLogOutput, visible: !fancyFunctionality()"></pre>
|
||||||
<div id="terminal-sendpanel" style="display: none;" data-bind="visible: loginState.isUser">
|
<div id="terminal-sendpanel" style="display: none;" data-bind="visible: loginState.isUser">
|
||||||
<div class="input-block-level input-append">
|
<div class="input-block-level input-append">
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
<span data-bind="visible: !autoscrollEnabled() && enableFancyFunctionality()" style="display: none">(<a href="javascript:void(0)" data-bind="click: scrollToEnd">{{ _("Scroll to end") }}</a>)</span>
|
<span data-bind="visible: !autoscrollEnabled() && enableFancyFunctionality()" style="display: none">(<a href="javascript:void(0)" data-bind="click: scrollToEnd">{{ _("Scroll to end") }}</a>)</span>
|
||||||
</small>
|
</small>
|
||||||
<small class="pull-right">
|
<small class="pull-right">
|
||||||
<a href="javascript:void(0)" data-bind="click: copyAll"><i class="fa fa-copy" title="{{ _('Copy all') }}"></i> {{ _('Copy all') }}</a>
|
<a href="javascript:void(0)" data-bind="click: copyAll"><i class="fa fa-copy" title="{{ _('Copy all') }}"></i> {{ _('Copy all') }}</a><br>
|
||||||
|
<a href="javascript:void(0)" data-bind="click: clearAllLogs"><i class="fa fa-trash-o" title="{{ _('Clear log window') }}"></i> {{ _('Clear all') }}</a>
|
||||||
</small>
|
</small>
|
||||||
<small class="pull-left text-warning" data-bind="visible: !fancyFunctionality()" style="display: none">
|
<small class="pull-left text-warning" data-bind="visible: !fancyFunctionality()" style="display: none">
|
||||||
{{ _('For performance reasons only a limited amount of terminal functionality is enabled right now.') }}
|
{{ _('For performance reasons only a limited amount of terminal functionality is enabled right now.') }}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from octoprint.settings import settings
|
|||||||
from octoprint.events import eventManager, Events
|
from octoprint.events import eventManager, Events
|
||||||
from octoprint.plugin import plugin_manager
|
from octoprint.plugin import plugin_manager
|
||||||
from octoprint.util import monotonic_time
|
from octoprint.util import monotonic_time
|
||||||
|
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||||
|
|
||||||
import sarge
|
import sarge
|
||||||
import collections
|
import collections
|
||||||
@@ -304,7 +305,8 @@ def notify_callbacks(timelapse):
|
|||||||
config = timelapse.config_data()
|
config = timelapse.config_data()
|
||||||
for callback in _update_callbacks:
|
for callback in _update_callbacks:
|
||||||
try: callback.sendTimelapseConfig(config)
|
try: callback.sendTimelapseConfig(config)
|
||||||
except: logging.getLogger(__name__).exception("Exception while pushing timelapse configuration")
|
except: logging.getLogger(__name__).exception("Exception while pushing timelapse configuration",
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
|
|
||||||
def configure_timelapse(config=None, persist=False):
|
def configure_timelapse(config=None, persist=False):
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
+32
-17
@@ -18,19 +18,24 @@ import wrapt
|
|||||||
import logging
|
import logging
|
||||||
from builtins import range, bytes
|
from builtins import range, bytes
|
||||||
|
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings as s
|
||||||
|
|
||||||
from octoprint.util import atomic_write, to_bytes, deprecated, monotonic_time
|
from octoprint.util import atomic_write, to_bytes, deprecated, monotonic_time
|
||||||
|
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||||
|
|
||||||
class UserManager(object):
|
class UserManager(object):
|
||||||
valid_roles = ["user", "admin"]
|
valid_roles = ["user", "admin"]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, settings=None):
|
||||||
self._logger = logging.getLogger(__name__)
|
self._logger = logging.getLogger(__name__)
|
||||||
self._session_users_by_session = dict()
|
self._session_users_by_session = dict()
|
||||||
self._sessionids_by_userid = dict()
|
self._sessionids_by_userid = dict()
|
||||||
self._enabled = True
|
self._enabled = True
|
||||||
|
|
||||||
|
if settings is None:
|
||||||
|
settings = s()
|
||||||
|
self._settings = settings
|
||||||
|
|
||||||
self._callbacks = []
|
self._callbacks = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -86,7 +91,8 @@ class UserManager(object):
|
|||||||
try:
|
try:
|
||||||
callback("login", user)
|
callback("login", user)
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Error while calling login callback {!r}".format(callback))
|
self._logger.exception("Error while calling login callback {!r}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@@ -118,7 +124,8 @@ class UserManager(object):
|
|||||||
try:
|
try:
|
||||||
callback("logout", user)
|
callback("logout", user)
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Error while calling logout callback {!r}".format(callback))
|
self._logger.exception("Error while calling logout callback {!r}".format(callback),
|
||||||
|
extra=dict(callback=fqcn(callback)))
|
||||||
|
|
||||||
def _cleanup_sessions(self):
|
def _cleanup_sessions(self):
|
||||||
for session, user in self._session_users_by_session.items():
|
for session, user in self._session_users_by_session.items():
|
||||||
@@ -128,16 +135,18 @@ class UserManager(object):
|
|||||||
self.logout_user(user)
|
self.logout_user(user)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def createPasswordHash(password, salt=None):
|
def createPasswordHash(password, salt=None, settings=None):
|
||||||
if not salt:
|
if not salt:
|
||||||
salt = settings().get(["accessControl", "salt"])
|
if settings is None:
|
||||||
|
settings = s()
|
||||||
|
salt = settings.get(["accessControl", "salt"])
|
||||||
if salt is None:
|
if salt is None:
|
||||||
import string
|
import string
|
||||||
from random import choice
|
from random import choice
|
||||||
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
|
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
|
||||||
salt = "".join(choice(chars) for _ in range(32))
|
salt = "".join(choice(chars) for _ in range(32))
|
||||||
settings().set(["accessControl", "salt"], salt)
|
settings.set(["accessControl", "salt"], salt)
|
||||||
settings().save()
|
settings.save()
|
||||||
|
|
||||||
return hashlib.sha512(to_bytes(password, encoding="utf-8", errors="replace") + to_bytes(salt)).hexdigest()
|
return hashlib.sha512(to_bytes(password, encoding="utf-8", errors="replace") + to_bytes(salt)).hexdigest()
|
||||||
|
|
||||||
@@ -146,13 +155,15 @@ class UserManager(object):
|
|||||||
if not user:
|
if not user:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hash = UserManager.createPasswordHash(password)
|
hash = UserManager.createPasswordHash(password,
|
||||||
|
settings=self._settings)
|
||||||
if user.check_password(hash):
|
if user.check_password(hash):
|
||||||
# new hash matches, correct password
|
# new hash matches, correct password
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
# new hash doesn't match, but maybe the old one does, so check that!
|
# new hash doesn't match, but maybe the old one does, so check that!
|
||||||
oldHash = UserManager.createPasswordHash(password, salt="mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW")
|
oldHash = UserManager.createPasswordHash(password,
|
||||||
|
salt="mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW")
|
||||||
if user.check_password(oldHash):
|
if user.check_password(oldHash):
|
||||||
# old hash matches, we migrate the stored password hash to the new one and return True since it's the correct password
|
# old hash matches, we migrate the stored password hash to the new one and return True since it's the correct password
|
||||||
self.changeUserPassword(username, password)
|
self.changeUserPassword(username, password)
|
||||||
@@ -216,12 +227,11 @@ class UserManager(object):
|
|||||||
##~~ FilebasedUserManager, takes available users from users.yaml file
|
##~~ FilebasedUserManager, takes available users from users.yaml file
|
||||||
|
|
||||||
class FilebasedUserManager(UserManager):
|
class FilebasedUserManager(UserManager):
|
||||||
def __init__(self):
|
def __init__(self, **kwargs):
|
||||||
UserManager.__init__(self)
|
UserManager.__init__(self, **kwargs)
|
||||||
|
userfile = self._settings.get(["accessControl", "userfile"])
|
||||||
userfile = settings().get(["accessControl", "userfile"])
|
|
||||||
if userfile is None:
|
if userfile is None:
|
||||||
userfile = os.path.join(settings().getBaseFolder("base"), "users.yaml")
|
userfile = os.path.join(self._settings.getBaseFolder("base"), "users.yaml")
|
||||||
self._userfile = userfile
|
self._userfile = userfile
|
||||||
self._users = {}
|
self._users = {}
|
||||||
self._dirty = False
|
self._dirty = False
|
||||||
@@ -276,7 +286,11 @@ class FilebasedUserManager(UserManager):
|
|||||||
if username in self._users.keys() and not overwrite:
|
if username in self._users.keys() and not overwrite:
|
||||||
raise UserAlreadyExists(username)
|
raise UserAlreadyExists(username)
|
||||||
|
|
||||||
self._users[username] = User(username, UserManager.createPasswordHash(password), active, roles, apikey=apikey)
|
self._users[username] = User(username,
|
||||||
|
UserManager.createPasswordHash(password, settings=self._settings),
|
||||||
|
active,
|
||||||
|
roles,
|
||||||
|
apikey=apikey)
|
||||||
self._dirty = True
|
self._dirty = True
|
||||||
self._save()
|
self._save()
|
||||||
|
|
||||||
@@ -327,7 +341,8 @@ class FilebasedUserManager(UserManager):
|
|||||||
if not username in self._users.keys():
|
if not username in self._users.keys():
|
||||||
raise UnknownUser(username)
|
raise UnknownUser(username)
|
||||||
|
|
||||||
passwordHash = UserManager.createPasswordHash(password)
|
passwordHash = UserManager.createPasswordHash(password,
|
||||||
|
settings=self._settings)
|
||||||
user = self._users[username]
|
user = self._users[username]
|
||||||
if user._passwordHash != passwordHash:
|
if user._passwordHash != passwordHash:
|
||||||
user._passwordHash = passwordHash
|
user._passwordHash = passwordHash
|
||||||
|
|||||||
@@ -228,6 +228,25 @@ def get_class(name):
|
|||||||
raise ImportError("No module named " + name)
|
raise ImportError("No module named " + name)
|
||||||
|
|
||||||
|
|
||||||
|
def get_fully_qualified_classname(o):
|
||||||
|
"""
|
||||||
|
Returns the fully qualified class name for an object.
|
||||||
|
|
||||||
|
Based on https://stackoverflow.com/a/2020083
|
||||||
|
|
||||||
|
Args:
|
||||||
|
o: the object of which to determine the fqcn
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(str) the fqcn of the object
|
||||||
|
"""
|
||||||
|
|
||||||
|
module = getattr(o.__class__, "__module__", None)
|
||||||
|
if module is None:
|
||||||
|
return o.__class__.__name__
|
||||||
|
return module + "." + o.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
def get_exception_string():
|
def get_exception_string():
|
||||||
"""
|
"""
|
||||||
Retrieves the exception info of the last raised exception and returns it as a string formatted as
|
Retrieves the exception info of the last raised exception and returns it as a string formatted as
|
||||||
@@ -867,6 +886,10 @@ def server_reachable(host, port, timeout=3.05, proto="tcp", source=None):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def guess_mime_type(data):
|
||||||
|
import filetype
|
||||||
|
return filetype.guess_mime(data)
|
||||||
|
|
||||||
def parse_mime_type(mime):
|
def parse_mime_type(mime):
|
||||||
import cgi
|
import cgi
|
||||||
|
|
||||||
|
|||||||
+75
-30
@@ -39,6 +39,7 @@ from octoprint.filemanager.destinations import FileDestinations
|
|||||||
from octoprint.util import get_exception_string, sanitize_ascii, filter_non_ascii, CountedEvent, RepeatedTimer, \
|
from octoprint.util import get_exception_string, sanitize_ascii, filter_non_ascii, CountedEvent, RepeatedTimer, \
|
||||||
to_unicode, bom_aware_open, TypedQueue, PrependableQueue, TypeAlreadyInQueue, chunks, ResettableTimer, \
|
to_unicode, bom_aware_open, TypedQueue, PrependableQueue, TypeAlreadyInQueue, chunks, ResettableTimer, \
|
||||||
monotonic_time
|
monotonic_time
|
||||||
|
from octoprint.util.platform import get_os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _winreg
|
import _winreg
|
||||||
@@ -440,6 +441,7 @@ class MachineCom(object):
|
|||||||
self._max_write_passes = settings().getInt(["serial", "maxWritePasses"])
|
self._max_write_passes = settings().getInt(["serial", "maxWritePasses"])
|
||||||
|
|
||||||
self._hello_command = settings().get(["serial", "helloCommand"])
|
self._hello_command = settings().get(["serial", "helloCommand"])
|
||||||
|
self._hello_sent = 0
|
||||||
self._trigger_ok_for_m29 = settings().getBoolean(["serial", "triggerOkForM29"])
|
self._trigger_ok_for_m29 = settings().getBoolean(["serial", "triggerOkForM29"])
|
||||||
|
|
||||||
self._hello_command = settings().get(["serial", "helloCommand"])
|
self._hello_command = settings().get(["serial", "helloCommand"])
|
||||||
@@ -451,7 +453,8 @@ class MachineCom(object):
|
|||||||
self._sdAlwaysAvailable = settings().getBoolean(["serial", "sdAlwaysAvailable"])
|
self._sdAlwaysAvailable = settings().getBoolean(["serial", "sdAlwaysAvailable"])
|
||||||
self._sdRelativePath = settings().getBoolean(["serial", "sdRelativePath"])
|
self._sdRelativePath = settings().getBoolean(["serial", "sdRelativePath"])
|
||||||
self._blockWhileDwelling = settings().getBoolean(["serial", "blockWhileDwelling"])
|
self._blockWhileDwelling = settings().getBoolean(["serial", "blockWhileDwelling"])
|
||||||
self._currentLine = 1
|
self._send_m112_on_error = settings().getBoolean(["serial", "sendM112OnError"])
|
||||||
|
self._current_line = 1
|
||||||
self._line_mutex = threading.RLock()
|
self._line_mutex = threading.RLock()
|
||||||
self._resendDelta = None
|
self._resendDelta = None
|
||||||
|
|
||||||
@@ -468,6 +471,10 @@ class MachineCom(object):
|
|||||||
self._lastResendNumber = None
|
self._lastResendNumber = None
|
||||||
self._currentResendCount = 0
|
self._currentResendCount = 0
|
||||||
|
|
||||||
|
self._currentConsecutiveResendNumber = None
|
||||||
|
self._currentConsecutiveResendCount = 0
|
||||||
|
self._maxConsecutiveResends = settings().getInt(["serial", "maxConsecutiveResends"])
|
||||||
|
|
||||||
self._errorValue = ""
|
self._errorValue = ""
|
||||||
|
|
||||||
self._firmware_detection = settings().getBoolean(["serial", "firmwareDetection"])
|
self._firmware_detection = settings().getBoolean(["serial", "firmwareDetection"])
|
||||||
@@ -1502,6 +1509,7 @@ class MachineCom(object):
|
|||||||
|
|
||||||
self.sendCommand(self._hello_command, force=True, tags=tags | {"trigger:comm.say_hello",})
|
self.sendCommand(self._hello_command, force=True, tags=tags | {"trigger:comm.say_hello",})
|
||||||
self._clear_to_send.set()
|
self._clear_to_send.set()
|
||||||
|
self._hello_sent += 1
|
||||||
|
|
||||||
def resetLineNumbers(self, number=0, part_of_job=False, tags=None):
|
def resetLineNumbers(self, number=0, part_of_job=False, tags=None):
|
||||||
if not self.isOperational():
|
if not self.isOperational():
|
||||||
@@ -1541,6 +1549,8 @@ class MachineCom(object):
|
|||||||
current_tool_key = "T%d" % current_tool
|
current_tool_key = "T%d" % current_tool
|
||||||
maxToolNum, parsedTemps = parse_temperature_line(line, current_tool)
|
maxToolNum, parsedTemps = parse_temperature_line(line, current_tool)
|
||||||
|
|
||||||
|
maxToolNum = max(maxToolNum, self._printerProfileManager.get_current_or_default()["extruder"]["count"] - 1)
|
||||||
|
|
||||||
for name, hook in self._temperature_hooks.items():
|
for name, hook in self._temperature_hooks.items():
|
||||||
try:
|
try:
|
||||||
parsedTemps = hook(self, parsedTemps)
|
parsedTemps = hook(self, parsedTemps)
|
||||||
@@ -1550,7 +1560,7 @@ class MachineCom(object):
|
|||||||
self._logger.exception("Error while processing temperatures in {}, skipping".format(name),
|
self._logger.exception("Error while processing temperatures in {}, skipping".format(name),
|
||||||
extra=dict(plugin=name))
|
extra=dict(plugin=name))
|
||||||
|
|
||||||
if current_tool_key in parsedTemps.keys():
|
if current_tool_key in parsedTemps:
|
||||||
shared_nozzle = self._printerProfileManager.get_current_or_default()["extruder"]["sharedNozzle"]
|
shared_nozzle = self._printerProfileManager.get_current_or_default()["extruder"]["sharedNozzle"]
|
||||||
for n in range(maxToolNum + 1):
|
for n in range(maxToolNum + 1):
|
||||||
tool = "T%d" % n
|
tool = "T%d" % n
|
||||||
@@ -1615,6 +1625,10 @@ class MachineCom(object):
|
|||||||
if try_hello:
|
if try_hello:
|
||||||
self.sayHello()
|
self.sayHello()
|
||||||
|
|
||||||
|
# we send a second one right away because sometimes there's garbage on the line on first connect
|
||||||
|
# that can kill oks
|
||||||
|
self.sayHello()
|
||||||
|
|
||||||
while self._monitoring_active:
|
while self._monitoring_active:
|
||||||
try:
|
try:
|
||||||
line = self._readline()
|
line = self._readline()
|
||||||
@@ -2142,8 +2156,12 @@ class MachineCom(object):
|
|||||||
self._handle_ok()
|
self._handle_ok()
|
||||||
self._onConnected()
|
self._onConnected()
|
||||||
elif monotonic_time() > self._timeout:
|
elif monotonic_time() > self._timeout:
|
||||||
self._log("There was a timeout while trying to connect to the printer")
|
if try_hello and self._hello_sent < 3:
|
||||||
self.close(wait=False)
|
self._log("No answer from the printer within the connection timeout, trying another hello")
|
||||||
|
self.sayHello()
|
||||||
|
else:
|
||||||
|
self._log("There was a timeout while trying to connect to the printer")
|
||||||
|
self.close(wait=False)
|
||||||
|
|
||||||
### Operational (idle or busy)
|
### Operational (idle or busy)
|
||||||
elif self._state in (self.STATE_OPERATIONAL,
|
elif self._state in (self.STATE_OPERATIONAL,
|
||||||
@@ -2470,7 +2488,7 @@ class MachineCom(object):
|
|||||||
self._send_queue.clear()
|
self._send_queue.clear()
|
||||||
|
|
||||||
with self._line_mutex:
|
with self._line_mutex:
|
||||||
self._currentLine = 0
|
self._current_line = 0
|
||||||
self._lastLines.clear()
|
self._lastLines.clear()
|
||||||
|
|
||||||
self.sayHello(tags={"trigger:comm.on_external_reset"})
|
self.sayHello(tags={"trigger:comm.on_external_reset"})
|
||||||
@@ -2613,20 +2631,26 @@ class MachineCom(object):
|
|||||||
self._log("Connecting to: %s" % port)
|
self._log("Connecting to: %s" % port)
|
||||||
|
|
||||||
serial_port_args = {
|
serial_port_args = {
|
||||||
"port": str(port),
|
|
||||||
"baudrate": baudrateList()[0] if baudrate == 0 else baudrate,
|
"baudrate": baudrateList()[0] if baudrate == 0 else baudrate,
|
||||||
"timeout": read_timeout,
|
"timeout": read_timeout,
|
||||||
"write_timeout": 0,
|
"write_timeout": 0,
|
||||||
"parity": serial.PARITY_ODD
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings().getBoolean(["serial", "exclusive"]):
|
if settings().getBoolean(["serial", "exclusive"]):
|
||||||
serial_port_args["exclusive"] = True
|
serial_port_args["exclusive"] = True
|
||||||
|
|
||||||
serial_obj = serial.Serial(**serial_port_args)
|
serial_obj = serial.Serial(**serial_port_args)
|
||||||
|
serial_obj.port = str(port)
|
||||||
|
|
||||||
|
use_parity_workaround = settings().get(["serial", "useParityWorkaround"])
|
||||||
|
needs_parity_workaround = get_os() == "linux" and os.path.exists("/etc/debian_version") # See #673
|
||||||
|
|
||||||
|
if use_parity_workaround == "always" or (needs_parity_workaround and use_parity_workaround == "detect"):
|
||||||
|
serial_obj.parity = serial.PARITY_ODD
|
||||||
|
serial_obj.open()
|
||||||
|
serial_obj.close()
|
||||||
|
serial_obj.parity = serial.PARITY_NONE
|
||||||
|
|
||||||
serial_obj.close()
|
|
||||||
serial_obj.parity = serial.PARITY_NONE
|
|
||||||
serial_obj.open()
|
serial_obj.open()
|
||||||
|
|
||||||
return BufferedReadlineWrapper(serial_obj)
|
return BufferedReadlineWrapper(serial_obj)
|
||||||
@@ -2755,6 +2779,8 @@ class MachineCom(object):
|
|||||||
self._changeState(self.STATE_ERROR)
|
self._changeState(self.STATE_ERROR)
|
||||||
eventManager().fire(Events.ERROR, {"error": self.getErrorString(), "reason": reason})
|
eventManager().fire(Events.ERROR, {"error": self.getErrorString(), "reason": reason})
|
||||||
if close:
|
if close:
|
||||||
|
if self._send_m112_on_error and not self.isSdPrinting():
|
||||||
|
self._trigger_emergency_stop(close=False)
|
||||||
self.close(is_error=True)
|
self.close(is_error=True)
|
||||||
|
|
||||||
def _readline(self):
|
def _readline(self):
|
||||||
@@ -2868,17 +2894,17 @@ class MachineCom(object):
|
|||||||
if lineToResend is None:
|
if lineToResend is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self._resendDelta is None and lineToResend == self._currentLine == 1:
|
if self._resendDelta is None and lineToResend == self._current_line == 1:
|
||||||
# We probably just handled a resend and this request originates from lines sent before that
|
# We probably just handled a resend and this request originates from lines sent before that
|
||||||
self._logger.info("Got a resend request for line 1 which is also our current line. It looks "
|
self._logger.info("Got a resend request for line 1 which is also our current line. It looks "
|
||||||
"like we just handled a reset and this is a left over of this")
|
"like we just handled a reset and this is a left over of this")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif self._resendDelta is None and lineToResend == self._currentLine:
|
elif self._resendDelta is None and lineToResend == self._current_line:
|
||||||
# We don't expect to have an active resend request and the printer is requesting a resend of
|
# We don't expect to have an active resend request and the printer is requesting a resend of
|
||||||
# a line we haven't yet sent.
|
# a line we haven't yet sent.
|
||||||
#
|
#
|
||||||
# This means the printer got a line from us with N = self._currentLine - 1 but had already
|
# This means the printer got a line from us with N = self._current_line - 1 but had already
|
||||||
# acknowledged that. This can happen if the last line was resent due to a timeout during
|
# acknowledged that. This can happen if the last line was resent due to a timeout during
|
||||||
# an active (prior) resend request.
|
# an active (prior) resend request.
|
||||||
#
|
#
|
||||||
@@ -2890,7 +2916,7 @@ class MachineCom(object):
|
|||||||
lastCommError = self._lastCommError
|
lastCommError = self._lastCommError
|
||||||
self._lastCommError = None
|
self._lastCommError = None
|
||||||
|
|
||||||
resendDelta = self._currentLine - lineToResend
|
resendDelta = self._current_line - lineToResend
|
||||||
|
|
||||||
if lastCommError is not None \
|
if lastCommError is not None \
|
||||||
and ("line number" in lastCommError.lower() or "expected line" in lastCommError.lower()) \
|
and ("line number" in lastCommError.lower() or "expected line" in lastCommError.lower()) \
|
||||||
@@ -2901,15 +2927,27 @@ class MachineCom(object):
|
|||||||
self._currentResendCount += 1
|
self._currentResendCount += 1
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if self._currentConsecutiveResendNumber == lineToResend:
|
||||||
|
self._currentConsecutiveResendCount += 1
|
||||||
|
if self._currentConsecutiveResendCount >= self._maxConsecutiveResends:
|
||||||
|
# printer keeps requesting the same line again and again, something is severely broken here
|
||||||
|
error_text = "Printer keeps requesting line {} again and again, communication stuck".format(lineToResend)
|
||||||
|
self._log(error_text)
|
||||||
|
self._logger.warn(error_text)
|
||||||
|
self._trigger_error(error_text, "resend_loop")
|
||||||
|
else:
|
||||||
|
self._currentConsecutiveResendNumber = lineToResend
|
||||||
|
self._currentConsecutiveResendCount = 0
|
||||||
|
|
||||||
self._resendActive = True
|
self._resendActive = True
|
||||||
self._resendDelta = resendDelta
|
self._resendDelta = resendDelta
|
||||||
self._lastResendNumber = lineToResend
|
self._lastResendNumber = lineToResend
|
||||||
self._currentResendCount = 0
|
self._currentResendCount = 0
|
||||||
|
|
||||||
if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0:
|
if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0:
|
||||||
error_text = "Printer requested line %d but no sufficient history is available, can't resend" % lineToResend
|
error_text = "Printer requested line {} but no sufficient history is available, can't resend".format(lineToResend)
|
||||||
self._log(error_text)
|
self._log(error_text)
|
||||||
self._logger.warn(error_text + ". Printer requested line {}, current line is {}, line history has {} entries.".format(lineToResend, self._currentLine, len(self._lastLines)))
|
self._logger.warn(error_text + ". Printer requested line {}, current line is {}, line history has {} entries.".format(lineToResend, self._current_line, len(self._lastLines)))
|
||||||
if self.isPrinting():
|
if self.isPrinting():
|
||||||
# abort the print & disconnect, there's nothing we can do to rescue it
|
# abort the print & disconnect, there's nothing we can do to rescue it
|
||||||
self._trigger_error(error_text, "resend")
|
self._trigger_error(error_text, "resend")
|
||||||
@@ -2931,7 +2969,7 @@ class MachineCom(object):
|
|||||||
self._log_resends_rate_count = 0
|
self._log_resends_rate_count = 0
|
||||||
|
|
||||||
self._to_logfile_with_terminal(u"Got a resend request from the printer: requested line = {}, "
|
self._to_logfile_with_terminal(u"Got a resend request from the printer: requested line = {}, "
|
||||||
u"current line = {}".format(lineToResend, self._currentLine))
|
u"current line = {}".format(lineToResend, self._current_line))
|
||||||
self._log_resends_rate_count += 1
|
self._log_resends_rate_count += 1
|
||||||
|
|
||||||
self._send_queue.resend_active = True
|
self._send_queue.resend_active = True
|
||||||
@@ -2975,7 +3013,7 @@ class MachineCom(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
cmd = self._lastLines[-self._resendDelta]
|
cmd = self._lastLines[-self._resendDelta]
|
||||||
lineNumber = self._currentLine - self._resendDelta
|
lineNumber = self._current_line - self._resendDelta
|
||||||
|
|
||||||
result = self._enqueue_for_sending(cmd, linenumber=lineNumber, resend=True)
|
result = self._enqueue_for_sending(cmd, linenumber=lineNumber, resend=True)
|
||||||
|
|
||||||
@@ -3379,9 +3417,9 @@ class MachineCom(object):
|
|||||||
|
|
||||||
def _do_increment_and_send_with_checksum(self, cmd):
|
def _do_increment_and_send_with_checksum(self, cmd):
|
||||||
with self._line_mutex:
|
with self._line_mutex:
|
||||||
linenumber = self._currentLine
|
linenumber = self._current_line
|
||||||
self._addToLastLines(cmd)
|
self._addToLastLines(cmd)
|
||||||
self._currentLine += 1
|
self._current_line += 1
|
||||||
self._do_send_with_checksum(cmd, linenumber)
|
self._do_send_with_checksum(cmd, linenumber)
|
||||||
|
|
||||||
def _do_send_with_checksum(self, command, linenumber):
|
def _do_send_with_checksum(self, command, linenumber):
|
||||||
@@ -3472,7 +3510,7 @@ class MachineCom(object):
|
|||||||
if not self._validate_tool(new_tool):
|
if not self._validate_tool(new_tool):
|
||||||
self._log("Not queuing T{}, that tool doesn't exist according to the printer profile or "
|
self._log("Not queuing T{}, that tool doesn't exist according to the printer profile or "
|
||||||
"was reported as invalid by the firmware".format(new_tool))
|
"was reported as invalid by the firmware".format(new_tool))
|
||||||
return None
|
return None,
|
||||||
|
|
||||||
before = self._getGcodeScript("beforeToolChange", replacements=dict(tool=dict(old=current_tool, new=new_tool)))
|
before = self._getGcodeScript("beforeToolChange", replacements=dict(tool=dict(old=current_tool, new=new_tool)))
|
||||||
after = self._getGcodeScript("afterToolChange", replacements=dict(tool=dict(old=current_tool, new=new_tool)))
|
after = self._getGcodeScript("afterToolChange", replacements=dict(tool=dict(old=current_tool, new=new_tool)))
|
||||||
@@ -3489,15 +3527,19 @@ class MachineCom(object):
|
|||||||
|
|
||||||
return convert(before) + [cmd] + convert(after)
|
return convert(before) + [cmd] + convert(after)
|
||||||
|
|
||||||
def _gcode_T_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
def _gcode_T_sending(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||||
toolMatch = regexes_parameters["intT"].search(cmd)
|
toolMatch = regexes_parameters["intT"].search(cmd)
|
||||||
if toolMatch:
|
if toolMatch:
|
||||||
new_tool = int(toolMatch.group("value"))
|
new_tool = int(toolMatch.group("value"))
|
||||||
if not self._validate_tool(new_tool):
|
if not self._validate_tool(new_tool):
|
||||||
self._log("Not sending T{}, that tool doesn't exist according to the printer profile or "
|
self._log("Not sending T{}, that tool doesn't exist according to the printer profile or "
|
||||||
"was reported as invalid by the firmware".format(new_tool))
|
"was reported as invalid by the firmware".format(new_tool))
|
||||||
return None
|
return None,
|
||||||
|
|
||||||
|
def _gcode_T_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||||
|
toolMatch = regexes_parameters["intT"].search(cmd)
|
||||||
|
if toolMatch:
|
||||||
|
new_tool = int(toolMatch.group("value"))
|
||||||
self._toolBeforeChange = self._currentTool
|
self._toolBeforeChange = self._currentTool
|
||||||
self._currentTool = new_tool
|
self._currentTool = new_tool
|
||||||
eventManager().fire(Events.TOOL_CHANGE, dict(old=self._toolBeforeChange, new=self._currentTool))
|
eventManager().fire(Events.TOOL_CHANGE, dict(old=self._toolBeforeChange, new=self._currentTool))
|
||||||
@@ -3620,7 +3662,7 @@ class MachineCom(object):
|
|||||||
|
|
||||||
def _gcode_M191_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
def _gcode_M191_sent(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
||||||
self._heatupWaitStartTime = monotonic_time()
|
self._heatupWaitStartTime = monotonic_time()
|
||||||
self._log_running_command = True
|
self._long_running_command = True
|
||||||
self._heating = True
|
self._heating = True
|
||||||
self._gcode_M141_sent(cmd, cmd_type, wait=True, support_r=True)
|
self._gcode_M141_sent(cmd, cmd_type, wait=True, support_r=True)
|
||||||
|
|
||||||
@@ -3662,13 +3704,13 @@ class MachineCom(object):
|
|||||||
self._logger.info("M110 detected, setting current line number to {}".format(newLineNumber))
|
self._logger.info("M110 detected, setting current line number to {}".format(newLineNumber))
|
||||||
|
|
||||||
# send M110 command with new line number
|
# send M110 command with new line number
|
||||||
self._currentLine = newLineNumber
|
self._current_line = newLineNumber
|
||||||
|
|
||||||
# after a reset of the line number we have no way to determine what line exactly the printer now wants
|
# after a reset of the line number we have no way to determine what line exactly the printer now wants
|
||||||
self._lastLines.clear()
|
self._lastLines.clear()
|
||||||
self._resendDelta = None
|
self._resendDelta = None
|
||||||
|
|
||||||
def _gcode_M112_queuing(self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs):
|
def _trigger_emergency_stop(self, close=True):
|
||||||
self._logger.info(u"Force-sending M112 to the printer")
|
self._logger.info(u"Force-sending M112 to the printer")
|
||||||
|
|
||||||
# emergency stop, jump the queue with the M112, regardless of whether the EMERGENCY_PARSER capability is
|
# emergency stop, jump the queue with the M112, regardless of whether the EMERGENCY_PARSER capability is
|
||||||
@@ -3689,17 +3731,20 @@ class MachineCom(object):
|
|||||||
self._do_increment_and_send_with_checksum("M140 S0")
|
self._do_increment_and_send_with_checksum("M140 S0")
|
||||||
|
|
||||||
# close to reset host state
|
# close to reset host state
|
||||||
self._errorValue = "Closing serial port due to emergency stop M112."
|
error_text = "Closing serial port due to emergency stop M112."
|
||||||
self._log(self._errorValue)
|
self._log(error_text)
|
||||||
self.close(is_error=True)
|
|
||||||
|
if close:
|
||||||
|
self._errorValue = error_text
|
||||||
|
self.close(is_error=True)
|
||||||
|
|
||||||
# fire the M112 event since we sent it and we're going to prevent the caller from seeing it
|
# fire the M112 event since we sent it and we're going to prevent the caller from seeing it
|
||||||
gcode = "M112"
|
gcode = "M112"
|
||||||
if gcode in gcodeToEvent:
|
if gcode in gcodeToEvent:
|
||||||
eventManager().fire(gcodeToEvent[gcode])
|
eventManager().fire(gcodeToEvent[gcode])
|
||||||
|
|
||||||
# return None 1-tuple to eat the one that is queuing because we don't want to send it twice
|
def _gcode_M112_queuing(self, *args, **kwargs):
|
||||||
# I hope it got it the first time because as far as I can tell, there is no way to know
|
self._trigger_emergency_stop()
|
||||||
return None,
|
return None,
|
||||||
|
|
||||||
def _gcode_M114_queued(self, *args, **kwargs):
|
def _gcode_M114_queued(self, *args, **kwargs):
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ class gcode(object):
|
|||||||
totalMoveTimeMinute = 0.0
|
totalMoveTimeMinute = 0.0
|
||||||
relativeE = False
|
relativeE = False
|
||||||
relativeMode = False
|
relativeMode = False
|
||||||
|
duplicationMode = False
|
||||||
scale = 1.0
|
scale = 1.0
|
||||||
fwretractTime = 0
|
fwretractTime = 0
|
||||||
fwretractDist = 0
|
fwretractDist = 0
|
||||||
@@ -339,6 +340,14 @@ class gcode(object):
|
|||||||
currentE[currentExtruder] += e
|
currentE[currentExtruder] += e
|
||||||
maxExtrusion[currentExtruder] = max(maxExtrusion[currentExtruder],
|
maxExtrusion[currentExtruder] = max(maxExtrusion[currentExtruder],
|
||||||
totalExtrusion[currentExtruder])
|
totalExtrusion[currentExtruder])
|
||||||
|
|
||||||
|
if currentExtruder == 0 and len(currentE) > 1 and duplicationMode:
|
||||||
|
# Copy first extruder length to other extruders
|
||||||
|
for i in range(1, len(currentE)):
|
||||||
|
totalExtrusion[i] += e
|
||||||
|
currentE[i] += e
|
||||||
|
maxExtrusion[i] = max(maxExtrusion[i],
|
||||||
|
totalExtrusion[i])
|
||||||
else:
|
else:
|
||||||
e = 0.0
|
e = 0.0
|
||||||
|
|
||||||
@@ -426,6 +435,14 @@ class gcode(object):
|
|||||||
fwretractDist = s
|
fwretractDist = s
|
||||||
else:
|
else:
|
||||||
fwrecoverTime = (fwretractDist + s) / f
|
fwrecoverTime = (fwretractDist + s) / f
|
||||||
|
elif M == 605: #Duplication/Mirroring mode
|
||||||
|
s = getCodeInt(line, 'S')
|
||||||
|
if s in [2, 4, 5, 6]:
|
||||||
|
# Duplication / Mirroring mode selected. Printer firmware copies extrusion commands
|
||||||
|
# from first extruder to all other extruders
|
||||||
|
duplicationMode = True
|
||||||
|
else:
|
||||||
|
duplicationMode = False
|
||||||
|
|
||||||
elif T is not None:
|
elif T is not None:
|
||||||
if T > max_extruders:
|
if T > max_extruders:
|
||||||
@@ -474,7 +491,7 @@ class gcode(object):
|
|||||||
printing_area=self.printing_area)
|
printing_area=self.printing_area)
|
||||||
|
|
||||||
def getCodeInt(line, code):
|
def getCodeInt(line, code):
|
||||||
return getCode(line, code, float)
|
return getCode(line, code, int)
|
||||||
|
|
||||||
|
|
||||||
def getCodeFloat(line, code):
|
def getCodeFloat(line, code):
|
||||||
|
|||||||
@@ -46,9 +46,8 @@ else:
|
|||||||
|
|
||||||
def is_lan_address(address, additional_private=None):
|
def is_lan_address(address, additional_private=None):
|
||||||
try:
|
try:
|
||||||
if address.lower().startswith("::ffff:") and "." in address:
|
address = unmap_v4_as_v6(address)
|
||||||
# ipv6 mapped ipv4 address, unmap
|
address = strip_interface_tag(address)
|
||||||
address = address[len("::ffff:"):]
|
|
||||||
|
|
||||||
ip = netaddr.IPAddress(address)
|
ip = netaddr.IPAddress(address)
|
||||||
if ip.is_private() or ip.is_loopback():
|
if ip.is_private() or ip.is_loopback():
|
||||||
@@ -71,10 +70,7 @@ def is_lan_address(address, additional_private=None):
|
|||||||
# v6 notation in netifaces output, e.g. "ffff:ffff:ffff:ffff::/64"
|
# v6 notation in netifaces output, e.g. "ffff:ffff:ffff:ffff::/64"
|
||||||
_, prefix = prefix.split("/")
|
_, prefix = prefix.split("/")
|
||||||
|
|
||||||
addr = address["addr"]
|
addr = strip_interface_tag(address["addr"])
|
||||||
if "%" in addr:
|
|
||||||
# interface comment in netifaces output, e.g. "fe80::457f:bbee:d579:1063%wlan0"
|
|
||||||
addr = addr[:addr.find("%")]
|
|
||||||
return netaddr.IPNetwork("{}/{}".format(addr, prefix))
|
return netaddr.IPNetwork("{}/{}".format(addr, prefix))
|
||||||
|
|
||||||
for interface in netifaces.interfaces():
|
for interface in netifaces.interfaces():
|
||||||
@@ -103,3 +99,17 @@ def is_lan_address(address, additional_private=None):
|
|||||||
# we are extra careful here since an unhandled exception in this method will effectively nuke the whole UI
|
# we are extra careful here since an unhandled exception in this method will effectively nuke the whole UI
|
||||||
logging.getLogger(__name__).exception("Error while trying to determine whether {} is a local address".format(address))
|
logging.getLogger(__name__).exception("Error while trying to determine whether {} is a local address".format(address))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def strip_interface_tag(address):
|
||||||
|
if "%" in address:
|
||||||
|
# interface comment, e.g. "fe80::457f:bbee:d579:1063%wlan0"
|
||||||
|
address = address[:address.find("%")]
|
||||||
|
return address
|
||||||
|
|
||||||
|
|
||||||
|
def unmap_v4_as_v6(address):
|
||||||
|
if address.lower().startswith("::ffff:") and "." in address:
|
||||||
|
# ipv6 mapped ipv4 address, unmap
|
||||||
|
address = address[len("::ffff:"):]
|
||||||
|
return address
|
||||||
@@ -123,7 +123,7 @@ def get_python_version_string():
|
|||||||
|
|
||||||
# Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072)
|
# Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072)
|
||||||
if version_string.endswith("+"):
|
if version_string.endswith("+"):
|
||||||
version_string = python_version[:-1]
|
version_string = version_string[:-1]
|
||||||
|
|
||||||
return version_string
|
return version_string
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -76,16 +76,16 @@ class RawWebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransport
|
|||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def send_pack(self, message, binary=False):
|
def send_pack(self, message, binary=False):
|
||||||
if IOLoop.current(False) == self.server.io_loop:
|
if IOLoop.current(False) == self.server.io_loop:
|
||||||
# Running in Main Thread
|
# Running in Main Thread
|
||||||
# Send message
|
# Send message
|
||||||
try:
|
try:
|
||||||
self.write_message(message, binary)
|
self.write_message(message, binary)
|
||||||
except (IOError, WebSocketError):
|
except (IOError, WebSocketError):
|
||||||
self.server.io_loop.add_callback(self.on_close)
|
self.server.io_loop.add_callback(self.on_close)
|
||||||
else:
|
else:
|
||||||
# Not running in Main Thread so use proper thread to send message
|
# Not running in Main Thread so use proper thread to send message
|
||||||
self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
|
self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
|
||||||
|
|
||||||
def session_closed(self):
|
def session_closed(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
+10
-10
@@ -83,16 +83,16 @@ class WebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransportMix
|
|||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
def send_pack(self, message, binary=False):
|
def send_pack(self, message, binary=False):
|
||||||
if IOLoop.current(False) == self.server.io_loop:
|
if IOLoop.current(False) == self.server.io_loop:
|
||||||
# Running in Main Thread
|
# Running in Main Thread
|
||||||
# Send message
|
# Send message
|
||||||
try:
|
try:
|
||||||
self.write_message(message, binary)
|
self.write_message(message, binary)
|
||||||
except (IOError, WebSocketError):
|
except (IOError, WebSocketError):
|
||||||
self.server.io_loop.add_callback(self.on_close)
|
self.server.io_loop.add_callback(self.on_close)
|
||||||
else:
|
else:
|
||||||
# Not running in Main Thread so use proper thread to send message
|
# Not running in Main Thread so use proper thread to send message
|
||||||
self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
|
self.server.io_loop.add_callback(lambda: self.send_pack(message, binary))
|
||||||
|
|
||||||
def session_closed(self):
|
def session_closed(self):
|
||||||
# If session was closed by the application, terminate websocket
|
# If session was closed by the application, terminate websocket
|
||||||
|
|||||||
@@ -21,11 +21,14 @@ class TestCommErrorHandling(unittest.TestCase):
|
|||||||
self._comm._errorValue = None
|
self._comm._errorValue = None
|
||||||
self._comm._clear_to_send = mock.Mock()
|
self._comm._clear_to_send = mock.Mock()
|
||||||
self._comm._error_message_hooks = dict()
|
self._comm._error_message_hooks = dict()
|
||||||
|
self._comm._trigger_emergency_stop = mock.Mock()
|
||||||
|
|
||||||
# settings
|
# settings
|
||||||
self._comm._ignore_errors = False
|
self._comm._ignore_errors = False
|
||||||
self._comm._disconnect_on_errors = True
|
self._comm._disconnect_on_errors = True
|
||||||
|
self._comm._send_m112_on_error = True
|
||||||
self._comm.isPrinting.return_value = True
|
self._comm.isPrinting.return_value = True
|
||||||
|
self._comm.isSdPrinting.return_value = False
|
||||||
self._comm.isError.return_value = False
|
self._comm.isError.return_value = False
|
||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
@@ -132,6 +135,7 @@ class TestCommErrorHandling(unittest.TestCase):
|
|||||||
self.assertEqual(line, result)
|
self.assertEqual(line, result)
|
||||||
|
|
||||||
# what should have happened
|
# what should have happened
|
||||||
|
self.assert_m112_sent()
|
||||||
self.assert_disconnected()
|
self.assert_disconnected()
|
||||||
|
|
||||||
# what should not have happened
|
# what should not have happened
|
||||||
@@ -140,6 +144,24 @@ class TestCommErrorHandling(unittest.TestCase):
|
|||||||
self.assert_not_print_cancelled()
|
self.assert_not_print_cancelled()
|
||||||
self.assert_not_cleared_to_send()
|
self.assert_not_cleared_to_send()
|
||||||
|
|
||||||
|
@ddt.data("Error: Printer on fire")
|
||||||
|
def test_other_error_no_m112(self, line):
|
||||||
|
"""Should trigger escalation"""
|
||||||
|
self._comm._send_m112_on_error = False
|
||||||
|
|
||||||
|
result = self._comm._handle_errors(line)
|
||||||
|
self.assertEqual(line, result)
|
||||||
|
|
||||||
|
# what should have happened
|
||||||
|
self.assert_disconnected()
|
||||||
|
|
||||||
|
# what should not have happened
|
||||||
|
self.assert_not_handle_ok()
|
||||||
|
self.assert_not_last_comm_error()
|
||||||
|
self.assert_not_print_cancelled()
|
||||||
|
self.assert_not_cleared_to_send()
|
||||||
|
self.assert_not_m112_sent()
|
||||||
|
|
||||||
@ddt.data("Error: Printer on fire")
|
@ddt.data("Error: Printer on fire")
|
||||||
def test_other_error_cancel(self, line):
|
def test_other_error_cancel(self, line):
|
||||||
"""Should trigger print cancel"""
|
"""Should trigger print cancel"""
|
||||||
@@ -155,6 +177,7 @@ class TestCommErrorHandling(unittest.TestCase):
|
|||||||
# what should not have happened
|
# what should not have happened
|
||||||
self.assert_not_handle_ok()
|
self.assert_not_handle_ok()
|
||||||
self.assert_not_last_comm_error()
|
self.assert_not_last_comm_error()
|
||||||
|
self.assert_not_m112_sent()
|
||||||
self.assert_not_disconnected()
|
self.assert_not_disconnected()
|
||||||
|
|
||||||
@ddt.data("Error: Printer on fire")
|
@ddt.data("Error: Printer on fire")
|
||||||
@@ -172,6 +195,8 @@ class TestCommErrorHandling(unittest.TestCase):
|
|||||||
self.assert_not_handle_ok()
|
self.assert_not_handle_ok()
|
||||||
self.assert_not_last_comm_error()
|
self.assert_not_last_comm_error()
|
||||||
self.assert_not_print_cancelled()
|
self.assert_not_print_cancelled()
|
||||||
|
self.assert_not_m112_sent()
|
||||||
|
self.assert_not_disconnected()
|
||||||
|
|
||||||
def test_not_an_error(self):
|
def test_not_an_error(self):
|
||||||
"""Should pass"""
|
"""Should pass"""
|
||||||
@@ -205,6 +230,12 @@ class TestCommErrorHandling(unittest.TestCase):
|
|||||||
def assert_not_last_comm_error(self):
|
def assert_not_last_comm_error(self):
|
||||||
self.assertIsNone(self._comm._lastCommError)
|
self.assertIsNone(self._comm._lastCommError)
|
||||||
|
|
||||||
|
def assert_m112_sent(self):
|
||||||
|
self._comm._trigger_emergency_stop.assert_called_once_with(close=False)
|
||||||
|
|
||||||
|
def assert_not_m112_sent(self):
|
||||||
|
self._comm._trigger_emergency_stop.assert_not_called()
|
||||||
|
|
||||||
def assert_disconnected(self):
|
def assert_disconnected(self):
|
||||||
self.assertIsNotNone(self._comm._errorValue)
|
self.assertIsNotNone(self._comm._errorValue)
|
||||||
self._comm._changeState.assert_called_with(self._comm.STATE_ERROR)
|
self._comm._changeState.assert_called_with(self._comm.STATE_ERROR)
|
||||||
|
|||||||
+23
-1
@@ -43,7 +43,8 @@ class UtilNetTest(unittest.TestCase):
|
|||||||
("11.1.2.3", [], False),
|
("11.1.2.3", [], False),
|
||||||
("11.1.2.3", ["11/8"], True),
|
("11.1.2.3", ["11/8"], True),
|
||||||
("12.1.1.123", [], True),
|
("12.1.1.123", [], True),
|
||||||
("2a01:4f8:1c0c:6958::1:23", [], True)
|
("2a01:4f8:1c0c:6958::1:23", [], True),
|
||||||
|
("fe80::89f3:31bb:ced0:2093%wlan0", [], True)
|
||||||
)
|
)
|
||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
@mock.patch("netifaces.interfaces", side_effect=patched_interfaces)
|
@mock.patch("netifaces.interfaces", side_effect=patched_interfaces)
|
||||||
@@ -52,3 +53,24 @@ class UtilNetTest(unittest.TestCase):
|
|||||||
def test_is_lan_address(self, input_address, input_additional, expected, nifa, nifs):
|
def test_is_lan_address(self, input_address, input_additional, expected, nifa, nifs):
|
||||||
actual = octoprint.util.net.is_lan_address(input_address, additional_private=input_additional)
|
actual = octoprint.util.net.is_lan_address(input_address, additional_private=input_additional)
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
@ddt.data(
|
||||||
|
("fe80::89f3:31bb:ced0:2093%wlan0", "fe80::89f3:31bb:ced0:2093"),
|
||||||
|
("2a01:4f8:1c0c:6958::1:23", "2a01:4f8:1c0c:6958::1:23"),
|
||||||
|
("10.1.2.3", "10.1.2.3")
|
||||||
|
)
|
||||||
|
@ddt.unpack
|
||||||
|
def test_strip_interface_tag(self, address, expected):
|
||||||
|
actual = octoprint.util.net.strip_interface_tag(address)
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
@ddt.data(
|
||||||
|
("::ffff:192.168.1.1", "192.168.1.1"),
|
||||||
|
("::ffff:2a01:4f8", "::ffff:2a01:4f8"),
|
||||||
|
("2a01:4f8:1c0c:6958::1:23", "2a01:4f8:1c0c:6958::1:23"),
|
||||||
|
("11.1.2.3", "11.1.2.3")
|
||||||
|
)
|
||||||
|
@ddt.unpack
|
||||||
|
def test_unmap_v4_in_v6(self, address, expected):
|
||||||
|
actual = octoprint.util.net.unmap_v4_as_v6(address)
|
||||||
|
self.assertEqual(expected, actual)
|
||||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
+807
-589
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user