Compare commits

...
953 Commits
Author SHA1 Message Date
Gina Häußge 8409fdaa48 Merge branch 'rc/maintenance' 2019-10-21 12:27:16 +02:00
Gina Häußge f29e736427 🔖 Preparing release of 1.3.12 2019-10-21 12:26:04 +02:00
Gina Häußge a70a45f062 Merge branch 'staging/maintenance' into rc/maintenance 2019-09-23 12:59:49 +02:00
Gina Häußge 61b0845f19 🔖 Preparing release of 1.3.12rc3 2019-09-23 12:55:39 +02:00
Gina Häußge b9665a8af4 🐛 Don't try to trigger M112 on connection errors
Doesn't make sense, we don't HAVE a connection yet.
2019-09-19 10:19:19 +02:00
Gina Häußge 15522a98b0 🐛 GCODE viewer: get rid of deep clone
Fixes #3277
2019-09-18 13:45:01 +02:00
Gina Häußge c4258c5bb0 🔖 Preparing release of 1.3.12rc2, part 2 2019-09-17 16:20:44 +02:00
Gina Häußge 58799888b7 🐛 SWU: Fix wrong version check
Fixes #3273
2019-09-17 16:18:07 +02:00
Gina Häußge fb6d57963b 🔖 Preparing release of 1.3.12rc2 2019-09-17 14:19:32 +02:00
Gina Häußge 03f228c0ef ☔ Extend safemode to language packs
Cherry-picked from cc1d88c

Implements #3271
2019-09-16 14:35:04 +02:00
Gina Häußge 93ae368f58 🐛 Escape single/double quotes in l10n strings
Cherry-picked from 72eef3e

Closes #3270
2019-09-16 14:34:21 +02:00
Gina Häußge 378752e155 🐛 GCODE viewer: Fix out-of-sync & slider issue, part 2
Now with all files...

Fixes #3272
2019-09-16 14:32:08 +02:00
Gina Häußge bec307900d 🐛 GCODE viewer: Fix out-of-sync & slider issue
Fixes #3272
2019-09-16 14:27:30 +02:00
Gina Häußge 0eac10d5a6 🔖 staging/maintenance is now 1.3.12rc2.dev 2019-09-10 16:54:20 +02:00
Gina Häußge 2a42f02aec ⬆️ Require newer environment for future upgrades
This is the last version that supports stock OctoPi 0.14, catering
towards the ancient setuptools and pip versions found on it becomes
more and more unjustifiable overhead.
2019-09-10 13:45:18 +02:00
Gina Häußge 7c48cfd0f7 🔖 Preparing 1.3.12rc1 2019-09-09 18:00:13 +02:00
Gina Häußge bba796d551 ☔ errortracking: filter specific callbacks
We don't want to get swamped by third party plugin error messages on
sentry as that costs money.

Blacklist astroprint messages since they caused issues in the past.
2019-09-09 13:51:54 +02:00
Gina Häußge a855f3e62c ☔ Add fqcn of callbacks to exception loggers
Will allow us to filter for them.
2019-09-09 13:45:22 +02:00
Gina Häußge 5079e7e891 🐛 Clear user management dialogs on close 2019-09-09 12:54:03 +02:00
Gina Häußge ddc948fa94 🔖 errortracking: new DSNs for 1.3.12rc1 2019-09-06 17:09:11 +02:00
Gina Häußge f88f2b25ea 🐛 tracking: Only track plugins in pong event 2019-09-06 16:55:27 +02:00
Gina Häußge ea59dab7ab ✨ Optional print start confirmation
Implements #3250
2019-09-05 14:51:51 +02:00
Gina Häußge f0914c2214 🐛 appkeys: empty user_id = unset user_id
Also some more debug logging

Closes #3257
2019-09-05 14:40:40 +02:00
Gina Häußge b3e76c3ecc 🐛 plugin.version can be None, episode 2 2019-09-05 14:25:17 +02:00
Gina Häußge a4d5acb0b8 Merge pull request #3263 from gdombiak/printer_profiles_add_del_events
All printer profile events are now triggered
2019-09-05 09:34:12 +02:00
Gaston Dombiak 79b66f17b6 Events PRINTER_PROFILE_ADDED and PRINTER_PROFILE_DELETED are now triggered 2019-09-04 22:57:17 -07:00
Gina Häußge bcb6c7a1d4 Create SECURITY.md 2019-09-04 18:03:02 +02:00
Gina Häußge 36198c684f 🐛 Fix scoping issue
Closes #3247
2019-09-04 16:22:31 +02:00
Gina Häußge a3a60c5967 ☔ appkeys: better handling of empty request body 2019-09-04 10:59:03 +02:00
Gina Häußge 6df3cb5c12 🐛 plugin.version may be None 2019-09-04 10:33:42 +02:00
Gina Häußge 0611329a6d Merge pull request #3256 from byarmis/fix/byarmis/3253
Resolve error detecting Python version
2019-09-04 10:01:43 +02:00
Gina Häußge 2f90fca5ce Merge pull request #3249 from gdombiak/printer_profile_events
Printer profile events
2019-09-04 09:51:01 +02:00
Ben Yarmis e4e97190da Resolving issue #3253
Added myself to the AUTHORS.md file
2019-08-25 01:48:11 -05:00
Gaston Dombiak 9c748a85b4 removed ' to march master 2019-08-12 20:40:17 -07:00
Gaston Dombiak 78c2199d89 Fire PRINTER_PROFILE_MODIFIED when printer profile was modified 2019-08-12 20:32:42 -07:00
Gina Häußge 0e67906d1e ♻ tracking: Send plugin list only once per day 2019-07-29 17:38:18 +02:00
Gina Häußge 4c602cba2e ☔ Further hardening against corrupt recovery data 2019-07-29 16:55:32 +02:00
Gina Häußge 89255e2ec9 ☔ Harden against corrupt recovery data
Closes #3199
2019-07-29 16:52:05 +02:00
Gina Häußge 372b3662e9 📝 Add docs for printTimeLeftOrigin field
Closes #3203
2019-07-29 16:37:52 +02:00
Gina Häußge e007dbaf4c 🐛 Fix file selection not being cleared on disconnect
Closes #3224
2019-07-29 13:27:08 +02:00
Gina Häußge f67f9b9399 🐛 Fix --admin flag on add command 2019-07-22 15:06:09 +02:00
Gina Häußge c6c5328418 ✨ Add list/activate/deactivate commands 2019-07-22 15:05:51 +02:00
Gina Häußge accbfc2b45 🐛 Fix settings passing 2019-07-22 15:04:27 +02:00
Gina Häußge 9976f2b7a3 🐛 Fix a broken import 2019-07-22 14:00:54 +02:00
Gina Häußge f249563b2c 🐛 At least use configured user manager class
Making the plugin hook work would be a ton of overhead due to the
components dictionary that needs to be supplied to it for user manager
initialization, however at the very least we should support
configuration of the used user manager class.

Both features are rarely used if at all, but we should be aware of this.

Also changed some wording, fixed to unicode and removed redundancy from
the sub commands (e.g. just "add" instead of "add_user") and flags.
2019-07-22 14:00:43 +02:00
Aliaksei Pilko 09e023917c Amend settings ref 2019-07-19 18:08:31 +01:00
Aliaksei Pilko 799b86b287 Update copyright 2019-07-18 15:41:32 +01:00
Aliaksei Pilko ea1bcf8e5d Add user accounts cli
Add forgot password link at login

Update AUTHORS.md
2019-07-17 19:54:21 +01:00
Piotr Usewicz ee93e25ffd Rename currentLine to current_line 2019-07-16 11:02:52 +02:00
Gina Häußge d25f664be3 🐛 printer safety: Anycubic 1.1.2 is already safe
Fix off by one error.

See also https://community.octoprint.org/t/octoprint-tells-me-that-my-printers-firmware-lacks-mandatory-safety-features-what-does-this-mean/350/61
2019-07-16 10:47:42 +02:00
Gina Häußge 3bffe4f7cb Merge pull request #3225 from eyal0/patch-4
Quote arguments in pip install
2019-07-11 11:20:20 +02:00
Eyal f140dd9d44 Quote arguments in pip install
If the argument is not quoted, the shell will interpret the braces.
2019-07-08 21:20:08 -04:00
Gina Häußge d44747b39a 🐛 Fix long_running_command flag for M191
Closes #3220
2019-07-08 11:26:02 +02:00
Gina Häußge f2da9d8d7d Merge pull request #3217 from gdombiak/docs_typo
Fixed typo in chambers documentation
2019-07-05 11:16:24 +02:00
Gaston Dombiak 5483ef7cd4 Fixed typo in chambers documentation 2019-07-04 23:19:35 -07:00
Gina Häußge 85d212ba97 ☔ More resilience against garbage on the line on initial connect
We'll now send the hello command twice, and a third time if we run into
a timeout during initial connect.

Closes #3206
2019-07-02 16:35:57 +02:00
Gina Häußge 44af09580a 🚸 Make clear when GCODE scripts are executed
Closes #3198
2019-07-02 13:56:19 +02:00
Gina Häußge 530fca95e4 ☔ Include wizard flag in etag
Additional protection against #3211 and #3166
2019-07-02 13:48:28 +02:00
Gina Häußge 59ae7e39f2 ☔ Only set relevant cache control headers
We don't want to accidentally overwrite anything again.
2019-07-02 13:43:57 +02:00
Gina Häußge 72167d14d2 🐛 Fix caching headers on / in case of wizards
Revalidation header from ceade46dd7 was
overwriting custom header in case of active wizards, causing the browser
to cache HTML code with enabled wizards.

This fixes this by checking if the headers in question actually need to
be set and aren't already there.
2019-07-02 12:44:29 +02:00
Gina Häußge 2c6568acd1 ✨ Mimetype guessing for the webcam test
Related to #3207
2019-07-01 17:17:34 +02:00
Gina Häußge e27c216a05 Merge branch 'master' into maintenance 2019-06-27 10:19:12 +02:00
Gina Häußge 7b4c148dd7 ✨ tracking: track slicing events
Gives us some numbers the next time someone complains about
slicer support.
2019-06-26 19:27:57 +02:00
Gina Häußge a924520dd6 ✨ tracking: track plugins & versions on startup
Requested feature by plugin developers, will also allow us to compile
stuff like top10 lists.
2019-06-26 18:32:33 +02:00
Gina Häußge e88eb6dd85 ☔ PMGR: Prevent installs while throttled 2019-06-19 15:48:18 +02:00
Gina Häußge 59dfa994bd ☔ SWU: Prevent updates while throttled 2019-06-19 15:41:11 +02:00
Gina Häußge 6959ce4d38 💚 Try to fix doc build by pinning a dep, 2nd try 2019-06-19 11:52:06 +02:00
Gina Häußge 08bc0082cf 💚 Try to fix doc build by pinning a dep 2019-06-19 11:46:53 +02:00
Gina Häußge 6069d74a54 💚 Fix unit tests 2019-06-18 13:35:21 +02:00
Gina Häußge 68ee7030f1 ☔ Send M112 on disconnect due to error (configurable)
Try to disable heaters and such. Might fail, but worth a try at least.
Only do that if we are not SD printing though.
2019-06-17 18:35:44 +02:00
Gina Häußge 81342acccc ☔ Detect endless resend requests & abort
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.
2019-06-17 18:35:44 +02:00
Gina Häußge e029f33901 Merge pull request #3195 from dmweis/patch-2
Fix typo
2019-06-11 10:41:33 +02:00
David Weis 7bd8cff137 Fix typo 2019-06-08 14:14:58 +01:00
Gina Häußge 055dcfa0e1 Merge pull request #3192 from dovecode/translatable-string-fixes
Various translatable text fixes and fixed plugin install message during restore
2019-06-05 13:32:10 +02:00
Nicolai Nielsen 8acf417383 Removed extra curly brace in plugin install message during restore
Fixed plugin install message for UI (never worked!)
Fixed grammar in connectivity initial setup
Added space at end of lines for several multiline messages
2019-06-04 11:47:41 -05:00
Gina Häußge b50e1aee8a 🚨 More consistent whitespace 2019-06-04 15:20:27 +02:00
Gina Häußge c714bce17e Merge pull request #3191 from Flamenco/my_maintenance
Add documentation when target temperature is set to 0
2019-06-04 15:19:23 +02:00
Steven Spungin a9a8e48489 Add new author 2019-06-04 09:00:35 -04:00
Steven Spungin 9dec840818 Add documentation when target temperature is set to 0 2019-06-04 08:57:10 -04:00
Gina Häußge 9af125ca6d 🚨 Consistent whitespace 2019-06-03 13:25:02 +02:00
Gina Häußge 1f4fabe6ef 🐛 PMGR: Refresh data from server if needed on endpoint GET
Closes #3190
2019-06-03 12:17:03 +02:00
Gina Häußge 121f36704d Merge pull request #3184 from dovecode/action_prompt_warning_missing_space
Add space in disable warning message
2019-05-29 18:13:51 +02:00
Nicolai Nielsen 85ff545c07 Add space in disable warning message 2019-05-29 10:10:52 -05:00
Gina Häußge 3662c84de5 Merge branch 'pr/3183' into maintenance 2019-05-28 16:35:00 +02:00
Gina Häußge 79558fdfbf Merge pull request #3179 from dovecode/uninstall_plugin_confirmation
Added confirmation dialog before uninstalling plugin
2019-05-28 16:21:44 +02:00
Nicolai Nielsen 11040f272a Added confirmation dialog before uninstalling plugin
Added confirmation dialog before disabling plugin
Added configuration options to control the confirmation dialogs
Defaults are not to confirm for disabling but confirm for uninstalling
2019-05-27 19:03:29 -05:00
Janne Mäntyharju fa2716c65c Calculate filament usage for all extruders is M605 duplicate/mirror command is used (Issue #3075) 2019-05-27 22:02:34 +03:00
Gina Häußge 768b06e35a ✨ Allow disabling of closing dialogs by click outside
New setting: Settings > Appearance > Close dialogs by clicking outside

Implements #3162
2019-05-27 16:58:45 +02:00
Gina Häußge 0820c23aea Merge pull request #3180 from AndyQ/clear_term_patch
Added button to terminal window to all log window to be cleared out
2019-05-27 16:26:34 +02:00
Gina Häußge 361fbaa366 🐛 pmgr: Smaller height for plugin list
Should work around #3161
2019-05-27 16:22:50 +02:00
Gina Häußge a91359f2af 🚸 Change icon & wording 2019-05-27 16:21:03 +02:00
AndyQ 4bfabf82ae Fixed typo and changed link to clearAllLogs
Both logs (fancy and plain) cleared out at same time
2019-05-27 15:01:14 +01:00
Gina Häußge c90f556fe9 📝 github meta: Clarify devel vs maintenance base 2019-05-27 11:14:31 +02:00
AndyQ 352b190a72 Added button to terminal window to all log window to be cleared out 2019-05-26 12:49:03 +01:00
Gina Häußge e9b0bd9e65 Create FUNDING.yml 2019-05-23 13:08:50 +02:00
Gina Häußge c8ea808d93 🚸 Include seconds in upload date
See #3174
2019-05-21 15:18:24 +02:00
Gina Häußge d40c3e6241 🚸 Add upload date to selected file information
Should make it more clear when an update due to a new upload happens.

Closes #3174
2019-05-21 15:05:28 +02:00
Gina Häußge e94f789b72 🐛 Always report all tools in sharedNozzle setups
Fixes #3177

See also https://community.octoprint.org/t/9620/4
2019-05-21 14:29:15 +02:00
Gina Häußge 9ff44c49a6 🐛 Fix broken tool filtering 2019-05-21 14:20:41 +02:00
Gina Häußge c7b933ba00 🐛 forcelogin: Do not touch static endpoints
Closes #3176
2019-05-21 12:07:39 +02:00
Gina Häußge 6765b25803 🚸 action prompt: show icon for dismissed prompts in navbar 2019-05-21 10:37:47 +02:00
Gina Häußge 59b60f5dad 🐛 action prompt: close & delete prompt on disconnect
As mentioned in #3171
2019-05-20 19:55:10 +02:00
Gina Häußge 2822992843 🚸 action prompt: allow to cancel dialogs
Closes #3171
2019-05-20 19:49:06 +02:00
Gina Häußge 1b82aa859f 🐛 Fix accidental test code commit 2019-05-20 16:48:00 +02:00
Gina Häußge 12be637f85 ✨ Add setting for parity double open workaround
Can now be set to be applied if possibly needed (OS is a Debian Linux),
always or never.

Closes #3169, enhances #3167
2019-05-20 16:46:45 +02:00
Kyle Evans 3bd9d11fc3 comm: Don't open twice on FreeBSD
Originally introduced by PR #673 to fix reconnect issues on pyserial,
OctoPrint will first open the serial port with PARITY_ODD then close it
again and reopen with the desired PARITY_NONE. This works around issues
likely sitting somewhere in the linux tty layer, at least on some
distributions, that don't necessarily exist on other platforms.

Stop doing the workaround on FreeBSD to start with, as this is the only
platform I can effectively test. I suspect MacOS/Windows likely also don't
need to do this.
2019-05-17 22:43:13 -05:00
Gina Häußge e864d6b03e 🚸 Ensure line breaks on copy of terminal contents 2019-05-15 17:35:57 +02:00
Gina Häußge 547db7c1f5 ☔ pmgr: better handling of unexpected repository format
Closes #3157 and Sentry SERVER-116
2019-05-15 17:34:54 +02:00
Gina Häußge d6516e4a4c 🐛 tracking: handle time==None case
Closes #3156 and Sentry SERVER-WR
2019-05-15 15:19:57 +02:00
Gina Häußge 2387b4a771 🐛 backup: make sure exclude is always a list
Closes #3155 and Sentry SERVER-119
2019-05-15 15:15:25 +02:00
Gina Häußge b03d43156d 🐛 Strip interface tags from addresses on local check
Closes #3143 and Sentry SERVER-11B
2019-05-15 13:19:14 +02:00
Gina Häußge 07423712a6 🐛 Fix wrong variable name in exception handler
Closes #3153 & Sentry SERVER-11A
2019-05-15 11:48:45 +02:00
Gina Häußge 2edd2ba887 Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance 2019-05-14 11:21:19 +02:00
Gina Häußge fcef3a1bbd Merge branch 'staging/maintenance' into maintenance 2019-05-14 11:21:01 +02:00
Gina Häußge d1d24dba9a Merge branch 'rc/maintenance' into staging/maintenance 2019-05-14 11:18:37 +02:00
Gina Häußge 81735d07c9 Merge branch 'rc/maintenance' 2019-05-13 14:54:51 +02:00
Gina Häußge 2c640ff8b8 🔖 Preparing release of 1.3.11 2019-05-13 13:52:32 +02:00
Gina Häußge 0331a25ae3 📝 Reflect API key changes in docs
Closes #3121
2019-05-13 12:55:25 +02:00
Gina Häußge 326422013a Merge pull request #3147 from esver/autofocus
Add autocofus to the username in the login plugin
2019-05-13 11:23:37 +02:00
Olivier Esver 9b4da62e69 Add autocofus to the username in the login plugin 2019-05-11 20:53:51 +02:00
Gina Häußge b46a66caa8 ♻ Slight refactoring... 2019-05-09 15:40:51 +02:00
Gina Häußge 6711813fef Merge pull request #3134 from tduehr/remote
Remote user support
2019-05-09 15:23:37 +02:00
Timur Duehr 7726e5c04e review fixes 2019-05-09 15:14:51 +02:00
Timur Duehr 495d99fbe9 Add support for remote users 2019-05-09 15:14:36 +02:00
Gina Häußge a35b7cddf2 🐛 Only add response text if there is one 2019-05-09 15:08:48 +02:00
Gina Häußge f2af5e8b86 💬 Change wording to reflect more potential error cases
Closes #3133
2019-05-09 14:59:00 +02:00
Gina Häußge 289c3a4d0f 🐛 Fix handling of Empty exception in send loop
Closes #3096
2019-05-09 13:39:56 +02:00
Gina Häußge 4cb67fe72c ☔ Don't allow NaN in generated JSON output on APIs
See also #3022
2019-05-08 17:52:27 +02:00
Gina Häußge b79fc94a4e ☔ Protect against NaN & Inf in GCODE
Also cleanup broken metadata entries that contain invalid json.

Fixes #3022
2019-05-08 17:49:53 +02:00
Gina Häußge fca626a3d6 ✨ Support tags on GCODE script hook
Also add `plugin:<plugin id>` to script parts from plugins.

Implements #3101
2019-05-08 16:55:18 +02:00
Gina Häußge f5a04973c4 🐛 Fix emergency codes not jumping queues
Fixes #3104
2019-05-07 15:10:18 +02:00
Gina Häußge 1c9ff91bae ♻️ Make emergency codes configurable 2019-05-07 15:09:41 +02:00
Gina Häußge e1e521300b 🐛 Only do autologin if not actively logged out
Fixes #3142
2019-05-07 13:11:33 +02:00
Gina Häußge c1e8bc717a 🐛 gcodeviewer: fix layers vanishing on rerender
Fixes #3143
2019-05-07 12:33:19 +02:00
Gina Häußge 22d7392769 🔊 gcodeviewer: Increase logging 2019-05-07 11:09:42 +02:00
Gina Häußge 904e7d2ecd 🐛 gcode viewer: do not invert axes
The axis inversion is only relevant to the control panel (depends on
how the print head is positioned), NOT the rendition of the GCODE.

Fixes #3137
2019-05-03 17:26:55 +02:00
Gina Häußge b3173386ae 🐛 modals: re-add missing minHeight support 2019-05-03 16:44:38 +02:00
Gina Häußge 1e3b8dfb2c Merge pull request #3131 from rfinnie/multiple-events
[Request] Allow subscriptions of multiple events
2019-05-03 16:08:46 +02:00
Gina Häußge 94d172ab67 Merge branch 'maintenance' into multiple-events 2019-05-03 15:57:50 +02:00
Gina Häußge 7dac6ca433 Merge pull request #3126 from jackwilsdon/toggle-search-filtering
Add option for disabling filters on search results
2019-05-03 15:32:51 +02:00
Ryan Finnie 9aeeb5fecc Allow subscriptions of multiple events
events > subscriptions[] > event may be either a string (existing
functionality) or now a list of strings.  If a list, the subscriptions
are treated the same for each event in the list.

To make it possible for command subscriptions to determine which event
was triggered, a {__eventname} substitution has been added.
2019-04-24 10:11:09 -07:00
Gina Häußge 52f65b469d Merge branch 'staging/maintenance' into maintenance 2019-04-24 16:29:20 +02:00
Gina Häußge 0843c0fbc7 📝 Reflect API key changes in docs
Closes #3121
2019-04-24 16:26:10 +02:00
Jack Wilsdon 11607fbc73 Add jackwilsdon to author list 2019-04-20 15:53:55 +01:00
Jack Wilsdon 1521b76090 Add option for disabling filters on search results 2019-04-20 15:24:06 +01:00
Gina Häußge a33a7b4d67 Merge branch 'staging/maintenance' into maintenance 2019-04-11 15:25:12 +02:00
Gina Häußge c00fdbf73b 🔖 staging/maintenance is now 1.3.11rc4.dev 2019-04-11 15:21:39 +02:00
Gina Häußge af32858549 🔖 Preparing release of 1.3.11rc3, part 2 2019-04-11 12:21:24 +02:00
Gina Häußge d1104ddbae 🐛 Fix file list refresh after SD list update 2019-04-11 12:14:59 +02:00
Gina Häußge e2519abbbe ✨ Add setting for exclusive comm port flag
Just in case there are issues with that on some setups as first RC seem
to indicate, we make it toggleable.
2019-04-11 12:14:38 +02:00
Gina Häußge 967b3bbff8 🔖 Preparing release of 1.3.11rc3 2019-04-10 17:38:17 +02:00
Gina Häußge 9721aec32a 🐛 printer safety: Fix for unicode issues
Fixes #3090
2019-04-10 17:15:59 +02:00
Gina Häußge 68952c20bd ⏪ Switch lines read from serial back to bytes
While long term we want to have unicode here, the rest of the code
is not even remotely prepared for handling utf-8 strings as visible in
the large amount of unicode issues visible in sentry.

So for now we go back to byte objects and fix #3091 differently
2019-04-10 17:15:58 +02:00
Gina Häußge 03e328fd13 📝 Fix a documentation issue
Fixes #3117
2019-04-10 17:13:29 +02:00
Gina Häußge 9775d99feb 🔇 error tracking: mute tornado's WebSocketErrors 2019-04-10 12:03:45 +02:00
Gina Häußge bfcff9a1cd 🐛 Fix some potential encoding errors 2019-04-10 12:03:31 +02:00
Gina Häußge 5ca286f4e3 🔇 error tracking: mute ispErrors 2019-04-10 11:39:02 +02:00
Gina Häußge 7dae700215 🐛 sockjs-tornado: Handle websocket errors 2019-04-09 17:32:29 +02:00
Gina Häußge 58806a3d00 🔧 error tracking: update DSNs 2019-04-09 17:22:16 +02:00
Gina Häußge 72cc1afb45 🐛 Refresh connection tab on disconnect
That way we'll hopefully notice vanishing/changed ports.

Potential fix for #3111, waiting for test results from @arhi
2019-04-09 17:00:57 +02:00
Gina Häußge 323131cbc5 ☔ Harden against estimation exceptions 2019-04-09 16:56:17 +02:00
Gina Häußge f389773036 ☔ Make sure rolling window is at least 1
See #3116
2019-04-09 16:56:02 +02:00
Gina Häußge 0a04043922 🐛 Fix potential division by zero
Fixes #3116
2019-04-09 16:55:35 +02:00
Gina Häußge 84fa3b6073 🐛 Don't log empty lines
See also #3115
2019-04-09 11:07:11 +02:00
Gina Häußge d6576306b0 🐛 Add missing rstrip
Fixes #3115
2019-04-09 11:06:04 +02:00
Gina Häußge 8970fb42b1 ✨ error tracking: further filtering 2019-04-08 14:08:57 +02:00
Gina Häußge 55e8cc1118 ☔ more type annotations 2019-04-08 13:05:27 +02:00
Gina Häußge 43e2f79575 🐛 Fix a unicode issue
Fixes #3109
2019-04-08 13:05:02 +02:00
Gina Häußge 132e2cb244 🐛 virtual printer: Fix handling of closed connection
Closes #3114
2019-04-08 12:24:24 +02:00
Gina Häußge de6d1afdd6 ✨ Add flag to ignore incomplete startup
See https://github.com/foosel/OctoPrint/issues/3103#issuecomment-480612935
2019-04-08 12:12:00 +02:00
Gina Häußge 0a1cc68a6b ♻ error tracking: minor restructuring 2019-04-05 18:36:50 +02:00
Gina Häußge f1309dad1d ✨ error tracking: filter all exceptions triggered in plugins
The new extra parameter passed to exception loggers throughout
OctoPrint allows even more aggressive filtering to reduce the noise
further.
2019-04-05 17:48:52 +02:00
Gina Häußge b353c4eee2 ✨ extra logging parameter to add plugin identifier
Will allow to identify logged exceptions originating from calling
plugins, but also log plugin identifiers directly in the log message
if so desired.
2019-04-05 17:47:36 +02:00
Gina Häußge 34c30ed73f 🐛 Fix wrong textual representation of STARTING state
See comment/log files in #3104
2019-04-05 16:23:11 +02:00
Gina Häußge c28faa8032 ☔ SWU: empty restart command == unset 2019-04-05 15:37:25 +02:00
Gina Häußge 8da5bb2d42 🐛 Fix bug in port detection
Closes #3108
2019-04-05 15:19:58 +02:00
Gina Häußge 54c885f1ad ☔ Prevent issues if hash is n/a
Apparently it can happen that no hash is available for an STL file.
See SERVER-TQ in Sentry.

So let's be a bit more careful here.

Closes #3107
2019-04-05 10:24:41 +02:00
Gina Häußge 65fe048ade ☔ error tracking: ignore RequestExceptions
We don't want to get error events every time someone's net connection
goes down or the webcam is misconfigured.
2019-04-05 10:17:12 +02:00
Gina Häußge 7efcf00baf Merge pull request #3106 from hlovdal/explicit_python_version
README: Use explicit python version for virtualenv
2019-04-05 09:47:52 +02:00
Håkon Løvdal a3254466f7 Whitespace fixes 2019-04-05 01:10:30 +02:00
Håkon Løvdal f8dc504773 Add example of using explicit python version 2019-04-05 01:10:30 +02:00
Gina Häußge 3574c2ddf9 🐛 virtual printer: Fix yet another unicode issue
Closes #3105
2019-04-04 19:05:17 +02:00
Gina Häußge 1dc0f1fb31 ☔ Define empty UI_API_KEY to be backwards compatible
Some plugins rely on this to be defined, let's give them some more time
to update.
2019-04-04 18:55:24 +02:00
Gina Häußge 30ddbfd324 Merge branch 'staging/maintenance' into maintenance 2019-04-04 17:12:01 +02:00
Gina Häußge 5c522d86ca Merge remote-tracking branch 'origin/staging/maintenance' into staging/maintenance 2019-04-04 17:09:11 +02:00
Gina Häußge f785c8180b 🔖 staging/maintenance is now 1.3.11rc3.dev 2019-04-04 17:08:33 +02:00
Gina Häußge 18e7d2b72a 🔖 Preparing release of 1.3.11rc2 2019-04-04 14:26:01 +02:00
Gina Häußge 410c3ee5f6 ☔ error tracking: ignore errors from packed_plugins.js 2019-04-04 14:12:19 +02:00
Gina Häußge 48825fd4c2 ⬆ error tracking: update js sentry sdk 2019-04-04 14:11:30 +02:00
Gina Häußge ff9c83ea25 ☔ Don't confuse users with pip's "OMG PY2.7 IS EOL!!1!" message
We know that python 2.7 is about to reach end of life. We are making
preparations for this in the devel branch. We don't need pip going
around and alarming our users about something they cannot solve, and
which pretty much is already solved anyhow.

So we nuke this stupid message present in current pip versions. Hard.

See also #2988
2019-04-04 11:51:16 +02:00
Gina Häußge 2c18a40dcb ⬆ Update bootstrap modal
Fixes #3095
2019-04-01 14:47:42 +02:00
Gina Häußge 0b6dd7e76e 🐛 backup: exclude timelapse_tmp if timelapse is excluded
Fixes #3098
2019-04-01 14:28:40 +02:00
Gina Häußge d68c7bfc67 ☔ More resilience against platform startup issues
Might solve problems like #3100, but that is only a shot in the dark at
this point.
2019-04-01 13:57:29 +02:00
Gina Häußge c879ad27f4 ♻ Turn lines read from serial into unicode
Backported from devel branch.

Should also fix #3091
2019-04-01 13:56:19 +02:00
Gina Häußge d1914824c6 🐛 Don't read returncode on async commands 2019-03-29 17:43:45 +01:00
Gina Häußge 79196eeaf7 🔇 Match up log level 2019-03-29 17:37:02 +01:00
Gina Häußge 6491db730d ☔ Harden against broken configs
See Sentry issue SERVER-BF
2019-03-29 17:22:00 +01:00
Gina Häußge bd07cda205 ✨ error tracking: support ignoring specific exceptions
We are not interested in any SerialExceptions raised in the comm layer
due to people ripping out cables or having otherwise broken comms.
2019-03-29 16:38:15 +01:00
Gina Häußge 9c7ca0ab7a ✏ Add thanks to sentry.io 2019-03-29 16:34:48 +01:00
Gina Häußge c4da5d6764 🔇 Some changes in what gets reported as error 2019-03-29 15:27:16 +01:00
Gina Häußge 47187c233d 🐛 Default value for self._errorValue 2019-03-29 15:08:44 +01:00
Gina Häußge 982ed793d9 📈 error tracking: change DSNs 2019-03-29 14:32:34 +01:00
Gina Häußge 718306073e ♻ error tracking: Restrict what gets tracked
We are only interested in

  * Exceptions that are
  * logged either in octoprint.* or tornado.* and not from third party
    plugins or unhandled

Implements #3094
2019-03-29 14:12:23 +01:00
Gina Häußge df6e94f7a3 🐛 Better validation of tool parameter on /api/printer/tool
Fixes #3092
2019-03-28 20:21:44 +01:00
Gina Häußge 1a2739c640 🐛 Fix /api/printer/tool endpoint
Fixes #3090

Fixes SERVER-24
2019-03-28 19:58:42 +01:00
Gina Häußge 9d318a4031 ☔ More hardening against invalid language packs
See issue SERVER-G in Sentry
2019-03-28 14:44:37 +01:00
Gina Häußge 292d608b97 🐛 Fix missing _chamberTemp definition
Closes #3089
2019-03-28 13:38:33 +01:00
Gina Häußge 2d7cb40633 🐛 Fix for plugin vars that contain unicode
ETag calculation could otherwise fall flat on its face.

Fixes #3088
2019-03-28 13:18:55 +01:00
Gina Häußge ce9315850f 🔖 maintenance is now 1.3.12.dev 2019-03-28 12:25:22 +01:00
Gina Häußge b8dbc627cb 🔖 staging/maintenance is now 1.3.11rc2.dev 2019-03-28 12:23:25 +01:00
Gina Häußge 73df8c2407 🔖 Preparing release of 1.3.11rc1, part 2 2019-03-28 10:54:19 +01:00
Gina Häußge 55ec8b1809 🐛 Partial revert of always sending SettingsUpdated event
It was causing a ton of issues with backend code using `Settings.save`
to persist changes outside of REST API calls, triggering configuration
update dialogs in the frontend way too often and when not needed.

Added a flag instead to cause the `save` method to trigger an event and
setting that to False by default. Settings REST API uses it, other
callees in e.g. plugin code will be able to as well in the future if
necessary.

It would be cleaner to always trigger this event and adjust calling code
and frontend code to compensate, but with third party plugins out there
this is not going to happen reliably so we go this route.
2019-03-28 10:52:15 +01:00
Gina Häußge 33eba705bf 🐛 invalid API key = no API key 2019-03-27 17:05:30 +01:00
Gina Häußge 9ec3a6ae7a ➖ Remove python-dateutil dependency
It's no longer installable from source under OctoPi 0.14 due to an
unpinned setup_requires dependency on setuptools_scm, and since we still
have to support that installation scenario that is a problem. Thankfully
it's only used in the plugin manager for parsing the notice date, and
we can just use datetime.strptime for that.
2019-03-27 14:34:13 +01:00
Gina Häußge ec2ba63425 🔖 Preparing release of 1.3.11rc1 2019-03-26 14:58:45 +01:00
Gina Häußge 6097222b7b ♻ Remove onWizardPreventSettingsRefreshDialog
Makes the whole wizard stuff less complex.
2019-03-26 14:46:06 +01:00
Gina Häußge 40396847e3 ⬆ werkzeug.contrib.cache is now cachelib 2019-03-26 10:12:58 +01:00
Gina Häußge a296574c70 🐛 Fix handling of invalid API keys 2019-03-25 11:31:56 +01:00
Gina Häußge 547962f4bc 🐛 Fix login via Authorization header 2019-03-25 11:31:41 +01:00
Gina Häußge 1d2ceefb72 🐛 appkeys: Fix in case of disabled access control
Closes #3071
2019-03-22 19:45:22 +01:00
Gina Häußge 3d4422021e ⬆ Updated various dependencies
Closes #3074
2019-03-22 18:52:16 +01:00
Gina Häußge 3b5c11a2bb ✏ Typo 2019-03-20 14:28:35 +01:00
Gina Häußge 4908d94c97 🐛 Fix initialization of temperature graph
Was broken by #3072 & followup work
2019-03-20 13:09:58 +01:00
Gina Häußge 17a7e508c3 ♻ Remove UI_API_KEY & API disabling
With the inclusion of the ForceLogin plugin that doesn't serve a real
purpose anymore in most cases, and it was only ever more of a rate
limiting feature than an actual security measure anyhow. Plus it lead to
a ton of false security alarms along the lines of "OMG UI_API_KEY IN THE
SOCKET HANDSHAKE, PWNED!!1!".

On stock installations, the behaviour will be unchanged since the
ForceLogin plugin prevents any kind of API access without authentication
that isn't the login request itself, including access to blueprint
plugin endpoints that do not specify that they are unprotected.

If a user decides to disable the ForceLogin plugin but keep access
control enabled, anonymous API access will now be possible without API
key or the need to fetch the current UI API Key from the server via the
websocket or the source code of the index page. This is a change
compared to earlier behaviour, but with a very limited impact as as
mentioned the UI API Key was so far also easily obtainable either via
the websocket or by parsing a fresh copy of the HTML page.

If the user decides to disable access control, there's no change
compared to previous behaviour.

Disabling the API - which was so far the only real use case for having
the UI API Key in the first place apart from basic rate limiting - has
also been removed. Allowing this only made things horribly complex as
the default frontend fully depends on the API's availability. Users
who do not wish third parties to have access to the API should
simply leave the ForceLogin plugin enabled.
2019-03-19 17:14:19 +01:00
Gina Häußge 0069c94d35 🐛 forcelogin: add favicon meta tags 2019-03-19 16:55:02 +01:00
Gina Häußge 99e7824913 🐛 Fix some outdated links to the forum 2019-03-19 15:00:10 +01:00
Gina Häußge ceade46dd7 🐛 Fix caching headers on main view
Clients/browsers should be instructed to always revalidate against the
server in order to prevent any kind of old content to be served.

See https://community.octoprint.org/t/cant-login-to-the-web-interface/7908/17?u=foosel
2019-03-19 14:48:45 +01:00
Gina Häußge bc66d29d02 🐛 Fix reporting back of active port & baudrate
Closes #2859
2019-03-19 13:24:00 +01:00
Gina Häußge 9ea1074b03 ✨ Process watched folder on startup
Implements #2462
2019-03-19 11:52:32 +01:00
Gina Häußge 6e069211cc Merge remote-tracking branch 'origin/maintenance' into maintenance 2019-03-18 17:06:26 +01:00
Gina Häußge 8d3befb01f ✨ Support for heated chamber fw capabilities
Chamber temperatures reported via M105 will only be parsed if the
fw reports chamber capabilities (through Cap:CHAMBER_TEMPERATURE:1) or
the currently selected printer profile has a heated chamber configured.
This is to avoid incompatibility issues with firmware variants that
might already use the C parameter for something else (which might be the
case since we don't have a reliable well defined standard that people
need to adhere to...)

Chamber temperature commands M141 and M191 will only be allowed to be
sent if the selected printer profile has a heated chamber configured.
This mirrors the behaviour for the bed temperature commands M140 and
M190 and heated bed configuration.

Display of chamber data in the graph will only happen if the printer
profile has a heated chamber configured.

Implements one workflow behind #321
2019-03-18 16:51:12 +01:00
Gina Häußge 42a6cab92e Merge pull request #3072 from Fabi0San/maint/temperature
Hides temperature tab if the machine has no heated bed nor extruders.
2019-03-18 12:57:35 +01:00
Gina Häußge 083e424529 ✏️ Fix a typo in the german translation
Closes #3061
2019-03-17 13:27:16 +01:00
Gina Häußge d5eefcd1a5 🐛 virtual: fix homing 2019-03-16 09:40:55 +01:00
Gina Häußge c1670d03c8 🐛 virtual: fix parsing of negative coordinates
Closes #3080
2019-03-16 09:29:04 +01:00
Gina Häußge b2637eb06a 🐛 Fix refactoring error 2019-03-13 15:09:27 +01:00
Gina Häußge 47179f2956 ☔ forcelogin: Never handle the UI if ACL is disabled
The following `passive_login` should always succeed if ACL is disabled
and hence this *should* not have caused issues, but considering

https://community.octoprint.org/t/cant-login-to-the-web-interface/7908/3

it might have after all, so better be safe than sorry here.
2019-03-13 15:09:02 +01:00
Gina Häußge d64b8512ab 💄 PGMR, SWU: Use scrollables instead of pagination 2019-03-12 17:02:14 +01:00
Gina Häußge 602ec5c495 🐛 Only use page size from local storage if configured
Should be a conscious decision by whoever uses ItemListHelper since
otherwise the size can never be changed again to a new default.

Follow-up to #2620
2019-03-12 16:52:17 +01:00
Gina Häußge a63ee9355e 🎨 Fix some linter warnings 2019-03-12 16:47:55 +01:00
Gina Häußge e44ae7a024 💚 Fix broken unit test
Who broke the test? That's right... me 😕
2019-03-12 16:26:14 +01:00
Gina Häußge 76ad332287 ♻ Use monotonic_time for relative times
Timeouts, durations and such shouldn't depend on the non-monotonic
system clock but instead use a monotonic time source.
2019-03-12 16:03:58 +01:00
Gina Häußge 93ab7bb089 Merge branch 'pr/3073' into maintenance 2019-03-12 13:57:08 +01:00
Gina Häußge b4e7e73e29 ♻ Use length of tool array for visibility
No need for an additional variable to keep in sync.
2019-03-12 13:56:53 +01:00
Gina Häußge 92ad53a9ec ♻ Use ko computed for visibility state 2019-03-12 13:42:45 +01:00
Gina Häußge 21c9c51858 ♻ Backport some more pieces from devel 2019-03-12 13:40:58 +01:00
Gina Häußge 38a321e175 ✨ Add configurable list of blocked and pausing commands
Instead of a boolean option to block sending of M0 *and* M1 and
hardcoding them and M25 to pause an ongoing print, we now have two lists
for blocked commands and pausing commands respectively.

Blocked by default: M0 and M1.

Pausing by default: M0, M1 and M25.

Implements #2970
2019-03-12 12:16:23 +01:00
Gina Häußge 32050c31ae 🐛 Only process pause if we aren't already pausing
Also don't process a pause if we are cancelling. "isPrinting" is too
broad here, so we use explicit states.
2019-03-12 12:12:24 +01:00
Gina Häußge f020fc1bc6 ✨ Add ipv4- and ipv6-only command line flags
-4 or --ipv4 will behave as if "--host 0.0.0.0" (or any other specific
v4 address) was supplied and only bind the server socket to v4. It will
be ignored if a v6 address is set to bind to.

-6 or --ipv6 will only bind the server socket to v6 instead of dual
stack on both v4 and v6. It will be ignored if a v4 address is set to
bind to.

Implements #2904
2019-03-11 17:21:28 +01:00
Gina Häußge a1e8694073 🐛 Don't change to PRINTING state on resume if not RESUMING
See #2955
2019-03-11 16:02:20 +01:00
Gina Häußge e748b52098 🐛 Don't change to PAUSED state if not PAUSING
Fixes #2955
2019-03-11 15:34:11 +01:00
Gina Häußge 8668c6200a ✨ Decorator for timing methods
Probably mostly helpful during development...
2019-03-06 13:53:53 +01:00
Gina Häußge e01f391b30 ⚡ More intelligent use of copy & deepcopy
Improves performance of file manipulation, especially in cases with a
lot of files in the folder, without the added complexity of fully
decoupling metadata file serialization from general processing.

Better fix for #3057
2019-03-06 13:44:45 +01:00
Gina Häußge 92618362e1 💚 Forgot to adjust the tests for d071684 2019-03-05 17:01:10 +01:00
Gina Häußge d071684d41 ♻ Remove old metadata.yaml files
Were deprecated and supposed to be removed with 1.3.10, we'll do it with
1.3.11.
2019-03-05 16:53:30 +01:00
Gina Häußge 7d0bd6a339 ☔ Remove stale entries from metadata
If a file no longer exists on disk for whatever reason it also doesn't
need to be kept in metadata.json.

See also #3057

Cherry-picked from 15d3b2ca
2019-03-05 16:20:13 +01:00
Fabi0San 1b5a654a2d Hide Tool section in Control for machines with no extruders. Such as Lasers. 2019-03-04 19:00:08 -08:00
FabioSan f0ee7f343e Hides temperature tab if the machine has no heated bed nor extruders. 2019-03-04 18:34:55 -08:00
Gina Häußge 3e16f0901a Merge remote-tracking branch 'origin/maintenance' into maintenance 2019-03-01 11:21:01 +01:00
Gina Häußge 8866ed716d ☔ Better resilience against invalid SD status reports 2019-03-01 11:20:45 +01:00
Gina Häußge 0f157d3747 ♻ Load bundled plugins under octoprint.plugins.*
Makes more sense than putting them into sys.modules as <identifier>,
which also can cause conflicts (e.g. in the case of octoprint.plugins
.logging which then suddenly gets found instead of the built-in crucial
logging module).
2019-02-28 16:37:09 +01:00
Gina Häußge fdb4e75241 Merge pull request #3066 from fieldOfView/fix_docs_job_state
Add missing documentation about state in `jobs` endpoint
2019-02-28 12:34:35 +01:00
Gina Häußge 4dbb24ecd7 📝 state is not a sub data model but a string 2019-02-28 12:26:25 +01:00
fieldOfView a15e2de251 Fix datamodel structure 2019-02-28 12:17:35 +01:00
fieldOfView c652bed871 Add missing documentation about state in jobs endpoint 2019-02-28 11:40:22 +01:00
Gina Häußge 253a38c32d ♻ gcode => printables 2019-02-26 15:31:22 +01:00
Gina Häußge e08becbb4c Merge pull request #3055 from AndyQ/show_current_layer
Added ability to preview the current layer to be drawn
2019-02-26 13:54:43 +01:00
Gina Häußge 09a043b393 🐛 tracking: fix handling of missing print time
See also #3063
2019-02-26 13:50:35 +01:00
Gina Häußge 0c4f4383e3 ♻ Introduce type hints
For now we'll only use them to have our IDEs scream at us...
2019-02-22 11:44:45 +01:00
Gina Häußge 45aa26f13e ♻ Add central methods for getting python version 2019-02-20 15:32:07 +01:00
Gina Häußge 4a64bc6023 Merge branch 'improve/moreFlexiblePrinterSafetyChecks' into maintenance
# Conflicts:
#	src/octoprint/plugins/printer_safety_check/__init__.py
2019-02-20 14:41:09 +01:00
Gina Häußge 8e6773d19f 🐛 printer_safety_check: Fix some issues with new implementation 2019-02-20 14:39:21 +01:00
Gina Häußge dfcddea581 🎨 Fix some whitespace issues 2019-02-19 13:28:15 +01:00
Gina Häußge ff59e275bf Merge branch 'improve/errortracking_plugin' into maintenance 2019-02-19 13:11:38 +01:00
Gina Häußge 0f8f1ec8e0 ✨ Finalize first version of errortracking plugin
Also add docs for that & the Anonymous Usage Tracking plugin.
2019-02-19 13:11:25 +01:00
AndyQ 0e302d440f Added ability to preview the current layer to be drawn
If selected, the current layer is drawn at 30% opacity and then the progress is drawn over the top at 100%
Added additional checkbox on GCodeView page to include current layer as preview
2019-02-18 11:28:41 +01:00
Gina Häußge 980616519d Merge pull request #3054 from rgriebl/master
Fix python version detection on Debian testing/unstable
2019-02-18 10:46:56 +01:00
Gina Häußge 434751634f Merge pull request #3053 from AndyQ/MultipleFiliament_fix
Fixed error in GCode viewer where multiple filaments available (e.g. …
2019-02-18 10:44:33 +01:00
Robert Griebl c35708a422 Fix python version detection on Debian testing/unstable
The current 2.7 Python binary on Debian returns "2.7.15+" as its version, which
is not PEP440 compliant. Tthere is no feedback at all from Debian maintainers
regarding the bug report as of now:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914072

This patch makes sure to drop any trailing '+' character in a version string.

Fixes #3049
2019-02-18 00:37:08 +01:00
AndyQ 64464a38ce Fixed error in GCode viewer where multiple filaments available (e.g. using Prusa MMU2), but only using a filament that isn't the first one
e.g. filament 4
2019-02-17 11:57:13 +00:00
Gina Häußge 0e482151fd Merge pull request #3051 from CapnBry/unfuzzy-timetips
Always show unfuzzy times for total print time and time left in tooltip
2019-02-14 15:59:34 +01:00
Gina Häußge c5bf58e1cc ♻️ == -> === 2019-02-14 15:56:09 +01:00
Bryan Mayland 38b7be0142 Fix whitespace 2019-02-14 14:52:24 +00:00
Bryan Mayland 28a515ba6a Always show unfuzzy times for total print time and time left in tooltip 2019-02-14 14:41:01 +00:00
Gina Häußge 38868303da 🐛 Fix tests 2019-02-13 14:55:48 +01:00
Gina Häußge fe65f18f78 💥 Unbundling the cura plugin
It lives on as curalegacy at

  https://github.com/OctoPrint/OctoPrint-CuraLegacy

which will be added to the plugin repository once the first RC of 1.3.11
lands.

Due to this change, the general handling of STL files has also changed
slightly. They will no longer be supported by upload out of the box
unless a SlicerPlugin is available (which will now by default extend the
extension tree with STL files, unless overwritten). As a consequence of
that the file type filters in the file list have also been adjusted to
only show up if there are additional file types to filter for.
2019-02-13 13:41:44 +01:00
Gina Häußge e1e302f93d ✨ Allow slicing while printing on multi core systems
If we don't know the number of cores or the number is less than two we
the old behaviour still applies.

Implements #1938
2019-02-13 12:06:32 +01:00
Gina Häußge 1cea388481 🐛 Fix _version.py generation 2019-02-12 13:53:20 +01:00
Gina Häußge 14a3d903d7 Merge remote-tracking branch 'origin/maintenance' into maintenance 2019-02-12 13:46:35 +01:00
Gina Häußge 34d6a6f8ce ⬆ Update versioneer & generated file 2019-02-12 12:29:00 +01:00
Gina Häußge 6a03532ea7 ♻ Backport py3 compat for versioneer 2019-02-12 12:25:41 +01:00
Gina Häußge 649bfdbe37 Merge branch 'master' into maintenance 2019-02-12 12:18:31 +01:00
Gina Häußge 8ce2290d63 📝 Improve docs for connection API
See #3043
2019-02-12 12:07:55 +01:00
Gina Häußge b1413abfff Merge pull request #3045 from akraus53/patch-1
I fixed a few typos in the German translation
2019-02-12 12:02:42 +01:00
Alexander Kraus 772914f38c Fixed a few typos
I hope this is the correct Branch....
2019-02-11 22:54:04 +01:00
Gina Häußge c6b4eee437 🐛 treat pausing as paused for resume handling
See MarlinFirmware/Marlin#13039 and #2955
2019-02-11 18:21:32 +01:00
Gina Häußge e67f72ce3d 🐛 paused action must not trigger *any* local processing
That includes sending M400 and M114 to capture the pause position.

See MarlinFirmware/Marlin#13039
2019-02-11 18:19:47 +01:00
Gina Häußge de6da3f360 Merge branch 'master' into maintenance 2019-02-11 10:08:54 +01:00
Gina Häußge b744c341eb 💬 discourse.octoprint.org => community.octoprint.org 2019-02-11 09:58:39 +01:00
Gina Häußge 697af69e97 Merge branch 'master' into maintenance 2019-02-08 17:06:59 +01:00
Gina Häußge 601451a3f1 ✨ Setting to disable fuzzy estimates
Implements #3040
2019-02-08 16:44:25 +01:00
Gina Häußge 81d523b73d ♻ Backport to_str -> to_bytes from devel
Add unit tests.
2019-02-08 14:39:07 +01:00
Gina Häußge deacd9c188 Merge pull request #3041 from Microtome/add-klipper-to-firmware-autodetect
Add support for klipper in firmware autodetect
2019-02-08 14:02:37 +01:00
Daniel Joyce 6e0024149e Add support for klipper firmware autodetect 2019-02-07 07:36:11 -08:00
Gina Häußge dd3b318327 Merge branch 'pr/3036' into maintenance 2019-02-07 12:07:13 +01:00
Gina Häußge 069e83c63c Merge pull request #3039 from Microtome/improve-backup-filename
Improve backup filename, fix for #3030
2019-02-07 11:43:02 +01:00
Daniel Joyce 0cf345f29b Fix bug where if no plugins are installed, restore fails
* When no plugins are installed, backup does not create a
  plugin_list.json file.
* Restore then fails when it tries to read the missing file.
* Add check to ensure plugin_list.json exists before restoring
  from backup.
2019-02-06 21:06:19 -08:00
Daniel Joyce 0fda153d60 Provide a better name for backup files, use utility function for consistent name 2019-02-06 20:45:07 -08:00
Daniel Joyce 61ac8430d6 Added self to Authors file 2019-02-05 08:46:58 -08:00
Daniel Joyce 6b4dfcb960 Support opening serial port in exclusive mode.
* Slight cleanup and refactoring
2019-02-05 08:46:44 -08:00
Gina Häußge 61431c0df3 Merge remote-tracking branch 'origin/master' 2019-02-04 18:48:10 +01:00
Gina Häußge cc0b63cbb9 📝 Fix a formatting issue
No events are about to be removed in 1.4.0, only the payload fields
marked as deprecated. And for some reason ReST doesn't appear to allow
including that piece of information within the `deprecated` directive,
so now we have a slightly different way of expressing it...
2019-02-04 18:40:57 +01:00
Gina Häußge 020403dc54 💬 Correct typo in german translation
Closes #3029
2019-02-04 14:43:12 +01:00
Gina Häußge 21a82bbdb6 🐛 Fix enableWebcam render kwarg
Was using the wrong setting name.
2019-02-01 15:10:28 +01:00
Gina Häußge 727fd12939 🚸 CORS change needs restart to take effect 2019-02-01 10:55:24 +01:00
Gina Häußge 100fe5f290 🐛 Allow disabling CORS headers on SockJS endpoints
Fixes 2) of #3024
2019-02-01 10:40:37 +01:00
Gina Häußge 1acf69cb6d 🐛 Add CORS headers to tornado endpoints (if enabled)
Fixes 1) of #3024
2019-01-31 17:38:10 +01:00
Gina Häußge 3815c340a8 ☔ Protect against corrupt language packs 2019-01-31 17:07:10 +01:00
Gina Häußge c36a378b60 Merge branch 'hotfix/documentation_error' into maintenance 2019-01-30 15:08:41 +01:00
Gina Häußge 9a7ebde76b 📝 Fix documentation for firmware info & capability plugin hooks 2019-01-30 15:02:32 +01:00
Gina Häußge c23bafd788 ☔ Protect against callback errors in decorators on default view 2019-01-30 14:36:53 +01:00
Gina Häußge 1aea92a5f1 ☔ Protect against invalid preemptive cache config data
Fixes #3023
2019-01-30 14:36:52 +01:00
Gina Häußge fb38c396e8 Merge pull request #3010 from HarlemSquirrel/maintenance-disk-usage
Add system usage API endpoint
2019-01-28 18:33:38 +01:00
Gina Häußge 904b3c6cf5 🔧 Adjust default regex of temperature terminal filter (2nd try)
Should no longer match lines like

    FIRMWARE_NAME:Marlin 1.1.7-C2 (Github) SOURCE_CODE_URL:https://github.com/Robo3D/Marlin-C2 PROTOCOL_VERSION:C2 MACHINE_TYPE:RoboC2 EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff EMERGENCY_CODES:M108,M112,M410

but should pass unit tests.

Fixes #2945
2019-01-28 18:20:03 +01:00
Gina Häußge 7f2b79bcd5 ⏪ Revert "🔧 Adjust default regex of temperature terminal filter"
This reverts commit dd692d6
2019-01-28 18:02:46 +01:00
Gina Häußge dd692d6f30 🔧 Adjust default regex of temperature terminal filter
Should no longer match lines like

    FIRMWARE_NAME:Marlin 1.1.7-C2 (Github) SOURCE_CODE_URL:https://github.com/Robo3D/Marlin-C2 PROTOCOL_VERSION:C2 MACHINE_TYPE:RoboC2 EXTRUDER_COUNT:1 UUID:cede2a2f-41a2-4748-9b12-c55c62f367ff EMERGENCY_CODES:M108,M112,M410

Fixes #2945
2019-01-28 17:56:10 +01:00
Gina Häußge 5d021d76a0 ✨ action_command_prompt: PROMPT_SUPPORT capability support
Allow configuration of whether to enable the plugin if firmware support
is detected, always or never. Handle PROMPT_SUPPORT capability report
accordingly.

See MarlinFirmware/Marlin#12982
2019-01-28 17:41:01 +01:00
Gina Häußge 2db230549e ✨ action_command_prompt: signal prompt support on connect (default off)
Note: Has to be enabled manually for now as long as we cannot detect
that the firmware indeed has support for M876.

See MarlinFirmware/Marlin#12982
2019-01-28 14:50:40 +01:00
Gina Häußge 01484b630a ✨ action_command_prompt: EMERGENCY_PARSER support (default off)
Note: Has to be enabled manually for now as long as we cannot detect
that the firmware indeed has support for M876 and hence has it as part
of the EMERGENCY_PARSER.

See MarlinFirmware/Marlin#12982
2019-01-28 14:32:10 +01:00
Gina Häußge d8088887e1 🐛 Fix bug introduced in bd58138acf 2019-01-28 13:45:09 +01:00
Gina Häußge 379411cea7 🔧 action_command_prompt: M876 as default command
See MarlinFirmware/Marlin#12982
2019-01-28 13:10:00 +01:00
Gina Häußge 5e953c12a1 💬 Rewording 2019-01-28 13:07:34 +01:00
Gina Häußge bd58138acf 🎨 Refactored for better code reuse 2019-01-28 13:05:27 +01:00
Gina Häußge 44b4c6cc40 🐛 sleep => time.sleep 2019-01-28 13:00:26 +01:00
Gina Häußge f3f1061f9d ❇️ Configurable terminal log size in comm layer
See https://discourse.octoprint.org/t/logging-terminal-information-on-failed-print/7047/3?u=foosel
2019-01-28 12:03:16 +01:00
Gina Häußge 68410cb3d7 🐛 Fix an issue with plugin sorting
If we just uninstalled a plugin there might not be a PluginInfo object.
In that case assume the plugin is not bundled (not False = True)
2019-01-25 16:14:45 +01:00
Gina Häußge db009e3ba2 🐛 backup: do not translate plugin name
Only translate it at template level, not before.

Fixes #3012
2019-01-25 15:48:35 +01:00
Gina Häußge 09d3c44161 🐛 unicode-ify octoprint.plugin.core
Fixes #3012
2019-01-25 15:39:31 +01:00
Gina Häußge c2814651f9 errortracking: keep disabled on unreleased versions
We don't want to track errors during development, unless overridden
via config flag.
2019-01-23 12:23:38 +01:00
Gina Häußge eb46815789 Slight refactoring for improved testability & fix tests 2019-01-22 15:40:08 +01:00
Kevin McCormack 449fa0c7ec WIP Update test_system 2019-01-21 12:49:57 -05:00
Kevin McCormack 0489dfeaee [WIP] Add disk usage API endpoint 2019-01-20 10:02:13 -05:00
Gina Häußge a9b395dac8 ✨ Dedicated settings for webcam/timelapse support
Implements #2974
2019-01-18 16:58:34 +01:00
Gina Häußge 44a40b8297 errortracking: fix typo -_- 2019-01-18 14:36:46 +01:00
Gina Häußge 49728f18c6 errortracking: add missing dependency 2019-01-18 14:27:26 +01:00
Gina Häußge f6ec0bca6e errortracking: first throw at an implementation
Currently uses a sponsored sentry instance on sentry.io. Error tracking
is disabled by default and currently still has to be enabled through
manual configuration in config.yaml (plugins.errortracking.enabled=true)
2019-01-18 14:13:26 +01:00
Gina Häußge 6a069de240 Put generic templates after javascript assets
That way it's possible for plugins to reference already loaded libraries
or constants in any injected generic templates.
2019-01-18 14:10:47 +01:00
Gina Häußge 2287c65784 forcelogin: ui_render sorting key of 0
If third party UIPlugin want to override the forcelogin plugin, they'll
need to return a negative sorting key.
2019-01-17 17:55:24 +01:00
Gina Häußge 3b26a2f7d2 Take bundle status into account for plugin sorting 2019-01-17 17:54:24 +01:00
Gina Häußge 18ffdcff6b forcelogin: Accept auth via apikey & auth headers
So far we only checked for keys or auth headers on the API, the plugin
so far only checked if there was an existing cookie via a passive login.

Now it will try to login the user from any provided api keys or
authorization headers as well and only fall back to the passive login if
that doesn't succeed. A call to the frontend with either will thus not
trigger the login dialog.

See #2997
2019-01-17 17:33:00 +01:00
Gina Häußge faab946aeb Add missing , 🤦‍♀️ 2019-01-17 15:34:57 +01:00
Gina Häußge a48e069aa6 Fix race condition on start of SD print
If an M27 to query SD status came after the change of state to printing
but before the M24 to actually start the print on the printer's side the
firmware would report "Not SD printing" and OctoPrint would consequently
cancel the just start job right away.

This patch introduces a new "Starting" state that will be active while
preparing a print job (in case of SD: selecting the file, setting file
position & finally starting the print). The comm layer treats as
nearly identically to the Printing state, the only difference is in the
treatment of received "not sd printing" messages which will be ignored
while still Starting.

Additionally this patch introduces a "two strikes rule" for "not sd
printing" messages (which can be configured to be another number of
strikes). Only if OctoPrint receives two consecutive "not sd printing"
messages from the printer will it actually cancel the printer. This is
to work around a potential (albeit very very unlikely) race condition
that still exists even with the starting state.

Fixes #3001
2019-01-17 13:16:07 +01:00
Gina Häußge d4d5bed514 Fix broken sdcard upload success handling
Spotted by @devildant, thanks!

Closes #3005
2019-01-17 10:49:48 +01:00
Gina Häußge 97f84f120c Improve inline docs for serial.disconnectOnErrors behaviour
See #3002
2019-01-16 19:17:10 +01:00
Gina Häußge cdc69ea93c tracking: add elapsed time to cancelled tracking event 2019-01-16 18:50:51 +01:00
Gina Häußge 467dd344cf docs: document time field in PrintCancelled payload 2019-01-16 18:48:53 +01:00
Gina Häußge 6b9c9f47da Don't send reason field in PrintCancelled event payload 2019-01-16 18:47:40 +01:00
Gina Häußge b7f17531d2 tracking: fix tracking not starting fully during runtime
We didn't start the ping thread and also not the throttle state monitor
if switched on during run time.
2019-01-16 18:38:47 +01:00
Gina Häußge 987379d6e7 Merge branch 'maintenance' into pr/2968
# Conflicts:
#	src/octoprint/plugins/tracking/__init__.py
2019-01-16 18:34:30 +01:00
Gina Häußge 62b1d91901 tracking: refactored individual enable check
Way less repetition this way.
2019-01-16 18:33:41 +01:00
Gina Häußge 7cb5013b08 tracking: always generate a uuid on startup
But just in case still check if it's set before doing anything with it.
2019-01-16 18:29:49 +01:00
Gina Häußge 06a3baa588 Merge branch 'maintenance' into pr/2900 2019-01-16 17:52:06 +01:00
Gina Häußge 07934d26eb Refactored some things and added more docs
There was still some redundancy due to how SD upload so far was
implemented. Things are now better reusable from hooks.

Also fixed the problem that OctoPrint would *always* use the first hook,
whether it actually handled the upload or not.
2019-01-16 17:51:53 +01:00
Gina Häußge 3ae97a3e13 Add user & job owner to print job events
Adds print job owner (= user who selected/started a job) and user who
started/paused/resumed/cancelled a job to the print job events as
applicable.

Also added logging of print job events to octoprint.log with this
information.

Plugins can use the event data for further logging or tracking.

Implements #2982
2019-01-16 14:04:16 +01:00
Gina Häußge 5f22e68985 Add clear button to files search
I would have preferred it to just depend on the default styling of
search type inputs in browsers, which at least on Webkit and IE will add
a clear button automatically, but Firefox doesn't add one and the
corresponding ticket [1] also doesn't look like that will change soon.

So a custom implementation it is. Hooray.

Implements #2983

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=558594
2019-01-16 12:01:03 +01:00
Gina Häußge df1dc17c51 Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance 2019-01-16 10:29:30 +01:00
Gina Häußge 71aa405b26 Merge pull request #3004 from gloomyandy/pr_write_timeout
Use non blocking I/O for writes to implement write timeout (take 2)
2019-01-16 10:29:02 +01:00
Gina Häußge 2d2986922d Merge pull request #2986 from tedder/responsive_login_page
make login page responsive
2019-01-16 10:27:59 +01:00
Andy Shaw 7b5dbef166 Use non blocking I/O for writes to implement write timeout
Currently write timeouts are not really implemented (as they are set to 10000 seconds). The current code also has the unwanted side effect of casuing the use of a select call (in the Linux PySerial library) even when a write does not need to block. This call to select can in some odd cases cause the write to block for the duration of the set timeout which in turn triggers a transmission error. See issue https://github.com/foosel/OctoPrint/issues/2996

This change addresses both issues by allowing the use of the existing write retry code to handle timeouts and by using non-blocking write mode to avoid the use of select.
2019-01-15 19:33:51 +00:00
Gina Häußge da61a49bd8 Forgot something 2019-01-15 17:28:13 +01:00
Gina Häußge 002802bb20 Deprecate appkey API in favor of Application Keys Plugin
Slated to be removed in 1.4.0. AFAIK nobody used it anyhow.
2019-01-15 17:25:58 +01:00
Gina Häußge 45b59494ca Add new hook too allow plugins to register custom events
Implements #2965
2019-01-15 16:54:50 +01:00
Gina Häußge 83530ec7b9 Logging: deletion confirmation & bulk delete
Implements #2962
2019-01-15 15:09:42 +01:00
Gina Häußge 918b70185e Set max-height on PNotify notifications
Fixes #2959
2019-01-15 14:51:57 +01:00
Gina Häußge 6aa89b77dc autologin: also check against v6 representation of v4 networks
See #2976
2019-01-14 12:03:53 +01:00
Gina Häußge 1679b45cd6 Merge pull request #2978 from agrif/fix/plugin-module-names
Use module name when loading plugins from entry points.
2019-01-11 15:11:06 +01:00
Gina Häußge 4728a1a5a9 Merge pull request #2993 from hgross/fix/restore-on-docker-volumes
Fix #2992 (restore mechanism on docker volumes)
2019-01-11 14:54:45 +01:00
Gina Häußge c35a387520 Merge pull request #2973 from melgish/bugfix/2971
use jQuery for checked state.
2019-01-11 14:53:01 +01:00
Gina Häußge d7aae66886 Add --disable-pip-version-check to pip calls
Users get too confused by the warning the lack of it generates on plugin
installs/uninstalls and updates of any kind through pip. An FAQ entry
on that matter hasn't helped, so we are now pulling out the nuclear
option to reduce support overhead.

Implements #2988
2019-01-11 14:23:48 +01:00
Henning Groß 67ab9d577a Merge branch 'maintenance' into fix/restore-on-docker-volumes 2019-01-08 10:58:19 +01:00
Henning Gross 10d045d743 Added @hgross to AUTHORS.md 2019-01-07 22:25:29 +01:00
Henning Gross 44818993ff #2992 use shutil.move instead of os.rename 2019-01-07 21:49:21 +01:00
tedder 970b9c3384 make login page responsive
with responsive plugins like TouchUI, all of the pages render on mobile just fine.. except the login page. I was tired of scrolling much wider than my phone's display to make it show up, so I did some investigation. Turns out it was just missing the meta viewport.
2019-01-02 19:53:21 -08:00
Aaron Griffith 89f94be96a Use module name when loading plugins from entry points. 2018-12-29 21:52:11 -05:00
Nicholas J. Fiorello Jr 52cfd93301 use jQuery for checked state. 2018-12-24 18:11:47 -05:00
tedder 2a8d103dc6 handle missing uuid at sha time
Even if a user doesn't have a uuid at startup, they might enable tracking later and .. then a uuid isn't created until the next startup. For this reason and others, we shouldn't pass None to sha.update. Also, by adding a 'uuid missing' string to the log post, we can now track how many instances are missing a uuid for some reason. (though these may show now as a uuid of 'None').
2018-12-22 14:47:52 -08:00
Gina Häußge d452051c0a Add systemd file
As discussed in #1716
2018-12-19 14:47:52 +01:00
Gina Häußge 99b32fc6c3 Merge remote-tracking branch 'origin/maintenance' into maintenance 2018-12-19 13:37:51 +01:00
Gina Häußge 4e9437114b Change wording & exception type 2018-12-19 13:35:18 +01:00
Connor Wolf 52c7321c78 Handle unsupported version at runtime.
If you have an ancient setuptools, 4a36ddb3aa
won't successfully prevent installing. These changes will at least give a sane error,
rather then  just barfing on random syntax errors due to the `unicode` type not
being present in py3k.

Cherry picked from 2f20f2d
2018-12-19 13:34:37 +01:00
Gina Häußge ef94646083 printer_safety: Added version restriction to anycubic detection
Had to refactor check system to make this possible. Checks are now
implemented in classes that allow to track state.
2018-12-19 13:17:45 +01:00
Unknown 37f3396be3 try fix default function 2018-12-18 19:32:31 +01:00
Unknown f8f461b804 add callback for on success/error for hook sdcopy 2018-12-18 19:07:15 +01:00
Unknown 5396daa7f6 move default fuction to local fuction + minor fix 2018-12-18 18:47:16 +01:00
Gina Häußge bb51dc23fc Merge pull request #2960 from jubaleth/fix/ExceptionMessageCorrection
Exception message correction
2018-12-18 11:06:35 +01:00
Jubaleth 2733838574 Corrected plugin manager failure exception message 2018-12-17 18:57:22 +01:00
Gina Häußge a23d92158b tracking: Track uptime of OctoPrint in ping event
That will give us an idea if the current hypothesis that quite a number
of people are shutting down their instance at night is correct or not,
which in turn will inform future startup optimizations.
2018-12-17 17:47:22 +01:00
Gina Häußge 99225244f1 Add full version string to API 2018-12-17 14:20:42 +01:00
Gina Häußge e30f1b9f82 Add "::1/128" to localNetworks for auto login
See BillyBlaze/OctoPrint-TouchUI#266
2018-12-17 12:29:19 +01:00
Unknown 054bbead72 clean doc + add default function + reduce parameter 2018-12-13 21:28:49 +01:00
Unknown 30294e9009 replace tab by space 2018-12-13 18:39:29 +01:00
Gina Häußge bf5bc14c87 backup: fix needed space calculation
It wasn't taking excludes into account. Now its calculation mirrors the
zip file creation.
2018-12-13 16:29:22 +01:00
Gina Häußge f6dd13af7a tracking: add printer safety warnings to tracking
We want to get an idea how many people are running unsafe firmware.
2018-12-13 15:24:24 +01:00
Gina Häußge 5760b4b264 tracking: check enabled state before preparing payload
Otherwise if tracking is disabled we still do the work and then throw
it away, which is kinda stupid.

Also fixes potential issues with using things like the unique_id when
it hasn't in fact been set due to disabled tracking.
2018-12-13 13:13:02 +01:00
Gina Häußge 49b995b234 Set 10min idle timeout on tornado under windows
Possible workaround for #2916
2018-12-12 16:06:15 +01:00
Gina Häußge 8cf5ca9589 tracking: Track firmware/communication errors 2018-12-12 15:41:36 +01:00
Gina Häußge ae36a3905a printer safety: Mark Malyan M200 fw 4.0+ as safe
Implements #2947
2018-12-12 15:25:38 +01:00
Gina Häußge bfd847f0a6 GCODE viewer: Bring back the layer count 2018-12-12 15:16:17 +01:00
Gina Häußge ef81702219 Merge remote-tracking branch 'origin/maintenance' into maintenance 2018-12-10 14:59:55 +01:00
Gina Häußge 7cbe6244ae Merge branch 'staging/maintenance' into maintenance 2018-12-10 14:59:39 +01:00
Gina Häußge 112a8b9c8b Merge branch 'rc/maintenance' 2018-12-10 13:01:23 +01:00
Gina Häußge 98b692d845 Preparing release of 1.3.10 2018-12-10 12:44:25 +01:00
Gina Häußge f4f7c87640 Always show actual received from printer instead of off
Regardless how cold the temperature is, display it in the table. Some
people otherwise seem to think that OctoPrint "can't handle"
temperatures below 10°C and will blame it for MINTEMP errors triggered
in the firmware.
2018-12-06 11:49:23 +01:00
Gina Häußge 5af5cbbb37 Merge branch 'staging/maintenance' into maintenance 2018-12-03 14:16:50 +01:00
Gina Häußge a657ebd528 staging/maintenance is now 1.3.10rc5.dev 2018-12-03 14:16:31 +01:00
Gina Häußge e628aedbc1 Preparing release of 1.3.10rc4 2018-12-03 12:42:28 +01:00
Gina Häußge 38fce1665b backup: signal restore done before reboot 2018-11-30 20:07:18 +01:00
Gina Häußge f51a98768c backup: more feedback during restore
The upload of a backup can take a while, so pop up the work dialog as
soon as that starts, not only when it is finished.
2018-11-30 20:06:57 +01:00
Gina Häußge 4d04c323f6 backup: use base version for version check 2018-11-30 20:06:24 +01:00
Gina Häußge 94116bfd53 backup: fix on_restore_failed calls 2018-11-30 18:33:58 +01:00
Gina Häußge a05761e63f backup: better error logging 2018-11-30 18:29:55 +01:00
Gina Häußge 89469d38ae printer safety: Fix localization of warning 2018-11-30 17:06:07 +01:00
Gina Häußge bd2616e888 backup: exclude generated, logs & watched
We don't need these in the backup, and in fact they only make things
more bloated and/or complicated.
2018-11-30 16:53:26 +01:00
Gina Häußge 02e996436d backup: restore is not supported on windows
Sadly the stupid file locking of windows makes it impossible to
hot swap the config directory. In order to support windows a two step
approach would be needed. Maybe at a later date, currently simply not
worth the effort tbh considering how seldomly windows is used as OS for
OctoPrint.
2018-11-30 16:53:19 +01:00
Gina Häußge a3f2e0b56c backup: fix plugin compatibility check on restore
Fixes #2920
2018-11-30 16:21:58 +01:00
Gina Häußge c4295d6a81 Merge branch 'staging/maintenance' into maintenance 2018-11-28 14:57:14 +01:00
Gina Häußge d60cab1962 staging/maintenance is now 1.3.10rc4.dev 2018-11-28 14:56:39 +01:00
Gina Häußge b01e327f9d Preparing release of 1.3.10rc3 2018-11-28 12:56:02 +01:00
Gina Häußge 09af2813d0 Add dedicated issue templates 2018-11-27 14:21:13 +01:00
Gina Häußge 2f69a84352 Use max of comm & temp timeout as serial timeout
That way we avoid issues if the user has set a longer temperature
reporting interval than (busy) communication timeout.

See #2905
2018-11-26 15:33:37 +01:00
Gina Häußge 13260fa219 tracking: file path instead of just name in print events
Closes #2908
2018-11-26 14:10:03 +01:00
Gina Häußge 9a90093dda tracking: file path instead of just name in print events
Closes #2908
2018-11-26 14:08:33 +01:00
Gina Häußge 8292408c79 Remove image from changelog, replace with text
Closes #2909
2018-11-26 12:05:58 +01:00
Gina Häußge 9165f83084 printer safety: Mark stock Micro3D fw as unsafe
See https://github.com/donovan6000/iMe/issues/67#issuecomment-441454163
2018-11-26 10:27:20 +01:00
Gina Häußge c2ef371089 Docs: add documentation for some config params 2018-11-23 11:12:40 +01:00
Gina Häußge fa9472d4aa Fix SWU restart command again
Accidentally committed something I only changed for a test. Oops.
2018-11-22 15:54:02 +01:00
Gina Häußge 037e92c447 Recognize incomplete startups and set safe mode flag 2018-11-22 15:52:18 +01:00
Gina Häußge 170804d4df Create a backup of working config.yaml after startup 2018-11-22 13:47:02 +01:00
Gina Häußge ac129a2576 Only patch sarge's async on python 2 2018-11-22 13:10:59 +01:00
Gina Häußge db8d420860 Decorator for sarge that translate async to async_
Should work around issues with third party plugins that haven't yet
adapted.
2018-11-22 12:37:28 +01:00
Gina Häußge 7d7cbb1760 Some reordering in the settings 2018-11-21 16:14:23 +01:00
Gina Häußge 89979f1bee Revert "Hardening against bad plugins"
Making on_after_startup asynchronous unearths some odd issue that causes
subsequent callback calls to duplicate. It might just be PyCharm's
debugger (disabling it makes the problem go away and I so far couldn't
reproduce it without it), but just in the case that I introduced some
weird race condition with this _async approach I'm removing it. I'd
rather have badly implemented plugins break the startup then the startup
being inherently broken from the get go.

Added a couple more warnings in the docs though.
2018-11-21 16:14:06 +01:00
Gina Häußge bd241e8e6c backup: allow zip64 2018-11-21 12:19:04 +01:00
Gina Häußge 7939b0ae4d backup: better error reporting 2018-11-21 12:10:03 +01:00
Gina Häußge 6b57ba2d7d printer_safety: detect iMe on Micro3D
See donovan6000/iMe#67
2018-11-20 12:42:52 +01:00
Gina Häußge 2c5465f9a6 Got rid of an unused import 2018-11-20 12:42:50 +01:00
Gina Häußge 1565129cfb docs: warning about blocking ops in some plugin callbacks 2018-11-20 12:42:49 +01:00
Gina Häußge b8d4a58207 SWU: remove one thread level
on_after_startup now runs in its own thread, no need to spawn yet
another.
2018-11-20 12:42:43 +01:00
Gina Häußge 900f03dc8a SWU: add a timeout to the wait on environment info 2018-11-20 12:24:50 +01:00
Gina Häußge 0c4c4a9d18 Hardening against bad plugins
We don't want on_after_startup or on_event handling to get blocked by
some rogue plugin that decides to block or outright kill the thread.
2018-11-20 12:19:17 +01:00
Gina Häußge ff4ed38329 Track user logout on socket 2018-11-19 15:24:12 +01:00
Gina Häußge 5f78ab7b73 Register for plugin messages on socket connect
Second part of the fix for #2898
2018-11-19 15:22:45 +01:00
Gina Häußge 6556d555bd forcelogin: Keep message backlog while not authed
First part of the fix for #2898
2018-11-19 15:22:33 +01:00
Gina Häußge d318ff82b8 More error resilience in the local ip check
Should solve #2897
2018-11-16 13:57:11 +01:00
Gina Häußge ff53a826f9 tracking: Fix link of plugin in plugin manager 2018-11-16 13:19:31 +01:00
Unknown abb14dc17a add hook for sdcard copy + documentation 2018-11-16 11:17:05 +01:00
Unknown a45c86eed1 Revert "add self param to error_hook + update documentation"
This reverts commit c30380d423.
2018-11-16 11:03:35 +01:00
Unknown c30380d423 add self param to error_hook + update documentation 2018-11-16 11:02:15 +01:00
Gina Häußge d79e777911 Update german translation 2018-11-15 14:42:48 +01:00
Gina Häußge 335e635ec7 printer_safety_check: Make a text translateable 2018-11-15 14:17:06 +01:00
Gina Häußge a5754a8552 pi_support: Add link to the new FAQ entry 2018-11-15 14:16:27 +01:00
Gina Häußge a8c91ff6ba pi_support: Better wording in popover & highlight current 2018-11-15 12:57:02 +01:00
Gina Häußge 6285fd8010 Allow dynamic values in ko popover binding 2018-11-15 12:40:03 +01:00
Gina Häußge 92629468c0 Merge remote-tracking branch 'origin/maintenance' into maintenance
# Conflicts:
#	setup.py
2018-11-13 16:17:56 +01:00
Gina Häußge 56a1d4f966 Merge branch 'staging/maintenance' into maintenance 2018-11-13 16:17:08 +01:00
Gina Häußge 799aedcaed staging/maintenance is now 1.3.10rc3.dev 2018-11-13 16:16:43 +01:00
Gina Häußge de42ce73f7 Preparing release of 1.3.10rc2 2018-11-13 12:43:06 +01:00
Gina Häußge 962e09906e tracking: Fix translatability of a message 2018-11-13 12:42:31 +01:00
Gina Häußge f607f55683 printer_safety_check: Detect Ender 3 stock fw
As reported in https://discourse.octoprint.org/t/thermal-runaway-protection-absent-on-creality-ender-3/2787
2018-11-13 11:17:24 +01:00
Gina Häußge 8e464f59ac Reapply "Updated several dependencies to current version"
This reverts commit e14c00f135.
2018-11-12 17:27:37 +01:00
Gina Häußge 91b524813c Minimum python version is now 2.7.9 2018-11-12 17:27:37 +01:00
Gina Häußge 1b45047826 tracking: wizard changes
* spinners for the enable/disable buttons
  * error handler for persisting the decision that unlocks the wizard

Might help to work around issues less than a hand full of people have
now observed where the wizard's buttons are non functional but the
wizard itself is active and blocking.

More data needed to reproduce and debug the core issue though.
2018-11-12 15:23:17 +01:00
Gina Häußge edd4d90b12 tracking: tracking.js -> usage.js
To work around some ad blockers that might block this otherwise - which
is kinda funny since the js file doesn't do any tracking, it just
makes the setup wizard for the opt-in functional 🤦‍♀️
2018-11-12 14:33:43 +01:00
Gina Häußge 0a3ad8a880 tracking: add time & reason for failure to print_failed
(cherry picked from commit b7e373c)
2018-11-12 14:33:43 +01:00
Gina Häußge 82615791a2 Add time & reason for failure to PrintFailed event
(cherry picked from commit dae0264)
2018-11-12 14:33:42 +01:00
Gina Häußge 4548be34f0 Always trigger SettingsUpdated event on new save
So far it was only triggered when saving via the REST API, causing some
issues here and there.
2018-11-12 11:40:21 +01:00
Gina Häußge 2b5af2c36a Add docs for octoprint.util.commandline 2018-11-09 18:16:57 +01:00
Gina Häußge a939130748 Better description for Error event 2018-11-08 18:39:03 +01:00
Gina Häußge b7e373c40f tracking: add time & reason for failure to print_failed 2018-11-08 17:41:45 +01:00
Gina Häußge dae0264a58 Add time & reason for failure to PrintFailed event 2018-11-08 17:41:27 +01:00
Gina Häußge b2e50e13d4 Blacklist broken regex version 2018-11-08 15:54:05 +01:00
Gina Häußge cb4404a833 Merge branch 'pr/2878' into staging/maintenance 2018-11-08 15:50:13 +01:00
Gina Häußge 38bb81cfe7 tracking: add throttle events, slightly change throttle payload
Also adjusted helper signature in pi_support plugin slightly.

Addon to #2878
2018-11-08 15:49:11 +01:00
Gina Häußge 1667f9bd52 Fix bug introduced in 4caf4ef09 2018-11-08 14:00:48 +01:00
Gina Häußge 1ec61a9fe6 Give the favicon mask SVG width and height attrs
Otherwise it won't render correctly in Firefox due to drawImage silently
failing, see also https://bugzilla.mozilla.org/show_bug.cgi?id=700533

Closes #2879
2018-11-08 13:42:19 +01:00
tedder 98c84b6bb9 fix test, match dict 2018-11-08 01:34:45 +00:00
tedder 76f48b3b13 PR feedback: throttle state and uuid
- add a way to get the raw value only from throttle state (glad I already plumbed it into the object!)
- add warning about not sending uuid, modify the log entry too
2018-11-08 01:29:15 +00:00
Gina Häußge 8596ae5c4a SWU: Make sure check providers are in the correct format
Just in case there's some odd data in `config.yaml` as reported in https://github.com/foosel/OctoPrint/issues/2871#issuecomment-436507623
2018-11-07 11:10:31 +01:00
tedder c1482eaacd add throttle_state to tracking
- weave the throttle_state through pi_support and tracking. This should come in handy to see how many throttled Pis are out there, as well as if it is correllated with canceled prints.
- upgraded disclosure of tracking information so it shows as INFO-level in the logs and all the information is dumped. If tracking.octoprint.org gets it, I should have it too :)
2018-11-06 15:37:45 -08:00
Gina Häußge e23fe4a925 forcelogin: Fix issue when running with acl disabled
Closes one variant of #2876
2018-11-06 17:34:01 +01:00
Gina Häußge 8939537fb5 Merge branch 'staging/maintenance' into maintenance 2018-11-06 15:57:18 +01:00
Gina Häußge 2f08b90200 Merge branch 'master' into staging/maintenance 2018-11-06 15:56:33 +01:00
Gina Häußge 68ca2c5e51 Pin regex dependency to last known working version
See #2874 and https://bitbucket.org/mrabarnett/mrab-regex/issues/301/typeerror-character-mapping-must-return
2018-11-06 15:52:41 +01:00
Gina Häußge 343195477b Fix connection fail if fw doesn't send start
Closes #2872
2018-11-06 14:47:39 +01:00
Gina Häußge 4caf4ef09b Fix GCODE viewer not being able to load files
Side effect of the ForcedLogin plugin and a bug in
get_flask_user_from_request.

Closes #2873
2018-11-06 14:02:49 +01:00
Gina Häußge 0ba987e126 maintenance is now 1.3.11.dev 2018-11-06 12:31:53 +01:00
Gina Häußge 0325628693 staging/maintenance is now 1.3.10rc2.dev 2018-11-06 12:29:28 +01:00
Gina Häußge e14c00f135 Revert "Updated several dependencies to current version"
This reverts commit 4ed5f7e

The updates cause issues on very old python environments (distribute
instead of setuptools, e.g. OctoPi 0.12) due to new package formats.

We'll postpone them to 1.3.11, since OctoPrint 1.3.10 will then refuse
to upgrade in such environments anyhow.
2018-11-05 14:25:10 +01:00
Gina Häußge b0a4a49f99 Changelog for 1.3.10rc1 2018-11-05 13:18:05 +01:00
Gina Häußge 5b4839369e appkeys: Probe endpoint to check for workflow support
Also adjusted docs and js client lib accordingly.
2018-11-05 12:50:05 +01:00
Gina Häußge 1ff02b9f1c Update bundled German translation 2018-11-05 11:59:48 +01:00
Gina Häußge e2c1fa3d43 Appkeys: request creation should respond with 201 2018-11-02 17:04:58 +01:00
Gina Häußge 39a466e316 Appkeys: Make timeout thread safe 2018-11-02 12:53:30 +01:00
Gina Häußge 9e940eacc3 Merge branch 'fix_appkey_orphan_dialogs' of https://github.com/fieldOfView/OctoPrint into pr/2869 2018-11-02 12:27:16 +01:00
Gina Häußge 2e38f237de Fix cancel snippet for shared nozzle setups
See https://discourse.octoprint.org/t/prusa-mmu2-how-to-properly-configure/4937/
2018-11-02 12:20:05 +01:00
fieldOfView 7f36ffdafd Expire request_access when the client stops polling 2018-11-02 11:04:06 +01:00
Gina Häußge 39b2da3230 Merge pull request #2868 from gdombiak/extrude_speed2
Documentation fixed and extrusion speed value check
2018-11-02 10:52:42 +01:00
fieldOfView c489829efb Add myself to AUTHORS.md
because it's a requirement for a PR
2018-11-02 09:31:56 +01:00
fieldOfView e30e129e2a Close request_access dialogs on other open connections when a decision is made
Once a decision is made on one connection (browser window), dialogs on other connections are no longer relevant.
2018-11-02 09:22:30 +01:00
Gaston Dombiak 32d5b25013 Removed unnecessary variable initialization 2018-11-01 21:44:42 -07:00
Gaston Dombiak 6227a0dfb9 1) Fixed documentation about speed unit and 2) extrusion speed is now limited to printer profile max value 2018-10-31 20:45:56 -07:00
Gina Häußge e234c6146e Better detection of ipv6 support
Apparently socket.has_ipv6 doesn't actually do what it says in the docs
(state whether the underlying platform supports ipv6). It returns True
even when ipv6 has manually been disabled for whatever reason. So we
will no longer trust this but instead attempt to actually create a v6
socket and only if that succeeds assume that v6 is indeed supported on
the platform.
2018-10-31 13:39:54 +01:00
Gina Häußge c146731e5a Merge pull request #2865 from gdombiak/extrude_speed
Extrude speed
2018-10-31 11:58:28 +01:00
Gina Häußge 5ee242be4a Fix doc bug: mm/s => mm/min 2018-10-31 11:54:17 +01:00
Gaston Dombiak 556878a774 Merge branch 'maintenance' into extrude_speed 2018-10-30 19:09:05 -07:00
Gaston Dombiak 00aa4876e9 Added support to specify extrude/retract speed. Only at REST API. No UI changes were made 2018-10-30 19:01:20 -07:00
Gina Häußge e5e8581f9a Detect invalid test setups in settings tests
Should prevent future cases of the chainmap issue observed in #2828 and
maybe also #2829
2018-10-30 17:16:48 +01:00
Gina Häußge 95a9f84b39 Reflect current connection in connection panel
Implements #2859
2018-10-30 15:56:36 +01:00
Gina Häußge 371f1a818f tracking: add uuid to filename hash in print event tracking
We don't need to be able to identify the same file across multiple
instances, just repeated prints on the same instance.

Thanks to @scoder for the suggestion.
2018-10-30 13:36:32 +01:00
Gina Häußge 4ed5f7ed28 Updated several dependencies to current version
Werkzeug update required a flask monkey patch since we can't update
flask due to it depending on a newer jinja version which is backwards
incompatible and hence would cause issues with third party plugins.

Also added notes to the dependencies that are found to be hard to update
so that future release preparations don't require to figure out the
"why not" all over again.
2018-10-30 13:31:36 +01:00
Gina Häußge 4eb81aae9d cura: workaround for broken placeholders in profiles
Apparently some exports contain ?print_temperature? instead of
{print_temperature} style placeholders? At least that was observed in
the example in #2629.

This fixes such placeholders.
2018-10-29 17:41:57 +01:00
Gina Häußge dafa4c97ad cura: fix extruder count for start gcode selection
Fixes #2629
2018-10-29 17:30:49 +01:00
Gina Häußge 0268cafa90 Reflect current port/baudrate/profile in connection tab
Fixes #2740
2018-10-29 13:56:34 +01:00
Gina Häußge a5caac8d38 Disable external heatup detection for teacup fw
Implements #2854
2018-10-29 11:55:37 +01:00
Gina Häußge 7ca9d56327 Merge branch 'improve/appauth' into maintenance 2018-10-29 11:45:05 +01:00
Gina Häußge d9323b7172 docs: new clientjs asset type 2018-10-29 11:44:27 +01:00
Gina Häußge 8f6d67195d appkeys: clean up pendings older than 10min & meta data 2018-10-29 11:42:12 +01:00
Gina Häußge 342d526a51 appkeys: finalize docs 2018-10-29 11:08:00 +01:00
Gina Häußge d7c5f57c98 appkeys: fix app bulk selection 2018-10-29 10:32:13 +01:00
Gina Häußge d89ca38ee8 WIP: Docs for appkeys plugin 2018-10-29 10:30:48 +01:00
Gina Häußge cb969be403 docs: clarify that user name == user id 2018-10-24 09:52:26 +02:00
Gina Häußge 7cb649c303 docs: fix auth message docs on push API
Thanks @gdombiak for the heads-up
2018-10-24 09:48:00 +02:00
Gina Häußge 6d7d365b27 appkeys: bulk delete & fixed sorting 2018-10-23 13:47:54 +02:00
Gina Häußge 8ad720e554 Merge remote-tracking branch 'origin/improve/appauth' into improve/appauth
# Conflicts:
#	src/octoprint/plugins/appkeys/__init__.py
#	src/octoprint/plugins/appkeys/static/clientjs/appkeys.js
#	src/octoprint/plugins/appkeys/static/js/appkeys.js
#	src/octoprint/plugins/appkeys/templates/appkeys_usersettings.jinja2
#	src/octoprint/server/util/flask.py
2018-10-22 18:53:28 +02:00
Gina Häußge 37190da2d6 Merge branch 'maintenance' into improve/appauth
# Conflicts:
#	src/octoprint/server/util/flask.py
2018-10-22 18:50:32 +02:00
Gina Häußge 2746139fa6 appkeys: central settings page with all keys 2018-10-22 18:44:55 +02:00
Gina Häußge c9f10ae723 printer_safety_check: docs update 2018-10-22 17:42:31 +02:00
Gina Häußge 202006149c forcelogin: documentation, incl. newly added hooks 2018-10-22 17:38:48 +02:00
Gina Häußge 671973062e announcements: add missing images for docs 2018-10-22 16:43:07 +02:00
Gina Häußge 1d15c2a176 backup: docs & small changes in wording 2018-10-22 16:42:47 +02:00
Gina Häußge 5e490ec7fd Revert "Update some dependencies"
This reverts commit 6d2be17
2018-10-22 16:19:42 +02:00
Gina Häußge 1889a40241 Merge branch 'improve/swuCheckEnvironment' into maintenance 2018-10-22 13:07:59 +02:00
Gina Häußge 6d2be1743a Update some dependencies
There are more updates, but they introduce backwards compatibility
issues that would hurt third party plugins, so we need to find
workarounds for these first - or trigger a grace period.
2018-10-22 13:02:57 +02:00
Gina Häußge e9e4adf09b tracking: flask.ext.babel => flask_babel 2018-10-22 13:01:42 +02:00
Gina Häußge 535ad6eae6 Merge pull request #2858 from gdombiak/issue_2850
Fixed unsafe write_message call from another thread
2018-10-22 11:47:16 +02:00
Gaston Dombiak c4167a82c5 Fixed unsafe write_message call from another thread.
Issue #2850
2018-10-21 00:58:14 -07:00
Gina Häußge 087a9ece2c Make sure to show only one external address warning notification at once 2018-10-19 17:00:42 +02:00
Gina Häußge b77380a8ac Add logging for active/passive login 2018-10-19 16:50:58 +02:00
Gina Häußge 169275b052 Fix wrong position of parentheses, add unit tests 2018-10-19 16:39:18 +02:00
Gina Häußge 757dfcf5c7 unmap ipv6 mapped v4 addresses on lan check 2018-10-19 16:19:51 +02:00
Gina Häußge 8e39eac207 discovery: start name counter at 1
We want our second instance with the same name to show up as (2) not (1)
2018-10-19 14:17:16 +02:00
Gina Häußge 9e48b8ab65 make sure to strip comments from address 2018-10-19 14:13:33 +02:00
Gina Häußge 36b07b2337 discovery: enumerate zeroconf service names on collision
Fixes #2852
2018-10-19 13:58:37 +02:00
Gina Häußge e57c46fb67 Missed something in yesterday's changes to contrib guide 2018-10-19 13:34:13 +02:00
Gina Häußge df8226b8c5 Small changes to the contribution guidelines
* allow PRs against `maintenance` branch for improvements and small
    new features
  * suggest getting in touch on the forum for larger changes
2018-10-19 13:34:12 +02:00
Gina Häußge 2f89082df2 Missed something in yesterday's changes to contrib guide 2018-10-19 13:14:52 +02:00
Gina Häußge e0943527d6 Merge pull request #2847 from eyal0/always_babel_extract
Remove requirement to have messages.pot to use babel_extract
2018-10-18 18:36:42 +02:00
Gina Häußge 108db045ce Small changes to the contribution guidelines
* allow PRs against `maintenance` branch for improvements and small
    new features
  * suggest getting in touch on the forum for larger changes
2018-10-18 18:06:01 +02:00
Eyal Soha 025986794f Remove requirement to have messages.pot to use babel_extract 2018-10-18 11:52:01 -04:00
Gina Häußge ac2354907a Remove some trailing whitespace 2018-10-18 17:33:08 +02:00
Gina Häußge 7b5d2e3e0c Allow whitespace after : in M114 responses
Closes #2839
2018-10-18 17:32:32 +02:00
Gina Häußge efa556a812 Announcements: forgot to git add the new doc page -_- 2018-10-15 17:23:21 +02:00
Gina Häußge 7f9764c386 Announcements: fix a bug & add docs 2018-10-15 17:11:07 +02:00
Gina Häußge e95e546c08 Appkey: Copy key to clipboard 2018-10-15 12:48:41 +02:00
Gina Häußge b0e7df47a6 Appkeys: Add key persistence 2018-09-29 15:00:28 +02:00
Gina Häußge 257fc0d1cd Appkeys: allow fetching of all keys
Also added TODO list ;)
2018-09-29 15:00:27 +02:00
Gina Häußge 3fe2b611bc Appkeys: fix template config 2018-09-29 15:00:27 +02:00
Gina Häußge d6c63a5cb9 appauth -> appkeys 2018-09-29 15:00:27 +02:00
Gina Häußge ad8205c386 AppAuth: workflow fully implemented & client lib 2018-09-29 15:00:27 +02:00
Gina Häußge 6efd4dfd08 New options for confirmation dialog
* oncancel: callback to call when cancel button is pressed
  * noclose: don't allow dismissing/closing the dialog without having
    chosen to proceed or cancel
2018-09-29 15:00:27 +02:00
Gina Häußge 469bf844ee Clientlib: support operation without api key 2018-09-29 15:00:27 +02:00
Gina Häußge 4f58c64881 New asset type "clientjs" for client library bits 2018-09-29 15:00:27 +02:00
Gina Häußge b428faacc8 Appauth plugin: WIP 2018-09-29 15:00:26 +02:00
Gina Häußge 4e3adcc3f3 Add no_firstrun_access decorator 2018-09-29 15:00:26 +02:00
Gina Häußge f88147003c Repetier firmware reports fatal errors with another prefix 2018-09-29 14:54:39 +02:00
Gina Häußge bbbe85f737 Multiline fatal error parsing for Marlin 2018-09-29 14:38:54 +02:00
Gina Häußge fc97d0b424 Virtual: simulate some fatal errors 2018-09-29 14:38:35 +02:00
Gina Häußge b054ec47ad Special handling for fatal errors
If the firmware locks up it doesn't make sense to stay connected to
it even if we are supposed to only cancel an ongoing print.
2018-09-29 13:28:09 +02:00
Gina Häußge 87e7a19fdd Forcelogin: Support theming via custom hook 2018-09-28 17:57:05 +02:00
Gina Häußge fed257b5d8 Forcelogin: Fix spinner 2018-09-28 17:19:31 +02:00
Gina Häußge e53ae8cd56 Forcelogin: Access to settings isn't needed either 2018-09-28 17:15:37 +02:00
Gina Häußge a9f76dd1a3 Forcelogin: allow socket when ACL isn't setup yet 2018-09-27 18:47:00 +02:00
Gina Häußge 6bc5b8a7a9 Forcelogin: lock down sockjs socket as well 2018-09-27 18:44:03 +02:00
Gina Häußge cb9bedb6a0 Add hooks to control sockjs registrations and messages 2018-09-27 18:43:46 +02:00
Gina Häußge 5ff790048d Fix unit tests 2018-09-26 15:52:10 +02:00
Gina Häußge f32ea65b2c Support EMERGENCY_PARSER & use M108 on cancel (unless disabled)
Implements #1504
2018-09-26 15:29:15 +02:00
Gina Häußge 1f957e1ee2 forcelogin: disable while ACL hasn't been configured 2018-09-26 15:21:51 +02:00
Gina Häußge 32be5ca87c Better error handling if file becomes unreadable
Implements #2674
2018-09-24 16:50:14 +02:00
Gina Häußge 8876ab0ce5 SWU: Fix version output of CLI update message 2018-09-21 18:43:20 +02:00
Gina Häußge ad8910354c SWU: Fix CLI updating
Closes #2712
2018-09-21 18:41:22 +02:00
Gina Häußge e8d6a9b221 Only reset timeout to busy once it has been set on printer
Should fix #2752
2018-09-21 18:25:58 +02:00
Gina Häußge f3cfe2ba48 Virtual: add long running pseudo G33
Useful for testing busy protocol on commands.
2018-09-21 18:25:58 +02:00
Gina Häußge d2ecb0a28f Merge pull request #2827 from tedder/docfix_sdReleativePath_maint
spellfix 'sdReleativePath'
2018-09-21 18:05:21 +02:00
Ted Timmons 134ee77e4a spellfix 'sdReleativePath'
It's only misspelled in the docs, it is correct in the code.
2018-09-21 08:45:53 -07:00
Gina Häußge 10f3f72b9c Unit tests: Fix duplicated test method
Closes #2805
2018-09-21 14:35:20 +02:00
Gina Häußge 78b6d3a5e2 Merge pull request #2800 from gerfderp/patch-1
Documentation conjugation fix.
2018-09-18 17:18:18 +02:00
Gina Häußge a920c4fe21 Merge pull request #2806 from tedder/201809_rewrite_test_get_recovery
rewrite test_get_recovery_data
2018-09-18 17:12:27 +02:00
Gina Häußge 52468e7e1c Merge pull request #2802 from tedder/201809_temperature_regex_update
201809 temperature regex update
2018-09-18 17:10:37 +02:00
Gina Häußge 9112a800c8 Add forcelogin plugin 2018-09-14 20:06:32 +02:00
Gina Häußge 177d235b29 Make a helper method public 2018-09-14 20:06:32 +02:00
Gina Häußge 2de2dc7c31 Allow further access restriction on API and Tornado routes through plugin hooks 2018-09-14 20:06:32 +02:00
Paul de Vries 8074a06d33 Use .fail instead of .error
.error() was removed in jQuery 3 and is throwing errors when logging out,
use .fail instead
2018-09-09 11:37:38 +00:00
Gina Häußge 75c801d63f Unit tests for is_lan_address
Also fixed a bug in subnet creation in the process.
2018-09-04 14:01:31 +02:00
Gina Häußge ed07764f09 Put warnings into core/first run wizard 2018-09-04 12:00:07 +02:00
Gina Häußge a929100889 Allow to disable ip check & define trusted subnets
Will need manually editing config.yaml for the time being. Someone who
is not able to edit a yaml file should not be able to disable the
warning.
2018-09-04 09:26:29 +02:00
Gina Häußge 286376321c Detect connections to the UI from external ips
Show warning to protect the innocent who don't know better than to
port forward.

Warning is ignorable (per browser) to allow users who know what they are
doing to easily get rid of it. If you don't know what you are doing and
also actively ignore THIS warning I really can't help you anymore.
2018-09-03 21:23:08 +02:00
Gina Häußge 4a36a3eed2 Appkeys: Add key persistence 2018-09-03 18:38:36 +02:00
tedder 8bf9b8650d rewrite test_get_recovery_data
I was pulling my hair out with some py3 compatability, so .. I ended up basically rewriting it. Basically a big refactor, still compatible with py2.
2018-09-01 22:07:41 -07:00
tedder d6da819cd6 add unit tests for temperature regexes 2018-09-01 10:46:29 -07:00
tedder 2fbc81604a update temperature regex
It exists in three locations, so I'm making sure they are all synced. This ensures the MP Mini Delta flavor of Marlin is properly masked; I have that and a Prusa mk3 to verify against.

This came out of this thread:
https://discourse.octoprint.org/t/temperature-message-filter-doesnt-filter-temperature-messages/3643
2018-09-01 08:39:25 -07:00
Gina Häußge 2ca63febee Appkeys: allow fetching of all keys
Also added TODO list ;)
2018-08-31 20:45:16 +02:00
Gina Häußge 224674f27e Appkeys: fix template config 2018-08-31 20:35:16 +02:00
Gina Häußge 2f1d71a98c appauth -> appkeys 2018-08-31 20:22:40 +02:00
gerfderp 7366110f07 Update helpers.rst
fixing conjugation
2018-08-29 14:59:00 -07:00
Gina Häußge e5eb72cbfb Docs: Make it extra crystal clear to use a VPN 2018-08-29 15:49:09 +02:00
Gina Häußge b0028cd3fb AppAuth: workflow fully implemented & client lib 2018-08-28 22:05:28 +02:00
Gina Häußge 2343caea30 New options for confirmation dialog
* oncancel: callback to call when cancel button is pressed
  * noclose: don't allow dismissing/closing the dialog without having
    chosen to proceed or cancel
2018-08-28 22:04:34 +02:00
Gina Häußge 61d037f188 Clientlib: support operation without api key 2018-08-28 22:02:40 +02:00
Gina Häußge 2a79d9183a New asset type "clientjs" for client library bits 2018-08-28 22:02:18 +02:00
Gina Häußge 5dbc88b6f2 Detect scrolling direction in terminal
Only disable autoscroll if we are scrolling up.
2018-08-27 15:58:15 +02:00
Gina Häußge 83876806db Force terminal scroll on browser tab activation
Possible fix for #2774
2018-08-27 15:57:59 +02:00
Gina Häußge 5a5785be4a Appauth plugin: WIP 2018-08-24 11:59:23 +02:00
Gina Häußge 25cd4f8201 Add no_firstrun_access decorator 2018-08-24 11:58:56 +02:00
Gina Häußge 2d72a52338 Backup: Fix a copy paste error 2018-08-22 17:58:29 +02:00
Gina Häußge b5a161594d Fix documentation error
We return 403 on a wrong API key, not 401 - 401 causes issues with Basic Auth setups as reported
in #2297 and hence fixed in b1f9e070a4.

Closes #2706
2018-08-20 14:25:28 +02:00
Gina Häußge a24363c4b0 Fix API error when accessing sdcard file details
Closes #2705
2018-08-20 14:04:09 +02:00
Gina Häußge 524562527e Cura: Error message if profile import fails
See #2769
2018-08-20 12:58:27 +02:00
Gina Häußge 26856d052f Fix wrong min/max parameter being used for timeouts
Closes #2780
2018-08-20 11:54:27 +02:00
Gina Häußge 17f8817b78 Backup: Got rid of caching plans 2018-08-17 15:06:07 +02:00
Gina Häußge 4eb1d2bf80 Backup: Check compatibility when installing plugins from repo during restore 2018-08-17 15:00:09 +02:00
Gina Häußge 62120affae PMGR: Finalize extraction of is_os_compatible into octoprint.util.platform 2018-08-17 14:13:01 +02:00
Gina Häußge 66b501cfaa Backup: Show list of plugins unknown during restore in settings 2018-08-16 17:50:58 +02:00
Gina Häußge 140bf9aa5a Backup: Fix recording list of uninstallable plugins 2018-08-16 15:20:11 +02:00
Gina Häußge 711ca457f2 Backup: WIP of handling unknown plugins 2018-08-16 09:05:45 +02:00
Gina Häußge 07ae4ffe14 Backup: Delete bck from earlier restore on startup 2018-08-14 19:56:17 +02:00
Gina Häußge 3800b21e69 Bkacup: Fix CLI logging of exceptions 2018-08-14 19:48:58 +02:00
Gina Häußge 196b152ec4 Backup: Remove left over parameter 2018-08-14 19:28:36 +02:00
Gina Häußge 970810dc92 Backup: Move into "OctoPrint" sub section 2018-08-14 19:28:11 +02:00
Gina Häußge 4fec14197b Backup: Some UI changes & confirmations 2018-08-14 19:27:47 +02:00
Gina Häußge b354334a2e Backup: Add log window during restore 2018-08-13 19:02:50 +02:00
Gina Häußge a934750504 Backup: Upload of backup to restore works 2018-08-10 20:46:30 +02:00
Gina Häußge 9dc29689f4 Backup: Restore now seems to work 2018-08-10 11:58:06 +02:00
Gina Häußge 8518b40b5f Backup: WIP on restore function
Plugin installation is still challenging.
2018-08-09 12:45:27 +02:00
Gina Häußge aabd624f88 Backup: WIP on restore 2018-08-07 15:14:12 +02:00
Gina Häußge 6ae88ab8c6 Backup: subfolder for basedir contents 2018-08-06 13:43:17 +02:00
Gina Häußge 6251031d6e Backup works, incl management UI 2018-08-06 13:35:02 +02:00
Gina Häußge 249b3f442b Slight refactoring 2018-08-06 13:34:30 +02:00
Gina Häußge ff6012bb00 WIP: Backup & Restore plugin 2018-08-03 17:20:28 +02:00
Gina Häußge a137946e3a Remove setup_requires - it's incompatible to pip 2018-07-28 23:36:28 +02:00
Gina Häußge 909dd551d6 Specify support python versions 2018-07-28 23:30:43 +02:00
Gina Häußge 687b449207 SWU: Prevent auto updates in outdated environments
We will now demand minimum versions of Python, pip and setuptools to be
present before we enable updating through the plugin.

Current minimum versions are those shipped with stock OctoPi 0.14.0.
2018-07-28 23:21:47 +02:00
Gina Häußge efe552264c SWU: Fix update button being visible if update impossible 2018-07-28 23:00:07 +02:00
Gina Häußge b7e788ec1b Work around an issue with sarge 0.1.5
Closes #2747
2018-07-25 17:34:54 +02:00
Gina Häußge e964d2410c Merge branch 'staging/maintenance' into maintenance
# Conflicts:
#	docs/bundledplugins/cura.rst
2018-07-25 16:56:43 +02:00
Gina Häußge 09284cd9b9 Merge branch 'rc/maintenance' into staging/maintenance 2018-07-25 16:54:21 +02:00
Gina Häußge 97d37c5078 Merge branch 'master' into rc/maintenance 2018-07-25 16:28:28 +02:00
Gina Häußge 432090a56a Preparing release of 1.3.9 (part 2) 2018-07-25 16:27:05 +02:00
Gina Häußge 1847b41f7e Preparing release of 1.3.9 2018-07-25 13:38:57 +02:00
Gina Häußge 4963a4b849 docs: warning re expensive code in gcode hooks 2018-07-24 17:44:59 +02:00
Gina Häußge 46e425de88 Gcodeviewer: fix some JS warnings 2018-07-24 16:30:03 +02:00
Gina Häußge 376d38e0cf Gcodeviewer: remove printed/visited layer counts
Apparently it was confusing people and it's not really adding any kind
of meaningful information anyhow.
2018-07-24 16:28:41 +02:00
Gina Häußge 92c43ee6f9 docs: slight adjustment in wording 2018-07-23 09:48:41 +02:00
Iván cce37f0501 Remove malicious link as noticed in #2746 2018-07-23 09:45:53 +02:00
Gina Häußge 2e8f543aa3 Merge branch 'pr/2748' into maintenance 2018-07-23 09:45:24 +02:00
Iván d2dfd22a2c Remove malicious link as noticed in #2746 2018-07-22 02:49:32 +02:00
Gina Häußge b51cb31b46 Merge branch 'staging/maintenance' into maintenance 2018-07-20 12:26:16 +02:00
Gina Häußge eea1050a18 staging/maintenance is now 1.3.9rc5.dev 2018-07-20 12:26:00 +02:00
Gina Häußge 71b2cc87a3 Preparing release of 1.3.9rc4 2018-07-20 11:14:48 +02:00
Gina Häußge a37165d7d9 Tracking: Fix unit tests 2018-07-19 18:25:16 +02:00
Gina Häußge b06f804e9e Tracking: Change printer connection event 2018-07-19 18:17:29 +02:00
Gina Häußge d64ca79f05 Tracking: Only send requests if online 2018-07-19 18:17:29 +02:00
Gina Häußge 490ade5e17 Tracking: Granular control over tracked events 2018-07-19 18:17:28 +02:00
Gina Häußge 573503e84d Tracking: Track firmware name 2018-07-19 18:17:28 +02:00
Gina Häußge 9e0e4bf7b6 Pi Support: Allow configuration of vcgencmd 2018-07-19 18:17:28 +02:00
Gina Häußge 452645d950 Merge pull request #2742 from eyal0/faster_analysis3
Faster gcode analysis: Remove kwargs Vector.__init__ and simplify getCodeFloat
2018-07-19 09:41:06 +02:00
Eyal Soha d2bb731bd7 Remove kwargs from Vector constructor and also simplify getCodeFloat 2018-07-19 09:43:48 +03:00
Gina Häußge 2062acd372 Fix print button being enabled w/o selected file
Closes #2737
2018-07-18 17:21:20 +02:00
Gina Häußge 40b5c272c4 Merge pull request #2723 from eyal0/always_gcode_analyze
Always run the GCodeAnalyser, even if the slicer provided analysis
2018-07-18 16:48:14 +02:00
Gina Häußge 31e4df44f9 Merge pull request #2739 from eyal0/faster_analysis2
Use infinity instead of None in MinMax3D to improve performance
2018-07-18 16:28:25 +02:00
Eyal Soha cd3c8ebbe6 Use infinity instead of None in MinMax3D to improve performance
Speed is improved by about 5%
2018-07-18 16:57:42 +03:00
Gina Häußge fe13348fd3 Don't perform write tests on every getBaseFolder call
Especially not when rendering the main UI - we don't want to trigger
a 500 then, even if some folders are misconfigured.
2018-07-18 15:41:26 +02:00
Gina Häußge 903dd36d68 Strip --no-cache-dir for pip < 1.6
Closes #2738
2018-07-18 11:08:47 +02:00
Gina Häußge 59a435a787 Pi support: spelling fixes 2018-07-17 18:37:24 +02:00
Gina Häußge 71cc312ccc Pi support: move itertools import into debugging cluster 2018-07-17 18:25:13 +02:00
Gina Häußge 8d1ae438e5 Pi support: re-enable production config m) 2018-07-17 17:52:37 +02:00
Gina Häußge 7ebcb47955 Pi support: remove obsolete URL from about dialog 2018-07-17 17:49:16 +02:00
Gina Häußge 71e60183c5 Pi Support: add setting for throttle check
Just in case something acts up with that...
2018-07-17 17:49:03 +02:00
Gina Häußge 9c055137eb Pi Support: fix ordering of about dialog 2018-07-17 17:46:50 +02:00
Gina Häußge eaa8933782 Pi Support: fix state update push 2018-07-17 17:46:36 +02:00
Gina Häußge 0d330e3c5a Pi Support: slight change in timer startup 2018-07-17 16:59:03 +02:00
Gina Häußge 18ed113122 Pi Support: fix logic error 2018-07-17 16:57:04 +02:00
Gina Häußge 48e454856c Pi Support: change check implementation 2018-07-17 15:54:18 +02:00
Gina Häußge 917b86655f Tracking: always use percentage encoding
Otherwise we'll run into https://discuss.elastic.co/t/cant-parse-field/26557/4
on our tracking server
2018-07-17 15:53:41 +02:00
Gina Häußge 7a2225b332 Pi Support: strip 0 bytes from strings 2018-07-17 15:30:28 +02:00
Gina Häußge 20237a73ac Pi Support: Add debug logging to throttle check 2018-07-17 15:17:36 +02:00
Gina Häußge 4a3f894064 Tracking: fix a missed renamed field 2018-07-17 15:15:35 +02:00
Gina Häußge 0c9098f7bf Tracking: Fix a typo 2018-07-17 15:10:04 +02:00
Gina Häußge 53a2e04501 Tracking: adapt to new pi support plugin 2018-07-17 14:59:10 +02:00
Gina Häußge c6f5f1a0f7 Less scary message if a plugin doesn't pass check 2018-07-17 14:38:28 +02:00
Gina Häußge 1cff2581db OctoPi support => Pi support
* changed model detection implementation to use device-tree
  * now active if running on a Pi, regardless whether that runs OctoPi
    or not
  * detect undervoltage/overheat issues via vcgencmd and report back on
    UI
2018-07-17 14:38:12 +02:00
Gina Häußge 5cf02ac9ee Merge branch 'staging/maintenance' into maintenance 2018-07-16 15:21:49 +02:00
Gina Häußge 460481c9c2 staging/maintenance is now 1.3.9rc4.dev 2018-07-16 15:21:25 +02:00
Gina Häußge 2806676707 Preparing release of 1.3.9rc3 2018-07-16 13:15:00 +02:00
Gina Häußge 9559f09ec7 Merge pull request #2730 from eyal0/faster_analysis
Improve octoprint gcode analysis speed
2018-07-13 19:25:54 +02:00
Eyal Soha 542edbc3e6 Revert "Use infinity instead of None for faster MinMax3d"
This reverts commit 792fe328ef.

Most of the speed-up comes from removing the unneeded import and the unrolling so no big deal.
2018-07-13 20:07:35 +03:00
Gina Häußge f82d50b0f6 Some compatibility fixes 2018-07-13 18:41:50 +02:00
Gina Häußge e224b0ac71 Fix & extend unit tests 2018-07-13 18:02:42 +02:00
Gina Häußge 68f4ecefb0 Add hook to extend supported timelapse extensions
Implements #2729
2018-07-13 17:42:34 +02:00
Gina Häußge d73d930e5f Move to sarge 0.1.5
Replace async with async_ where necessary
2018-07-13 15:20:12 +02:00
Eyal 8c1262dd3f Replace infinity tests with inequality 2018-07-13 11:57:52 +03:00
Eyal Soha 792fe328ef Use infinity instead of None for faster MinMax3d 2018-07-13 00:44:04 +03:00
Eyal Soha 111a37e97e Unroll record for improved speed 2018-07-13 00:42:33 +03:00
Eyal Soha c2bb234c20 Remove extra import math 2018-07-13 00:29:43 +03:00
Gina Häußge 0a634a76a0 Different fix for #2632
Our original one causes dead locks as reported in #2677
2018-07-12 16:46:28 +02:00
Gina Häußge 41c0dac19d Fix state comparisons in timeout handling
We weren't yet looking at the new intermediary states here.
2018-07-12 14:40:57 +02:00
Gina Häußge f728423f29 Fix resend handling during job_on_hold
Missing response to a resent line was not properly detected and handled.
2018-07-12 14:39:45 +02:00
Gina Häußge 61e5184377 Fix "now" timestamp
Should be taken *after* reading from the serial line, not before.
2018-07-12 14:38:12 +02:00
Gina Häußge a2527998c2 Resolve dead lock issue in job_on_hold implementation
(Hopefully) closes #2677
2018-07-11 18:10:51 +02:00
Eyal Soha 2dda3a0e32 Always run the GCodeAnalyser, even if the slicer provided analysis
The analysis from the Slicer or other sources is sent to the GCodeAnalyser, which can use it or ignore it.

This fixes https://github.com/foosel/OctoPrint/issues/2445#issuecomment-403599347
This fixes https://github.com/eyal0/OctoPrint-PrintTimeGenius/issues/13
2018-07-10 09:06:15 +03:00
Gina Häußge e2394446b0 Merge branch 'pr/2717' into maintenance 2018-07-06 17:15:45 +02:00
Gina Häußge 1befd0ecc1 Merge branch 'staging/maintenance' into maintenance 2018-07-06 16:59:48 +02:00
Gina Häußge 386ae7609d Fix initialization order of estimator
Closes #2719
2018-07-06 16:55:05 +02:00
Gina Häußge 7587f34c94 Tracking: track software updates 2018-07-06 16:19:32 +02:00
Gina Häußge 6b54a15ed9 Tracking: add shutdown & extend startup data 2018-07-06 16:16:09 +02:00
Gina Häußge d391f0c12b Tracking: better kwarg encoding 2018-07-06 15:44:29 +02:00
Gina Häußge 8460a4173d Tracking: fix print reporting 2018-07-06 15:43:42 +02:00
Brad Fisher fe7149c715 Rendering speed enhancements; New event hooks 'onDragStart', 'onDrag', 'onDragStop', 'onViewportChange'; Bugfix to correct refresh() and refresh(0) both causing redraw of last drawn layer instead of refresh(0) drawing layer 0 2018-07-06 08:16:50 -05:00
Gina Häußge 443647e78e Add detection for Pi3B+ 2018-07-06 15:11:45 +02:00
Gina Häußge 50bb0bcfd4 Merge branch 'staging/maintenance' into maintenance 2018-07-06 14:35:54 +02:00
Gina Häußge e15946ff79 staging/maintenance is now 1.3.9rc3.dev 2018-07-06 14:34:19 +02:00
Gina Häußge fd94fc94a0 Merge branch 'staging/maintenance' into rc/maintenance 2018-07-06 13:01:31 +02:00
Gina Häußge 798bc2b225 Preparing release of 1.3.9rc2 2018-07-06 13:01:19 +02:00
Gina Häußge 6728302bb3 Preparing release of 1.3.9rc2 2018-07-06 12:55:25 +02:00
Gina Häußge f7a3e6a6ee Add --no-cache-dir flag to update pip operations
Otherwise we might run into some weird infinite loop issues within
pip's cache handling under certain circumstances, and we really
don't want to risk that in the field.

See also #2543 for another issue worked around by this, and
pypa/pip#3532 for the core issue
2018-07-06 12:08:52 +02:00
Gina Häußge 0834288cfc Fix estimator initialization on SD print start
Closes #2715
2018-07-05 10:59:14 +02:00
Gina Häußge faff20943f Capture & log any errors in the state update worker
See #2715
2018-07-05 10:58:45 +02:00
Gina Häußge 14661339ef Merge branch 'improve/tracking' into maintenance 2018-07-04 15:14:59 +02:00
Gina Häußge 8ca188e509 Tracking: rename tab in settings 2018-07-04 15:10:48 +02:00
Gina Häußge 3da4877d50 Tracking: Display instance ID in settings 2018-07-04 15:08:09 +02:00
Gina Häußge 382f10557e Tracking: Add explanation text & links 2018-07-04 11:17:17 +02:00
Gina Häußge d9c6cca370 Anonymous usage tracking 2018-07-03 19:06:53 +02:00
Gina Häußge abf4f90f0e Fix an issue with collision free sd name detection 2018-06-26 17:32:58 +02:00
Gina Häußge 13ab34a5c8 Better API key check 2018-06-25 18:53:42 +02:00
Gina Häußge 2a67772f46 Different base icon & setting
(cherry picked from commit dc61b61)
2018-06-25 12:47:31 +02:00
tedder f69718b060 make favicon color match custom theme color
With multiple octopis, the theme/header color is really nice for quickly distinguishing them. But it doesn't help with an ocean of open tabs. This does- simply carry the theme color onto the favicon.

I could do this as a plugin and/or make it a configurable setting, but it's very small change that doesn't need that much overhead, and generally I have opinions about having a plethora of setting flags for nonfunctional things. Thanks to @jneilliii for [helping me through the viewmodels](https://discourse.octoprint.org/t/where-can-i-get-the-theme-color/2354/5).

(cherry picked from commit e1089de)
2018-06-25 12:47:31 +02:00
Gina Häußge a97b8c2fd9 Sanity check disabled plugin list just in case
See https://github.com/foosel/OctoPrint/issues/2687#issuecomment-399797596
2018-06-25 11:20:31 +02:00
Gina Häußge 08c384ac68 Merge pull request #2697 from eyal0/patch-2
estimatedPrintTime is in seconds, not minutes
2018-06-25 11:07:41 +02:00
Gina Häußge 00354f4a1e Merge pull request #2696 from eyal0/patch-1
Fix comment in types.py to match the code
2018-06-25 11:06:34 +02:00
Eyal 1a9b6c01a6 estimatedPrintTime is in seconds, not minutes
The documentation says that the estimated print time should be given in minute.  But in practice, when I give it in minutes, the GUI shows an error factor of 60.  By supplying it in seconds, the correct value is shown.

So it should probably actually be "in seconds"
2018-06-24 15:45:29 +03:00
Eyal c4dc7d0f55 Fix comment in types.py to match the code
The comment says that the key should be `_analysis` but in the code it is `analysis`: https://github.com/foosel/OctoPrint/blob/master/src/octoprint/slicing/__init__.py#L312

This fixes the comment but leaves the code unchanged.
2018-06-24 15:04:38 +03:00
Gina Häußge 5a60af9d13 Improve SD print detection 2018-06-22 11:22:22 +02:00
Gina Häußge 887304fe18 Some more badges 2018-06-20 23:01:23 +02:00
Gina Häußge 2bd8aa00f3 Add build status and IRC badge 2018-06-20 20:03:19 +02:00
Gina Häußge cb8ce62ec4 maintenance is now 1.3.10.dev 2018-06-20 15:52:46 +02:00
Gina Häußge e49a4d8cfa staging/maintenance is now 1.3.9rc2.dev 2018-06-20 15:52:00 +02:00
Gina Häußge fdf0f75ffa Preparing release of 1.3.9rc1 (part 2) 2018-06-20 15:18:42 +02:00
Gina Häußge 5fb8674937 Merge branch 'master' into maintenance 2018-06-20 13:08:25 +02:00
Gina Häußge d3871e3487 Pin sarge to 0.1.4
0.1.5 renamed the async keyword.

Library authors, please, stick to semantic versioning :(
2018-06-20 12:48:10 +02:00
Gina Häußge 9dd9badb33 Pin tornado to 4.5.3
We don't want to accidentally pull in 5.0b1
2018-06-19 18:49:41 +02:00
Gina Häußge 3de9635180 Preparing release of 1.3.9rc1 2018-06-19 18:48:28 +02:00
Gina Häußge e2f626d421 Virtual printer: select_sd command 2018-06-19 11:24:05 +02:00
Gina Häußge b7a8c29fb4 Add an API endpoint to fetch template order
That should make it easier for third party plugins that want to offer
reordering capabilities of tab, sidebar, etc
2018-06-18 19:35:47 +02:00
Gina Häußge 15f10d4a84 sidebar > tabs 2018-06-18 18:23:03 +02:00
Gina Häußge 0faf2792e9 Clarify something about component ordering 2018-06-18 18:21:59 +02:00
Andy Castille caa1a3d76f Display absolute file upload times on hover 2018-06-18 18:03:01 +02:00
Gina Häußge fae01d2c75 Merge branch 'pr/2633' into maintenance 2018-06-18 17:53:47 +02:00
Gina Häußge 248235c5e0 Fix indentation 2018-06-18 17:53:32 +02:00
Gina Häußge 2febfcd8b3 Announcements: Don't reload on mark read
Only reload if we mark read from the management dialog.
2018-06-18 16:05:10 +02:00
Gina Häußge 704331525f Split settings init to allow better error logging 2018-06-18 15:37:51 +02:00
Gina Häußge 6c279f155a Improve fatal startup error handling 2018-06-18 15:07:18 +02:00
Gina Häußge e5afde2c2c Up a couple of versions 2018-06-18 14:33:28 +02:00
Gina Häußge f5b99a6e34 Fix symlink test util
That was resolving the path completely before checking
whether the symlink is broken or not.
2018-06-18 14:24:04 +02:00
Gina Häußge 8ef13ba529 Fix flask version 2018-06-18 14:22:56 +02:00
Gina Häußge 654055da61 Add symlink check to test API endpoint 2018-06-18 11:37:36 +02:00
Gina Häußge 68f67219ed Refactor test API endpoint 2018-06-18 11:37:02 +02:00
Gina Häußge 436ffb6db8 Detect broken symlinks during folder validation
Closes #2644
2018-06-18 11:20:21 +02:00
Gina Häußge b569cc456b Fix typePath missing for sdcard files on files API
Closes #2589
2018-06-18 10:48:27 +02:00
dadosch 023b9eda90 Two spaces were missing 2018-06-18 09:54:33 +02:00
Gina Häußge fe2dbf699d SWU: Lock down UI while updating
Implements #1217
2018-06-15 18:15:13 +02:00
Gina Häußge 17c6c83503 Fix SD printing 2018-06-15 17:02:53 +02:00
Gina Häußge 688e4d36d1 Fix script order
beforePrint* should always precede any commands from the print job.

Also make sure we only jump from "finishing" to "operational" after the
afterPrintDone script has been sent. Also wait for all moves to finish.
2018-06-15 15:44:34 +02:00
Gina Häußge 86b886ede7 Remove resend repetition code
It's apparently completely broken and the fact that no one noticed
and reported that means it never really gets used either from the looks
of it.

So instead of allowing it to introduce broken resend handling, we'll
rather remove it for now.
2018-06-15 13:15:27 +02:00
Gina Häußge 392149b504 Add view model list to coreui object 2018-06-14 19:25:46 +02:00
Gina Häußge 85ef3f1df2 Fix modals not hiding fully anymore 2018-06-09 13:07:34 +02:00
Gina Häußge 6e44149284 Treat scripts triggered by job as part of the job
Including blocking their sending via job_on_hold.

Closes #2583
2018-06-09 11:58:53 +02:00
Gina Häußge 534f3aa2d4 Fix for potential division by zero on SD upload
Closes #2675
2018-06-09 10:15:56 +02:00
Gina Häußge 13e5cf45ec Fix reset handling while printing
Could get stuck in cancelling due to resend issues.

Should fix #2509
2018-06-08 17:14:40 +02:00
Gina Häußge 4cb103e042 Fix cancel_preparation call in case of failure
It should be _failed if the timer runs out, not _done. Only difference
is a log entry though, so not that big of a deal.
2018-06-08 11:03:44 +02:00
Gina Häußge db81bf1e72 Add new states "resuming" and "finishing"
The later allows us to distinguish between a file having been streamed
completely and the print job done script having streamed completely as
well.

Should fix #2547
2018-06-05 11:07:31 +02:00
Gina Häußge 9c89c4c999 Simplified a log handler 2018-06-04 18:44:10 +02:00
Gina Häußge d133bd47e5 Fix uninstall detection of disabled plugins
Fixes #2549 part 2
2018-06-04 18:01:34 +02:00
Gina Häußge 90391d2897 Forbid <=0 for various timeouts & intervals
Closes #2551
2018-06-04 15:13:45 +02:00
Gina Häußge d124efdb71 Fix race condition in resend handling
Could be triggered if two resend requests without an ok were directly
following each other, causing a resend ok timer to be triggered for each
and a consequent attempt to process the same resend status again.

Should fix #2632
2018-05-29 17:30:59 +02:00
Gina Häußge 4f1b781219 docs: forgot to push two images 2018-05-29 16:13:50 +02:00
Gina Häußge 6673536e10 Added some additional printer safety checks
* Repetier firmware versions prior to 0.92 don't have thermal runaway/
    decouple detection, so we always warn about those
  * If the firmware supports the THERMAL_PROTECTION capability report
    but it's reported as disabled, we also warn about that (see also
    MarlinFirmware/Marlin#10465)
2018-05-29 15:19:35 +02:00
Gina Häußge 118afd4720 Refactor version parsing helpers
Extract get_comparable_version for use in other places as well.
2018-05-29 15:16:14 +02:00
Gina Häußge a0cbc10ba7 Add two new hooks for firmware information
octoprint.comm.firmware.info - response to M115
octoprint.comm.firmware.capabilities - capability report lines
2018-05-29 15:13:25 +02:00
Gina Häußge 38b7640769 Add support for prompt_* action commands 2018-05-28 18:16:06 +02:00
Gina Häußge b266f1ca55 Update psutil dependency
Might fix #2658 (although I'm still at a complete loss as to how that
lib could influence serial connection stability O_O).
2018-05-28 10:46:40 +02:00
Gina Häußge 0ef0eff917 Add paused and resumed action commands
Slightly different behaviour than the already existing pause and resume,
see the docs.
2018-05-25 18:21:11 +02:00
Gina Häußge fd29efe88e Update jQuery to 3.3.1 2018-05-25 17:25:58 +02:00
Gina Häußge cd3acfb384 Merge branch 'pr/2606' into maintenance 2018-05-25 16:49:33 +02:00
Gina Häußge f9548a7ece Sort serial ports naturally 2018-05-25 16:42:46 +02:00
Gina Häußge ce5275c91e docs: Add example for float factors
Closes #2663
2018-05-25 14:57:35 +02:00
Gina Häußge 8a1db8e4c5 Disable fade in for cancel confirmation
Requests to add an option for it in 3, 2, 1...

Closes #2597
2018-05-18 18:22:19 +02:00
Gina Häußge 0d120b2977 Merge pull request #2650 from ntoff/fix/grey-plugin-delete-clickable
Fix greyed plugin manager delete icons still being clickable
2018-05-18 12:42:00 +02:00
ntoff bf71a20ac1 Fix greyed plugin manager delete icons still being clickable
Fixes https://github.com/foosel/OctoPrint/issues/2549
2018-05-18 19:21:50 +10:00
Gina Häußge 846d3a63bc Merge pull request #2648 from malnvenshorn/class-methods-as-callbacks
Allow class methods as callbacks in view model
2018-05-18 10:00:48 +02:00
malnvenshorn 15d6bf3a70 Allow class methods as callbacks in view model 2018-05-17 19:11:52 +02:00
Gina Häußge cec1bc6c0f Allow plugins to override analysis & print time estimation
Using two new hooks, plugins may now provide alternative implementations
for the GCODE analysis and the live print time estimation.

Should allow people to get creative with regards to #1203, #1905, #2281,
#2445, #2514

Implements #1797, #1905
2018-05-17 18:58:15 +02:00
Gina Häußge 5456f5a70a Fix potential for invalid sorting of uploads
"date" and "size" might be undefined on both parameters (e.g. for
folders, SD files). We have no guarantee that "a" will always have
either defined, so make sure to test or a wrong sorting order might be
the consequence.

Fixes #2355
2018-05-17 10:57:01 +02:00
Gina Häußge e980444f86 Merge pull request #2642 from malnvenshorn/itemlisthelper-add-update
ItemListHelper - Methods for adding and updating items
2018-05-15 17:14:37 +02:00
malnvenshorn 9d1f4fb126 Add methods for adding and updating items 2018-05-14 13:52:03 +02:00
sylvled 3de5bca48b Update config_yaml.rst
gcodeAnalysis and gcodeViewer were without section name. Added them.
2018-05-07 10:28:14 +02:00
Gina Häußge 81471df419 Option to send M0/M1 to the printer
Also added a message to the serial output if M0/M1 is blocked.

Closes #1513
2018-05-05 15:49:59 +02:00
Gina Häußge 99ef84788a SWU: Support updating single items via UI
Closes #2615
2018-05-05 15:13:25 +02:00
Gina Häußge bfbf9fb66e Confirmation dialog helper now supports an html body 2018-05-05 15:12:03 +02:00
Gina Häußge 6074a3d964 Never send referrers with links 2018-05-05 14:01:29 +02:00
Gina Häußge 74e82afa24 About: Use github logo for source link 2018-05-05 13:50:27 +02:00
Gina Häußge 2b5c14b3c3 Change "Cancel" to "Close" on Settings
The Settings dialog also allows some "instant actions" (e.g. adding
users, changing specific plugin settings and so on). Having to click on
"Cancel" after actually doing something just feels wrong in such cases
so the Settings dialog now has a "Close" instead of a "Cancel" button.

Other sub dialogs will stay as is since that better reflects their
behaviour.
2018-05-05 13:48:19 +02:00
Gina Häußge e5b167bcb4 Merge branch 'pr/2595' into maintenance 2018-05-05 13:29:33 +02:00
Gina Häußge a70928aac6 Revert "Fix trivial copy and paste errors"
This reverts commit e02679a

It actually wasn't a copy and paste error - it *is* a plugin after all,
so "PluginSettings" makes sense.
2018-05-05 13:29:11 +02:00
Gina Häußge 7548e7a623 Revert "Replace "Cancel" label with "Abort" on buttons for consistency"
This reverts commit eb37607
2018-05-05 13:28:04 +02:00
Gina Häußge 8d9034b5a4 Gcode viewer: show approx. print head position
Also change retract/resume from dot to triangle/inverted triangle.

Closes #2318
2018-05-05 12:56:12 +02:00
Gina Häußge b5194ffc00 Plugin core: Fetch package name from entry point
See also #2625
2018-05-05 12:56:12 +02:00
Gina Häußge fa6cda3356 Merge pull request #2620 from malnvenshorn/itemlisthelper-save-pagesize
ItemListHelper - Save page size to local storage
2018-05-05 10:14:25 +02:00
Ben Lye 4d9ec9a7e3 Add M118 to commands to not uppercase
Adds M118 to the default list of commands which should not automatically be converted to uppercase.
2018-05-05 10:10:02 +02:00
Gina Häußge e44a2fdd97 Update pkginfo dependency 2018-05-04 12:55:32 +02:00
Gina Häußge 95ac669d5c Plugin subsystem: Use entry_point.dist to fetch metadata
Support egg "PKG-INFO" and wheel "METADATA" files in metadata folder. Less
guess work throughout the include path this way.

Better solution for #2625 than c3eebdb
2018-05-04 12:55:16 +02:00
Gina Häußge 5e899204f0 Merge branch 'hotfix/pip10' into maintenance 2018-05-03 18:02:14 +02:00
Gina Häußge c3eebdb158 Fix plugin metadata parsing for pip 10+ 2018-05-03 18:00:28 +02:00
Gina Häußge 13b85fbbd0 Fix fps source when rendering unrendered timelapse
Should be taken from config unless provided as parameter, not hard coded
to 25.

Closes #2621
2018-05-03 15:40:36 +02:00
Gina Häußge ddd2711f95 Fix a broken unit test
We now initialize the folders when initializing the settings, so the
test that the folder didn't yet exist before retrieving its path
naturally failed.
2018-05-03 12:18:10 +02:00
Gina Häußge 9addbbb9a1 Fix refactoring bug
Closes #2617
2018-05-03 11:45:46 +02:00
malnvenshorn 735e2c6c94 Convert page size to integer when reading from local storage 2018-05-01 15:50:27 +02:00
malnvenshorn 9d2ee2b55b Save page size to local storage 2018-05-01 12:32:55 +02:00
malnvenshorn 7988e7487f DRY principle for storage IDs 2018-05-01 12:21:01 +02:00
Gina Häußge 4bbe49ac6d Sanity check for configured folders
* On startup: Check they are writable, if not revert to defaults
  * On settings save: Check they are writable, if not return an HTTP 400
  * In the settings dialog: Allow quick check of writability via Test
    buttons

Should hopefully prevent users from nuking their instance by configuring
some custom folder that isn't writable.

TODO:
Currently simply doesn't close the settings dialog, needs some message
or something (or client side folder validation on clicking the button).
2018-04-27 17:44:07 +02:00
Gina Häußge 9e32439f44 Watchdog: Ignore hidden & removed files
Closes #2558
2018-04-27 16:17:04 +02:00
Gina Häußge 3ebb36f877 Disable user display if access control is disabled
Also show something more human friendly if the active user for a print
job is the "_api" user of the global api key.
2018-04-27 11:53:49 +02:00
Gina Häußge b2996f10ff Get rid of a bit of Python2 only code 2018-04-26 12:56:07 +02:00
Gina Häußge 42fb4f4700 Fix remember me and IPv4/IPv6 sessions
Session protection mode "strong" is apparently incompatible to the
remember me function in general and on top of that I observed issues
with at least Windows happily switching between connecting to an
instance via IPv4 and IPv6, causing changes in the reported client IP
and hence the session protection killing the session as a result.
2018-04-26 12:40:07 +02:00
Gina Häußge 52934602cd Fix forgotten self 2018-04-26 12:03:34 +02:00
Gina Häußge 2a0eda5c34 Make sure we have the current user data in editor
Fixes #2534
2018-04-26 11:30:48 +02:00
Gina Häußge a3b3fbe269 Add some more strings to the known error classes
"Missing linenumber" is apparently also an option we want to recognize
as non critical error, and while we are at it let's make sure we also
capture "linenumber" without a space for resend request communication
errors, just in case firmware devs add some variance here.
2018-04-26 11:00:29 +02:00
Gina Häußge 2fe177ffb8 Virtual: Fix default M114 format string 2018-04-25 17:01:24 +02:00
Gina Häußge d8bc75222f Remove some left overs from a small refactor
Closes #2610
2018-04-25 17:01:24 +02:00
Gina Häußge c3bb651d9e Properly decouple individual metadata locks
Thanks to @CapnBry for the heads-up here.
2018-04-25 17:01:24 +02:00
Gina Häußge 135cf6a9cc Migrate file storage metadata to json
As suggested by @CapnBry, that should give us a significant speed
boost considering that yaml serialization and deserialization is some
orders of magnitude slower than json.

We only do that for the file metadata for now - it has the biggest gain
to expect from a speed boost, and having the configuration as yaml
actually has its readability advantages.
2018-04-25 17:01:24 +02:00
Gina Häußge be4b98b9da Merge pull request #2604 from dforsi/fix/issue/2534
Reload older values after cancelling the Settings dialog
2018-04-25 10:51:41 +02:00
Gina Häußge 673b367902 Merge pull request #2591 from dforsi/fix/valid-html
Fix markup for some HTML labels
2018-04-25 10:41:57 +02:00
Gina Häußge 81626ceec5 Small change in user display in state panel 2018-04-24 16:52:17 +02:00
Gina Häußge b653ee59c8 Merge branch 'pr/2576' into maintenance
# Conflicts:
#	src/octoprint/printer/standard.py
2018-04-24 16:45:08 +02:00
Gina Häußge 79abe31a06 Move printing user into job data & add UI representation 2018-04-24 16:44:41 +02:00
Gina Häußge 30a523b8c1 Fix printer.select_file
* properly handle relative paths for selection
  * properly handle absolute paths for recovery data comparison

Fixes #2601
2018-04-24 16:00:09 +02:00
Gina Häußge c104f45b16 SWU: Default to force_base = False 2018-04-24 13:49:21 +02:00
Gina Häußge a9bc814016 Merge branch 'master' into maintenance 2018-04-24 13:18:47 +02:00
Gina Häußge edd00cfa80 Some adjustments for PyPI stuff 2018-04-24 12:41:45 +02:00
Daniele Forsi 60baf54d7b Refresh the details in the Connection pane when settings are updated 2018-04-23 23:54:02 +02:00
Daniele Forsi 536f5458bb Show details in the Connection pane ordered as in the Settings dialog
Return the Serial Port and the Baudrate lists without sorting them.
2018-04-23 16:05:47 +02:00
Daniele Forsi a4cc3a9309 Reload older values after cancelling the Settings dialog
Fixes #2534
2018-04-22 23:09:37 +02:00
Gina Häußge f72b92caff Revert Tornado 5 fixes for sockjs 2018-04-20 22:39:26 +02:00
Gina Häußge d3e7842c3a Revert "Minor adjustments for Tornado 5"
This reverts commit 258f3725bf.
2018-04-20 22:39:25 +02:00
Gina Häußge 555bdefd46 Pin tornado to >=4.5.3,<5 for now
There appears to be a memory leak issue with tornado 5.x as reported in #2585
2018-04-20 22:39:20 +02:00
Daniele Forsi 206c22f6aa Add some icons to the About page
Also moves Documentation so that the first 4 items are the same as in the footer.
2018-04-19 18:34:40 +02:00
Daniele Forsi 14959c2d66 Hide the buttons when the file list is hidden 2018-04-19 17:51:00 +02:00
Daniele Forsi eb3760715f Replace "Cancel" label with "Abort" on buttons for consistency
Now only the main settings dialog has a "Cancel" button and the other
dialogs have "Abort" on the buttons that do not save the changes.
2018-04-19 15:55:35 +02:00
Daniele Forsi e02679a587 Fix trivial copy and paste errors 2018-04-19 15:36:09 +02:00
Daniele Forsi 4064b3fc72 Make the API buttons and title in the Settings similar to those in other dialogs 2018-04-19 15:36:09 +02:00
Daniele Forsi e3f2a16e92 Fix caret icon always shown in position "closed" even whe details are visible 2018-04-19 15:36:09 +02:00
Gina Häußge a9441400b3 Merge branch 'fix/positionLogTimeout' into maintenance
# Conflicts:
#	src/octoprint/util/comm.py
2018-04-19 14:10:16 +02:00
Gina Häußge 09781613ce Add timeout for position log on pause/cancel
Workaround for firmware which doesn't provide a proper M114 report that might
be unparseable. We don't want to get stuck in such cases (which appear to be more
common than should be the case - this whole comm situation is just FUBAR).
2018-04-19 14:09:18 +02:00
Gina Häußge 63b63f6aad Test for image/* in snapshot test 2018-04-19 13:10:58 +02:00
Gina Häußge 1637187c76 Extend URL test to also allow whitelist/blacklist check for the returned content type 2018-04-19 13:10:41 +02:00
Gina Häußge 303ef405bb Fix snapshot test button not resetting on error 2018-04-19 13:01:37 +02:00
Gina Häußge bf3da2a662 Fixes a race condition causing stalls when pausing/cancelling
Closes #2581 & closes #2587
2018-04-18 13:02:36 +02:00
Gina Häußge b8194ecc84 Fixes a race condition causing stalls when pausing/cancelling
Closes #2581
2018-04-18 12:59:38 +02:00
Gina Häußge 472ab367b0 Disable logging the position on cancel by default
Apparently that is causing too many issues in the field. If someone
actually DOES need the position data, they can always enable this.
2018-04-18 12:59:38 +02:00
Gina Häußge 8f50180543 Virtual: allow defining custom M114 responses 2018-04-17 09:10:33 +02:00
Daniele Forsi 11eae082fc Remove invalid xmlns attributes so that the default value is used
Fixes 2 validation errors:
Error: Bad value http://www.w3.org/1999/html for the attribute xmlns (only http://www.w3.org/1999/xhtml permitted here).
          <div id="offline_overlay" xmlns="http://www.w3.org/1999/html">↩    <
Error: Bad value http://www.w3.org/1999/html for the attribute xmlns (only http://www.w3.org/1999/xhtml permitted here).
          <div id="reloadui_overlay" xmlns="http://www.w3.org/1999/html">↩    <
2018-04-16 20:07:28 +02:00
Daniele Forsi 885446328d Add missing "for" and "id" attributes to some HTML labels 2018-04-16 20:07:28 +02:00
Daniele Forsi 8cb4d84905 Fix HTML labels with wrong "for" attribute
Fixes some validation errors detected by https://validator.w3.org and other errors.
2018-04-16 20:07:28 +02:00
Gina Häußge 0da52cb366 Update pyserial to 3.4
Final part of the fix for #2333
2018-04-13 18:32:09 +02:00
Gina Häußge 57ea18a9a4 Fix Print Job Left display
Fixes #2579
2018-04-13 18:17:03 +02:00
Gina Häußge 06478415b5 Merge remote-tracking branch 'refs/remotes/origin/maintenance' into maintenance 2018-04-13 17:08:47 +02:00
Gina Häußge 6a8a1c31e3 maintenance is now 1.3.9.dev 2018-04-13 17:08:19 +02:00
Gina Häußge cce7961ee3 Merge branch 'staging/maintenance' into maintenance 2018-04-13 17:07:48 +02:00
Gina Häußge 725227338a Merge branch 'rc/maintenance' into staging/maintenance 2018-04-13 17:06:36 +02:00
Gina Häußge c55c568bbd Preparing release of 1.3.8 2018-04-13 16:22:44 +02:00
Gina Häußge 45d8c28883 Pin psutil to 5.4.3
Fixes #2577
2018-04-13 15:31:44 +02:00
Gina Häußge 8076e59861 Add hotfix branch type & set to tag tracking 2018-04-13 15:31:01 +02:00
malnvenshorn b41df46491 Added @malnvenshorn to AUTHORS.md 2018-04-12 17:00:37 +02:00
malnvenshorn 5205d2e352 Tracking user of print job 2018-04-12 16:15:53 +02:00
Gina Häußge 9c923be5f0 Better solution for the Tornado 5 + SockJS + haproxy issue
Looks like Nagle's algorithm was the cause. Adding

    option http-no-delay

to haproxy.cfg solves the problem without modification of the timeout,
however that is not an option for the thousands of instances already
deployed in the field.

So instead we add 300ms to the roundtrip based connection timeout, that
should hopefully get around any Nagle-induced delays (usually between
40 and 200ms according to various sites on the net).
2018-04-12 13:19:02 +02:00
Gina Häußge 88328bbe0e Merge pull request #2568 from vitormhenrique/master
Fix dead link on hooks documentation
2018-04-12 12:58:46 +02:00
Gina Häußge 132614045c Early detection & logging of broken files response
Fixes #2572
2018-04-12 12:08:19 +02:00
Gina Häußge a33b037364 Fix ItemListHelper throwing an error on undefined items
Just fall back to an empty list.

Fixed #2572 (at least the bit that isn't a broken nginx config)
2018-04-12 11:55:14 +02:00
Gina Häußge 33b27e450f Merge branch 'fix/sockjs' into maintenance 2018-04-11 18:47:18 +02:00
Gina Häußge a5d541dafc Fix sockjs not working behind haproxy
For some reason the websocket connection runs into a timeout, the xhr
transport doesn't properly take over, and then stuff takes ages to
realign again.

Only happens under Tornado 5, doesn't happen under Tornado 4.5

Increasing the timeout for now instead of pinning to Tornado 4.5 in the
hopes that might still be figured out.

Incredibly weird though.
2018-04-11 18:47:08 +02:00
Gina Häußge 258f3725bf Minor adjustments for Tornado 5 2018-04-11 18:43:23 +02:00
Gina Häußge c4d8e344d1 Remove wrongly placed whitespace 2018-04-11 11:15:46 +02:00
Gina Häußge f3128a15d9 Safety Plugin: Add Malyan M200 & CR-10S
Malyan M200 identified by firmware name "Malyan" and model "M200".
Printer also known as Monoprice Select Mini, see also ID strings in
#2271.

CR-10S identified by "Author: (CR-10Slanguage)".
2018-04-11 11:15:18 +02:00
Gina Häußge 6f224bd825 Workaround for typo & whitespace in Malyan M115 responses
NAME. instead of NAME:, whitespace between key and value component.
2018-04-11 11:12:56 +02:00
Vitor de Miranda Henrique 58bbbc2ad9 Update hooks.rst
Fix Software Update plugin link, it was pointing to an old github page --> https://github.com/OctoPrint/OctoPrint-SoftwareUpdate
instead of the bundled plugin--> https://github.com/foosel/OctoPrint/tree/master/src/octoprint/plugins/softwareupdate
2018-04-10 16:19:55 -05:00
Gina Häußge 75de062b55 Safety Plugin: Add detection of Anycubic Mega
Identified by "Author: (Jolly, xxxxxxxx.CO.)" in startup messages.
2018-04-10 18:09:55 +02:00
Gina Häußge 85dfcbd156 Merge branch 'staging/maintenance' into maintenance 2018-04-09 17:03:15 +02:00
Gina Häußge a6cec7d2ef Merge branch 'rc/maintenance' into staging/maintenance 2018-04-09 17:02:51 +02:00
Gina Häußge 7e0b187cb8 Bundle sockjs-tornado dependency
It appears to be unmaintained at the moment, and the current version
is incompatible to Tornado 5.

Instead of monkey patching ad infinitum we instead bundle the dependency
in the new vendor sub package.
2018-04-06 18:38:06 +02:00
Gina Häußge 025f545ef7 Better requirement detection in octoprint_setuptools
Plus unit tests.
2018-04-06 14:59:11 +02:00
Gina Häußge 6af1afb546 Don't tab to "forget password" link 2018-04-06 14:59:11 +02:00
Gina Häußge 1dd1eb3768 Merge pull request #2554 from tedder/upstream_maintenance
docfix: make 'settings' proper yaml
2018-04-06 09:33:32 +02:00
tedder 77d126fc09 make 'settings' proper yaml
See PR #2530; I assumed it should go into 'devel' so it is right in new releases, but Gina asked for it to be done here.
2018-04-05 13:38:25 -07:00
Gina Häußge 4a3902c060 Merge pull request #2533 from dforsi/fix/fix-api-buttons
Fix buttons not disabled when there isn't an API key available
2018-04-05 12:59:08 +02:00
Gina Häußge 83cdd4d79d Merge pull request #2552 from dforsi/fix/fix-typos
Fix typos in the docs
2018-04-05 12:58:00 +02:00
Daniele Forsi 1d1191eae0 Fix typos in the docs 2018-04-04 23:13:32 +02:00
Daniele Forsi 1efa0fa1e6 Fix buttons not disabled when there isn't an API key available
Also keeps always enabled the button to refresh the global API key.
Bootstrap buttons made from HTML <a> tags can only be disabled with CSS.
2018-04-04 20:09:06 +02:00
Gina Häußge 085424f192 Support for binding to IPv6 addresses
Defaults to :: if IPv6 is supported, 0.0.0.0 otherwise. Both
intermediary server and Tornado are instructed to bind their sockets to
both IP versions.

Positive IPv6 support detection relies on

  * socket.has_ipv6 being True
  * socket.IPPROTO_IPV6 and socket.IPV6_V6ONLY being available (or
    redefined in case of Windows) in order to ensure dual stack binding
    for the intermediary server

Implements #2351
2018-04-04 15:04:33 +02:00
Gina Häußge db23bed00b Remove intermediary dialog for "forgot password"
Might annoy people after all having to click twice just to get the
information they are looking for.

Can be changed if the process gets changed.
2018-04-04 13:12:53 +02:00
Gina Häußge 9c31fa88a5 Merge branch 'staging/maintenance' into maintenance 2018-04-04 12:36:24 +02:00
Gina Häußge c5439da9d2 staging/maintenance is now 1.3.7rc5.dev 2018-04-04 12:34:57 +02:00
Gina Häußge 561bf83d88 Merge pull request #2540 from dforsi/fix/fix-rst
Add missing documentation for GCODE analysis and other small fixes
2018-04-04 09:51:06 +02:00
Gina Häußge baf8941f31 Merge pull request #2532 from dforsi/fix/fix-typos
Fix typo
2018-04-04 09:49:42 +02:00
Daniele Forsi f7dec5542b Fix typos 2018-04-03 23:41:34 +02:00
Daniele Forsi 6ec8b97ddb Add missing documentation for GCODE analysis and other small fixes
Adds documentation for `dimensions` and `printingArea`; fixes `length`
and `volume`; adds two internal references.
Fixes #2463.
2018-04-03 20:35:58 +02:00
Gina Häußge 35343705ca Merge pull request #2543 from ganey/bugfix/pip--no-cache-dir
Pip install with --no-cache-dir to handle plugin installations with MemoryError
2018-04-03 13:49:59 +02:00
Ganey 22e894c245 Merge branch 'maintenance' into bugfix/pip--no-cache-dir 2018-04-03 12:46:05 +01:00
Gina Häußge 4ef01610d0 Merge pull request #2541 from dforsi/dev/forgot-email
Add link to instructions to reset passwords
2018-04-03 13:34:29 +02:00
Michael Gane bb065828f2 pip install using --no-cache-dir for low memory devices 2018-04-03 10:51:52 +01:00
Daniele Forsi d0637f61d4 Add link to instructions to reset passwords 2018-04-02 23:46:06 +02:00
Daniele Forsi 84319366d1 Fix typo 2018-03-29 22:11:36 +02:00
Gina Häußge 2152c401bf Merge branch 'staging/maintenance' into maintenance 2018-03-29 16:59:24 +02:00
Gina Häußge 0070349d66 Fix browser session getting overwritten by API key
Closes #2505
2018-03-27 16:53:14 +02:00
Gina Häußge 0cbad44055 Fix temperature profiles saving string values
Closes #2520
2018-03-27 16:23:13 +02:00
Gina Häußge 2571d32134 Include children on first level folder listings
This allows step-by-step traversal of file listings without the
recursive flag.

Fixes #2496
2018-03-27 15:29:53 +02:00
Gina Häußge 64ee8bac60 Support parsing xheaders in tornado
That will give us more accurate client ips, with a one hop limitation
however, see http://www.tornadoweb.org/en/stable/httpserver.html. If
more than one hop/reverse proxy is used in front of OctoPrint, their IPs
should be configured as server.reverseProxy.trustedDownstream in
config.yaml so they don't get detected as client IPs.

Implements #2512
2018-03-27 14:54:52 +02:00
Gina Häußge da392b9c9f Log asynchronously
Implements #2522
2018-03-27 13:50:03 +02:00
Gina Häußge 3179a1846f Update to Tornado 5 2018-03-27 11:45:02 +02:00
Gina Häußge b3912b2281 Remove legacyPluginAssets flag 2018-03-26 15:33:33 +02:00
Gina Häußge db14723ea2 Use regular scrollbars instead of slimscroll
See #2379
2018-03-26 15:17:17 +02:00
Gina Häußge 28831a68dd Add (configurable) small delay before baudrate detection
Solves issue with controllers that don't like baudrate switches right
after connection, e.g. the Einsy board.

Fixes #2517
2018-03-26 14:43:56 +02:00
Gina Häußge 6f18495395 Merge branch 'staging/maintenance' into maintenance 2018-03-23 16:29:06 +01:00
Gina Häußge fc2ef8a09c Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance 2018-03-23 14:59:25 +01:00
Gina Häußge 0809540bd7 force always means "now", even when printing 2018-03-23 14:58:47 +01:00
Gina Häußge 3a71d39785 Merge pull request #2504 from dforsi/fix/fix-typos
Fix typos
2018-03-23 10:11:55 +01:00
Gina Häußge c41aecc2b8 Merge pull request #2502 from dforsi/fix/valid-html
Fix some invalid HTML
2018-03-23 10:11:21 +01:00
Daniele Forsi 06f62bd874 Fix a typo in the docs 2018-03-22 00:23:02 +01:00
Daniele Forsi 23bcbba013 Fix typo 2018-03-21 19:28:22 +01:00
Daniele Forsi cb18d3fe32 Fix some invalid HTML
Fixes 4 kinds of errors found with https://validator.w3.org/nu/#textarea
Bad value javascript for attribute lang on element script
Bad character after < . Probable cause: Unescaped < . Try
escaping it as &lt; .
The element label must not appear as a descendant of the label element.
Element legend not allowed as child of element form in this context.

Note: the change related to <legend> seems big because of the increased
indent of the existing code (use "git diff --ignore-all-space" or
"git log --patch --ignore-all-space" to see the lines actually added).
2018-03-21 16:14:02 +01:00
Gina Häußge 95694453f4 Merge pull request #2495 from dforsi/fix/remove-unneeded-format
Remove unneeded format() filter from template
2018-03-20 16:51:16 +01:00
Gina Häußge 0825e0660f Merge pull request #2498 from dforsi/fix/issue/2487
Document the async flag of custom system commands
2018-03-20 16:50:19 +01:00
Daniele Forsi 819d4d0fdf Expand the description of custom system commands
Fixes #2487
2018-03-20 16:12:49 +01:00
Daniele Forsi 1c43e193ba Remove unneeded format() filter 2018-03-19 18:55:14 +01:00
Gina Häußge 4f1cd6b3a2 maintenance is now 1.3.8.dev 2018-03-19 17:19:38 +01:00
369 changed files with 33847 additions and 13905 deletions

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ trim_trailing_whitespace = true
[**.py]
indent_style = tab
indent_size = 4
[src/octoprint/static/js/app/**.js]
indent_style = space
+5
View File
@@ -0,0 +1,5 @@
# These are supported funding model platforms
github: [foosel]
patreon: foosel
custom: https://octoprint.org/support-octoprint/
@@ -1,3 +1,9 @@
---
name: Bug report
about: Create a report to help improve OctoPrint
---
<!--
READ THE FOLLOWING FIRST:
@@ -12,7 +18,7 @@ plugins and not unofficial OctoPrint versions).
Do not seek support here ("I need help with ...", "I have a
question ..."), that belongs on the community forum at
discourse.octoprint.org, NOT here.
community.octoprint.org, NOT here.
Mark requests with a "[Request]" prefix in the title please. For bug
reports fully fill out the bug reporting template (if you don't know
@@ -39,9 +45,10 @@ don't know what you did to get it to happen in the first place.
Ideally provide exact steps to follow in order to reproduce your problem:
-->
1. ...
2. ...
3. ...
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
<!--
If you encountered a problem with specific files of any sorts, make sure
+21
View File
@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
---
<!--
Please make sure to add [Request] to your issue's title. Thank you!
-->
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
+3 -2
View File
@@ -16,8 +16,9 @@ checklist:
made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a
Brainstorming ticket
* [ ] Your PR targets OctoPrint's devel branch, or maintenance if it's
a bug fix for an issue present in the current stable version (no PRs
* [ ] Your PR targets OctoPrint's devel branch if it's a completely
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)
* [ ] Your PR was opened from a custom branch on your repository
(no PRs from your version of master, maintenance or devel please),
+8 -7
View File
@@ -11,22 +11,23 @@
master
meta/.*
rc/.*
hotfix/.*
prerelease
# neither should disconnected checkouts, e.g. 'git checkout <tag>'
HEAD
\(detached.*
# maintenance is currently the branch for preparation of maintenance release 1.3.7
# maintenance is currently the branch for preparation of maintenance release 1.3.12
# so are any fix/... and improve/... branches
maintenance 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
fix/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
improve/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
maintenance 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
fix/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
improve/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
# staging/maintenance is currently the branch for preparation of 1.3.7rc4
# staging/maintenance is currently the branch for preparation of 1.3.12rc2
# so is regressionfix/...
staging/maintenance 1.3.7rc4 9c5d996ea2b66a085392981a5e6e0ee341013674 pep440-dev
regressionfix/.* 1.3.7rc4 9c5d996ea2b66a085392981a5e6e0ee341013674 pep440-dev
staging/maintenance 1.3.12rc2 2a42f02aecaedf2c55579984e0bc94e44402cc15 pep440-dev
regressionfix/.* 1.3.12rc2 2a42f02aecaedf2c55579984e0bc94e44402cc15 pep440-dev
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
+21
View File
@@ -87,6 +87,27 @@ date of first contribution):
* [Josh Major](https://github.com/astateofblank)
* ["alex-gh"](https://github.com/alex-gh)
* [Bernd Zeimetz](https://github.com/bzed)
* [Daniele Forsi](https://github.com/dforsi)
* [Ganey](https://github.com/ganey)
* [Sven Lohrmann](https://github.com/malnvenshorn)
* [Andy Castille](https://github.com/klikini)
* [Gaston Dombiak](https://github.com/gdombiak)
* [Brad Fisher](https://github.com/bradcfisher)
* [Aldo Hoeben](https://github.com/fieldofview)
* [Henning Groß](https://github.com/hgross)
* [Jubaleth](https://github.com/jubaleth)
* [Daniel Joyce](https://github.com/DanielJoyce)
* [Andy Qua](https://github.com/AndyQ)
* [Fabio Santos](https://github.com/Fabi0San)
* [Jack Wilsdon](https://github.com/jackwilsdon)
* [Ryan Finnie](https://github.com/rfinnie)
* [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
[Daid Braam](https://github.com/daid). Parts of its communication layer and
+560 -1015
View File
File diff suppressed because it is too large. Load diff
+18 -14
View File
@@ -27,7 +27,7 @@ to **address problems in a timely manner** but also keep it possible for them
to **fix bugs, add new and improve on existing functionality** instead of doing
nothing but ticket management.
![Ticket flow chart](https://i.imgur.com/SmU7iCJ.png)
![Ticket flow chart](https://i.imgur.com/cw19qHX.png)
- **[Read the FAQ](https://faq.octoprint.org)**
- If you want to report a **bug**, [read "How to file a bug report" below](#how-to-file-a-bug-report)
@@ -36,14 +36,14 @@ nothing but ticket management.
- If you want to post a **feature request** or a **documentation request**, add `[Request]`
to your issue's title (e.g. `[Request] Awesome new feature`). A question on how to run/change/setup
something is **not** what qualifies as a request here, use the
[community forum at discourse.octoprint.org](https://discourse.octoprint.org) for
[community forum at community.octoprint.org](https://community.octoprint.org) for
such support issues.
- If you are a **developer** that wants to brainstorm a pull request or possible
changes to the plugin system, add [Brainstorming] to your issue's title (e.g.
`[Brainstorming] New plugin hook for doing some cool stuff`).
changes to the plugin system, please get in touch on the
[community forum at community.octoprint.org](https://community.octoprint.org/c/development).
- If you need **support**, have a **question** or some **other reason** that
doesn't fit any of the above categories, the issue tracker is not the right place.
Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org) instead.
Consult the [community forum at community.octoprint.org](https://community.octoprint.org/c/support) instead.
No matter what kind of ticket you create, never mix two or more "ticket reasons"
into one ticket: One ticket per bug, request, brainstorming thread please.
@@ -53,7 +53,7 @@ into one ticket: One ticket per bug, request, brainstorming thread please.
> A bot is in place that monitors new tickets, automatically
> categorizes them and checks new bug reports for usage of the provided template.
> That bot will only bother you if you open a ticket that appears to be a bug (no
> `[Request]` or `[Brainstorming]` in the title) without the complete template, and it
> `[Request]` in the title) without the complete template, and it
> will do that only to ensure that all information needed to solve the issue is
> available for the maintainers to directly start tackling that problem.
@@ -75,7 +75,7 @@ following section *completely* and also follow the instructions in the
**OctoPrint doesn't manage your network connection or your webcam nor
can it fix your printer not getting detected as a serial interface** -
if you have any kinds of problems with that, get in touch on the
[community forum](https://discourse.octoprint.org).
[community forum](https://community.octoprint.org).
**This is not the bug tracker of OctoPi**, which is the preconfigured
Raspberry Pi image including OctoPrint among other things - that one can be found
@@ -126,7 +126,7 @@ following section *completely* and also follow the instructions in the
there's now also a [red herring](https://en.wikipedia.org/wiki/Red_herring) interfering - so please be
very diligent here!
If in doubt about any of the above - get in touch on the [community forum](https://discourse.octoprint.org)
If in doubt about any of the above - get in touch on the [community forum](https://community.octoprint.org)
instead of opening a ticket here. If you are actually running into a bug, we'll figure it out together
there.
@@ -153,7 +153,7 @@ plugins and not unofficial OctoPrint versions).
Do not seek support here ("I need help with ...", "I have a
question ..."), that belongs on the community forum at
discourse.octoprint.org, NOT here.
community.octoprint.org, NOT here.
Mark requests with a "[Request]" prefix in the title please. For bug
reports fully fill out the bug reporting template (if you don't know
@@ -275,11 +275,11 @@ all requested information or your ticket will be closed.
### Where can I find which version and branch I'm on?
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/how-can-i-find-out-the-version-of-octoprint-or-octopi-i-am-running/204/1).
Please refer to [this FAQ entry](https://community.octoprint.org/t/how-can-i-find-out-the-version-of-octoprint-or-octopi-i-am-running/204/1).
### Where can I find those log files you keep talking about?
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299/1).
Please refer to [this FAQ entry](https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299/1).
### Where can I find my browser's error console?
@@ -301,7 +301,8 @@ the documentation.
the discussion going on how best to solve *this* in OctoPrint's plugin
system - maybe that's the actual PR you have been waiting for to contribute :)
2. If you plan to make **any large or otherwise disruptive changes to the
code or appearance, please open a "Brainstorming" ticket first** so
code or appearance, please get in touch on the
[forums](https://community.octoprint.org/c/development)** first so
that we can determine if it's a good time for your specific pull
request. It might be that we're currently in the process of making
heavy changes to the code locations you'd target as well, or your
@@ -311,7 +312,8 @@ the documentation.
3. Create your pull request **from a custom branch** on your end (e.g.
`dev/myNewFeature`)[1].
4. Create your pull request **only against the `maintenance` or `devel` branch**:
* if it's a bug fix for a bug in the current stable version: `maintenance` branch
* if it's a bug fix for a bug in the current stable version, an improvement of existing functionality or a
*small* new feature (e.g. a new hook, a new config flag, ...): `maintenance` branch
* otherwise: `devel` branch
5. Create **one pull request per feature/bug fix**.
6. Make sure there are **only relevant changes** included in your PR. No
@@ -472,7 +474,9 @@ the local version identifier to allow for an exact determination of the active c
* 2017-11-22: Added note on how to run the unit tests
* 2018-03-15: Link to new community forum and some clarifications re bug
reporting
* 2018-03-29: "Where to find version numbers" is now located on the FAQ
* 2018-03-29: "Where to find version numbers" is now located on the FAQ
* 2018-10-18: Allow PRs against `maintenance` branch for improvements and small
new features, suggest getting in touch on the forum for larger changes
## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
View File
File renamed without changes.
+22 -10
View File
@@ -1,13 +1,21 @@
# OctoPrint
[![GitHub version](https://badge.fury.io/gh/foosel%2FOctoPrint.svg)](https://badge.fury.io/gh/foosel%2FOctoPrint)
![GitHub release](https://img.shields.io/github/release/foosel/OctoPrint.svg?colorB=brightgreen)
[![Travis build status](https://img.shields.io/travis/foosel/OctoPrint.svg)](https://travis-ci.org/foosel/OctoPrint)
[![Discourse topics](https://img.shields.io/discourse/https/community.octoprint.org/users.svg)](https://community.octoprint.org)
[![IRC](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://chat.octoprint.org)
[![Twitter Follow](https://img.shields.io/twitter/follow/OctoPrint3d.svg?style=social&label=Follow)](https://twitter.com/OctoPrint3d)
OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software
and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html).
Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme).
The community forum is available at [discourse.octoprint.org](https://discourse.octoprint.org/?utm_source=github&utm_medium=readme).
The community forum is available at [community.octoprint.org](https://community.octoprint.org/?utm_source=github&utm_medium=readme).
The official IRC channel is [#octoprint on freenode](https://chat.octoprint.org). Its logs can be found [here](https://freenode.logbot.info/octoprint).
The FAQ can be accessed by following [faq.octoprint.org](https://faq.octoprint.org/?utm_source=github&utm_medium=readme).
@@ -23,16 +31,16 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!**
You are currently looking at the source code repository of OctoPrint. If you already installed it
(e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
might be of more interest for you. You might also want to subscribe to join
[the community forum at discourse.octoprint.org](https://discourse.octoprint.org) where there are other active users who might be
might be of more interest for you. You might also want to subscribe to join
[the community forum at community.octoprint.org](https://community.octoprint.org) where there are other active users who might be
able to help you with any questions you might have.
## Contributing
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
[official documentation](http://docs.octoprint.org/) 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
[the community forum at discourse.octoprint.org](https://discourse.octoprint.org)
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
[the community forum at community.octoprint.org](https://community.octoprint.org)
and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
If you think something is bad about OctoPrint or its documentation the way it is, please help
@@ -57,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`
2. Change into the OctoPrint folder: `cd OctoPrint`
3. Create a user-owned virtual environment therein: `virtualenv venv`
3. Create a user-owned virtual environment therein: `virtualenv venv` if your system default python version is
python 2.7, otherwise you need to specify the version explicitly, e.g. `virtualenv --python=python2.7 venv`.
4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .`
You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage)
for details.
After installation, please make sure you follow the first-run wizard and set up
access control as necessary.
access control as necessary.
## Dependencies
@@ -134,5 +143,8 @@ be edited from OctoPrint's settings dialog.
## Special Thanks
Cross-browser testing services are kindly provided by [BrowserStack](http://www.browserstack.com/).
Profiling is done with the help of [PyVmMonitor](http://www.pyvmmonitor.com).
Cross-browser testing services are kindly provided by [BrowserStack](https://www.browserstack.com/).
Profiling is done with the help of [PyVmMonitor](https://www.pyvmmonitor.com).
Error tracking is powered and sponsored by [Sentry](https://sentry.io).
+11
View File
@@ -0,0 +1,11 @@
# Security Policy
## Supported Versions
Always update to the latest version of OctoPrint to keep up with security patches.
## Reporting a Vulnerability
Email to security@octoprint.org.
For the sake of the userbase of OctoPrint please always disclose responsibly and with a 90+ day window.
+22 -21
View File
@@ -1,58 +1,59 @@
# Supporters
Development of this version of OctoPrint wouldn't have been possible without
[financial support by the community](http://octoprint.org/support-octoprint/) -
[the financial support by the community](https://octoprint.org/support-octoprint/) -
thanks to everyone who contributed!
## Patreon Patrons
* Andre Bubel
* Andrew Moorby
* ANTONIO AUGUSTO DE LIMA PONTES
* Arnljot Arntsen
* Boris Hussein
* Brad Jackson
* Brian E. Tyler
* Christian Petropolis
* Christian Wolf
* COLLE+McVOY
* D Brian Kimmel
* DeltaMaker 3D Printers
* Dorian Gray
* E3D BigBox
* Eric Betts
* Ernesto Martinez
* F. Kunsmann
* Frank Sander
* Gary Deen
* günter weber
* James Seigel
* Jeff Moe
* Franziska Kunsmann
* George Robles
* jean-claude migneault
* Jeff Renfer
* Jefferson Hunt
* Jeremiah Avery
* Josh Daniels
* Joshua Wills
* Justin Kaufman
* Kaile Riser
* Kale Stedman
* Kazuhiro Ogura
* Kodama Inc.
* LA 3D Printer Repair
* Lee Dohm
* LulzBot®
* Makespace Madrid
* Mark Walker
* Martin Beattie
* Michael Aumock
* Miles Flavel
* mitchell hirsch
* Mohammed khorakiwala
* Noe Ruiz
* Mosaic Manufacturing
* OMER MEHMET SUTAS
* Patrick Glyré
* Patrick McGinnis
* Peter Schmehl
* Prof Yuh Wen Chen
* Randy C. Will
* Ranjib Dey
* Robert Gusek
* Roger Strolz
* Roy Cortes
* Samer Najia
* Shawn Lewis
* Simon Hallam
* Stefan Krister
* Stephane Schittly
* Sven Mueller
* Symbiotic Devices
* Thomas Hatley
* Trent Shumay
* Ulrich Kempken
* Vladislav Kuzemchik
and 1233 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1615 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
-2
View File
@@ -36,7 +36,6 @@
* [Awesome-Slugify](https://pypi.python.org/pypi/awesome-slugify): GPLv3
* [chainmap](https://bitbucket.org/jeunice/chainmap): Python
* [Click](http://click.pocoo.org/): BSD
* [dateutil](https://dateutil.readthedocs.io/): BSD
* [emoji](https://github.com/carpedm20/emoji/): BSD
* [feedparser](https://github.com/kurtmckee/feedparser): BSD
* [Flask](http://flask.pocoo.org/): BSD
@@ -71,7 +70,6 @@
* [ddt](https://github.com/txels/ddt): MIT
* [mock](https://github.com/testing-cabal/mock): BSD
* [nose](http://pythonhosted.org/nose/): LGPL
* [pypandoc](https://github.com/bebraw/pypandoc): MIT
* [Sphinx](http://sphinx-doc.org/): BSD
* [sphinxcontrib-httpdomain](https://bitbucket.org/birkenfeld/sphinx-contrib/src/default/httpdomain/): BSD
* [sphinxcontrib-mermad](https://github.com/mgaitan/sphinxcontrib-mermaid): BSD
+4
View File
@@ -11,6 +11,10 @@ Apps
Session Keys
============
.. deprecated:: 1.3.11
This functionality will be removed in 1.4.0. Use the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` instead.
OctoPrint offers a special API key type for apps to use, the so called App Session Key. These keys have a time based
validity and are generated by OctoPrint for requesting apps.
+1 -1
View File
@@ -59,7 +59,7 @@ Issue a connection command
Issue a connection command. Currently available command are:
connect
Instructs OctoPrint to connect to the printer. Additional parameters are:
Instructs OctoPrint to connect or, if already connected, reconnect to the printer. Additional parameters are:
* ``port``: Optional, specific port to connect to. If not set the current ``portPreference`` will be used, or if
no preference is available auto detection will be attempted.
+67 -9
View File
@@ -218,6 +218,17 @@ Progress information
- 1
- Integer
- 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:
@@ -263,8 +274,11 @@ File information
- Path to type of file in extension tree. E.g. ``["model", "stl"]`` for ``.stl`` files, or ``["machinecode", "gcode"]``
for ``.gcode`` files. ``["folder"]`` for folders.
Additional properties depend on ``type``. For a ``type`` value of ``folder``, see "Folders". For any other value
see "Files".
Additional properties depend on ``type``.
For a ``type`` value of ``folder``, see :ref:`Folders <sec-api-datamodel-files-folders>`.
For any other value see :ref:`Files <sec-api-datamodel-files-files>`.
.. _sec-api-datamodel-files-folders:
Folders
'''''''
@@ -280,13 +294,14 @@ Folders
* - ``children``
- 0..*
- Array of :ref:`File information items <sec-api-datamodel-files-file>`
- Contained children for entries of type ``folder``. Will only include children in subfolders in recursive
listings. Not present in non recursive listings, this might be revisited in the future.
- Contained children for entries of type ``folder``. On non recursive listings only present on first level
sub folders!
* - ``size``
- 0..1
- Number
- The size of all files contained in the folder and its subfolders. Not present in non recursive listings, this might
be revisited in the future.
- The size of all files contained in the folder and its subfolders. Not present in non recursive listings!
.. _sec-api-datamodel-files-files:
Files
'''''
@@ -385,14 +400,58 @@ GCODE analysis information
- 0..1
- Object
- The estimated usage of filament
* - ``filament.length``
* - ``filament.tool{n}.length``
- 0..1
- Integer
- The length of filament used, in mm
* - ``filament.volume``
* - ``filament.tool{n}.volume``
- 0..1
- Float
- The volume of filament used, in cm³
* - ``dimensions``
- 0..1
- Object
- Information regarding the size of the printed model
* - ``dimensions.depth``
- 0..1
- Float
- The depth of the printed model, in mm
* - ``dimensions.height``
- 0..1
- Float
- The height of the printed model, in mm
* - ``dimensions.width``
- 0..1
- Float
- The width of the printed model, in mm
* - ``printingArea``
- 0..1
- Object
- Information regarding the size of the printing area
* - ``printingArea.maxX``
- 0..1
- Float
- The maximum X coordinate of the printed model, in mm
* - ``printingArea.maxY``
- 0..1
- Float
- The maximum Y coordinate of the printed model, in mm
* - ``printingArea.maxZ``
- 0..1
- Float
- The maximum Z coordinate of the printed model, in mm
* - ``printingArea.minX``
- 0..1
- Float
- The minimum X coordinate of the printed model, in mm
* - ``printingArea.minY``
- 0..1
- Float
- The minimum Y coordinate of the printed model, in mm
* - ``printingArea.minZ``
- 0..1
- Float
- The minimum Z coordinate of the printed model, in mm
.. _sec-api-datamodel-files-ref:
@@ -421,4 +480,3 @@ References
- URL
- The model from which this file was generated (e.g. an STL, currently not used). Never present for
folders.
+32 -3
View File
@@ -82,8 +82,37 @@ Retrieve all files
"path": "folderA",
"type": "folder",
"typePath": ["folder"],
"children": [],
"size": 1334
"children": [
{
"name": "whistle_v2_copy.gcode",
"path": "whistle_v2_copy.gcode",
"type": "machinecode",
"typePath": ["machinecode", "gcode"],
"hash": "...",
"size": 1468987,
"date": 1378847754,
"origin": "local",
"refs": {
"resource": "http://example.com/api/files/local/folderA/whistle_v2_copy.gcode",
"download": "http://example.com/downloads/files/local/folderA/whistle_v2_copy.gcode"
},
"gcodeAnalysis": {
"estimatedPrintTime": 1188,
"filament": {
"length": 810,
"volume": 5.36
}
},
"print": {
"failure": 4,
"success": 23,
"last": {
"date": 1387144346,
"success": true
}
}
}
]
}
],
"free": "3.2GB"
@@ -443,7 +472,7 @@ Upload file or create folder
:form select: Whether to select the file directly after upload (``true``) or not (``false``). Optional, defaults
to ``false``. Ignored when creating a folder.
:form print: Whether to start printing the file directly after upload (``true``) or not (``false``). If set, ``select``
is implicitely ``true`` as well. Optional, defaults to ``false``. Ignored when creating a folder.
is implicitly ``true`` as well. Optional, defaults to ``false``. Ignored when creating a folder.
:form userdata: [Optional] An optional string that if specified will be interpreted as JSON and then saved along
with the file as metadata (metadata key ``userdata``). Ignored when creating a folder.
:form foldername: The name of the folder to create. Ignored when uploading a file.
+115 -10
View File
@@ -11,9 +11,12 @@ General information
Authorization
=============
OctoPrint's API expects an API key to be supplied with each request. This API key can be either the globally
configured one, a user specific one if "Access Control" is enabled or an :ref:`App Session Key <sec-api-apps-sessionkey>`.
Users are able to generate and revoke their custom API key via the "Change password" dialog.
If :ref:`Access Control <sec-features-access_control>` is enabled OctoPrint's API expects an API key to be supplied with each request. This API
key can be either the globally configured one, a user specific one or an app and user specific one as generated by the
authorization workflow implemented by the bundled :ref:`Application Keys Plugin <sec-bundledplugins-appkeys>` (since 1.3.10).
Clients are advised to implement the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` first and
fallback on directing the user to manually supply the the user specific API key. The global key should rarely be used.
The API key must be supplied in the custom HTTP header ``X-Api-Key``, e.g.
@@ -23,8 +26,6 @@ The API key must be supplied in the custom HTTP header ``X-Api-Key``, e.g.
Host: example.com
X-Api-Key: abcdef...
If it is missing or included but invalid, OctoPrint will directly return a response with status :http:statuscode:`401`.
For testing purposes it is also possible to supply the API key via a query parameter ``apikey``, e.g.
.. sourcecode:: http
@@ -34,6 +35,24 @@ For testing purposes it is also possible to supply the API key via a query param
Please be advised that clients should use the header field variant if at all possible.
If the key is missing or invalid, OctoPrint will treat the request as it would any unauthenticated anonymous request to the endpoint.
Consequently, if the bundled :ref:`ForceLogin plugin <sec-bundledplugins-forcelogin>` is active (which is the default), that means
that any requests without or with an invalid API key targeting other API endpoints than :ref:`Login <sec-api-general-login>`
will be denied with a :http:statuscode:`403`.
.. warning::
If :ref:`Access Control <sec-features-access_control>` is disabled, OctoPrint will treat any unauthenticated anonymous requests and thus also requests
with an invalid or outright missing API key as requests with full admin rights!
.. note::
The API key requirements changed in 1.3.11. Up to that version, even if Access Control was disabled, all requests needed to
be supplied with an API Key. To make the webinterface work under these circumstances, an unauthenticated anonymous API key was injected into the
HTML page and also available on the :ref:`Push API <sec-api-push>`. The presence and ready availability of this unauthenticated
anonymous "UI API key" caused confusion and false alarm among users and didn't contribute to the security of the platform in a
meaningful way, so it was finally abandoned in 1.3.11.
.. _fig-api-general-globalapikey:
.. figure:: ../images/settings-global-api-key.png
:align: center
@@ -55,11 +74,6 @@ Please be advised that clients should use the header field variant if at all pos
The API key options in the "Change password" dialog. Users can generate and revoke their custom API key here.
.. note::
OctoPrint's web interface uses a custom API key that is freshly generated on every server start. This key is not
intended to be used by any other client and would not be very useful in any case, since it basically represents
a completely anonymous client.
.. _sec-api-general-contenttype:
Content Type
@@ -120,3 +134,94 @@ If CORS is not enabled you will get errors like the following::
XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin'
header is present on the requested resource.
.. _sec-api-general-login:
Login
=====
.. http:post:: /api/login
Creates a login session or retrieves information about the currently existing session ("passive login").
Can be used in one of two ways: to login a user via username and password and create a persistent session (usually
from a UI in the browser), or to retrieve information about the active user (from an existing session or an API key)
via the ``passive`` flag.
Will return a :http:statuscode:`200` with a :ref:`login response <sec-api-general-datamodel-login>` on successful
login, whether active or passive. The active (username/password) login may also return a :http:statuscode:`401` in
case of a username/password mismatch or unknown user and a :http:statuscode:`403` in case of a deactivated account.
:json passive: If present, performs a passive login only, returning information about the current user that's
active either through an existing session or the used API key
:json user: (active login only) Username
:json pass: (active login only) Password
:json remember: (active login only) Whether to set a "remember me" cookie on the session
:status 200: Successful login
:status 401: Username/password mismatch or unknown user
:status 403: Deactivated account
.. _sec-api-general-logout:
Logout
======
.. http:post:: /api/logout
Ends the current login session of the current user.
Only makes sense in the context of browser based workflows.
Will return a :http:statuscode:`204`.
:status 204: No error
.. _sec-api-general-datamodel:
Data model
==========
.. _sec-api-general-datamodel-login:
Login response
--------------
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``name``
- 1
- string
- the user's name/id
* - ``active``
- 1
- boolean
- Whether the user's account is active or not
* - ``admin``
- 1
- boolean
- Whether the user has admin rights or not
* - ``user``
- 1
- boolean
- Whether the user has user rights or not (always ``true``)
* - ``apikey``
- 1
- string or None
- The user's API key, if set
* - ``settings``
- 1
- dict
- The user's settings, if any
* - ``session``
- 1
- string
- The session key, can be used to authenticate with the ``auth`` message on the :ref:`push API <sec-api-push>`.
* - ``_is_external_client``
- 1
- boolean
- Whether the client that made the request got detected as external from the local network or not.
+7 -2
View File
@@ -212,7 +212,8 @@ Retrieve information about the current job
"filepos": 337942,
"printTime": 276,
"printTimeLeft": 912
}
},
"state": "Printing"
}
:statuscode 200: No error
@@ -243,4 +244,8 @@ Job information response
- 1
- :ref:`sec-api-datamodel-jobs-progress`
- Information regarding the progress of the current print job
* - ``state``
- 1
- String
- A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused",
"Cancelling", "Error" or "Offline".
+208 -13
View File
@@ -22,6 +22,11 @@ Bed
corresponding resource returns temperature information including an optional history. Note that Bed commands
are only available if the currently selected printer profile has a heated bed.
See :ref:`sec-api-printer-bedcommand`.
Chamber
Chamber commands allow setting the temperature and temperature offset for the printer's heated chamber. Querying
the corresponding resource returns temperature information including an option history. Note that Chamber commands
are only available if the currently selected printer profile has a heated chamber.
See :ref:`sec-api-printer-chambercommand`.
SD card
SD commands allow initialization, refresh and release of the printer's SD card (if available). Querying the
corresponding resource returns the current SD card state.
@@ -37,7 +42,7 @@ Besides that, OctoPrint also provides a :ref:`full state report of the printer <
OctoPrint's internal webserver is single threaded and can only handle one request at a time. This is
not a problem generally since asynchronous programming allows to just have one request which is waiting for
data from a long running backend operation to sleep while handling other requests. The internal framework
used for providing the REST API though, Flask, is based on WSGI, which is synchrounous in nature. This means
used for providing the REST API though, Flask, is based on WSGI, which is synchronous in nature. This means
that it is impossible to wait in a non blocking wait while handling a request on the REST API. So in order to
return the response of a command sent to the printer, the single thread of the webserver would have to be blocked
by the API while the response wasn't available yet. Which in turn would mean that the whole web server would
@@ -219,7 +224,7 @@ Issue a print head command
axes values are relative amounts) or to absolute position (provided axes values are coordinates)
* ``speed``: Optional. Speed at which to move. If not provided, minimum speed for all selected axes from printer
profile will be used. If provided but ``false``, no speed parameter will be appended to the command. Otherwise
interpreted as an integer signifying the speed in mm/s, to append to the command.
interpreted as an integer signifying the speed in mm/min, to append to the command.
home
Homes the print head in all of the given axes. Additional parameters are:
@@ -229,7 +234,7 @@ Issue a print head command
feedrate
Changes the feedrate factor to apply to the movements of the axes.
* ``factor``: The new factor, percentage as integer or float (percentage divided by 100) between 50 and 200%.
* ``factor``: The new factor, percentage between 50 and 200% as integer (``50`` to ``200``) or float (``0.5`` to ``2.0``).
All of these commands except ``feedrate`` may only be sent if the printer is currently operational and not printing.
Otherwise a :http:statuscode:`409` is returned.
@@ -280,9 +285,9 @@ Issue a print head command
HTTP/1.1 204 No Content
**Example feed rate request**
**Example feed rate request (1/2)**
Set the feed rate factor to 105%.
Set the feed rate factor to 105% using an integer argument.
.. sourcecode:: http
@@ -300,6 +305,26 @@ Issue a print head command
HTTP/1.1 204 No Content
**Example feed rate request (2/2)**
Set the feed rate factor to 105% using a float argument.
.. sourcecode:: http
POST /api/printer/printhead HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...
{
"command": "feedrate",
"factor": 1.05
}
.. sourcecode:: http
HTTP/1.1 204 No Content
:json string command: The command to issue, either ``jog`` or ``home``.
:json number x: ``jog`` command: The amount to travel on the X axis in mm.
:json number y: ``jog`` command: The amount to travel on the Y axis in mm.
@@ -325,7 +350,7 @@ Issue a tool command
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
tool's index starting with 0.
tool's index starting with 0. A value of `0` will turn the heater off.
offset
Sets the given temperature offset on the printer's tools. Additional parameters:
@@ -342,11 +367,13 @@ Issue a tool command
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
* ``speed``: Optional. Speed at which to extrude. If not provided, maximum speed for E axis from printer
profile will be used. Otherwise interpreted as an integer signifying the speed in mm/min, to append to the command.
flowrate
Changes the flow rate factor to apply to extrusion of the tool.
* ``factor``: The new factor, percentage as integer or float (percentage divided by 100) between 75 and 125%.
* ``factor``: The new factor, percentage between 75 and 125% as integer (``75`` to ``125``) or float (``0.75`` to ``1.25``).
All of these commands may only be sent if the printer is currently operational and -- in case of ``select`` and
``extrude`` -- not printing. Otherwise a :http:statuscode:`409` is returned.
@@ -461,9 +488,9 @@ Issue a tool command
HTTP/1.1 204 No Content
**Example flow rate request**
**Example flow rate request (1/2)**
Set the flow rate factor to 95%.
Set the flow rate factor to 95% using an integer attribute.
.. sourcecode:: http
@@ -481,6 +508,26 @@ Issue a tool command
HTTP/1.1 204 No Content
**Example flow rate request (2/2)**
Set the flow rate factor to 95% using a float attribute.
.. sourcecode:: http
POST /api/printer/tool HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...
{
"command": "flowrate",
"factor": 0.95
}
.. sourcecode:: http
HTTP/1.1 204 No Content
:json string command: The command to issue, either ``target``, ``offset``, ``select`` or ``extrude``.
:json object targets: ``target`` command: The target temperatures to set. Valid properties have to match the format ``tool{n}``.
:json object offsets: ``offset`` command: The offset temperature to set. Valid properties have to match the format ``tool{n}``.
@@ -581,12 +628,12 @@ Issue a bed command
are:
target
Sets the given target temperature on the printer's tools. 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
Sets the given temperature offset on the printer's tools. Additional parameters:
Sets the given temperature offset on the printer's bed. Additional parameters:
* ``offset``: Offset to set.
@@ -668,7 +715,7 @@ Retrieve the current bed state
an :http:statuscode:`409`.
.. note::
If you want both tool and bed temperature information at the same time, take a look at
If you want tool, bed and chamber temperature information at the same time, take a look at
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
**Example**
@@ -718,6 +765,154 @@ Retrieve the current bed state
:statuscode 409: If the printer is not operational or the selected printer profile
does not have a heated bed.
.. _sec-api-printer-chambercommand:
Issue a chamber command
=======================
.. http:post:: /api/printer/chamber
Chamber commands allow setting the temperature and temperature offsets for the printer's heated chamber. Available commands
are:
target
Sets the given target temperature on the printer's chamber. Additional parameters:
* ``target``: Target temperature to set. A value of `0` will turn the heater off.
offset
Sets the given temperature offset on the printer's chamber. Additional parameters:
* ``offset``: Offset to set.
All of these commands may only be sent if the printer is currently operational. Otherwise a :http:statuscode:`409`
is returned.
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
If no heated chamber is configured for the currently selected printer profile, the resource will return
an :http:statuscode:`409`.
Requires user rights.
**Example Target Temperature Request**
Set the target temperature for the printer's heated chamber to 50°C.
.. sourcecode:: http
POST /api/printer/chamber HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...
{
"command": "target",
"target": 50
}
.. sourcecode:: http
HTTP/1.1 204 No Content
**Example Offset Temperature Request**
Set the temperature offset for the heated chamber to -5°C.
.. sourcecode:: http
POST /api/printer/chamber HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...
{
"command": "offset",
"offset": -5
}
.. sourcecode:: http
HTTP/1.1 204 No Content
:json string command: The command to issue, either ``target`` or ``offset``.
:json object target: ``target`` command: The target temperature to set.
:json object offset: ``offset`` command: The offset temperature to set.
:statuscode 204: No error
:statuscode 400: If ``target`` or ``offset`` is not a valid number or outside of the supported range, or if the
request is otherwise invalid.
:statuscode 409: If the printer is not operational or the selected printer profile
does not have a heated chamber.
.. _sec-api-printer-chamberstate:
Retrieve the current chamber state
==================================
.. http:get:: /api/printer/chamber
Retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target,
timestamp) for the printer's heated chamber.
It's also possible to retrieve the temperature history by supplying the ``history`` query parameter set to ``true``. The
amount of returned history data points can be limited using the ``limit`` query parameter.
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
If no heated chamber is configured for the currently selected printer profile, the resource will return
an :http:statuscode:`409`.
.. note::
If you want tool, bed and chamber temperature information at the same time, take a look at
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
**Example**
Query the chamber temperature data and also include the temperature history but limit it to two entries.
.. sourcecode:: http
GET /api/printer/chamber?history=true&limit=2 HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"chamber": {
"actual": 50.221,
"target": 70.0,
"offset": 5
},
"history": [
{
"time": 1395651928,
"chamber": {
"actual": 50.221,
"target": 70.0
}
},
{
"time": 1395651926,
"chamber": {
"actual": 49.1123,
"target": 70.0
}
}
]
}
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
will be returned. Will be ignored if ``history`` is not enabled.
:statuscode 200: No error
:statuscode 409: If the printer is not operational or the selected printer profile
does not have a heated chamber.
.. _sec-api-printer-sdcommand:
Issue an SD command
+10 -1
View File
@@ -52,6 +52,7 @@ Retrieve all printer profiles
"height": 200
},
"heatedBed": true,
"heatedChamber": false,
"axes": {
"x": {
"speed": 6000,
@@ -93,6 +94,7 @@ Retrieve all printer profiles
"height": 200
},
"heatedBed": true,
"heatedChamber": true,
"axes": {
"x": {
"speed": 6000,
@@ -184,6 +186,7 @@ Add a new printer profile
"height": 200
},
"heatedBed": true,
"heatedChamber": false,
"axes": {
"x": {
"speed": 6000,
@@ -267,6 +270,7 @@ Add a new printer profile
"height": 300
},
"heatedBed": false,
"heatedChamber": false,
"axes": {
"x": {
"speed": 6000,
@@ -352,6 +356,7 @@ Update an existing printer profile
"height": 200
},
"heatedBed": true,
"heatedChamber": false,
"axes": {
"x": {
"speed": 6000,
@@ -578,10 +583,14 @@ Profile
- 0..1
- ``boolean``
- Whether the printer has a heated bed (``true``) or not (``false``)
* - ``heatedChamber``
- 0..1
- ``boolean``
- Whether the printer has a heated chamber (``true``) or not (``false``)
* - ``axes``
- 0..1
- Object
- Description of the printer's axes properties, one entry each for ``x``, ``y``, ``z`` and ``e`` holding maxium speed
- Description of the printer's axes properties, one entry each for ``x``, ``y``, ``z`` and ``e`` holding maximum speed
and whether this axis is inverted or not.
* - ``axes.{axis}.speed``
- 0..1
+32 -14
View File
@@ -47,23 +47,41 @@ Clients must ignore any unknown messages.
The data model of the attached payloads is described further below.
OctoPrint's SockJS socket also accepts one command from the client to the server,
the ``throttle`` command. Usually, OctoPrint will push the general state update
in the ``current`` message twice per second. For some clients that might still
be too fast, so they can signal a different factor to OctoPrint utilizing the
``throttle`` message. OctoPrint expects a single integer here which represents
the multiplier for the base rate limit of one message every 500ms. A value of
1 hence will produce the default behaviour of getting every update. A value of
2 will set the rate limit to maximally one message every 1s, 3 to maximally one
message every 1.5s and so on.
OctoPrint's SockJS socket also accepts two commands from the client to the server.
Example for a ``throttle`` client-server-message:
* ``auth`` (since 1.3.10): With the ``auth`` message, clients may associate an
existing user session with the socket. That is of special importance to receive
any kind of messages if the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` is enabled
(as it is by default), since it will prevent any kind of status messages to be sent to connected unauthenticated
clients.
.. sourcecode:: javascript
The ``auth`` message expects the user id of the user to authenticate followed by ``:`` and a session key to be
obtained from the successful payload of a :ref:`(passive or active) login via the API <sec-api-general-login>`.
{
"throttle": 2
}
Example for a ``auth`` client-server-message:
.. sourcecode:: javascript
{
"auth": "someuser:LGZ0trf8By"
}
* ``throttle``: Usually, OctoPrint will push the general state update
in the ``current`` message twice per second. For some clients that might still
be too fast, so they can signal a different factor to OctoPrint utilizing the
``throttle`` message. OctoPrint expects a single integer here which represents
the multiplier for the base rate limit of one message every 500ms. A value of
1 hence will produce the default behaviour of getting every update. A value of
2 will set the rate limit to maximally one message every 1s, 3 to maximally one
message every 1.5s and so on.
Example for a ``throttle`` client-server-message:
.. sourcecode:: javascript
{
"throttle": 2
}
.. _sec-api-push-datamodel:
+262 -2
View File
@@ -86,6 +86,266 @@ Regenerate the system wide API key
:status 200: No error
:status 403: No admin rights
.. _sec-api-settings-fetchtemplaatedata:
Fetch template data
===================
.. http:get:: /api/settings/templates
Fetch data (currently only the sorting order) of all registered template components in the system.
Use this to get a full list of the identifiers of all UI components provided either by core OctoPrint or any
currently active plugins.
Example:
.. sourcecode:: http
GET /api/settings/templates HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"order": {
"about": [
{
"id": "about",
"name": "About OctoPrint"
},
{
"id": "supporters",
"name": "Supporters"
},
{
"id": "authors",
"name": "Authors"
},
{
"id": "changelog",
"name": "Changelog"
},
{
"id": "license",
"name": "OctoPrint License"
},
{
"id": "thirdparty",
"name": "Third Party Licenses"
},
{
"id": "plugin_pluginmanager",
"name": "Plugin Licenses",
"plugin_id": "pluginmanager",
"plugin_name": "Plugin Manager"
}
],
"generic": [
{
"id": "plugin_announcements",
"name": "plugin_announcements",
"plugin_id": "announcements",
"plugin_name": "Announcement Plugin"
}
],
"navbar": [
{
"id": "settings",
"name": "settings"
},
{
"id": "systemmenu",
"name": "systemmenu"
},
{
"id": "plugin_announcements",
"name": "plugin_announcements",
"plugin_id": "announcements",
"plugin_name": "Announcement Plugin"
},
{
"id": "login",
"name": "login"
}
],
"plugin_pluginmanager_about_thirdparty": [],
"settings": [
{
"id": "section_printer",
"name": "Printer"
},
{
"id": "serial",
"name": "Serial Connection"
},
{
"id": "printerprofiles",
"name": "Printer Profiles"
},
{
"id": "temperatures",
"name": "Temperatures"
},
{
"id": "terminalfilters",
"name": "Terminal Filters"
},
{
"id": "gcodescripts",
"name": "GCODE Scripts"
},
{
"id": "section_features",
"name": "Features"
},
{
"id": "features",
"name": "Features"
},
{
"id": "webcam",
"name": "Webcam & Timelapse"
},
{
"id": "accesscontrol",
"name": "Access Control"
},
{
"id": "gcodevisualizer",
"name": "GCODE Visualizer"
},
{
"id": "api",
"name": "API"
},
{
"id": "section_octoprint",
"name": "OctoPrint"
},
{
"id": "server",
"name": "Server"
},
{
"id": "folders",
"name": "Folders"
},
{
"id": "appearance",
"name": "Appearance"
},
{
"id": "plugin_logging",
"name": "Logging",
"plugin_id": "logging",
"plugin_name": "Logging"
},
{
"id": "plugin_pluginmanager",
"name": "Plugin Manager",
"plugin_id": "pluginmanager",
"plugin_name": "Plugin Manager"
},
{
"id": "plugin_softwareupdate",
"name": "Software Update",
"plugin_id": "softwareupdate",
"plugin_name": "Software Update"
},
{
"id": "plugin_announcements",
"name": "Announcements",
"plugin_id": "announcements",
"plugin_name": "Announcement Plugin"
},
{
"id": "section_plugins",
"name": "Plugins"
},
{
"id": "plugin_action_command_prompt",
"name": "Action Command Prompt",
"plugin_id": "action_command_prompt",
"plugin_name": "Action Command Prompt Support"
},
{
"id": "plugin_curalegacy",
"name": "Cura Legacy",
"plugin_id": "curalegacy",
"plugin_name": "Cura Legacy"
}
],
"sidebar": [
{
"id": "plugin_printer_safety_check",
"name": "Printer Safety Warning",
"plugin_id": "printer_safety_check",
"plugin_name": "Printer Safety Check"
},
{
"id": "connection",
"name": "Connection"
},
{
"id": "state",
"name": "State"
},
{
"id": "files",
"name": "Files"
}
],
"tab": [
{
"id": "temperature",
"name": "Temperature"
},
{
"id": "control",
"name": "Control"
},
{
"id": "gcodeviewer",
"name": "GCode Viewer"
},
{
"id": "terminal",
"name": "Terminal"
},
{
"id": "timelapse",
"name": "Timelapse"
}
],
"usersettings": [
{
"id": "access",
"name": "Access"
},
{
"id": "interface",
"name": "Interface"
}
],
"wizard": []
}
}
Requires admin rights.
.. warning::
This API endpoint is in beta. Things might change. If you happen to want to develop against it, you should drop
me an email to make sure I can give you a heads-up when something changes in an backwards incompatible way.
:status 200: No error
:status 403: No admin rights
.. _sec-api-settings-datamodel:
Data model
@@ -106,7 +366,7 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
* - ``api.key``
- Only maps to ``api.key`` in ``config.yaml`` if request is sent with admin rights, set to ``n/a`` otherwise.
Starting with OctoPrint 1.3.3 setting this field via :ref:`the API <sec-api-settings-save>` is not possible,
only :ref:`regenerting it <sec-api-settings-generateapikey>` is supported. Setting a custom value is only
only :ref:`regenerating it <sec-api-settings-generateapikey>` is supported. Setting a custom value is only
possible through `config.yaml`.
* - ``api.allowCrossOrigin``
-
@@ -136,7 +396,7 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
-
* - ``feature.sdSupport``
-
* - ``feature.sdReleativePath``
* - ``feature.sdRelativePath``
-
* - ``feature.sdAlwaysAvailable``
-
+14 -14
View File
@@ -42,22 +42,22 @@ List All Slicers and Slicing Profiles
Content-Type: application/json
{
"cura": {
"key": "cura",
"displayName": "CuraEngine",
"curalegacy": {
"key": "curalegacy",
"displayName": "Cura Legacy",
"default": true,
"profiles": {
"high_quality": {
"key": "high_quality",
"displayName": "High Quality",
"default": false,
"resource": "http://example.com/api/slicing/cura/profiles/high_quality"
"resource": "http://example.com/api/slicing/curalegacy/profiles/high_quality"
},
"medium_quality": {
"key": "medium_quality",
"displayName": "Medium Quality",
"default": true,
"resource": "http://example.com/api/slicing/cura/profiles/medium_quality"
"resource": "http://example.com/api/slicing/curalegacy/profiles/medium_quality"
}
}
}
@@ -81,7 +81,7 @@ List Slicing Profiles of a Specific Slicer
.. sourcecode:: http
GET /api/slicing/cura/profiles HTTP/1.1
GET /api/slicing/curalegacy/profiles HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
@@ -95,13 +95,13 @@ List Slicing Profiles of a Specific Slicer
"key": "high_quality",
"displayName": "High Quality",
"default": false,
"resource": "http://example.com/api/slicing/cura/profiles/high_quality"
"resource": "http://example.com/api/slicing/curalegacy/profiles/high_quality"
},
"medium_quality": {
"key": "medium_quality",
"displayName": "Medium Quality",
"default": true,
"resource": "http://example.com/api/slicing/cura/profiles/medium_quality"
"resource": "http://example.com/api/slicing/curalegacy/profiles/medium_quality"
}
}
@@ -125,7 +125,7 @@ Retrieve Specific Profile
.. sourcecode:: http
GET /api/slicing/cura/profiles/quick_test HTTP/1.1
GET /api/slicing/curalegacy/profiles/quick_test HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
@@ -137,7 +137,7 @@ Retrieve Specific Profile
{
"displayName": "Just a test",
"description": "This is just a test",
"resource": "http://example.com/api/slicing/cura/profiles/quick_test",
"resource": "http://example.com/api/slicing/curalegacy/profiles/quick_test",
"data": {
"bottom_layer_speed": 20.0,
"bottom_thickness": 0.3,
@@ -174,14 +174,14 @@ Add Slicing Profile
.. sourcecode:: http
PUT /api/slicing/cura/profiles/quick_test HTTP/1.1
PUT /api/slicing/curalegacy/profiles/quick_test HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
Content-Type: application/json
{
"displayName": "Just a test",
"description": "This is just a test to show how to create a cura profile with a different layer height and skirt count",
"description": "This is just a test to show how to create a curalegacy profile with a different layer height and skirt count",
"data": {
"layer_height": 0.2,
"skirt_line_count": 3
@@ -197,8 +197,8 @@ Add Slicing Profile
{
"displayName": "Just a test",
"description": "This is just a test to show how to create a cura profile with a different layer height and skirt count",
"resource": "http://example.com/api/slicing/cura/profiles/quick_test"
"description": "This is just a test to show how to create a curalegacy profile with a different layer height and skirt count",
"resource": "http://example.com/api/slicing/curalegacy/profiles/quick_test"
}
:param slicer: The identifying key of the slicer for which to add the profile
+31 -13
View File
@@ -30,6 +30,14 @@ Test paths or URLs
existence but also whether it is of the specified type. Optional.
* ``check_access``: A list of any of ``r``, ``w`` and ``x``. If present it will also
be checked if OctoPrint has read, write, execute permissions on the specified path.
* ``allow_create_dir``: If ``check_type`` is provided and set to ``dir``, this will allow
OctoPrint to create the target ``path`` as a directory if it doesn't yet exist to allow
for further tests.
* ``check_writable_dir``: If ``check_type`` is provided and set to ``dir``, this will
check that the provided ``path`` is a writable directory. OctoPrint not only check if the
permissions on the directory allow for writing but also attempt to write (and delete) a
small test file ``.testballoon.txt`` to the directory to test if writing is actually
possible.
The ``path`` command returns a :http:statuscode:`200` with a :ref:`path test result <sec-api-util-datamodel-pathtestresult>`
when the test could be performed. The status code of the response does NOT reflect the
@@ -65,6 +73,12 @@ Test paths or URLs
from the URL check will be returned as part of the check result as well. ``json`` will attempt
to parse the response as json and return the parsed result. ``true`` or ``bytes`` will base64 encode the body
and return that.
* ``content_type_whitelist``: Optional array of supported content types. If set and the URL returns a content
type not included in this list, the test will fail. E.g. ``["image/*", "text/plain"]``.
* ``content_type_blacklist``: Optional array of unsupported content types. If set and the URL returns a content
type included in this list, the test wil fail. E.g. ``["video/*"]``. Can be used together with ``content_type_whitelist``
to further limit broader content type definition, e.g. by putting ``image/*`` into the whitelist, but disallowing
PNG by including ``image/png`` on the blacklist.
The ``url`` command returns :http:statuscode:`200` with a :ref:`URL test result <sec-api-util-datamodel-urltestresult>`
when the test could be performed. The status code of the response does NOT reflect the
@@ -272,19 +286,23 @@ Test paths or URLs
"result": true
}
:json command: The command to execute, currently either ``path`` or ``url``
:json path: ``path`` command only: the path to test
:json check_type: ``path`` command only: the type of path to test for, either ``file`` or ``dir``
:json check_access: ``path`` command only: a list of access permissions to check for
:json url: ``url`` command only: the URL to test
:json status: ``url`` command only: one or more expected status codes
:json method: ``url`` command only: the HTTP method to use for the check
:json timeout: ``url`` and ``server`` commands only: the timeout for the test request
:json response: ``url`` command only: whether to include response data and if so in what form
:json host: ``server`` command only: the server to test
:json port: ``server`` command only: the port to test
:json protocol: ``server`` command only: the protocol to test
:statuscode 200: No error occurred
:json command: The command to execute, currently either ``path`` or ``url``
:json path: ``path`` command only: the path to test
:json check_type: ``path`` command only: the type of path to test for, either ``file`` or ``dir``
:json check_access: ``path`` command only: a list of access permissions to check for
:json allow_create_dir: ``path`` command and ``checktype`` of ``dir`` only: whether to allow creation of the
directory if it doesn't yet exist (``true``) or not (``false``, default)
:json check_writable_dir: ``path`` command and ``checktype`` of ``dir`` only: whether to test if the directory
is writable by also trying to create a test file in it (``true``) or not (``false``, default)
:json url: ``url`` command only: the URL to test
:json status: ``url`` command only: one or more expected status codes
:json method: ``url`` command only: the HTTP method to use for the check
:json timeout: ``url`` and ``server`` commands only: the timeout for the test request
:json response: ``url`` command only: whether to include response data and if so in what form
:json host: ``server`` command only: the server to test
:json port: ``server`` command only: the port to test
:json protocol: ``server`` command only: the protocol to test
:statuscode 200: No error occurred
.. _sec-api-util-datamodel:
+4 -2
View File
@@ -7,7 +7,8 @@ Version information
.. http:get:: /api/version
Retrieve information regarding server and API version. Returns a JSON object with two keys, ``api`` containing
the API version, ``server`` containing the server version.
the API version, ``server`` containing the server version, ``text`` containing the server version including
the prefix ``OctoPrint `` (to determine that this is indeed a genuine OctoPrint instance).
**Example Request**
@@ -26,7 +27,8 @@ Version information
{
"api": "0.1",
"server": "1.1.0"
"server": "1.3.10",
"text": "OctoPrint 1.3.10"
}
:statuscode 200: No error
@@ -0,0 +1,110 @@
.. _sec-bundledplugins-action_command_prompt:
Action Command Prompt support
=============================
The OctoPrint Action Command Prompt Support Plugin comes bundled with OctoPrint (starting with 1.3.9).
It allows firmware to trigger dialog prompts for logged in users using :ref:`action commands <sec-features-action_commands>`, e.g. to wait
for user acknowledgement or allow the user to choose between options, and also to close the dialog again
in case its no longer needed, e.g. due to the user proceeding on the printer's own controller.
The choice of the user can be communicated back to the firmware via a configurable GCODE command with a
placeholder for the selected option's index.
.. _fig-bundledplugins-action_command_prompt-example:
.. figure:: ../images/bundledplugins-action_command_prompt-example.png
:align: center
:alt: Simple prompt example
A simple dialog example triggered by the firmware
.. _sec-bundledplugins-action_command_prompt-firststeps:
First Steps
-----------
In order for this plugin to work, you'll need to configure it with the command your firmware uses to accept
dialog selections. You can do that in the settings dialog.
Currently there is no agreed upon command for this since no firmware has yet made use of this feature, so OctoPrint
ships with an empty value here.
.. _sec-bundledplugins-action_command_prompt-configuration:
Configuring the plugin
----------------------
The plugin supports the following configuration keys:
* ``selection_command``: The command to send to the firmware on choice, including the ``{choice}`` placeholder, e.g. ``M876 S{choice}``.
You can modify them either through the plugin's configuration dialog under Settings, or by directly editing ``config.yaml``.
.. _sec-bundledplugins-action_command_prompt-action_commands:
Supported action commands
-------------------------
prompt_begin <message>
Starts the definition of a prompt dialog. ``<message>`` is the message to display to the user. Will be ignored
if a dialog is already defined.
prompt_choice <text>
Defines a choice with the associated ``<text>``. Will be ignored if no dialog has been defined yet.
prompt_button <text>
Same as ``prompt_choice``.
prompt_show
Tells OctoPrint that the dialog is now fully defined and to prompt the user. Will be ignored if no dialog is
defined yet.
prompt_end
Tells OctoPrint that the dialog should now be closed (e.g. the user made the choice on the printer directly instead
of through OctoPrint). Will be ignored if no dialog is defined yet.
.. _sec-bundledplugins-action_command_prompt-example:
Example communication with the firmware
---------------------------------------
.. _sec-bundledplugins-action_command_prompt-sourcecode:
To display the :ref:`above dialog <fig-bundledplugins-action_command_prompt-example>` the firmware sent these action commands:
.. code-block:: none
//action:prompt_begin Filament unloaded, swap then proceed
//action:prompt_choice Filament swapped
//action:prompt_show
If the user clicks the button, assuming a ``selection_command`` of ``M876 S{choice}`` is configured, OctoPrint
will send back ``M876 S0`` (0-based index).
A more complicated example with three options would be the following:
.. code-block:: none
//action:prompt_begin Filament runout detected. Please choose how to proceed:
//action:prompt_choice Swap filament
//action:prompt_choice Home X/Y and pause print
//action:prompt_choice Abort print
//action:prompt_show
This would produce the following output:
.. _fig-bundledplugins-action_command_prompt-example2:
.. figure:: ../images/bundledplugins-action_command_prompt-example2.png
:align: center
:alt: Another prompt example
Another dialog example triggered by the firmware
If the user selects "Abort print", OctoPrint will send ``2`` as selected choice.
Source code
-----------
The source of the Action Command Prompt Support plugin is bundled with OctoPrint and can be found in
its source repository under ``src/octoprint/plugins/action_command_prompt``.
+67
View File
@@ -0,0 +1,67 @@
.. _sec-bundledplugins-announcements:
Announcement Plugin
===================
The OctoPrint Announcement Plugin comes bundled with OctoPrint (starting with 1.2.11).
It displays announcements fetched from OctoPrint's websites, such as important updates, release announcements, new
plugins and similar. Through some manual configuration via ``config.yaml`` it also allows adding additional channels
via RSS or Atom feed URLs.
.. _fig-bundledplugins-announcements-example1:
.. figure:: ../images/bundledplugins-announcements-example1.png
:align: center
:alt: Example notification
An example notification from the Announcement Plugin.
.. _fig-bundledplugins-announcements-example2:
.. figure:: ../images/bundledplugins-announcements-example2.png
:align: center
:alt: Announcement reader
The Announcement Plugin's reader dialog.
.. _fig-bundledplugins-announcements-settings:
.. figure:: ../images/bundledplugins-announcements-settings.png
:align: center
:alt: Announcement settings
The Announcement Plugin's settings dialog.
.. _sec-bundledplugins-announcements-configuration:
Configuring the plugin
----------------------
The plugin allows enabling and disabling the preconfigured announcement channels via its settings dialog.
On top of that it's possible to add additional announcement channels (as RSS or Atom feed URLs) or change the
configuration of the existing channels through ``config.yaml``.
The available configuration keys are:
* ``channels``: Configured announcement channels. A mapping from a unique identifier to a configuration structure
that follows this format:
* ``name``: Name of the channel, used e.g. in the title of the displayed notifications.
* ``description``: Description of the channel.
* ``priority``: ``1`` for high priority announcements (red notification), ``2`` for regular ones (yellow notification).
* ``type``: Currently unused.
* ``url``: URL for the feed acting as notification source, must be RSS or Atom format.
* ``enabled_channels``: List of identifiers of enabled channels.
* ``forced_channels``: List of identifiers of channels that cannot be disabled (currently only ``_important`` which is used sparingly).
* ``channel_order``: List of channel identifiers in the order they should appear in the UI.
* ``ttl``: Time to live of the channel cache in minutes (default: 6 hours).
* ``display_limit``: Limit of items to display per channel (default: 3).
* ``summary_limit``: Limit of characters to display from each channel entry (default: 300).
.. _sec-bundledplugins-announcements-sourcecode:
Source code
-----------
The source of the Announcement plugin is bundled with OctoPrint and can be found in
its source repository under ``src/octoprint/plugins/announcements``.
+543
View File
@@ -0,0 +1,543 @@
.. _sec-bundledplugins-appkeys:
Application Keys Plugin
=======================
The OctoPrint Application Keys Plugin comes bundled with OctoPrint (starting with version 1.3.10).
It implements a workflow for third party apps or clients to obtain an application specific API key from OctoPrint to interact with it
on a user's behalf, via confirmation of the user through OctoPrint's web interface. Existing keys can be managed
on a per-user base as well as globally by administrators.
.. _fig-bundledplugins-appkeys-confirmation:
.. figure:: ../images/bundledplugins-appkeys-confirmation_prompt.png
:align: center
:alt: Confirmation
The plugin's confirmation generated for a new application key request.
.. _fig-bundledplugins-appkeys-user_settings:
.. figure:: ../images/bundledplugins-appkeys-user_settings.png
:align: center
:alt: Key management via user settings
Users can manage the application specific API keys registered to their account via their user settings.
.. _fig-bundledplugins-appkeys-settings:
.. figure:: ../images/bundledplugins-appkeys-settings.png
:align: center
:alt: Global key management via settings
Administrators can manage all application specific API keys registered to any user.
.. _sec-bundledplugins-appkeys-workflow:
Workflow
--------
The workflow to receive an API key for a third party client/an app via the Application Keys Plugin should consist
of the following steps:
1. The User opens the App and gets prompted to enter or select an instance URL. Optionally (recommended!) the User also
enters their username which is also their user ID into the App.
2. The App :ref:`probes for workflow support <sec-bundledplugins-appkeys-api-probe>` on the Server. If this request
doesn't get an HTTP :http:statuscode:`204` the App needs to direct the user to an alternative manual workflow
(copy-paste API key) and abort this one. Otherwise it proceeds to the next step.
3. The App sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
authorization process.
4. The Server triggers a confirmation dialog for the User on the Webinterface and returns an endpoint to the
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`.
5. The App uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
signals that no decision has been made yet.
6. The User either accepts or denies the access request which makes the Webinterface send a
:ref:`decision request <sec-bundledplugins-appkey-datamodel-decisionrequest>` to the Server.
7. If the User accepted the request, the App receives an HTTP :http:statuscode:`200` with an attached
:ref:`API key response <sec-bundledplugins-appkey-datamodel-keyresponse>`. If they deny it, the App will receive
an HTTP :http:statuscode:`404`.
.. mermaid::
sequenceDiagram
participant User
participant App
participant Webinterface
participant Server
note over User, Server: Step 1, 2 & 3
User->>App: enters URL of instance to connect to and optional user_id
App->>Server: GET /plugin/appkeys/probe
alt Workflow unsupported
Server->>App: 404
App->>User: alternative workflow, copy-paste key manually
else Workflow supported
App->>Server: POST /plugin/appkeys/request, (app_name, user_id)
note over User, Server: Step 4
Server-->>Webinterface: plugin message for "appkeys" w/ (app_name, user_token, user_id)
Webinterface-->>User: Display confirmation dialog
Server->>App: 201, Location: /plugin/appkeys/request/<app_token>
note over User, Server: Step 5
loop Poll for decision
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 202
end
note over User, Server: Step 6 & 7
alt User accepts
User-->>Webinterface: Allow access
Webinterface->>Server: POST /plugin/appkeys/decision/<user_token>, (True)
Server->>Webinterface: 204
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 200, api_key
else User denies
User-->>Webinterface: Deny access
Webinterface->>Server: POST /plugin/appkeys/decision/<user_token>, (False)
Server->>Webinterface: 204
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 404
end
end
.. _sec-bundledplugins-appkeys-api:
API
---
.. _sec-bundledplugins-appkeys-api-probe:
Probe for workflow support
..........................
.. http:get:: /plugin/appkeys/probe
Probes for support of the workflow.
Normally returns an HTTP :http:statuscode:`204`, indicating workflow availability. If a different status code is returned
(usually an HTTP :http:statuscode:`404`), the plugin is disabled or not installed. Fall back to manual api key exchange.
:status 204: the workflow is supported
.. _sec-bundledplugins-appkeys-api-startauthprocess:
Start authorization process
...........................
.. http:post:: /plugin/appkeys/request
Starts the authorization process.
Expects a :ref:`Key request <sec-bundledplugins-appkey-datamodel-keyrequest>` as request body.
The ``app`` parameter should be a human readable identifier to use
for the application requesting access. It will be displayed to the user. Internally it will be used case insensitively,
so ``My App`` and ``my APP`` are considered the same application identifiers.
The optional ``user`` parameter should be used to limit the authorization process to a specified user. If the parameter
is left unset, any user will be able to complete the authorization process and grant access to the app with their
account. E.g. if a user ``me`` starts the process in an app, the app should request that name from the user and use
it in the ``user`` parameter. OctoPrint will then only display the authorization request on browsers the user ``me``
is logged in on.
:json app: application identifier to use for the request, case insensitive
:json user: optional user id to restrict the decision to the specified user
:status 201: authorization process started, polling URL to query can be found in ``Location`` header
.. _sec-bundledplugins-appkeys-api-polldecision:
Poll for decision on existing request
.....................................
.. http:get:: /plugin/appkeys/request/<str:app_token>
Endpoint generated per authorization request to poll for the result.
Returns an HTTP :http:statuscode:`202` while no decision has been made yet, an HTTP :http:statuscode:`200` and
a :ref:`Key response <sec-bundledplugins-appkey-datamodel-keyresponse>` if access has been granted and an
HTTP :http:statuscode:`404` if the request has been denied or timed out.
.. note::
The request will be considered stale and deleted internally if the polling endpoint for it isn't called
for more than 5s.
:status 200: access granted, API key in response body
:status 202: no decision has been made yet, continue polling
:status 404: access denied or request timed out
.. _sec-bundledplugins-appkeys-api-decide:
Decide on existing request
..........................
.. http:post:: /plugin/appkeys/decision/<str:user_token>
Endpoint to decide on the authorization request.
Expects a :ref:`Decision request <sec-bundledplugins-appkey-datamodel-decisionrequest>` as request body.
Returns an HTTP :http:statuscode:`204` on success.
:json decision: boolean value to indicate whether to confirm (``True``) or deny (``False``) access
:status 204: success
.. _sec-bundledplugins-appkeys-api-fetchlist:
Fetch list of existing application keys
.......................................
.. http:get:: /api/plugin/appkeys
Fetches a list of existing application keys and pending requests registered in the system for the current user.
If the additional optional parameter ``all`` is provided and the user has administrator rights, fetches a list
of *all** application keys and pending requests registered in the system for any user.
Returns a :http:statuscode:`200` with a :ref:`List response <sec-bundledplugins-appkey-datamodel-listreponse>` in the
body upon success.
:query all: Fetch all application keys and pending requests from all users. Requires administrator rights.
.. _sec-bundledplugins-appkeys-api-issuecommand:
Issue an application key command
................................
.. http:post:: /api/plugin/appkeys
Application key commands allow revoking existing application keys and manually generating new ones. The available
commands are:
revoke
Revokes an existing application key. Must belong to the user issuing the command, unless the user has admin rights
in which case they make revoke any application key in the system. Expects the key in question as parameter ``key``.
generate
Generates a new application key for the user, using the application identifier provided as parameter ``app``.
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
Requires user rights.
**Example revoke request**
Revokes the (fictional) key ``aabbccddeeff112233445566``.
.. sourcecode:: http
POST /api/plugin/appkeys HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...
{
"command": "revoke",
"key": "aabbccddeeff112233445566"
}
.. sourcecode:: http
HTTP/1.1 204 No Content
**Example generate request**
Generates a new key for application identifier "My awesome application 1.0".
.. sourcecode:: http
POST /api/plugin/appkeys HTTP/1.1
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...
{
"command": "generate",
"key": "My awesome application 1.0"
}
.. sourcecode:: http
HTTP/1.1 204 No Content
:json string command: The command to issue, either ``revoke`` or ``generate``
:json string key: ``revoke`` command: The key to revoke
:json string app: ``generate`` command: Application identifier for which to generate a key
:statuscode 204: No error
:statuscode 400: Invalid or missing parameter
.. _sec-bundledplugins-appkey-datamodel:
Data model
----------
.. _sec-bundledplugins-appkey-datamodel-keyrequest:
Key request
...........
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``app``
- 1
- str
- Application identifier to use for the request
* - ``user``
- 0..1
- str
- User identifier/name to restrict the request to
.. _sec-bundledplugins-appkey-datamodel-keyresponse:
Key response
............
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``apikey``
- 1
- str
- the API key generated for the application
.. _sec-bundledplugins-appkey-datamodel-decisionrequest:
Decision request
................
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``decision``
- 1
- boolean
- ``True`` if the access request it to be granted, ``False`` otherwise
.. _sec-bundledplugins-appkey-datamodel-listreponse:
List response
.............
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``keys``
- 1
- list of :ref:`key list entries <sec-bundledplugins-appkey-datamodel-keylistentry>`
- Keys registered in the system
* - ``pending``
- 1
- list of :ref:`pending list entries <sec-bundledplugins-appkey-datamodel-pendinglistentry>`
- Currently pending authorization requests
.. _sec-bundledplugins-appkey-datamodel-keylistentry:
Key list entry
..............
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``api_key``
- 1
- str
- API key
* - ``app_id``
- 1
- str
- Application identifier
* - ``user_id``
- 1
- str
- User ID of the key's owner
.. _sec-bundledplugins-appkey-datamodel-pendinglistentry:
Pending list entry
..................
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``app_id``
- 1
- str
- Application identifier
* - ``user_id``
- 0..1
- str
- optional: User ID of user who can grant or deny request
* - ``user_token``
- 1
- str
- Token to grant or deny request
.. _sec-bundledplugins-appkeys-jsclientlib:
JavaScript Client Library
-------------------------
.. js:function:: OctoPrintClient.plugins.appkeys.getKeys(opts)
Retrieves registered keys and pending requests for the current user.
See :ref:`Fetch list of existing application keys <sec-bundledplugins-appkeys-api-fetchlist>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.getAllKeys(opts)
Retrieves registered keys and pending requests for all users.
Needs administrator rights.
See :ref:`Fetch list of existing application keys <sec-bundledplugins-appkeys-api-fetchlist>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.generateKey(app, opts)
Generates a key for the given ``app`` and the current user.
See :ref:`Issue an application key command <sec-bundledplugins-appkeys-api-issuecommand>` for details.
:param string app: Application identifier
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.revokeKey(key, opts)
Revokes the given ``key``. The key must belong to the current user, or the current user must have administrator
rights.
See :ref:`Issue an application key command <sec-bundledplugins-appkeys-api-issuecommand>` for details.
:param string key: Key to revoke
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.decide(token, decision, opts)
Decides on an existing authorization request.
See :ref:`Decide on existing request <sec-bundledplugins-appkeys-api-decide>` for more details.
:param string token: User token for which to make the decision, as pushed to the client via the socket.
:param boolean decision: Whether to grant access (``true``) or not (``false``).
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.probe(opts)
Probes for workflow support.
See :ref:`Probe for workflow support <sec-bundledplugins-appkeys-api-probe>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.request(app, opts)
Starts a new authorization request for the provided ``app`` identifier.
See :ref:`Start authorization process <sec-bundledplugins-appkeys-api-startauthprocess>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.requestForUser(app, user, opts)
Starts a new authorization request for the provided ``app`` and ``user`` identifiers.
See :ref:`Start authorization process <sec-bundledplugins-appkeys-api-startauthprocess>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.checkDecision(token, opts)
Polls for a decision on an existing authorization request identified by ``token``.
See :ref:`Poll for decision on existing request <sec-bundledplugins-appkeys-api-polldecision>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.authenticate(app, user, opts)
Convenience function that probes for support, issues a request and then automatically starts polling for a decision
on the returned polling endpoint every 1s, until either a positive or negative decision is returned. On success the
returned promise is resolved with the generated API key as argument. If anything goes wrong or there is no support
for the workflow, the promise is rejected.
**Example usage**
.. sourcecode:: javascript
OctoPrint.plugins.appkeys.authenticate("My App", "some_user")
.done(function(api_key) {
console.log("Got our API key:", api_key);
})
.fail(function() {
console.log("No API key for us");
})
:param string app: Application identifier
:param string user: Optional user identifier
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. _sec-bundledplugins-appkeys-sourcecode:
Source code
-----------
The source of the Application Keys plugin is bundled with OctoPrint and can be found in
its source repository under ``src/octoprint/plugins/appkeys``.
+70
View File
@@ -0,0 +1,70 @@
.. _sec-bundledplugins-backup:
Backup Plugin
=============
The OctoPrint Backup Plugin comes bundled with OctoPrint (starting with 1.3.10).
It allows the creation and restoration of backups of OctoPrint's settings, data and installed plugins [#]_.
This allows easy migration
to newly setup instances as well as making regular backups to prevent data loss.
.. _fig-bundledplugins-backup-settings:
.. figure:: ../images/bundledplugins-backup-settings.png
:align: center
:alt: OctoPrint Backup Plugin
The plugin's settings panel with existing backups, the backup creation and restore sections.
As long as plugins adhere to the standard of storing their data and settings in OctoPrint's plugin data folders, their
data will be part of the backup. Note that the backups made by the Backup Plugin will *not* be part of any backups -
you'll need to persist the resulting zip files yourself!
.. _sec-bundledplugins-backup-cli:
Command line usage
------------------
The Backup Plugin implements a command line interface that allows creation and restoration of backups.
It adds two new commands, ``backup:backup`` and ``backup_restore``.
.. code-block:: none
$ octoprint plugins backup:backup --help
Initializing settings & plugin subsystem...
Usage: octoprint plugins backup:backup [OPTIONS]
Creates a new backup.
Options:
--exclude TEXT Identifiers of data folders to exclude, e.g. 'uploads' to
exclude uploads or 'timelapse' to exclude timelapses.
--help Show this message and exit.
$ octoprint plugins backup:restore --help
Initializing settings & plugin subsystem...
Usage: octoprint plugins backup:restore [OPTIONS] PATH
Restores an existing backup from the backup zip provided as argument.
OctoPrint does not need to run for this to proceed.
Options:
--help Show this message and exit.
.. note::
The ``backup:backup`` command can be useful in combination with a cronjob to create backups in regular intervals.
.. _sec-bundledplugins-backup-sourcecode:
Source code
-----------
The source of the Backup plugin is bundled with OctoPrint and can be found in
its source repository under ``src/octoprint/plugins/backup``.
.. [#] Note that only those plugins that are available on `OctoPrint's official plugin repository <https://plugins.octoprint.org>`_
can be automatically restored. If you have plugins installed that are not available on there you'll get their
names and - if available - homepage URL displayed after restore in order to be able to manually reinstall them.
-138
View File
@@ -1,138 +0,0 @@
.. _sec-bundledplugins-cura:
Cura
====
The Cura Plugin allows slicing of STL files uploaded to OctoPrint directly via
the `CuraEngine <http://github.com/Ultimaker/CuraEngine>`_ **up to and
including version 15.04.x** and supersedes the slicing support integrated into
OctoPrint so far. It comes bundled with OctoPrint starting with version 1.2.0.
.. note::
Versions of CuraEngine later than 15.04.x have changed their calling
parameters in such a way that the current implementation of OctoPrint's Cura plugin
is not compatible to it. For this reason, please use only CuraEngine versions up to
and including 15.04 for now, as available in the ``legacy`` branch of the CuraEngine
repository on Github.
The plugin offers a settings module that allows configuring the path to the
CuraEngine executable to use, as well as importing and managing slicing
profiles to be used. Please note that the Cura Plugin will use the printer
parameters you configured within OctoPrint (meaning bed size and extruder
count and offsets) for slicing.
.. _sec-bundledplugins-cura-firststeps:
First Steps
-----------
Before you can slice from within OctoPrint, you'll need to
#. :ref:`Install CuraEngine <sec-bundledplugins-cura-installing>`
#. :ref:`Configure the path to CuraEngine within OctoPrint <sec-bundledplugins-cura-configuring>`
#. :ref:`Export a slicing profile from Cura and import it within OctoPrint <sec-bundledplugins-cura-profiles>`
.. note::
OctoPi 0.12.0 and later ships with steps 1 and 2 already done, you only need to
supply one or more slicing profiles to get going :)
.. _sec-bundledplugins-cura-installing:
Installing CuraEngine
---------------------
You'll need a build of ``legacy`` branch of `CuraEngine <http://github.com/Ultimaker/CuraEngine>`_
in order to be able to use the Cura OctoPrint plugin. You can find the ``legacy`` branch
`here <https://github.com/ultimaker/curaengine/tree/legacy>`__.
If you previously used the `old variant of the Cura integration <https://github.com/foosel/OctoPrint/wiki/Cura-Integration>`_,
you probably still have a fully functional binary lying around in the
installation folder of the full install of Cura you used then -- just put the
path to that in the plugin settings.
.. _sec-bundledplugins-cura-installing-raspbian:
Compiling for Raspbian
++++++++++++++++++++++
.. note::
A binary of CuraEngine 15.04.06 precompiled on Raspbian Jessie Lite 2016-03-18 is available
`here <http://bit.ly/octopi_cura_engine_150406>`__. Don't forget to make it
executable after copying it to your preferred destination on your Pi
(suggestion: ``/usr/local/bin``) with ``chmod +x cura_engine``. Use at your
own risk.
Raspbian Jessie
~~~~~~~~~~~~~~~
Building on Raspbian Jessie is as easy as::
sudo apt-get -y install gcc-4.7 g++-4.7
git clone -b legacy https://github.com/Ultimaker/CuraEngine.git
cd CuraEngine
make
After this has completed, you'll find your shiny new build of CuraEngine in
the `build` folder (full path for above example:
``~/CuraEngine/build/CuraEngine``).
Raspbian Wheezy
~~~~~~~~~~~~~~~
You'll need to install a new version of gcc and g++ and patch CuraEngine's
Makefile (see `this post <http://umforum.ultimaker.com/index.php?/topic/5943-recent-build-of-curaengine-wont-compile-on-raspberry-pi/#entry58539>`_)
in order for the compilation to work on current Raspbian builds (e.g. OctoPi)::
sudo apt-get -y install gcc-4.7 g++-4.7
git clone -b legacy https://github.com/Ultimaker/CuraEngine.git
cd CuraEngine
wget http://bit.ly/curaengine_makefile_patch -O CuraEngine.patch
patch < CuraEngine.patch
make CXX=g++-4.7
After this has completed, you'll find your shiny new build of CuraEngine in
the `build` folder (full path for above example:
``~/CuraEngine/build/CuraEngine``).
.. _sec-bundledplugins-cura-configuring:
Configuring the plugin
----------------------
The Cura plugin needs to be configured with the full path to your copy of the
CuraEngine executable that it's supposed to use. You can do this either via
the Cura plugin settings dialog or by manually configuring the path to the
executable via ``config.yaml``, example:
.. code-block:: yaml
plugins:
cura:
cura_engine: /path/to/CuraEngine
.. _sec-bundledplugins-cura-profiles:
Using Cura Profiles
-------------------
The Cura Plugin supports importing your existing profiles for Cura **up to and
including Cura 15.04.x**. Newer Cura releases (e.g. 15.06 or 2.x) use a different
internal format that will *not* work with the current version of the Cura Plugin.
You can find downloads of Cura 15.04.x for Windows, Mac and Linux `on Ultimaker's download page <https://ultimaker.com/en/products/cura-software/list>`_.
In order to export a slicing profile from the Cura desktop UI, open it,
set up your profile, then click on "File" and there on "Save Profile". You can
import the .ini-file this creates via the "Import Profile" button in the
Cura Settings within OctoPrint.
.. _sec-bundledplugins-cura-sourcecode:
Source code
-----------
The source of the Cura plugin is bundled with OctoPrint and can be found in
its source repository under ``src/octoprint/plugins/cura``.
+40
View File
@@ -0,0 +1,40 @@
.. _sec-bundledplugins-errortracking:
Error Tracking Plugin
=====================
The Error Tracking plugin will cause any logged exceptions in the server and the browser interface to be sent to
OctoPrint's `Sentry instance <https://sentry.io/>`_.
By enabling it you help to gather detailed information on the cause of bugs or other issues. This is especially
valuable on release candidates, which is why this plugin will also prompt you to enable error tracking if it detects
that you are subscribed to an RC release channel.
By default, even when enabled it will only be active if you are running a released OctoPrint version, so either a stable
release or a release candidate.
The Error Tracking plugin is using a Sentry instance kindly provided by `sentry.io <https://sentry.io/>`_. For information on their service
please refer to their `Security & Compliance documentation <https://sentry.io/security/>`_
and their `Privacy Policy <https://sentry.io/privacy/>`_.
The Error Tracking plugin has been bundled with OctoPrint since version 1.3.11.
.. _sec-bundledplugins-errortracking-configuration:
Configuring the plugin
----------------------
The plugin supports the following configuration keys:
* ``enabled``: Whether to enable error tracking. Defaults to ``false``.
* ``enabled_unreleased``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases
or release candidates). Defaults to ``false``.
* ``unique_id``: Unique instance identifier, auto generated on first activation
.. _sec-bundledplugins-errortracking-sourcecode:
Source Code
-----------
The source of the Error Tracking plugin is bundled with OctoPrint and can be
found in its source repository under ``src/octoprint/plugins/errortracking``.
+35
View File
@@ -0,0 +1,35 @@
.. _sec-bundledplugins-forcelogin:
ForceLogin Plugin
=================
The ForceLogin Plugin comes bundled with OctoPrint (starting with version 1.3.10). It removes the anonymous
read-only access that up until 1.3.10 was standard when accessing OctoPrint instances without being logged in and
instead forces users to log in if they want to get any kind of information from OctoPrint.
.. _fig-bundledplugins-forcelogin:
.. figure:: ../images/bundledplugins-forcelogin-dialog.png
:align: center
:alt: Forced login dialog
OctoPrint's new forced login dialog.
.. warning::
Keep in mind that **OctoPrint does not manage your webcam**, it merely embeds it. If you have a webcam,
it will still be accessible to users who are not logged in under its (guessable) URL. If you need to restrict
access to your webcam, you'll need to find a way to do so directly on the webcam server which - again -
is not OctoPrint itself.
.. note::
If you want back the old behaviour of allowing anonymous read-only access to your OctoPrint instance, disable
the ForceLogin Plugin in OctoPrint's plugin manager.
.. _sec-bundledplugins-forcelogin-sourcecode:
Source code
-----------
The source of the ForceLogin plugin is bundled with OctoPrint and can be found in
its source repository under ``src/octoprint/plugins/forcelogin``.
+7 -1
View File
@@ -7,8 +7,14 @@ Bundled Plugins
.. toctree::
:maxdepth: 2
cura.rst
action_command_prompt.rst
announcements.rst
tracking.rst
appkeys.rst
backup.rst
discovery.rst
errortracking.rst
forcelogin.rst
logging.rst
pluginmanager.rst
printer_safety_check.rst
+39
View File
@@ -82,6 +82,45 @@ under Settings > Plugin Manager, or by directly editing ``config.yaml``:
- hidden
- plugins
.. _sec-bundledplugins-pluginmanager-events:
Events
------
plugin_pluginmanager_install_plugin
A plugin was installed.
Payload:
* ``id``: the identifier of the installed plugin
* ``version``: the version of the installed plugin
* ``source``: source from which the plugin was installed, can be an URL or a path in the local file system
* ``source_type``: type of source from which the plugin was installed, can be ``url`` or ``path``
plugin_pluginmanager_uninstall_plugin
A plugin was uninstalled.
Payload:
* ``id``: the identifier of the uninstalled plugin
* ``version``: the version of the uninstalled plugin
plugin_pluginmanager_enable_plugin
A plugin was enabled.
Payload:
* ``id``: the identifier of the enabled plugin
* ``version``: the version of the enabled plugin
plugin_pluginmanager_disabled_plugin
A plugin was disabled.
Payload:
* ``id``: the identifier of the disabled plugin
* ``version``: the version of the disabled plugin
.. _sec-bundledplugins-pluginmanager-hooks:
Hooks
+16 -7
View File
@@ -16,17 +16,12 @@ such identification.
An example of a warning generated by the Printer Safety Check
Currently the following firmwares produce this warning:
* Anet A8 stock firmware
Please refer to the `entry on the "unsafe firmware" warning in OctoPrint's FAQ <https://faq.octoprint.org/warning-firmware-unsafe>`_
for a list of currently identified printers.
If you know of further printers/printer firmwares that need to be added here, please
`get in touch on the forum and provide their response to an M115 <https://faq.octoprint.org/warning-firmware-unsafe>`_.
.. seealso::
`Entry on the "unsafe firmware" warning in OctoPrint's FAQ <https://faq.octoprint.org/warning-firmware-unsafe>`_
.. note::
Feel free to disable the plugin in OctoPrint's Plugin Manager if you feel like it is unnecessary. Be advised though
@@ -34,6 +29,20 @@ If you know of further printers/printer firmwares that need to be added here, pl
unexpectedly and with `catastrophic <https://www.thissmarthouse.net/dont-burn-your-house-down-3d-printing-a-cautionary-tale/>`_
`results <https://www.reddit.com/r/3Dprinting/comments/6cekgk/house_fire_thanks_to_cheap_printer_from_china/>`_.
.. _sec-bundledplugins-printer_safety_check-events:
Events
------
warning
A printer safety warning was triggered.
Payload:
* ``check_type``: type of check that was triggered (e.g. ``m115``, ``received`` or ``cap``)
* ``check_name``: name of check that was triggered (e.g. ``aneta8``)
* ``warning_type``: type of warning that was triggered (e.g. ``firmware-unsafe``)
.. _sec-bundledplugins-printer_safety_check-source:
Source Code
+23
View File
@@ -325,6 +325,29 @@ The same, but tracking all commits pushed to branch ``devel`` (thus allowing
branch: devel
pip: 'https://github.com/someUser/OctoPrint-SomePlugin/archive/{target}.zip'
.. _sec-bundledplugins-softwareupdate-events:
Events
------
plugin_softwareupdate_update_succeeded
An update succeeded.
Payload:
* ``target``: update target
* ``from_version``: version from which was updated
* ``to_version``: version to which was updated
plugin_softwareupdate_update_failed
An update failed.
Payload:
* ``target``: update target
* ``from_version``: version from which was updated
* ``to_version``: version to which was updated
.. _sec-bundledplugins-softwareupdate-hooks:
Hooks
+45
View File
@@ -0,0 +1,45 @@
.. _sec-bundledplugins-tracking:
Anonymous Usage Tracking Plugin
===============================
The Anonymous Usage Tracking plugin provides valuable insights into how many instances running what versions of
OctoPrint are out there, whether they are successfully completing print jobs and various other metrics.
By enabling it you help to identify problems with new releases and release candidates early on, and to better tailor
OctoPrint's future development to actual use.
For details on what gets tracked, please refer to `tracking.octoprint.org <https://tracking.octoprint.org>`_
and also the `Privacy Policy at tracking.octoprint.org <https://tracking.octoprint.org/privacy>`_.
The Anonymous Usage Tracking plugin has been bundled with OctoPrint since version 1.3.10.
.. _sec-bundledplugins-tracking-configuration:
Configuring the plugin
----------------------
The plugin supports the following configuration keys:
* ``enabled``: Whether to enable usage tracking. Defaults to ``false``.
* ``unique_id``: Unique instance identifier, auto generated on first activation
* ``server``: The tracking server to track against. Defaults to a tracking endpoint on ``https://tracking.octoprint.org``.
* ``ping``: How often to send a ``ping`` tracking event, in seconds. Defaults to a 15min interval.
* ``events``: Granular configuration of enabled tracking events. All default to ``true``.
* ``startup``: Whether to track startup/shutdown events
* ``printjob``: Whether to track print job related events (start, completion, cancel, ...)
* ``commerror``: Whether to track communication errors with the printer
* ``plugin``: Whether to track plugin related events (install, uninstall, ...)
* ``update``: Whether to track update related events (update successful or not, ...)
* ``printer``: Whether to track printer related events (connected, firmware, ...)
* ``printer_safety_check``: Whether to track warnings of the :ref:`Printer Safety Check <sec-bundledplugins-printer_safety_check>`
* ``throttled``: Whether to track throttle events detected on the underlying system
.. _sec-bundledplugins-tracking-sourcecode:
Source Code
-----------
The source of the Anonymous Usage Tracking plugin is bundled with OctoPrint and can be
found in its source repository under ``src/octoprint/plugins/tracking``.
+91 -28
View File
@@ -62,6 +62,18 @@ Use the following settings to enable access control:
# header and login the user without further checks. Use with caution.
checkBasicAuthenticationPassword: true
# Whether to trust remote user headers. If you have setup authentication in front of
# OctoPrint and the user names you use there match OctoPrint accounts, by setting this to true users will
# be logged into OctoPrint as the user provided in the header. Your should ONLY ENABLE THIS if your
# OctoPrint instance is only accessible through a connection locked down through an authenticating reverse proxy!
trustRemoteUser: false
# Header used by the reverse proxy to convey the authenticated user.
remoteUserHeader: REMOTE_USER
# If a remote user is not found, add them. Use this only if all users from the remote system can use OctoPrint.
addRemoteUsers: false
.. _sec-configuration-config_yaml-api:
API
@@ -81,7 +93,8 @@ Settings for the REST API:
# Whether to allow cross origin access to the API or not
allowCrossOrigin: false
# Additional app api keys, see REST API > Apps in the docs
# Additional app api keys, see REST API > Apps in the docs.
# Deprecated since 1.3.11, to be removed in 1.4.0!
apps:
"some.app.identifier:some_version":
pubkey: <RSA pubkey>
@@ -151,7 +164,7 @@ appearance or to modify the order and presence of the various UI components:
# order of settings, if settings plugins are registered gets extended internally by
# section_plugins and all settings plugins
settings
settings:
- section_printer
- serial
- printerprofiles
@@ -209,7 +222,7 @@ appearance or to modify the order and presence of the various UI components:
tab:
- plugin_helloworld
OctoPrint will then turn this into the order ``plugin_helloworld``, ``temperature``, ``control``, ``gcodeviewer``,
OctoPrint will then display the tabs in the order ``plugin_helloworld``, ``temperature``, ``control``, ``gcodeviewer``,
``terminal``, ``timelapse`` plus any other plugins.
@@ -322,6 +335,9 @@ The following settings are only relevant to you if you want to do OctoPrint deve
# Whether the simulated printer should also simulate a heated bed or not
hasBed: true
# Whether the simulated printer should also simulate a heated chamber or not
hasChamber: false
# If enabled, reports the set target temperatures as separate messages from the firmware
#
# True: > M109 S220.0
@@ -409,8 +425,7 @@ The following settings are only relevant to you if you want to do OctoPrint deve
# Lines to send on simulated reset
resetLines:
- start
- Marlin: Virtual Marlin!
- "\x80"
- "Marlin: Virtual Marlin!"
- "SD card ok"
# Initial set of prepared oks to use instead of regular ok (e.g. to simulate
@@ -454,7 +469,7 @@ the estimation of the left print time during an active job utilizes this section
.. code-block:: yaml
estimation:
# Parameters for the print time estmation during an ongoing print job
# Parameters for the print time estimation during an ongoing print job
printTime:
# Until which percentage to do a weighted mixture of statistical duration (analysis or
# past prints) with the result from the calculated estimate if that's already available.
@@ -560,6 +575,10 @@ Use the following settings to enable or disable OctoPrint features:
# Defaults to only M117.
autoUppercaseBlacklist:
- M117
- M118
# whether G90/G91 also influence absolute/relative mode of extruders
g90InfluencesExtruder: false
.. _sec-configuration-config_yaml-folder:
@@ -616,15 +635,16 @@ Settings pertaining to the server side GCODE analysis implementation.
.. code-block:: yaml
# Maximum number of extruders to support/to sanity check for
maxExtruders: 10
gcodeAnalysis:
# Maximum number of extruders to support/to sanity check for
maxExtruders: 10
# Pause between each processed GCODE line in normal priority mode, seconds
throttle_normalprio: 0.01
# Pause between each processed GCODE line in normal priority mode, seconds
throttle_normalprio: 0.01
# Pause between each processed GCODE line in high priority mode (e.g. on fresh
# uploads), seconds
throttle_highprio: 0.0
# Pause between each processed GCODE line in high priority mode (e.g. on fresh
# uploads), seconds
throttle_highprio: 0.0
.. _sec-configuration-config_yaml-gcodeviewer:
@@ -635,16 +655,17 @@ Settings pertaining to the built in GCODE Viewer.
.. code-block:: yaml
# Whether to enable the GCODE viewer in the UI
enabled: true
gcodeViewer:
# Whether to enable the GCODE viewer in the UI
enabled: true
# Maximum size a GCODE file may have on mobile devices to automatically be loaded
# into the viewer, defaults to 2MB
mobileSizeThreshold: 2097152
# Maximum size a GCODE file may have on mobile devices to automatically be loaded
# into the viewer, defaults to 2MB
mobileSizeThreshold: 2097152
# Maximum size a GCODE file may have to automatically be loaded into the viewer,
# defaults to 20MB
sizeThreshold: 20971520
# Maximum size a GCODE file may have to automatically be loaded into the viewer,
# defaults to 20MB
sizeThreshold: 20971520
.. _sec-configuration-config_yaml-plugins:
@@ -803,6 +824,19 @@ Use the following settings to configure the serial connection to the printer:
additionalBaudrates:
- 123456
# Commands which should not be sent to the printer, e.g. because they are known to block serial
# communication until physical interaction with the printer as is the case on most firmwares with
# the default M0 and M1.
blockedCommands:
- M0
- M1
# Commands which should cause OctoPrint to pause any ongoing prints.
pausingCommands:
- M0
- M1
- M25
# Commands which are known to take a long time to be acknowledged by the firmware. E.g.
# homing, dwelling, auto leveling etc. Defaults to the below commands.
longRunningCommands:
@@ -893,7 +927,7 @@ Use the following settings to configure the serial connection to the printer:
supportResendsWithoutOk: false
# Whether to "manually" trigger an ok for M29 (a lot of versions of this command are buggy and
# the responds skips on the ok)
# the response skips on the ok)
triggerOkForM29: true
capabilities:
@@ -929,12 +963,19 @@ Use the following settings to configure the server:
# reset the setting to false
startOnceInSafeMode: false
# Signals to OctoPrint that the last startup was incomplete. OctoPrint will then startup
# in safe mode
incompleteStartup: false
# Set this to true to make OctoPrint ignore incomplete startups. Helpful for development.
ignoreIncompleteStartup: false
# Secret key for encrypting cookies and such, randomly generated on first run
secretKey: someSecretKey
# Settings if OctoPrint is running behind a reverse proxy (haproxy, nginx, apache, ...).
# These are necessary in order to make OctoPrint generate correct external URLs so
# that AJAX requests and download URLs work.
# that AJAX requests and download URLs work, and so that client IPs are read correctly.
reverseProxy:
# The request header from which to determine the URL prefix under which OctoPrint
@@ -968,6 +1009,14 @@ Use the following settings to configure the server:
# (X-Forwarded-Host by default, see above) with forwarded requests.
hostFallback:
# List of trusted downstream servers for which to ignore the IP address when trying to determine
# the connecting client's IP address. If you have OctoPrint behind more than one reverse proxy
# you should add their IPs here so that they won't be interpreted as the client's IP. One reverse
# proxy will be handled correctly by default.
trustedDownstream:
- 192.168.1.254
- 192.168.23.42
# Settings for file uploads to OctoPrint, such as maximum allowed file size and
# header suffixes to use for streaming uploads. OctoPrint does some nifty things internally in
# order to allow streaming of large file uploads to the application rather than just storing
@@ -1047,6 +1096,15 @@ Use the following settings to configure the server:
# How many days to leave unused entries in the preemptive cache config
until: 7
# Configuration of the client IP check to warn about connections from external networks
ipCheck:
# whether to enable the check, defaults to true
enabled: true
# additional non-local subnets to consider trusted, in CIDR notation, e.g. "192.168.1.0/24"
trustedSubnets: []
.. note::
@@ -1076,14 +1134,14 @@ Settings for the built-in slicing support:
slicing:
# Whether to enable slicing support or not
enabled:
enabled: true
# Default slicer to use
defaultSlicer: cura
defaultSlicer: null
# Default slicing profiles per slicer
defaultProfiles:
cura: ...
curalegacy: ...
.. _sec-configuration-config_yaml-system:
@@ -1092,7 +1150,12 @@ System
Use the following settings to add custom system commands to the "System" dropdown within OctoPrint's top bar.
Commands consist of a name, an action identifier, the commandline to execute and an optional confirmation message to
Commands consist of a ``name`` shown to the user, an ``action`` identifier used by the code and the actual
``command`` including any argument needed for its execution.
By default OctoPrint blocks until the command has returned so that the exit code can be used to show a success
or failure message; use the flag ``async: true`` for commands that don't return.
Optionally you can add a confirmation message to
display before actually executing the command (should be set to False if a confirmation dialog is not desired).
The following example defines a command for shutting down the system under Linux. It assumes that the user under which
@@ -1149,7 +1212,7 @@ Use `Javascript regular expressions <https://developer.mozilla.org/en/docs/Web/J
# A list of filters to display in the terminal tab. Defaults to the filters shown below
terminalFilters:
- name: Suppress temperature messages
regex: '(Send: (N\d+\s+)?M105)|(Recv: ok T:)'
regex: '(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?.*(B|T\d*):\d+)'
- name: Suppress SD status messages
regex: '(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)'
- name: Suppress wait responses
+2 -2
View File
@@ -39,8 +39,8 @@ A list of important components for which an increase in logging might be interes
* ``octoprint.filemanager``: the file management layer
* ``octoprint.plugin``: the plugin sub system
* ``octoprint.plugins.<plugin>``: the plugin ``<plugin>``, e.g. ``octoprint.plugins.discovery`` to change the log level of
the `Discovery plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Discovery>`_ or ``octoprint.plugins.cura``
to change the log level of the `Cura plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura>`_.
the :ref:`Discovery plugin <sec-bundledplugins-discovery>` or ``octoprint.plugins.backup``
to change the log level of the :ref:`Backup plugin <sec-bundledplugins-backup>`.
* ``octoprint.slicing``: the slicing sub system
This list will be expanded when deemed necessary.
+55 -44
View File
@@ -57,60 +57,71 @@ You can simulate certain conditions and communications through the terminal tab
All commands start with ``!!DEBUG:`` and are followed by the command you want to execute. For instance, sending
``!!DEBUG:action_disconnect`` will disconnect the printer. Sending ``!!DEBUG`` without command will show a help
message with all the available commands.
message with all the available commands:
Action Triggers
...............
.. code-block:: none
``action_pause``
Sends a "// action:pause" action trigger to the host.
OctoPrint Virtual Printer debug commands
``action_resume``
Sends a "// action:resume" action trigger to the host.
help
?
| This help.
``action_disconnect``
Sends a "// action:disconnect" action trigger to the host.
# Action Triggers
``action_custom <action>[ <parameters>]``
Sends a custom "// action:<action> <parameters>" action trigger to the host.
action_pause
| Sends a "// action:pause" action trigger to the host.
action_resume
| Sends a "// action:resume" action trigger to the host.
action_disconnect
| Sends a "// action:disconnect" action trigger to the
| host.
action_custom <action>[ <parameters>]
| Sends a custom "// action:<action> <parameters>"
| action trigger to the host.
Communication Errors
....................
# Communication Errors
``dont_answer``
Will not acknowledge the next command.
dont_answer
| Will not acknowledge the next command.
go_awol
| Will completely stop replying
trigger_resend_lineno
| Triggers a resend error with a line number mismatch
trigger_resend_checksum
| Triggers a resend error with a checksum mismatch
trigger_missing_checksum
| Triggers a resend error with a missing checksum
trigger_missing_lineno
| Triggers a "no line number with checksum" error w/o resend request
drop_connection
| Drops the serial connection
prepare_ok <broken ok>
| Will cause <broken ok> to be enqueued for use,
| will be used instead of actual "ok"
``go_awol``
Will completely stop replying.
# Reply Timing / Sleeping
``trigger_resend_lineno``
Triggers a resend error with a line number mismatch
sleep <int:seconds>
| Sleep <seconds> s
sleep_after <str:command> <int:seconds>
| Sleeps <seconds> s after each execution of <command>
sleep_after_next <str:command> <int:seconds>
| Sleeps <seconds> s after execution of next <command>
``trigger_resend_checksum``
Triggers a resend error with a checksum mismatch
# SD printing
``drop_connection``
Drops the serial connection
start_sd <str:file>
| Select and start printing file <file> from SD
select_sd <str:file>
| Select file <file> from SD, don't start printing it yet. Use
| start_sd to start the print
cancel_sd
| Cancels an ongoing SD print
``prepare_ok <broken ok>``
Will cause <broken ok> to be enqueued for use, will be used instead of actual "ok"
# Misc
Reply Timing / Sleeping
.......................
``sleep <int:seconds>``
Sleep <seconds> s
``sleep_after <str:command> <int:seconds>``
Sleeps <seconds> s after each execution of <command>
``sleep_after_next <str:command> <int:seconds>``
Sleeps <seconds> s after execution of next <command>
Misc
....
``help``
Show the available commands.
``send <str:message>``
Sends back <message>
send <str:message>
| Sends back <message>
reset
| Simulates a reset. Internal state will be lost.
+97 -54
View File
@@ -6,15 +6,6 @@ Events
.. contents::
.. note::
With release of OctoPrint 1.1.0, the payload data has been harmonized, it is now a key-value-map for all events.
Additionally, the format of the placeholders in both system command and gcode command triggers has been changed to
accommodate for this new format. Last but not least, the way of specifying event hooks has changed, OctoPrint no longer
separates hooks into two sections (gcodeCommandTrigger and systemCommandTrigger) but instead event hooks are now typed
to indicate what to do with the command contained.
.. _sec-events-configuration:
Configuration
@@ -47,6 +38,13 @@ Example
- event: PrintDone
command: python ~/growl.py -t mygrowlserver -d "Completed {file}" -a OctoPrint -i http://raspi/Octoprint_logo.png
type: system
- event:
- PrintStarted
- PrintFailed
- PrintDone
- PrintCancelled
command: python ~/growl.py -t mygrowlserver -d "Event {__eventname} ({name})" -a OctoPrint -i http://raspi/Octoprint_logo.png
type: system
- event: Connected
command:
- M115
@@ -62,6 +60,7 @@ Placeholders
You can use the following generic placeholders in your event hooks:
* ``{__currentZ}``: the current Z position of the head if known, -1 if not available
* ``{__eventname}`` : the name of the event hook being triggered
* ``{__filename}`` : name of currently selected file, or ``NO FILE`` if no file is selected
* ``{__filepath}`` : path in origin location of currently selected file, or ``NO FILE`` if no file is selected
* ``{__fileorigin}`` : origin of currently selected file, or ``NO FILE`` if no file is selected
@@ -85,6 +84,12 @@ and its origin via the placeholder ``{origin}``.
Available Events
================
.. note::
Plugins may add additional events via the :ref:`octoprint.events.register_custom_events hook <sec-plugins-hook-events-register_custom_events>`.
.. _sec-events-available_events-server:
Server
------
@@ -118,6 +123,8 @@ ConnectivityChanged
* ``old``: Old connectivity value (true for online, false for offline)
* ``new``: New connectivity value (true for online, false for offline)
.. _sec-events-available_events-printer_commmunication:
Printer communication
---------------------
@@ -141,7 +148,8 @@ Disconnected
The server has disconnected from the printer
Error
An error has occurred in the printer communication.
An unrecoverable error has been encountered, either as reported by the firmware (e.g. a thermal runaway) or
on the connection.
Payload:
@@ -156,6 +164,8 @@ PrinterStateChanged
:func:`~octoprint.printer.PrinterInterface.get_state_id` for possible values.
* ``state_string``: Text representation of the new state.
.. _sec-events-available_events-file_handling:
File handling
-------------
@@ -169,9 +179,7 @@ Upload
.. deprecated:: 1.3.0
* ``file``: the file's path within its storage location
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
FileAdded
A file has been added to a storage.
@@ -207,8 +215,8 @@ FolderAdded
Payload:
* ``storage``: the storage's identifier
* ``path``: the folders's path within its storage location
* ``name``: the folders's name
* ``path``: the folder's path within its storage location
* ``name``: the folder's name
.. note::
@@ -220,8 +228,8 @@ FolderRemoved
Payload:
* ``storage``: the storage's identifier
* ``path``: the folders's path within its storage location
* ``name``: the folders's name
* ``path``: the folder's path within its storage location
* ``name``: the folder's name
.. note::
@@ -253,9 +261,7 @@ MetadataAnalysisStarted
.. deprecated:: 1.3.0
* ``file``: the file's path within its storage location
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
MetadataAnalysisFinished
The metadata analysis of a file has finished.
@@ -269,9 +275,7 @@ MetadataAnalysisFinished
.. deprecated:: 1.3.0
* ``file``: the file's path within its storage location
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
FileSelected
A file has been selected for printing.
@@ -284,10 +288,8 @@ FileSelected
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
FileDeselected
No file is selected any more for printing.
@@ -311,6 +313,8 @@ TransferDone
* ``local``: the file's name as stored locally
* ``remote``: the file's name as stored on SD
.. _sec-events-available_events-printing:
Printing
--------
@@ -322,13 +326,14 @@ PrintStarted
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``user``: the user who started the print job (if available)
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
PrintFailed
A print failed.
@@ -338,13 +343,15 @@ PrintFailed
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``time``: the elapsed time of the print when it failed, in seconds (float)
* ``reason``: the reason the print failed, either ``cancelled`` or ``error``
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
PrintDone
A print completed successfully.
@@ -354,14 +361,14 @@ PrintDone
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``time``: the time needed for the print, in seconds (float)
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
PrintCancelling
The print is about to be cancelled.
@@ -371,6 +378,9 @@ PrintCancelling
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``user``: the user who cancelled the print job (if available)
* ``firmwareError``: the firmware error that caused cancelling the print job, if any
PrintCancelled
@@ -381,7 +391,12 @@ PrintCancelled
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``position``: the print head position at the time of cancelling, if available
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``time``: the elapsed time of the print when it was cancelled, in seconds (float)
* ``user``: the user who cancelled the print job (if available)
* ``position``: the print head position at the time of cancelling (if available, not available if recording of the
position on cancel is disabled)
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
@@ -395,10 +410,8 @@ PrintCancelled
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
PrintPaused
The print has been paused.
@@ -408,7 +421,11 @@ PrintPaused
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``position``: the print head position at the time of pausing, if available
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``user``: the user who paused the print job (if available)
* ``position``: the print head position at the time of pausing (if available, not available if the recording of
the position on pause is disabled or the pause is completely handled by the printer's firmware)
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
@@ -422,10 +439,8 @@ PrintPaused
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
PrintResumed
The print has been resumed.
@@ -435,13 +450,16 @@ PrintResumed
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
* ``size``: the file's size in bytes (if available)
* ``owner``: the user who started the print job (if available)
* ``user``: the user who resumed the print job (if available)
.. deprecated:: 1.3.0
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
* ``filename``: the file's name
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
* ``filename``: the file's name. To be removed in 1.4.0.
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
.. _sec-events-available_events-gcode_processing:
GCODE processing
----------------
@@ -504,6 +522,8 @@ ToolChange
* ``old``: old tool index
* ``new``: new tool index
.. _sec-events-available_events-timelapses:
Timelapses
----------
@@ -558,6 +578,8 @@ MovieFailed
returned a non-0 return code, ``no_frames`` if no frames were captured that could be rendered
to a timelapse, or ``unknown`` for any other reason of failure to render.
.. _sec-events-available_events-slicing:
Slicing
-------
@@ -566,6 +588,7 @@ SlicingStarted
Payload:
* ``slicer``: the used slicer
* ``stl``: the STL's filename
* ``stl_location``: the STL's location
* ``gcode``: the sliced GCODE's filename
@@ -577,6 +600,7 @@ SlicingDone
Payload:
* ``slicer``: the used slicer
* ``stl``: the STL's filename
* ``stl_location``: the STL's location
* ``gcode``: the sliced GCODE's filename
@@ -589,6 +613,7 @@ SlicingCancelled
Payload:
* ``slicer``: the used slicer
* ``stl``: the STL's filename
* ``stl_location``: the STL's location
* ``gcode``: the sliced GCODE's filename
@@ -599,6 +624,7 @@ SlicingFailed
Payload:
* ``slicer``: the used slicer
* ``stl``: the STL's filename
* ``stl_location``: the STL's location
* ``gcode``: the sliced GCODE's filename
@@ -614,7 +640,7 @@ SlicingProfileAdded
* ``profile``: the profile that was added
SlicingProfileModified
A new slicing profile was modified.
A slicing profile was modified.
Payload:
@@ -629,8 +655,25 @@ SlicingProfileDeleted
* ``slicer``: the slicer for which the profile was deleted
* ``profile``: the profile that was deleted
.. _sec-events-available_events-settings:
Settings
--------
SettingsUpdated
The internal settings were updated.
The settings were updated via the REST API.
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``.
.. _sec-events-available_events-printer_profile:
Printer Profile
--------
PrinterProfileModified
A printer profile was modified.
Payload:
* ``identifier``: the identifier of the modified printer profile
+9 -3
View File
@@ -21,17 +21,23 @@ Commands, which are admin-only.
If Access Control is disabled, everything is directly accessible. **That also
includes all administrative functionality as well as full control over the
printer!**
printer**, and without the need for an :ref:`API key <sec-api-general-authorization>`!
Upon first start a configuration wizard is provided which allows configuration
of the first administrator account or alternatively disabling Access Control
(which is **NOT** recommended for systems that are directly accessible via the
Internet!).
internet or other untrusted networks!).
.. hint::
If you plan to have your OctoPrint instance accessible over the internet,
**always enable Access Control**.
**always enable Access Control** and ideally **don't make it accessible to
everyone over the internet but instead use a VPN** or at the very least
HTTP basic authentication on a layer above OctoPrint.
A physical device that includes heaters and stepper motors really should not be
publicly reachable by everyone with an internet connection, even with access
control enabled.
.. _sec-features-access_control-rerunning_wizard:
+15
View File
@@ -29,12 +29,27 @@ pause
When this command is received from the printer, OctoPrint will pause a current print job just like if the
"Pause" button had been clicked.
paused
When this command is received from the printer, OctoPrint will pause a current print job but *without* triggering
any GCODE scripts or sending SD print control commands to the printer. This might be interesting for firmware
that wants to signal to OctoPrint that a print should be paused but without any control interference from
OctoPrint, e.g. in case of a filament change fully managed by the firmware.
resume
When this command is received from the printer, OctoPrint will resume a current print job just like if
the "Resume" button had been clicked.
resumed
When this command is received from the printer, OctoPrint will resume a current print job but *without* triggering
any GCODE scripts or sending SD print control commands to the printer. This might be interesting for firmware
that wants to signal to OctoPrint that a print should be resumed but without any control interference from
OctoPrint, e.g. in case of a filament change fully managed by the firmware.
disconnect
When this command is received from the printer, OctoPrint will immediately disconnect from it.
If the bundled :ref:`Action Command Prompt Support Plugin <sec-bundledplugins-action_command_prompt>` is enabled (which
should be the case by default), OctoPrint will also interactive dialog creation through its :ref:`supported commands <sec-bundledplugins-action_command_prompt-action_commands>`.
Support for additional commands may be added by plugins by implementing a handler for the
:ref:`octoprint.comm.protocol.action <sec-plugins-hook-comm-protocol-action>` hook.
+5 -1
View File
@@ -75,7 +75,7 @@ All GCODE scripts have access to the following template variables through the te
* ``last_temperature``: Last actual and target temperature reported for all available tools and if available the
heated bed. This is a dictionary of key-value pairs. The keys are the indices of the available tools (``0``, ``1``,
...) and ``b`` for the heated bed. The values are a dictionary consisting of ``actual`` and ``target`` keys mapped
to the corresponding temperature in degrees celsius. Note that not all tools your printer has must necessarily be
to the corresponding temperature in degrees Celsius. Note that not all tools your printer has must necessarily be
present here, neither must the heated bed - it depends on whether OctoPrint has values for a tool or the bed. Also
note that ``actual`` and ``target`` might be ``None``.
* ``script``: An object wrapping the script's type (``gcode``) and name (e.g. ``afterPrintCancelled``) as ``script.type``
@@ -157,9 +157,13 @@ The ``disable_hotends`` snippet is defined as follows:
.. code-block:: jinja
:caption: Default ``disable_hotends`` snippet
{% if printer_profile.extruder.sharedNozzle %}
M104 T0 S0
{% else %}
{% for tool in range(printer_profile.extruder.count) %}
M104 T{{ tool }} S0
{% endfor %}
{% endif %}
The ``disable_bed`` snippet is defined as follows:
+17 -10
View File
@@ -5,19 +5,20 @@ Safe mode
*********
With the advent of support for plugins in OctoPrint, it quickly became apparent that some of the bugs
reported on OctoPrint's bug tracker were actually bugs with installed third party plugins instead of
OctoPrint itself.
reported on OctoPrint's bug tracker were actually bugs with installed third party plugins or language
packs instead of OctoPrint itself.
To allow an easier identification of these cases, OctoPrint 1.3.0 introduced safe mode. Starting
OctoPrint in safe mode disables all plugins that are not bundled with OctoPrint, allowing to easier
identify most cases where a third party plugin is the culprit of an observed issue.
OctoPrint in safe mode disables all plugins (and starting with 1.3.13 also all language packs) that are
not bundled with OctoPrint, allowing to easier identify most cases where a third party plugin or language
pack is the culprit of an observed issue.
Additionally, OctoPrint allows uninstalling plugins in this mode, allowing recovery from cases where
a third party plugin causes the server to not start up or the web interface to not render or function
correctly anymore.
Additionally, OctoPrint allows uninstalling plugins and language packs in this mode, allowing recovery
from cases where a third party addition causes the server to not start up or the web interface to not
render or function correctly anymore.
Whenever reporting an issue with OctoPrint, please always attempt to reproduce it in safe mode as well to
ensure it really is an issue in OctoPrint itself and now caused by one of your installed third party plugins.
ensure it really is an issue in OctoPrint itself and now caused by one of your installed third party additions.
.. _sec-features-safemode-how:
@@ -73,11 +74,17 @@ When OctoPrint is running in safe mode the following changes to its normal opera
* OctoPrint will not enable any of the installed third party plugins. OctoPrint considers all plugins third
party plugins that do not ship with OctoPrint's sources, so any plugins installed either via `pip` or
into OctoPrint's plugin folder at ``~/.octoprint/plugins`` (Linux), ``%APPDATA%/OctoPrint`` (Windows) and
``~/Library/Application Support/OctoPrint`` (MacOS).
into OctoPrint's plugin folder at ``~/.octoprint/plugins`` (Linux), ``%APPDATA%/OctoPrint/plugins`` (Windows) and
``~/Library/Application Support/OctoPrint/plugins`` (MacOS).
* OctoPrint will not enable any of the installed third party language packs. OctoPrint considers all language packs
third party language packs that do not ship with OctoPrint's sources, so any language plugins installed
through the language pack manager within settings and/or stored in the language pack folder at
``~/.octoprint/translations`` (Linux), ``%APPDATA%/OctoPrint/translations`` (Windows) or
``~/Library/Application Support/OctoPrint/translations`` (MacOS).
* OctoPrint will still allow to uninstall third party plugins through the built-in Plugin Manager.
* OctoPrint will still allow to disable (bundled) plugins that are still enabled.
* OctoPrint will not allow to enable third party plugins.
* OctoPrint will still allow to manage language packs.
* OctoPrint's web interface will display a notification to remind you that it is running in
safe mode.
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 58 KiB

+2 -2
View File
@@ -11,7 +11,7 @@ and released under the `GNU Affero General Public License V3 <http://www.gnu.org
Its website can be found at `octoprint.org <https://octoprint.org/>`_.
The community forum is available at `discourse.octoprint.org <https://discourse.octoprint.org/>`_.
The community forum is available at `community.octoprint.org <https://community.octoprint.org/>`_.
The FAQ can be accessed by following `faq.octoprint.org <https://faq.octoprint.org/>`_.
@@ -23,7 +23,7 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!
.. note::
This documentation currently focuses primarily on developers and less on end users. If you are interested in
helping to change this, please get in touch `on the forum <https://discourse.octoprint.org/>`_!
helping to change this, please get in touch `on the forum <https://community.octoprint.org/>`_!
Contents
========
+1 -1
View File
@@ -417,7 +417,7 @@
Creates a custom exception class. ``name`` may be either a function in which case it will be used
as constructor for the new exception class, or a string, in which case a constructor with proper
``name``, ``message`` and ``stack`` attributes will be created. The class hierarchy will be propery
``name``, ``message`` and ``stack`` attributes will be created. The class hierarchy will be properly
setup to subclass ``Error``.
**Example:**
+1 -1
View File
@@ -189,7 +189,7 @@
A boolean value, specifies whether to immediately start printing the file after the upload
completes (true) or not (false, default)
userdata
An optional object or a serialized JSON string of additional user supplised data to associate with
An optional object or a serialized JSON string of additional user supplied data to associate with
the uploaded file.
See :ref:`Upload file or create folder <sec-api-fileops-uploadfile>` for more details on the file upload API and
+7 -3
View File
@@ -80,9 +80,13 @@ connection options (``baseurl`` and ``apikey``) directly in the constructor or s
.. seealso::
`OctoPrint-ForceLogin <https://github.com/OctoPrint/OctoPrint-ForceLogin>`_
A plugin that disables anonymous access to the regular OctoPrint UI by implementing a custom UI. Utilizes the
client library's :ref:`browser component <sec-jsclientlib-browser>` to login the user.
:ref:`Application Key Plugin <sec-bundledplugins-appkeys>`
A bundled plugin that implements an authorization workflow for third party clients. It adds various additional
methods to the JS Client Library.
:ref:`ForceLogin Plugin <sec-bundledplugins-forcelogin>`
A bundled plugin that disables anonymous access to the regular OctoPrint UI by implementing a custom UI and
various hooks. Utilizes the client library's :ref:`browser component <sec-jsclientlib-browser>` to login the
user.
.. toctree::
:maxdepth: 3
+58
View File
@@ -210,6 +210,64 @@
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.printer.getChamberState(data, opts)
Retrieves the current printer chamber state/temperature information, and optionally also the temperature
history.
The ``flags`` object can be used to specify the data to retrieve further via the following
properties:
* ``history``: a boolean value to specify whether the temperature history should be included (``true``)
or not (``false``), defaults to it not being included
* ``limit``: an integer value to specify how many history entries to include
See :ref:`Retrieve the current bed state <sec-api-printer-chamberstate>` for more details.
:param object flags: Flags that further specify which data to retrieve, see above for details
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.printer.setChamberTargetTemperature(target, opts)
Sets the given temperature on the printer's heated chamber (if available).
``target`` is expected to be the target temperature as a float value.
**Example:**
Set the chamber to 50°C.
.. code-block:: javascript
OctoPrint.printer.setChamberTargetTemperature(50.0);
See the ``target`` command in :ref:`Issue a chamber command <sec-api-printer-chambercommand>` for more details.
:param float target: The target to set
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.printer.setChamberTemperatureOffset(offset, opts)
Sets the given temperature offset for the printer's heated chamber (if available).
``offset`` is expected to be the temperature offset to set.
**Example:**
Set the offset for the chamber to -5°C.
.. code-block:: javascript
OctoPrint.printer.setChamberTemperatureOffset(-5);
See the ``offset`` command in :ref:`Issue a chamber command <sec-api-printer-chambercommand>` for more details.
:param object offsets: The offsets to set
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.printer.jog(amounts, opts)
Jogs the specified axes by the specified ``amounts``.
+1 -1
View File
@@ -85,7 +85,7 @@
.. js:function:: OctoPrintClient.socket.onRateTooHigh(measured, maximum)
Called by the socket client when the last measured round trip time was higher than the
current upper procesisng limit, indicating that the messages are now processed slower than
current upper processing limit, indicating that the messages are now processed slower than
the current rate requires and a slower rate might be necessary.
Can be overwritten with custom handler methods. The default implementation will call
+6
View File
@@ -6,4 +6,10 @@ octoprint.util
.. automodule:: octoprint.util
:members:
.. _sec-modules-util-commandline:
octoprint.util.commandline
--------------------------
.. automodule:: octoprint.util.commandline
:members:
+3 -3
View File
@@ -410,8 +410,8 @@ Now look at that!
Settings Galore: How to make parts of your plugin user adjustable
-----------------------------------------------------------------
Remember that Wikipedia link we added to our little link in the navigation bar? It links to the english Wikipedia. But
what if we want to allow our users to adjust that according to their wishes, e.g. to link to the german language node
Remember that Wikipedia link we added to our little link in the navigation bar? It links to the English Wikipedia. But
what if we want to allow our users to adjust that according to their wishes, e.g. to link to the German language node
about "Hello World" programs instead?
To allow your users to customized the behaviour of your plugin you'll need to implement the :class:`~octoprint.plugin.SettingsPlugin`
@@ -509,7 +509,7 @@ section doesn't yet exist in the file, create it):
# [...]
Restart OctoPrint. Not only should the URL displayed in the log file have changed, but also the link should now (after
a proper shift-reload) point to the german Wikipedia node about "Hello World" programs::
a proper shift-reload) point to the German Wikipedia node about "Hello World" programs::
2015-01-30 11:47:18,634 - octoprint.plugins.helloworld - INFO - Hello World! (more: https://de.wikipedia.org/wiki/Hallo-Welt-Programm)
+1 -1
View File
@@ -3,7 +3,7 @@
Helpers
=======
Helpers are methods that plugin can exposed to other plugins in order to make common functionality available on the
Helpers are methods that plugins can expose to other plugins in order to make common functionality available on the
system. They are registered with the OctoPrint plugin system through the use of the control property ``__plugin_helpers__``.
An example for providing some helper functions to the system can be found in the
+443 -4
View File
@@ -66,7 +66,7 @@ the general type of script for which to look for additions ("gcode") and the scr
return a 2-tuple of prefix and postfix if has something for either of those, otherwise ``None``. OctoPrint will then take
care to add prefix and suffix as necessary after a small round of preprocessing.
Plugins can easily add their own hooks too. For example, the `Software Update Plugin <https://github.com/OctoPrint/OctoPrint-SoftwareUpdate>`_
Plugins can easily add their own hooks too. For example, the `Software Update Plugin <https://github.com/foosel/OctoPrint/tree/master/src/octoprint/plugins/softwareupdate>`_
declares a custom hook "octoprint.plugin.softwareupdate.check_config" which other plugins can add handlers for in order
to register themselves with the Software Update Plugin by returning their own update check configuration.
@@ -208,6 +208,10 @@ octoprint.accesscontrol.appkey
.. py:function:: acl_appkey_hook(*args, **kwargs)
.. deprecated:: 1.3.11
This functionality will be removed in 1.4.0. Use the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` instead.
By handling this hook plugins may register additional :ref:`App session key providers <sec-api-apps-sessionkey>`
within the system.
@@ -380,6 +384,66 @@ octoprint.cli.commands
OctoPrint's CLI.
:rtype: list
.. _sec-plugins-hook-comm-protocol-firmware-info:
octoprint.comm.protocol.firmware.info
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: firmware_info_hook(comm_instance, firmware_name, firmware_data, *args, **kwargs)
Be notified of firmware information received from the printer following an ``M115``.
Hook handlers may use this to react/adjust behaviour based on reported firmware data. OctoPrint parses the received
report line and provides the parsed ``firmware_name`` and additional ``firmware_data`` contained therein. A
response line ``FIRMWARE_NAME:Some Firmware Name FIRMWARE_VERSION:1.2.3 PROTOCOL_VERSION:1.0`` for example will
be turned into a ``dict`` looking like this:
.. code-block:: python
dict(FIRMWARE_NAME="Some Firmware Name",
FIRMWARE_VERSION="1.2.3",
PROTOCOL_VERSION="1.0")
``firmware_name`` will be ``Some Firmware Name`` in this case.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you will effectively block the receive loop, causing the communication with the printer to stall.
This includes I/O of any kind.
:param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str firmware_name: The name of the parsed capability
:param dict firmware_data: All data contained in the ``M115`` report
.. _sec-plugins-hook-comm-protocol-firmware-capabilities:
octoprint.comm.firmware.protocol.capabilities
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: firmware_capability_hook(comm_instance, capability, enabled, already_defined, *args, **kwargs)
Be notified of capability report entries received from the printer.
Hook handlers may use this to react to custom firmware capabilities. OctoPrint parses the received capability
line and provides the parsed ``capability`` and whether it's ``enabled`` to the handler. Additionally all already
parsed capabilities will also be provided.
Note that hook handlers will be called once per received capability line.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you will effectively block the receive loop, causing the communication with the printer to stall.
This includes I/O of any kind.
:param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str capability: The name of the parsed capability
:param bool enabled: Whether the capability is reported as enabled or disabled
:param dict already_defined: Already defined capabilities (capability name mapped to enabled flag)
.. _sec-plugins-hook-comm-protocol-action:
octoprint.comm.protocol.action
@@ -389,11 +453,18 @@ octoprint.comm.protocol.action
React to a :ref:`action command <sec-features-action_commands>` received from the printer.
Hook handlers may use this to react to react to custom firmware messages. OctoPrint parses the received action
Hook handlers may use this to react to custom firmware messages. OctoPrint parses the received action
command ``line`` and provides the parsed ``action`` (so anything after ``// action:``) to the hook handler.
No returned value is expected.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within your handlers as
you will effectively block the receive loop, causing the communication with the printer to stall.
This includes I/O of any kind.
**Example:**
Logs if the ``custom`` action (``// action:custom``) is received from the printer's firmware.
@@ -431,6 +502,13 @@ This describes actually two hooks:
trigger the *actual execution* of whatever functionality lies behind a given @ command, similar to
:ref:`the action command hook <sec-plugins-hook-comm-protocol-action>`.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within your handlers as
you will effectively block the send/receive loops, causing the communication with the printer to stall.
This includes I/O of any kind.
**Example**
Pause the print on ``@wait`` (this mirrors the implementation of the built-in ``@pause`` command, just with a
@@ -577,6 +655,13 @@ This describes actually four hooks:
Note: Only one command of a given ``cmd_type`` (other than None) may be queued at a time. Trying to rewrite the ``cmd_type``
to one already in the queue will give an error.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you will effectively block the send loop, causing the communication with the printer to stall.
This includes I/O of any kind.
**Example**
The following hook handler replaces all ``M107`` ("Fan Off", deprecated) with an ``M106 S0`` ("Fan On" with speed
@@ -612,6 +697,13 @@ octoprint.comm.protocol.gcode.received
empty string as the received line. Note that Python functions will also automatically return ``None`` if an empty
``return`` statement is used or just nothing is returned explicitly from the handler.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you will effectively block the receive loop, causing the communication with the printer to stall.
This includes I/O of any kind.
**Example:**
Looks for the response of an ``M115``, which contains information about the ``MACHINE_TYPE``, among other things.
@@ -641,6 +733,13 @@ octoprint.comm.protocol.gcode.error
Plugins might utilize this hook to handle errors generated by the printer that are recoverable in one way or
the other and should not trigger the normal handling that assumes the worst.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you will effectively block the receive loop, causing the communication with the printer to stall.
This includes I/O of any kind.
**Example:**
Looks for error messages containing "fan error" or "bed missing" (ignoring case) and marks them as handled by the
@@ -667,9 +766,10 @@ octoprint.comm.protocol.scripts
make sure to only proceed with returning additional scripts if the ``script_type`` and ``script_name`` match
handled scripts. If not, None should be returned directly.
If the hook handler has something to add to the specified script, it may return a 2-tuple or a 3-tuple with the first entry
If the hook handler has something to add to the specified script, it may return a 2-tuple, a 3-tuple or a 4-tuple with the first entry
defining the prefix (what to *prepend* to the script in question), the second entry defining the postfix (what to
*append* to the script in question), and finally if desired a dictionary of variables to be made available to the script. Both prefix and postfix can be None to signify that nothing should be prepended
*append* to the script in question), and finally if desired a dictionary of variables to be made available to the script on third and additional tags to set on the
commands on fourth position. Both prefix and postfix can be None to signify that nothing should be prepended
respectively appended.
The returned prefix and postfix entries may be either iterables of script lines or a string including newlines of the script lines (which
@@ -716,6 +816,13 @@ octoprint.comm.protocol.temperatures.received
additional sanity checking to be applied and invalid values to be filtered out. If a handler returns an empty
dictionary or ``None``, no further processing will take place.
.. warning::
Make sure to not perform any computationally expensive or otherwise long running actions within these handlers as
you will effectively block the receive loop, causing the communication with the printer to stall.
This includes I/O of any kind.
**Example**
The following example shows how to filter out actual temperatures that are outside a sane range of 1°C to 300°C.
@@ -801,6 +908,72 @@ octoprint.comm.transport.serial.factory
:rtype: A serial instance implementing implementing the methods ``readline(...)``, ``write(...)``, ``close()`` and
optionally ``baudrate`` and ``timeout`` attributes as described above.
.. _sec-plugins-hook-events-register_custom_events:
octoprint.events.register_custom_events
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: register_custom_events_hook(*args, **kwargs)
Return a list of custom :ref:`events <sec-events>` to register in the system for your plugin.
Should return a list of strings which represent the custom events. Their name on the `octoprint.events.Events` object
will be the returned value transformed into upper case ``CAMEL_CASE`` and prefixed with ``PLUGIN_<IDENTIFIER>``. Their
value will be prefixed with ``plugin_<identifier>_``.
Example:
Consider the following hook part of a plugin with the identifier ``myplugin``. It will register two custom events
in the system, ``octoprint.events.Events.PLUGIN_MYPLUGIN_MY_CUSTOM_EVENT`` with value ``plugin_myplugin_my_custom_event``
and ``octoprint.events.Events.PLUGIN_MYPLUGIN_MY_OTHER_CUSTOM_EVENT`` with value ``plugin_myplugin_my_other_custom_event``.
.. code-block:: python
:linenos:
def register_custom_events(*args, **kwargs):
return ["my_custom_event", "my_other_custom_event"]
:return: A list of custom events to register
:rtype: list
.. _sec-plugins-hook-filemanager-analysis-factory:
octoprint.filemanager.analysis.factory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: analysis_queue_factory_hook(*args, **kwargs)
Return additional (or replacement) analysis queue factories used for analysing uploaded files.
Should return a dictionary to merge with the existing dictionary of factories, mapping from extension tree leaf
to analysis queue factory. Analysis queue factories are expected to be :class:`~octoprint.filemanager.analysis.AbstractAnalysisQueue`
subclasses or factory methods taking one argument (the finish callback to be used by the queue implementation
to signal that an analysis has been finished to the system). See the source of :class:`~octoprint.filemanager.analysis.GcodeAnalysisQueue`
for an example.
By default, only one analysis queue factory is registered in the system, for file type ``gcode``: :class:`~octoprint.filemanager.analysis.GcodeAnalysisQueue`.
This can be replaced by plugins using this hook, allowing other approaches to file analysis.
This is useful for plugins wishing to provide (alternative) methods of metadata analysis for printable files.
**Example:**
The following handler would replace the existing analysis queue for ``gcode`` files with a custom implementation:
.. code-block:: python
:linenos:
from octoprint.filemanager.analysis import AbstractAnalysisQueue
class MyCustomGcodeAnalysisQueue(AbstractAnalysisQueue):
# ... custom implementation here ...
def custom_gcode_analysis_queue(*args, **kwargs):
return dict(gcode=MyCustomGcodeAnalysisQueue)
:return: A dictionary of analysis queue factories, mapped by their targeted file type.
:rtype: dict
.. _sec-plugins-hook-filemanager-extensiontree:
octoprint.filemanager.extension_tree
@@ -903,6 +1076,185 @@ octoprint.printer.factory
:return: The ``printer`` instance to use globally.
:rtype: PrinterInterface subclass or None
.. _sec-plugins-hook-printer-estimation-factory:
octoprint.printer.estimation.factory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: print_time_estimator_factory(*args, **kwargs)
Return a :class:`~octoprint.printer.estimation.PrintTimeEstimator` subclass (or factory) to use for print time
estimation. This will be called on each start of a print or streaming job with a single parameter ``job_type``
denoting the type of job that was just started: ``local`` meaning a print of a local file through the serial connection,
``sdcard`` a print of a file stored on the printer's SD card, ``stream`` the streaming of a local file to the
printer's SD card.
This is useful for plugins wishing to provide alternative methods of live print time estimation.
If none of the registered factories return a ``PrintTimeEstimator`` subclass, the default :class:`~octoprint.printer.estimation.PrintTimeEstimator`
will be used.
**Example:**
The following example would replace the stock print time estimator with (a nonsensical) one that always estimates
two hours of print time left:
.. code-block:: python
from octoprint.printer.estimation import PrintTimeEstimator
class CustomPrintTimeEstimator(PrintTimeEstimator):
def __init__(self, job_type):
pass
def estimate(self, progress, printTime, cleanedPrintTime, statisticalTotalPrintTime, statisticalTotalPrintTimeType):
# always reports 2h as printTimeLeft
return 2 * 60 * 60, "estimate"
def create_estimator_factory(*args, **kwargs):
return CustomPrintTimeEstimator
__plugin_hooks__ = {
"octoprint.printer.estimation.factory": create_estimator_factory
}
:return: The :class:`~octoprint.printer.estimation.PrintTimeEstimator` class to use, or a factory method
:rtype: class or function
.. _sec-plugins-hook-octoprint-printer-sdcardupload:
octoprint.printer.sdcardupload
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: sd_card_upload_hook(printer, filename, path, start_callback, success_callback, failure_callback, *args, **kwargs)
Via this hook plugins can change the way files are being uploaded to the sd card of the printer.
Implementations **must** call the provided ``start_callback`` on start of the file transfer and either the ``success_callback``
or ``failure_callback`` on the end of the file transfer, depending on whether it was successful or not.
The ``start_callback`` has the following signature:
.. code-block:: python
def start_callback(local_filename, remote_filename):
# ...
``local_filename`` must be the name of the file on the ``local`` storage, ``remote_filename`` the name of the file
to be created on the ``sdcard`` storage.
``success_callback`` and ``failure_callback`` both have the following signature:
.. code-block:: python
def success_or_failure_callback(local_filename, remote_filename, elapsed):
# ...
``local_filename`` must be the name of the file on the ``local`` storage, ``remote_filename`` the name of the file
to be created on the ``sdcard`` storage. ``elapsed`` is the elapsed time in seconds.
If the hook is going to handle the upload, it must return the (future) remote filename of the file on the ``sdcard``
storage. If it returns ``None`` (or an otherwise falsy value), OctoPrint will interpret this as the hook not going to
handle the file upload, in which case the next hook or - if no other hook is registered - the default implementation
will be called.
**Example**
The following example creates a dummy SD card uploader that does nothing but sleep for ten seconds when a file
is supposed to be uploaded. Note that the long running process of sleeping for ten seconds is extracted into its
own thread, which is important in order to not block the main application!
.. code-block:: python
import threading
import logging
import time
def nop_upload_to_sd(printer, filename, path, sd_upload_started, sd_upload_succeeded, sd_upload_failed, *args, **kwargs):
logger = logging.getLogger(__name__)
remote_name = printer._get_free_remote_name(filename)
logger.info("Starting dummy SDCard upload from {} to {}".format(filename, remote_name))
sd_upload_started(filename, remote_name)
def process():
logger.info("Sleeping 10s...")
time.sleep(10)
logger.info("And done!")
sd_upload_succeeded(filename, remote_name, 10)
thread = threading.Thread(target=process)
thread.daemon = True
thread.start()
return remote_name
__plugin_name__ = "No-op SDCard Upload Test"
__plugin_hooks__ = {
"octoprint.printer.sdcardupload": nop_upload_to_sd
}
.. versionadded:: 1.3.11
:param object printer: the :py:class:`~octoprint.printer.PrinterInterface` instance the hook was called from
:param str filename: filename on the ``local`` storage
:param str path: path of the file in the local file system
:param function sd_upload_started: callback for when the upload started
:param function sd_upload_success: callback for successful finish of upload
:param function sd_upload_failure: callback for failure of upload
:return: the name of the file on the ``sdcard`` storage or ``None``
:rtype: string or ``None``
.. _sec-plugins-hook-server-http-after_request:
octoprint.server.api.after_request
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: after_request_handlers_hook(*args, **kwargs)
Allows adding additional after-request-handlers to API endpoints defined by OctoPrint itself and installed plugins.
Your plugin might need this to further restrict access to API methods. See the bundled "Force Login" plugin for a
usage example.
.. important::
Implementing this hook will make your plugin require a restart of OctoPrint for enabling/disabling it fully.
.. _sec-plugins-hook-server-http-before_request:
octoprint.server.api.before_request
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: after_request_handlers_hook(*args, **kwargs)
Allows adding additional before-request-handlers to API endpoints defined by OctoPrint itself and installed plugins.
Your plugin might need this to further restrict access to API methods. See the bundled "Force Login" plugin for a
usage example.
.. important::
Implementing this hook will make your plugin require a restart of OctoPrint for enabling/disabling it fully.
.. _sec-plugins-hook-server-http-access_validator:
octoprint.server.http.access_validator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: access_validator_hook(request, *args, **kwargs)
Allows adding additional access validators to the default tornado routers.
Your plugin might need to this to restrict acccess to downloads and webcam snapshots further. See the bundled
"Force Login" plugin for a usage example.
.. important::
Implementing this hook will make your plugin require a restart of OctoPrint for enabling/disabling it fully.
.. _sec-plugins-hook-server-http-bodysize:
octoprint.server.http.bodysize
@@ -977,6 +1329,14 @@ octoprint.server.http.routes
view of the blueprint will thus not be reachable since processing of the request will directly be handed over
to your defined handler class.
.. important::
If you want your route to support CORS if it's enabled in OctoPrint, your `RequestHandler <http://tornado.readthedocs.org/en/branch4.0/web.html#request-handlers>`_
needs to implement the :class:`~octoprint.server.util.tornado.CorsSupportMixin` for this to work. Note that all of
:class:`~octoprint.server.util.tornado.LargeResponseHandler`, :class:`~octoprint.server.util.tornado.UrlProxyHandler`,
:class:`~octoprint.server.util.tornado.StaticDataHandler` and :class:`~octoprint.server.util.tornado.DeprecatedEndpointHandler`
already implement this mixin.
.. important::
Implementing this hook will make your plugin require a restart of OctoPrint for enabling/disabling it fully.
@@ -1004,6 +1364,85 @@ octoprint.server.http.routes
:return: a list of 3-tuples with additional routes as defined above
:rtype: list
.. _sec-plugins-hook-server-sockjs-authed:
octoprint.server.sockjs.authed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: socket_authed_hook(socket, user, *args, **kwargs):
Allows plugins to be notified that a user got authenticated or deauthenticated on the socket (e.g. due to logout).
See the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` for an example on how to utilize this.
:param object socket: the socket object which is about to be registered
:param object user: the user that got authenticated on the socket, or None if the user got deauthenticated
.. _sec-plugins-hook-server-sockjs-register:
octoprint.server.sockjs.register
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: socket_registration_hook(socket, user, *args, **kwargs):
Allows plugins to prevent a new :ref:`push socket client <sec-api-push>` to be registered to the system.
Handlers should return either ``True`` or ``False``. ``True`` signals to proceed with normal registration. ``False``
signals to not register the client.
See the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` for an example on how to utilize this.
:param object socket: the socket object which is about to be registered
:param object user: the user currently authenticated on the socket - might be None
:return: whether to proceed with registration (``True``) or not (``False``)
:rtype: boolean
.. _sec-plugins-hook-server-sockjs-emit:
octoprint.server.sockjs.emit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: socket_emit_hook(socket, user, message, payload, *args, **kwargs):
Allows plugins to prevent any messages to be emitted on an existing :ref:`push connection <sec-api-push>`.
Handlers should return either ``True`` to allow the message to be emitted, or ``False`` to prevent it.
See the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` for an example on how to utilize this.
:param object socket: the socket object on which a message is about to be emitted
:param object user: the user currently authenticated on the socket - might be None
:param string message: the message type about to be emitted
:param dict payload: the payload of the message about to be emitted (may be None)
:return: whether to proceed with sending the message (``True``) or not (``False``)
:rtype: boolean
.. _sec-plugins-hook-timelapse-extensions:
octoprint.timelapse.extensions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: timelapse_extension_hook(*args, **kwargs)
Allows extending the set of supported file extensions for timelapse files. Handlers must return a list of
additional file extensions.
**Example**
Allow the management of timelapse GIFs with extension ``gif``.
.. code-block:: python
def get_timelapse_extensions(*args, **kwargs):
return ["gif"]
__plugin_hooks__ = {
"octoprint.timelapse.extensions": get_timelapse_extensions
}
:return: a list of additional file extensions
:rtype: list
.. _sec-plugins-hook-ui-web-templatetypes:
octoprint.ui.web.templatetypes
+44 -9
View File
@@ -68,11 +68,14 @@ calls are done is as follows:
* Plugins with a return value that is not ``None`` for :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`
for the provided sorting context will be ordered among each other first. If the returned order number is equal for
two or more implementations, the plugin's identifier will be the next sorting criteria.
* After that follow plugins which returned ``None`` (the default). They are sorted by their identifier.
two or more implementations, they will be sorted first by whether they come bundled with OctoPrint or not, then by
their identifier.
* After that follow plugins which returned ``None`` (the default). They are first sorted by whether they come bundled
with OctoPrint or not, then by their identifier.
Example: Consider three plugin implementations implementing the :class:`~octoprint.plugin.StartupPlugin` mixin, called
``plugin_a``, ``plugin_b`` and ``plugin_c``. ``plugin_a`` doesn't override :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`.
Example: Consider four plugin implementations implementing the :class:`~octoprint.plugin.StartupPlugin` mixin, called
``plugin_a``, ``plugin_b``, ``plugin_c`` and ``plugin_d``, the latter coming bundled with OctoPrint. ``plugin_a``
and ``plugin_d`` don't override :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`.
``plugin_b`` and ``plugin_c`` both return ``1`` for the sorting context ``StartupPlugin.on_startup``, ``None`` otherwise:
.. code-block:: python
@@ -99,7 +102,7 @@ Example: Consider three plugin implementations implementing the :class:`~octopri
class PluginB(octoprint.plugin.StartupPlugin):
def get_sorting_key(context):
def get_sorting_key(self, context):
if context == "StartupPlugin.on_startup":
return 1
return None
@@ -120,7 +123,7 @@ Example: Consider three plugin implementations implementing the :class:`~octopri
class PluginC(octoprint.plugin.StartupPlugin):
def get_sorting_key(context):
def get_sorting_key(self, context):
if context == "StartupPlugin.on_startup":
return 1
return None
@@ -134,13 +137,45 @@ Example: Consider three plugin implementations implementing the :class:`~octopri
__plugin_implementation__ = PluginC()
.. code-block:: python
:linenos:
:caption: plugin_d.py
# in this example this is bundled with OctoPrint
import octoprint.plugin
class PluginD(octoprint.plugin.StartupPlugin):
def on_startup(self, *args, **kwargs):
self._logger.info("PluginD starting up")
def on_after_startup(self, *args, **kwargs):
self._logger.info("PluginD started up")
__plugin_implementation__ = PluginD()
OctoPrint will detect that ``plugin_b`` and ``plugin_c`` define a order number, and since it's identical for both (``1``)
will order both plugins based on their plugin identifier. ``plugin_a`` doesn't define a sort key and hence will be
put after the other two. The execution order of the ``on_startup`` method will hence be ``plugin_b``, ``plugin_c``, ``plugin_a``.
will order both plugins based first on their bundling status and then on their plugin identifier.
``plugin_a`` and ``plugin_d`` don't define a sort key and hence will be
put after the other two, with ``plugin_d`` coming *before* ``plugin_a`` since it comes bundled with OctoPrint.
The execution order of the ``on_startup`` method will hence be ``plugin_b``, ``plugin_c``, ``plugin_d``, ``plugin_a``.
Now, the execution order of the ``on_after_startup`` method will be determined based on another sorting context,
``StartupPlugin.on_after_startup`` for which all of the plugins return ``None``. Hence, the execution order of the
``on_after_startup`` method will be purely ordered by plugin identifier, ``plugin_a``, ``plugin_b``, ``plugin_c``.
``on_after_startup`` method will be ordered first by bundle status, then by plugin identifier: ``plugin_d``, ``plugin_a``, ``plugin_b``, ``plugin_c``.
This will result in the following messages to be generated:
.. code-block:: plain
Plugin B starting up
Plugin C starting up
Plugin D starting up
Plugin A starting up
Plugin D started up
Plugin A started up
Plugin B started up
Plugin C started up
.. _sec-plugins-mixins-injectedproperties:
+2 -2
View File
@@ -56,9 +56,9 @@ Example:
// more of your view model's implementation
}
// we don't explicitely declare a name property here
// we don't explicitly declare a name property here
// our view model will be registered under "myCustomViewModel" (implicit
// name derived from contructor name) and "yourCustomViewModel" (explicitely
// name derived from constructor name) and "yourCustomViewModel" (explicitly
// provided as additional name)
OCTOPRINT_VIEWMODELS.push({
construct: MyCustomViewModel,
+17
View File
@@ -0,0 +1,17 @@
# init/systemd files for OctoPrint.
Assumes OctoPrint is installed under user pi at /home/pi/OctoPrint/venv/bin/octoprint. If you have a different
setup you'll need to adjust octoprint.default (init) or octoprint.service (systemd) accordingly.
## init
```
octoprint.default => /etc/default/octoprint
octoprint.init => /etc/init.d/octoprint
```
## systemd
```
octoprint.service => /etc/systemd/service/octoprint.service
```
+12
View File
@@ -0,0 +1,12 @@
[Unit]
Description=The snappy web interface for your 3D printer
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
ExecStart=/home/pi/OctoPrint/venv/bin/octoprint
[Install]
WantedBy=multi-user.target
+1 -1
View File
@@ -1,5 +1,5 @@
[metadata]
description-file = README.md
license_file = LICENSE.txt
[versioneer]
VCS = git
+80 -65
View File
@@ -12,48 +12,57 @@ import octoprint_setuptools
#-----------------------------------------------------------------------------------------------------------------------
# Supported python versions
PYTHON_REQUIRES = ">=2.7.9,<3"
# Requirements for our application
INSTALL_REQUIRES = [
"flask>=0.9,<0.11",
"Jinja2>=2.8,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
"werkzeug>=0.8.3,<0.9",
"tornado==4.0.2", # pinned for now, we need to migrate to a newer tornado, but due
# to some voodoo needed to get large streamed uploads and downloads
# to work that is probably not completely straightforward and therefore
# something for post-1.3.0-stable release
"sockjs-tornado>=1.0.3,<1.1",
"PyYAML>=3.10,<3.11",
"Flask-Login>=0.2.2,<0.3",
"Flask-Principal>=0.3.5,<0.4",
"Flask-Babel>=0.9,<0.10",
"Flask-Assets>=0.10,<0.11",
"markdown>=2.6.4,<2.7",
"pyserial>=2.7,<3.5",
"netaddr>=0.7.17,<0.8",
"watchdog>=0.8.3,<0.9",
"sarge>=0.1.4,<0.2",
"netifaces>=0.10,<0.11",
"pylru>=1.0.9,<1.1",
"rsa>=3.2,<3.3",
"pkginfo>=1.2.1,<1.3",
"requests>=2.18.4,<3",
"semantic_version>=2.4.2,<2.5",
"psutil>=5.4.1,<6",
"Click>=6.2,<6.3",
# the following dependencies are non trivial to update since later versions introduce backwards incompatible
# changes that might affect plugins, or due to other observed problems
"flask>=0.10.1,<0.11", # newer versions require newer Jinja versions
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
"tornado==4.5.3", # a memory leak was observed in tornado >= 5, see #2585
"Flask-Login>=0.2.11,<0.3", # some functions changed to properties in 0.3
"regex!=2018.11.6", # avoid broken 2018.11.6. See #2874
# anything below this should be checked on releases for new versions
"Flask-Principal>=0.4,<0.5",
"Flask-Babel>=0.12,<0.13",
"Flask-Assets>=0.12,<0.13",
"werkzeug>=0.15.1,<0.16",
"cachelib>=0.1,<0.2",
"PyYAML>=5.1,<6",
"markdown>=3.0,<3.1",
"pyserial>=3.4,<3.5",
"netaddr>=0.7.19,<0.8",
"watchdog>=0.9.0,<0.10",
"sarge==0.1.5post0",
"netifaces>=0.10.9,<0.11",
"pylru>=1.2,<1.3",
"rsa>=4.0,<5",
"pkginfo>=1.5.0.1,<1.6",
"requests>=2.21.0,<3",
"semantic_version>=2.6,<2.7",
"psutil>=5.6.1,<5.7",
"Click>=7,<8",
"awesome-slugify>=1.6.5,<1.7",
"feedparser>=5.2.1,<5.3",
"chainmap>=1.0.2,<1.1",
"future>=0.15,<0.16",
"scandir>=1.3,<1.4",
"websocket-client>=0.40,<0.41",
"python-dateutil>=2.6,<2.7",
"wrapt>=1.10.10,<1.11",
"futures>=3.1.1,<3.2",
"emoji>=0.4.5,<0.5",
"monotonic>=1.3,<1.4",
"frozendict>=1.2,<1.3"
"chainmap>=1.0.3,<1.1",
"future>=0.17.1,<0.18",
"scandir>=1.10,<1.11",
"websocket-client>=0.56,<0.57",
"wrapt>=1.11.1,<1.12",
"futures>=3.2,<3.3",
"emoji>=0.5.1,<0.6",
"monotonic>=1.5,<1.6",
"frozendict>=1.2,<1.3",
"sentry-sdk==0.7.7",
"typing>=3.6.6,<4",
"filetype>=1.0.5,<2"
]
if sys.platform == "darwin":
@@ -65,7 +74,7 @@ EXTRA_REQUIRES = dict(
develop=[
# Testing dependencies
"mock>=2.0.0,<3",
"nose>=1.3.0,<1.4",
"nose>=1.3.7,<1.4",
"ddt",
# Documentation dependencies
@@ -73,26 +82,28 @@ EXTRA_REQUIRES = dict(
"sphinxcontrib-httpdomain",
"sphinxcontrib-mermaid>=0.3",
"sphinx_rtd_theme",
# PyPi upload related
"pypandoc"
"readthedocs-sphinx-ext==0.5.7"
],
# Dependencies for developing OctoPrint plugins
plugins=[
"cookiecutter>=1.4,<1.7"
"cookiecutter>=1.6,<1.7"
]
)
# Additional requirements for setup
SETUP_REQUIRES = []
# Dependency links for any of the aforementioned dependencies
DEPENDENCY_LINKS = []
#-----------------------------------------------------------------------------------------------------------------------
# Anything below here is just command setup and general setup configuration
here = os.path.abspath(os.path.dirname(__file__))
def read_file_contents(path):
import codecs
with codecs.open(path, encoding="utf-8") as f:
return f.read()
def data_copy_build_py_factory(files, baseclass):
class data_copy_build_py(baseclass):
files = dict()
@@ -148,45 +159,49 @@ def params():
version = versioneer.get_version()
cmdclass = get_cmdclass()
description = "A snappy web interface for 3D printers"
long_description = open("README.md").read()
description = "The snappy web interface for your 3D printer"
long_description = read_file_contents(os.path.join(here, "README.md"))
long_description_content_type = "text/markdown"
python_requires = PYTHON_REQUIRES
install_requires = INSTALL_REQUIRES
extras_require = EXTRA_REQUIRES
dependency_links = DEPENDENCY_LINKS
setup_requires = SETUP_REQUIRES
try:
import pypandoc
setup_requires += ["setuptools-markdown"]
long_description_markdown_filename = "README.md"
del pypandoc
except:
pass
classifiers = [
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Flask",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Manufacturing",
"Intended Audience :: Other Audience",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Natural Language :: English",
"Natural Language :: German",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: JavaScript",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Printing",
"Topic :: System :: Networking :: Monitoring"
"Topic :: System :: Monitoring"
]
author = "Gina Häußge"
author_email = "osd@foosel.net"
url = "http://octoprint.org"
license = "AGPLv3"
author_email = "gina@octoprint.org"
url = "https://octoprint.org"
license = "GNU Affero General Public License v3"
keywords = "3dprinting 3dprinter 3d-printing 3d-printer octoprint"
project_urls={
"Community Forum": "https://community.octoprint.org",
"Bug Reports": "https://github.com/foosel/OctoPrint/issues",
"Source": "https://github.com/foosel/OctoPrint",
"Funding": "https://donate.octoprint.org"
}
packages = find_packages(where="src")
package_dir = {
+73 -29
View File
@@ -50,15 +50,24 @@ del version_info
#~~ custom exceptions
class FatalStartupError(BaseException):
pass
class FatalStartupError(Exception):
def __init__(self, message, cause=None):
self.cause = cause
Exception.__init__(self, message)
def __str__(self):
result = Exception.__str__(self)
if self.cause:
return "{}: {}".format(result, str(self.cause))
else:
return result
#~~ init methods to bring up platform
def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
logging_config=None, debug=False, verbosity=0, uncaught_logger=None,
uncaught_handler=None, safe_mode=False, ignore_blacklist=False, after_preinit_logging=None,
after_settings=None, after_logging=None, after_safe_mode=None,
after_settings_init=None, after_logging=None, after_safe_mode=None, after_settings_valid=None,
after_event_manager=None, after_connectivity_checker=None,
after_plugin_manager=None, after_environment_detector=None):
kwargs = dict()
@@ -70,55 +79,84 @@ def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
if callable(after_preinit_logging):
after_preinit_logging(**kwargs)
settings = init_settings(basedir, configfile)
try:
settings = init_settings(basedir, configfile)
except Exception as ex:
raise FatalStartupError("Could not initialize settings manager", cause=ex)
kwargs["settings"] = settings
if callable(after_settings):
after_settings(**kwargs)
if callable(after_settings_init):
after_settings_init(**kwargs)
try:
logger = init_logging(settings,
use_logging_file=use_logging_file,
logging_file=logging_file,
default_config=logging_config,
debug=debug,
verbosity=verbosity,
uncaught_logger=uncaught_logger,
uncaught_handler=uncaught_handler)
except Exception as ex:
raise FatalStartupError("Could not initialize logging", cause=ex)
logger = init_logging(settings,
use_logging_file=use_logging_file,
logging_file=logging_file,
default_config=logging_config,
debug=debug,
verbosity=verbosity,
uncaught_logger=uncaught_logger,
uncaught_handler=uncaught_handler)
kwargs["logger"] = logger
if callable(after_logging):
after_logging(**kwargs)
settings_safe_mode = settings.getBoolean(["server", "startOnceInSafeMode"])
safe_mode = safe_mode or settings_safe_mode
settings_start_once_in_safemode = "settings" if settings.getBoolean(["server", "startOnceInSafeMode"]) else None
settings_incomplete_startup_safemode = "incomplete_startup" \
if settings.getBoolean(["server", "incompleteStartup"]) \
and not settings.getBoolean(["server", "ignoreIncompleteStartup"]) \
else None
safe_mode = safe_mode or settings_start_once_in_safemode or settings_incomplete_startup_safemode
kwargs["safe_mode"] = safe_mode
if callable(after_safe_mode):
after_safe_mode(**kwargs)
event_manager = init_event_manager(settings)
# now before we continue, let's make sure *all* our folders are sane
try:
settings.sanity_check_folders()
except Exception as ex:
raise FatalStartupError("Configured folders didn't pass sanity check", cause=ex)
if callable(after_settings_valid):
after_settings_valid(**kwargs)
try:
event_manager = init_event_manager(settings)
except Exception as ex:
raise FatalStartupError("Could not initialize event manager", cause=ex)
kwargs["event_manager"] = event_manager
if callable(after_event_manager):
after_event_manager(**kwargs)
connectivity_checker = init_connectivity_checker(settings, event_manager)
try:
connectivity_checker = init_connectivity_checker(settings, event_manager)
except Exception as ex:
raise FatalStartupError("Could not initialize connectivity checker", cause=ex)
kwargs["connectivity_checker"] = connectivity_checker
if callable(after_connectivity_checker):
after_connectivity_checker(**kwargs)
plugin_manager = init_pluginsystem(settings,
safe_mode=safe_mode,
ignore_blacklist=ignore_blacklist,
connectivity_checker=connectivity_checker)
kwargs["plugin_manager"] = plugin_manager
try:
plugin_manager = init_pluginsystem(settings,
safe_mode=safe_mode,
ignore_blacklist=ignore_blacklist,
connectivity_checker=connectivity_checker)
except Exception as ex:
raise FatalStartupError("Could not initialize plugin manager", cause=ex)
kwargs["plugin_manager"] = plugin_manager
if callable(after_plugin_manager):
after_plugin_manager(**kwargs)
environment_detector = init_environment_detector(plugin_manager)
kwargs["environment_detector"] = environment_detector
try:
environment_detector = init_environment_detector(plugin_manager)
except Exception as ex:
raise FatalStartupError("Could not initialize environment detector", cause=ex)
kwargs["environment_detector"] = environment_detector
if callable(after_environment_detector):
after_environment_detector(**kwargs)
@@ -198,7 +236,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"class": "octoprint.logging.handlers.OctoPrintStreamHandler",
"level": "DEBUG",
"formatter": "simple",
"stream": "ext://sys.stdout"
@@ -308,9 +346,12 @@ def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connecti
import os
# we need this so that octoprint.plugins is in sys.modules and no warnings are caused when loading bundled plugins
import octoprint.plugins
logger = log.getLogger(__name__ + ".startup")
plugin_folders = [(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins")), True),
plugin_folders = [(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins")), "octoprint.plugins", True),
settings.getBaseFolder("plugins")]
plugin_entry_points = ["octoprint.plugin"]
plugin_disabled_list = settings.get(["plugins", "_disabled"])
@@ -561,6 +602,9 @@ def main():
# cut off stuff from the beginning
args = args[-1 * sys_args_length:] if sys_args_length else []
from octoprint.util.fixes import patch_sarge_async_on_py2
patch_sarge_async_on_py2()
from octoprint.cli import octo
octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
+4
View File
@@ -2,6 +2,10 @@
# coding=utf-8
from __future__ import absolute_import, division, print_function
import sys
if sys.version_info[0] >= 3:
raise RuntimeError("Sorry, OctoPrint does not yet support Python 3")
if __name__ == "__main__":
import octoprint
octoprint.main()
+46 -11
View File
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
@@ -9,13 +11,14 @@
# versioneer-0.15+dev (https://github.com/warner/python-versioneer)
"""Git implementation of _version.py."""
from __future__ import absolute_import, division, print_function
import errno
import io
import os
import re
import subprocess
import sys
import logging
def get_keywords():
@@ -41,7 +44,7 @@ def get_config():
# _version.py
cfg = VersioneerConfig()
cfg.VCS = "git"
cfg.style = "pep440-post"
cfg.style = "pep440-tag"
cfg.tag_prefix = ""
cfg.parentdir_prefix = ""
cfg.versionfile_source = "src/octoprint/_version.py"
@@ -130,7 +133,7 @@ def git_get_keywords(versionfile_abs):
# _version.py.
keywords = {}
try:
f = open(versionfile_abs, "r")
f = io.open(versionfile_abs, "rt", encoding="utf-8")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
@@ -156,11 +159,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
if verbose:
print("keywords are unexpanded, not using")
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
refs = set([r.strip() for r in refnames.strip("()").split(",")])
refs = set(r.strip() for r in refnames.strip("()").split(","))
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
tags = set(r[len(TAG):] for r in refs if r.startswith(TAG))
if not tags:
# Either we're using git < 1.8.3, or there really are no tags. We use
# a heuristic: assume all version tags have a digit. The old git %d
@@ -169,7 +172,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# between branches and tags. By ignoring refnames without digits, we
# filter out many common branch names like "release" and
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
tags = set(r for r in refs if re.search(r'\d', r))
if verbose:
print("discarding '%s', no digits" % ",".join(refs-tags))
@@ -254,7 +257,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
abbrev_ref_out = run_command(GITS,
["rev-parse", "--abbrev-ref", "HEAD"],
cwd=root)
if abbrev_ref_out is not None:
if abbrev_ref_out is not None and abbrev_ref_out != "HEAD":
pieces["branch"] = abbrev_ref_out.strip()
# now we have TAG-NUM-gHEX or HEX
@@ -305,17 +308,18 @@ def git_parse_lookup_file(path):
if not os.path.exists(path):
return []
import re
lookup = []
with open(path, "r") as f:
with io.open(path, "rt", encoding="utf-8") as f:
for line in f:
if '#' in line:
line = line[:line.rindex("#")]
line = line[:line.index("#")]
line = line.strip()
if not line:
continue
try:
split_line = map(lambda x: x.strip(), line.split())
split_line = list(map(lambda x: x.strip(), line.split()))
if not len(split_line):
continue
@@ -336,7 +340,8 @@ def git_parse_lookup_file(path):
continue
lookup.append(entry)
except:
except Exception:
logging.getLogger(__name__).exception("Versioneer problem")
break
return lookup
@@ -354,6 +359,9 @@ def git_pieces_from_lookup(lookup, root, verbose, run_command=run_command):
raise NotThisMethod("git rev-parse --abbrev-ref HEAD failed")
current_branch = stdout.strip()
if current_branch == "HEAD":
raise NotThisMethod("not on a branch")
for matcher, render, tag, ref_commit in lookup:
if matcher.match(current_branch):
if tag is None or ref_commit is None:
@@ -441,6 +449,31 @@ def render_pep440(pieces):
return rendered
def render_pep440_tag(pieces):
"""TAG[[.postDISTANCE].dev0+gHEX] -- Just the tag if not dirty, else more info
Useful for projects that want commit based tracking on some branches
but have the master branch only report tags, to allow for commits that
do not modify actual code (e.g. to .github/* or docs).
Exceptions:
1: no tags. 0.postDISTANCE[.dev0]+gHEX
"""
if pieces["closest-tag"]:
rendered = pieces["closest-tag"]
if pieces["dirty"]:
rendered += ".post%d" % pieces["distance"]
rendered += ".dev0"
rendered += "+g%s" % pieces["short"]
else:
# exception #1
rendered = "0.post%d" % pieces["distance"]
if pieces["dirty"]:
rendered += ".dev0"
rendered += "+g%s" % pieces["short"]
return rendered
def render_pep440_pre(pieces):
"""TAG[.post.devDISTANCE] -- No -dirty.
@@ -591,6 +624,8 @@ def render(pieces, style):
rendered = render_pep440_old(pieces)
elif style == "pep440-dev":
rendered = render_pep440_dev(pieces)
elif style == "pep440-tag":
rendered = render_pep440_tag(pieces)
elif style == "git-describe":
rendered = render_git_describe(pieces)
elif style == "git-describe-long":
+2 -1
View File
@@ -137,9 +137,10 @@ from .dev import dev_commands
from .client import client_commands
from .config import config_commands
from .analysis import analysis_commands
from .user import user_commands
@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()
@legacy_options
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
+6 -2
View File
@@ -34,6 +34,7 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
import time
import yaml
from octoprint.util import monotonic_time
from octoprint.util.gcodeInterpreter import gcode
throttle_callback = None
@@ -52,7 +53,7 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
if len(offsets) < maxt:
offsets += [(0, 0)] * (maxt - len(offsets))
start_time = time.time()
start_time = monotonic_time()
progress_callback = None
if progress:
@@ -68,6 +69,9 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
max_extruders=maxt,
g90_extruder=g90_extruder)
click.echo("DONE:{}s".format(time.time() - start_time))
click.echo("DONE:{}s".format(monotonic_time() - start_time))
click.echo("RESULTS:")
click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=" ", allow_unicode=True))
if __name__ == "__main__":
gcode_command()
+2 -1
View File
@@ -92,7 +92,8 @@ class OctoPrintPluginCommands(click.MultiCommand):
continue
result[name + self.sep + command.name] = command
except:
self._logger.exception("Error while retrieving cli commands for plugin {}".format(name))
self._logger.exception("Error while retrieving cli commands for plugin {}".format(name),
extra=dict(plugin=name))
return result
+47 -18
View File
@@ -11,7 +11,7 @@ import sys
from octoprint.cli import bulk_options, standard_options, set_ctx_obj_option, get_ctx_obj_option
def run_server(basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode,
def run_server(basedir, configfile, host, port, v6_only, debug, allow_root, logging_config, verbosity, safe_mode,
ignore_blacklist, octoprint_daemon=None):
"""Initializes the environment and starts up the server."""
@@ -26,6 +26,15 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
logger.info("Starting OctoPrint {}".format(__display_version__))
if safe_mode:
logger.info("Starting in SAFE MODE. Third party plugins will be disabled!")
if safe_mode == "flag":
reason = "command line flag"
elif safe_mode == "settings":
reason = "setting in config.yaml"
elif safe_mode == "incomplete_startup":
reason = "problem during last startup"
else:
reason = "unknown"
logger.info("Reason for safe mode: {}".format(reason))
if recorder and len(recorder):
logger.info(get_divider_line("-", "Logged during platform initialization:"))
@@ -82,12 +91,16 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
ignore_blacklist=ignore_blacklist,
after_safe_mode=log_startup,
after_environment_detector=log_register_rollover)
settings, _, safe_mode, event_manager, connectivity_checker, plugin_manager, environment_detector = components
except FatalStartupError as e:
click.echo(e.message, err=True)
click.echo("There was a fatal error starting up OctoPrint.", err=True)
logger = logging.getLogger("octoprint.startup").fatal
echo = lambda x: click.echo(x, err=True)
for method in logger, echo:
method(str(e))
method("There was a fatal error starting up OctoPrint.")
else:
from octoprint.server import Server
octoprint_server = Server(settings=settings,
@@ -97,6 +110,7 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
environment_detector=environment_detector,
host=host,
port=port,
v6_only=v6_only,
debug=debug,
safe_mode=safe_mode,
allow_root=allow_root,
@@ -107,9 +121,13 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
server_options = bulk_options([
click.option("--host", type=click.STRING, callback=set_ctx_obj_option,
help="Specify the host on which to bind the server."),
help="Specify the host address on which to bind the server."),
click.option("--port", type=click.INT, callback=set_ctx_obj_option,
help="Specify the port on which to bind the server."),
click.option("-4", "--ipv4", "v4", is_flag=True, callback=set_ctx_obj_option,
help="Bind to IPv4 addresses only. Implies '--host 0.0.0.0'. Silently ignored if -6 is present."),
click.option("-6", "--ipv6", "v6", is_flag=True, callback=set_ctx_obj_option,
help="Bind to IPv6 addresses only. Disables dual stack when binding to any v6 addresses. Silently ignored if -4 is present."),
click.option("--logging", type=click.Path(), callback=set_ctx_obj_option,
help="Specify the config file to use for configuring logging."),
click.option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option,
@@ -119,7 +137,7 @@ server_options = bulk_options([
click.option("--ignore-blacklist", "ignore_blacklist", is_flag=True, callback=set_ctx_obj_option,
help="Disable processing of the plugin blacklist.")
])
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``,
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``, ``-4``, ``-6``
``--logging``, ``--iknowwhatimdoing`` and ``--debug``."""
daemon_options = bulk_options([
@@ -149,11 +167,11 @@ def enable_safemode(ctx, **kwargs):
click.echo(e.message, err=True)
click.echo("There was a fatal error initializing the settings manager.", err=True)
ctx.exit(-1)
else:
settings.setBoolean(["server", "startOnceInSafeMode"], True)
settings.save()
settings.setBoolean(["server", "startOnceInSafeMode"], True)
settings.save()
click.echo("Safe mode flag set, OctoPrint will start in safe mode on next restart.")
click.echo("Safe mode flag set, OctoPrint will start in safe mode on next restart.")
@server_commands.command(name="serve")
@@ -168,6 +186,8 @@ def serve_command(ctx, **kwargs):
host = get_value("host")
port = get_value("port")
v4 = get_value("v4")
v6 = get_value("v6")
logging = get_value("logging")
allow_root = get_value("allow_root")
debug = get_value("debug")
@@ -175,10 +195,13 @@ def serve_command(ctx, **kwargs):
basedir = get_value("basedir")
configfile = get_value("configfile")
verbosity = get_value("verbosity")
safe_mode = get_value("safe_mode")
safe_mode = "flag" if get_value("safe_mode") else None
ignore_blacklist = get_value("ignore_blacklist")
run_server(basedir, configfile, host, port, debug,
if v4 and not host:
host = "0.0.0.0"
run_server(basedir, configfile, host, port, v6, debug,
allow_root, logging, verbosity, safe_mode,
ignore_blacklist)
@@ -205,6 +228,8 @@ if sys.platform != "win32" and sys.platform != "darwin":
host = get_value("host")
port = get_value("port")
v4 = get_value("v4")
v6 = get_value("v6")
logging = get_value("logging")
allow_root = get_value("allow_root")
debug = get_value("debug")
@@ -213,9 +238,12 @@ if sys.platform != "win32" and sys.platform != "darwin":
basedir = get_value("basedir")
configfile = get_value("configfile")
verbosity = get_value("verbosity")
safe_mode = get_value("safe_mode")
safe_mode = "flag" if get_value("safe_mode") else None
ignore_blacklist = get_value("ignore_blacklist")
if v4 and not host:
host = "0.0.0.0"
if pid is None:
click.echo("No path to a pidfile set",
file=sys.stderr)
@@ -223,14 +251,15 @@ if sys.platform != "win32" and sys.platform != "darwin":
from octoprint.daemon import Daemon
class OctoPrintDaemon(Daemon):
def __init__(self, pidfile, basedir, configfile, host, port, debug, allow_root, logging_config, verbosity,
safe_mode, ignore_blacklist):
def __init__(self, pidfile, basedir, configfile, host, port, v6_only, debug, allow_root, logging_config,
verbosity, safe_mode, ignore_blacklist):
Daemon.__init__(self, pidfile)
self._basedir = basedir
self._configfile = configfile
self._host = host
self._port = port
self._v6_only = v6_only
self._debug = debug
self._allow_root = allow_root
self._logging_config = logging_config
@@ -239,12 +268,12 @@ if sys.platform != "win32" and sys.platform != "darwin":
self._ignore_blacklist = ignore_blacklist
def run(self):
run_server(self._basedir, self._configfile, self._host, self._port, self._debug,
run_server(self._basedir, self._configfile, self._host, self._port, self._v6_only, self._debug,
self._allow_root, self._logging_config, self._verbosity, self._safe_mode,
self._ignore_blacklist, octoprint_daemon=self)
octoprint_daemon = OctoPrintDaemon(pid, basedir, configfile, host, port, debug, allow_root, logging, verbosity,
safe_mode, ignore_blacklist)
octoprint_daemon = OctoPrintDaemon(pid, basedir, configfile, host, port, v6, debug, allow_root, logging,
verbosity, safe_mode, ignore_blacklist)
if command == "start":
octoprint_daemon.start()
+157
View File
@@ -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")
+11 -5
View File
@@ -7,7 +7,6 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms
import copy
import logging
import os
import platform
import sys
import threading
import yaml
@@ -16,6 +15,7 @@ import psutil
from octoprint.plugin import EnvironmentDetectionPlugin
from octoprint.util.platform import get_os
from octoprint.util.version import get_python_version_string
class EnvironmentDetector(object):
@@ -25,10 +25,15 @@ class EnvironmentDetector(object):
self._cache = None
self._cache_lock = threading.RLock()
self._environment_plugins = self._plugin_manager.get_implementations(EnvironmentDetectionPlugin)
self._logger = logging.getLogger(__name__)
try:
self._environment_plugins = self._plugin_manager.get_implementations(EnvironmentDetectionPlugin)
except Exception:
# just in case, see #3100...
self._logger.exception("There was an error fetching EnvironmentDetectionPlugins from the plugin manager")
self._environment_plugins = []
@property
def environment(self):
with self._cache_lock:
@@ -70,7 +75,7 @@ class EnvironmentDetector(object):
# determine python version
try:
result["version"] = platform.python_version()
result["version"] = get_python_version_string()
except:
self._logger.exception("Error detecting python version")
@@ -120,7 +125,8 @@ class EnvironmentDetector(object):
result[implementation._identifier] = additional
except:
self._logger.exception("Error while fetching additional "
"environment data from plugin {}".format(implementation._identifier))
"environment data from plugin {}".format(implementation._identifier),
extra=dict(plugin=implementation._identifier))
return result
+45 -18
View File
@@ -14,6 +14,7 @@ except ImportError:
import Queue as queue
import threading
import collections
import re
from octoprint.settings import settings
import octoprint.plugin
@@ -23,7 +24,7 @@ _instance = None
def all_events():
return [getattr(Events, name) for name in Events.__dict__ if not name.startswith("__")]
return [getattr(Events, name) for name in Events.__dict__ if not name.startswith("_") and not name in ("register_event",)]
class Events(object):
@@ -119,6 +120,23 @@ class Events(object):
# Settings
SETTINGS_UPDATED = "SettingsUpdated"
@classmethod
def register_event(cls, event, prefix=None):
name = cls._to_identifier(event)
if prefix:
event = prefix + event
name = cls._to_identifier(prefix) + name
setattr(cls, name, event)
return name, event
# based on https://stackoverflow.com/a/1176023
_first_cap_re = re.compile('(.)([A-Z][a-z]+)')
_all_cap_re = re.compile('([a-z0-9])([A-Z])')
@classmethod
def _to_identifier(cls, name):
s1 = cls._first_cap_re.sub(r'\1_\2', name)
return cls._all_cap_re.sub(r'\1_\2', s1).upper()
def eventManager():
global _instance
@@ -135,6 +153,7 @@ class EventManager(object):
def __init__(self):
self._registeredListeners = collections.defaultdict(list)
self._logger = logging.getLogger(__name__)
self._logger_fire = logging.getLogger("{}.fire".format(__name__))
self._startup_signaled = False
self._shutdown_signaled = False
@@ -156,19 +175,18 @@ class EventManager(object):
self._shutdown_signaled = True
eventListeners = self._registeredListeners[event]
self._logger.debug("Firing event: %s (Payload: %r)" % (event, payload))
self._logger_fire.debug("Firing event: {} (Payload: {!r})".format(event, payload))
for listener in eventListeners:
self._logger.debug("Sending action to %r" % listener)
self._logger.debug("Sending action to {!r}".format(listener))
try:
listener(event, payload)
except:
self._logger.exception("Got an exception while sending event %s (Payload: %r) to %s" % (event, payload, listener))
self._logger.exception("Got an exception while sending event {} (Payload: {!r}) to {}".format(event, payload, listener))
octoprint.plugin.call_plugin(octoprint.plugin.types.EventHandlerPlugin,
"on_event",
args=(event, payload),
initialized=True)
args=(event, payload))
self._logger.info("Event loop shut down")
except:
self._logger.exception("Ooops, the event bus worker loop crashed")
@@ -211,7 +229,7 @@ class EventManager(object):
if event == Events.UPDATED_FILES and "type" in payload and payload["type"] == "printables":
# when sending UpdatedFiles with type "printables", also send another event with deprecated type "gcode"
# TODO v1.3.0 Remove again
# TODO v1.4.0 Remove again
import copy
legacy_payload = copy.deepcopy(payload)
legacy_payload["type"] = "gcode"
@@ -227,7 +245,7 @@ class EventManager(object):
return
self._registeredListeners[event].append(callback)
self._logger.debug("Subscribed listener %r for event %s" % (callback, event))
self._logger.debug("Subscribed listener {!r} for event {}".format(callback, event))
def unsubscribe (self, event, callback):
"""
@@ -239,7 +257,7 @@ class EventManager(object):
return
self._registeredListeners[event].remove(callback)
self._logger.debug("Unsubscribed listener %r for event %s" % (callback, event))
self._logger.debug("Unsubscribed listener {!r} for event {}".format(callback, event))
def join(self, timeout=None):
self._worker.join(timeout)
@@ -325,17 +343,24 @@ class CommandTrigger(GenericEventListener):
self._logger.info("Disabled command trigger: {!r}".format(subscription))
continue
event = subscription["event"]
events = subscription["event"]
command = subscription["command"]
commandType = subscription["type"]
debug = subscription["debug"] if "debug" in subscription else False
if not event in self._subscriptions.keys():
self._subscriptions[event] = []
self._subscriptions[event].append((command, commandType, debug))
# "event" in the configuration can be a string, or
# a list of strings. If it's the former, convert it
# into the latter.
if not isinstance(events, (tuple, list, set)):
events = [events]
if not event in eventsToSubscribe:
eventsToSubscribe.append(event)
for event in events:
if not event in self._subscriptions.keys():
self._subscriptions[event] = []
self._subscriptions[event].append((command, commandType, debug))
if not event in eventsToSubscribe:
eventsToSubscribe.append(event)
self.subscribe(eventsToSubscribe)
@@ -355,9 +380,9 @@ class CommandTrigger(GenericEventListener):
if isinstance(command, (tuple, list, set)):
processedCommand = []
for c in command:
processedCommand.append(self._processCommand(c, payload))
processedCommand.append(self._processCommand(c, event, payload))
else:
processedCommand = self._processCommand(command, payload)
processedCommand = self._processCommand(command, event, payload)
self.executeCommand(processedCommand, commandType, debug=debug)
except KeyError as e:
self._logger.warn("There was an error processing one or more placeholders in the following command: %s" % command)
@@ -406,13 +431,14 @@ class CommandTrigger(GenericEventListener):
self._logger.info("Executing GCode commands: %r" % command)
self._printer.commands(commands)
def _processCommand(self, command, payload):
def _processCommand(self, command, event, payload):
"""
Performs string substitutions in the command string based on a few current parameters.
The following substitutions are currently supported:
- {__currentZ} : current Z position of the print head, or -1 if not available
- {__eventname} : the name of the event hook being triggered
- {__filename} : name of currently selected file, or "NO FILE" if no file is selected
- {__filepath} : path in origin location of currently selected file, or "NO FILE" if no file is selected
- {__fileorigin} : origin of currently selected file, or "NO FILE" if no file is selected
@@ -434,6 +460,7 @@ class CommandTrigger(GenericEventListener):
params = {
"__currentZ": "-1",
"__eventname": event,
"__filename": "NO FILE",
"__filepath": "NO PATH",
"__progress": "0",
+58 -43
View File
@@ -17,6 +17,7 @@ from .destinations import FileDestinations
from .analysis import QueueEntry, AnalysisQueue
from .storage import LocalFileStorage
from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
from octoprint.util import get_fully_qualified_classname as fqcn
from collections import namedtuple
@@ -30,10 +31,6 @@ extensions = dict(
def full_extension_tree():
result = dict(
# extensions for 3d model files
model=dict(
stl=ContentTypeMapping(["stl"], "application/sla")
),
# extensions for printable machine code
machinecode=dict(
gcode=ContentTypeMapping(["gcode", "gco", "g"], "text/plain")
@@ -74,6 +71,18 @@ def full_extension_tree():
else:
return merged
slicer_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SlicerPlugin)
for plugin in slicer_plugins:
try:
plugin_result = plugin.get_slicer_extension_tree()
if plugin_result is None or not isinstance(plugin_result, dict):
continue
result = octoprint.util.dict_merge(result, plugin_result, leaf_merger=leaf_merger)
except:
logging.getLogger(__name__).exception("Exception while retrieving additional extension "
"tree entries from SlicerPlugin {name}".format(name=plugin._identifier),
extra=dict(plugin=plugin._identifier))
extension_tree_hooks = octoprint.plugin.plugin_manager().get_hooks("octoprint.filemanager.extension_tree")
for name, hook in extension_tree_hooks.items():
try:
@@ -82,12 +91,14 @@ def full_extension_tree():
continue
result = octoprint.util.dict_merge(result, hook_result, leaf_merger=leaf_merger)
except:
logging.getLogger(__name__).exception("Exception while retrieving additional extension tree entries from hook {name}".format(name=name))
logging.getLogger(__name__).exception("Exception while retrieving additional extension "
"tree entries from hook {name}".format(name=name),
extra=dict(plugin=name))
return result
def get_extensions(type, subtree=None):
if not subtree:
if subtree is None:
subtree = full_extension_tree()
for key, value in subtree.items():
@@ -101,7 +112,7 @@ def get_extensions(type, subtree=None):
return None
def get_all_extensions(subtree=None):
if not subtree:
if subtree is None:
subtree = full_extension_tree()
result = []
@@ -120,7 +131,7 @@ def get_all_extensions(subtree=None):
return result
def get_path_for_extension(extension, subtree=None):
if not subtree:
if subtree is None:
subtree = full_extension_tree()
for key, value in subtree.items():
@@ -136,11 +147,11 @@ def get_path_for_extension(extension, subtree=None):
return None
def get_content_type_mapping_for_extension(extension, subtree=None):
if not subtree:
if subtree is None:
subtree = full_extension_tree()
for key, value in subtree.items():
content_extension_matches = isinstance(value, (ContentTypeMapping, ContentTypeDetector)) and extension in value. extensions
content_extension_matches = isinstance(value, (ContentTypeMapping, ContentTypeDetector)) and extension in value.extensions
list_extension_matches = isinstance(value, (list, tuple)) and extension in value
if content_extension_matches or list_extension_matches:
@@ -256,7 +267,7 @@ class FileManager(object):
file_name = storage_manager.split_path(path)
# we'll use the default printer profile for the backlog since we don't know better
queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default())
queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default(), None)
if self._analysis_queue.enqueue(queue_entry, high_priority=high_priority):
counter += 1
@@ -319,25 +330,27 @@ class FileManager(object):
printer_profile_id, callback, callback_args, _error=None, _cancelled=False, _analysis=None):
try:
if _error:
eventManager().fire(Events.SLICING_FAILED, dict(stl=source_path,
stl_location=source_location,
gcode=dest_path,
gcode_location=dest_location,
reason=_error))
eventManager().fire(Events.SLICING_FAILED, dict(slicer=slicer_name,
stl=source_path,
stl_location=source_location,
gcode=dest_path,
gcode_location=dest_location,
reason=_error))
elif _cancelled:
eventManager().fire(Events.SLICING_CANCELLED, dict(stl=source_path,
stl_location=source_location,
gcode=dest_path,
gcode_location=dest_location))
eventManager().fire(Events.SLICING_CANCELLED, dict(slicer=slicer_name,
stl=source_path,
stl_location=source_location,
gcode=dest_path,
gcode_location=dest_location))
else:
source_meta = self.get_metadata(source_location, source_path)
hash = source_meta["hash"]
hash = source_meta.get("hash", "n/a")
import io
links = [("model", dict(name=source_path))]
_, stl_name = self.split_path(source_location, source_path)
file_obj = StreamWrapper(os.path.basename(dest_path),
io.BytesIO(u";Generated from {stl_name} {hash}\n".format(**locals()).encode("ascii", "replace")),
io.BytesIO(u";Generated from {stl_name} (hash: {hash})\n".format(**locals()).encode("ascii", "replace")),
io.FileIO(tmp_path, "rb"))
printer_profile = self._printer_profile_manager.get(printer_profile_id)
@@ -345,12 +358,13 @@ class FileManager(object):
display=display, links=links, allow_overwrite=True,
printer_profile=printer_profile, analysis=_analysis)
end_time = time.time()
eventManager().fire(Events.SLICING_DONE, dict(stl=source_path,
stl_location=source_location,
gcode=dest_path,
gcode_location=dest_location,
time=end_time - start_time))
end_time = octoprint.util.monotonic_time()
eventManager().fire(Events.SLICING_DONE, dict(slicer=slicer_name,
stl=source_path,
stl_location=source_location,
gcode=dest_path,
gcode_location=dest_location,
time=end_time - start_time))
if callback is not None:
if callback_args is None:
@@ -370,9 +384,9 @@ class FileManager(object):
slicer = self._slicing_manager.get_slicer(slicer_name)
import time
start_time = time.time()
eventManager().fire(Events.SLICING_STARTED, {"stl": source_path,
start_time = octoprint.util.monotonic_time()
eventManager().fire(Events.SLICING_STARTED, {"slicer": slicer_name,
"stl": source_path,
"stl_location": source_location,
"gcode": dest_path,
"gcode_location": dest_location,
@@ -416,7 +430,8 @@ class FileManager(object):
self._last_slicing_progress = progress_int
for callback in self._slicing_progress_callbacks:
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:
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
@@ -424,7 +439,8 @@ class FileManager(object):
try:
plugin.on_slicing_progress(slicer, source_location, source_path, dest_location, dest_path, progress)
except:
self._logger.exception("Exception while sending slicing progress to plugin %s" % plugin._identifier)
self._logger.exception("Exception while sending slicing progress to plugin %s" % plugin._identifier,
extra=dict(plugin=plugin._identifier))
import threading
thread = threading.Thread(target=call_plugins, args=(slicer, source_location, source_path, dest_location, dest_path, progress_int))
@@ -459,11 +475,11 @@ class FileManager(object):
if printer_profile is None:
printer_profile = self._printer_profile_manager.get_current_or_default()
for hook in self._preprocessor_hooks.values():
for name, hook in self._preprocessor_hooks.items():
try:
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
except:
self._logger.exception("Error when calling preprocessor hook {}, ignoring".format(hook))
self._logger.exception("Error when calling preprocessor hook for plugin {}, ignoring".format(name), extra=dict(plugin=name))
continue
if hook_file_object is not None:
@@ -476,12 +492,9 @@ class FileManager(object):
path_in_storage = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite, display=display)
if analysis is None:
queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile)
if queue_entry:
self._analysis_queue.enqueue(queue_entry, high_priority=True)
else:
self._add_analysis_result(destination, path, analysis)
queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile, analysis=analysis)
if queue_entry:
self._analysis_queue.enqueue(queue_entry, high_priority=True)
_, name = self._storage(destination).split_path(path_in_storage)
eventManager().fire(Events.FILE_ADDED, dict(storage=destination,
@@ -647,6 +660,8 @@ class FileManager(object):
try:
with open(self._recovery_file) as 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
except:
self._logger.exception("Could not read recovery data from file {}".format(self._recovery_file))
@@ -700,7 +715,7 @@ class FileManager(object):
def _on_analysis_finished(self, entry, result):
self._add_analysis_result(entry.location, entry.path, result)
def _analysis_queue_entry(self, destination, path, printer_profile=None):
def _analysis_queue_entry(self, destination, path, printer_profile=None, analysis=None):
if printer_profile is None:
printer_profile = self._printer_profile_manager.get_current_or_default()
@@ -709,6 +724,6 @@ class FileManager(object):
file_type = get_file_type(absolute_path)
if file_type:
return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile)
return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile, analysis)
else:
return None
+42 -12
View File
@@ -18,9 +18,11 @@ import time
from octoprint.events import Events, eventManager
from octoprint.settings import settings
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")):
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
"""
A :class:`QueueEntry` for processing through the :class:`AnalysisQueue`. Wraps the entry's properties necessary
for processing.
@@ -33,6 +35,7 @@ class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, locatio
location (str): Location the file is located on.
absolute_path (str): Absolute path on disk through which to access the file.
printer_profile (PrinterProfile): :class:`PrinterProfile` which to use for analysis.
analysis (dict): :class:`GcodeAnalysisQueue` results from prior analysis, or ``None`` if there is none.
"""
def __str__(self):
@@ -50,8 +53,6 @@ class AnalysisQueue(object):
OctoPrint's :class:`AnalysisQueue` can manage various :class:`AbstractAnalysisQueue` implementations, mapped
by their machine code type.
At the moment, only the analysis of GCODE files for 3D printing is supported, through :class:`GcodeAnalysisQueue`.
By invoking :meth:`register_finish_callback` it is possible to register oneself as a callback to be invoked each
time the analysis of a queue entry finishes. The call parameters will be the finished queue entry as the first
and the analysis result as the second parameter. It is also possible to remove the registration again by invoking
@@ -62,12 +63,13 @@ class AnalysisQueue(object):
entry will be enqueued with the type specific analysis queue.
"""
def __init__(self):
def __init__(self, queue_factories):
self._logger = logging.getLogger(__name__)
self._callbacks = []
self._queues = dict(
gcode=GcodeAnalysisQueue(self._analysis_finished)
)
self._queues = dict()
for key, queue_factory in queue_factories.items():
self._queues[key] = queue_factory(self._analysis_finished)
def register_finish_callback(self, callback):
self._callbacks.append(callback)
@@ -108,7 +110,11 @@ class AnalysisQueue(object):
def _analysis_finished(self, entry, result):
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,
"path": entry.path,
"origin": entry.location,
@@ -249,7 +255,7 @@ class AbstractAnalysisQueue(object):
self._current_progress = 0
try:
start_time = time.time()
start_time = monotonic_time()
self._logger.info("Starting analysis of {}".format(entry))
eventManager().fire(Events.METADATA_ANALYSIS_STARTED, {"name": entry.name,
"path": entry.path,
@@ -262,7 +268,7 @@ class AbstractAnalysisQueue(object):
result = self._do_analysis(high_priority=high_priority)
except TypeError:
result = self._do_analysis()
self._logger.info("Analysis of entry {} finished, needed {:.2f}s".format(entry, time.time() - start_time))
self._logger.info("Analysis of entry {} finished, needed {:.2f}s".format(entry, monotonic_time() - start_time))
self._finished_callback(self._current, result)
finally:
self._current = None
@@ -299,7 +305,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
- * **Key**
* **Description**
- * ``estimatedPrintTime``
* Estimated time the file take to print, in minutes
* Estimated time the file take to print, in seconds
- * ``filament``
* Substructure describing estimated filament usage. Keys are ``tool0`` for the first extruder, ``tool1`` for
the second and so on. For each tool extruded length and volume (based on diameter) are provided.
@@ -307,6 +313,28 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
* The extruded length in mm
- * ``filament.toolX.volume``
* The extruded volume in cm³
- * ``printingArea``
* Bounding box of the printed object in the print volume (minimum and maximum coordinates)
- * ``printingArea.minX``
* Minimum X coordinate of the printed object
- * ``printingArea.maxX``
* Maximum X coordinate of the printed object
- * ``printingArea.minY``
* Minimum Y coordinate of the printed object
- * ``printingArea.maxY``
* Maximum Y coordinate of the printed object
- * ``printingArea.minZ``
* Minimum Z coordinate of the printed object
- * ``printingArea.maxZ``
* Maximum Z coordinate of the printed object
- * ``dimensions``
* Dimensions of the printed object in X, Y, Z
- * ``dimensions.width``
* Width of the printed model along the X axis, in mm
- * ``dimensions.depth``
* Depth of the printed model along the Y axis, in mm
- * ``dimensions.height``
* Height of the printed model along the Z axis, in mm
"""
def __init__(self, finished_callback):
@@ -320,6 +348,8 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
import sys
import yaml
if self._current.analysis:
return self._current.analysis
try:
throttle = settings().getFloat(["gcodeAnalysis", "throttle_highprio"]) if high_priority \
else settings().getFloat(["gcodeAnalysis", "throttle_normalprio"])
@@ -343,7 +373,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
self._logger.info("Invoking analysis command: {}".format(" ".join(command)))
self._aborted = False
p = sarge.run(command, async=True, stdout=sarge.Capture())
p = sarge.run(command, async_=True, stdout=sarge.Capture())
while len(p.commands) == 0:
# somewhat ugly... we can't use wait_events because
+173 -55
View File
@@ -8,9 +8,10 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
import logging
import os
import pylru
import shutil
import re
import pylru
import copy
try:
from os import scandir, walk
@@ -19,7 +20,6 @@ except ImportError:
from octoprint.util import atomic_write
from contextlib import contextmanager
from copy import deepcopy
from past.builtins import basestring
@@ -28,7 +28,7 @@ from slugify import Slugify
import octoprint.filemanager
from octoprint.util import is_hidden_path, to_unicode
from octoprint.util import is_hidden_path, to_unicode, timing
class StorageInterface(object):
"""
@@ -153,7 +153,8 @@ class StorageInterface(object):
from root of base folder
:param function filter: a filter that matches the files that are to be returned, may be left out in which case no
filtering will take place
:param bool recursive: will also step into sub folders for building the complete list if set to True
:param bool recursive: will also step into sub folders for building the complete list if set to True, otherwise will only
do one step down into sub folders to be able to populate the ``children``.
:return: a dictionary mapping entry names to entry data that represents the whole file list
"""
raise NotImplementedError()
@@ -176,14 +177,14 @@ class StorageInterface(object):
Removes the folder at ``path``
:param string path: the path of the folder to remove
:param bool recursive: if set to True, contained folders and files will also be removed, otherwise and error will
be raised if the folder is not empty (apart from ``.metadata.yaml``) when it's to be removed
:param bool recursive: if set to True, contained folders and files will also be removed, otherwise an error will
be raised if the folder is not empty (apart from any metadata files) when it's to be removed
"""
raise NotImplementedError()
def copy_folder(self, source, destination):
"""
Copys the folder ``source`` to ``destination``
Copies the folder ``source`` to ``destination``
:param string source: path to the source folder
:param string destination: path to destination
@@ -232,7 +233,7 @@ class StorageInterface(object):
def copy_file(self, source, destination):
"""
Copys the file ``source`` to ``destination``
Copies the file ``source`` to ``destination``
:param string source: path to the source file
:param string destination: path to destination
@@ -443,7 +444,7 @@ class LocalFileStorage(StorageInterface):
"""
The ``LocalFileStorage`` is a storage implementation which holds all files, folders and metadata on disk.
Metadata is managed inside ``.metadata.yaml`` files in the respective folders, indexed by the sanitized filenames
Metadata is managed inside ``.metadata.json`` files in the respective folders, indexed by the sanitized filenames
stored within the folder. Metadata access is managed through an LRU cache to minimize access overhead.
This storage type implements :func:`path_on_disk`.
@@ -484,6 +485,8 @@ class LocalFileStorage(StorageInterface):
import threading
self._metadata_lock_mutex = threading.RLock()
self._metadata_locks = dict()
self._persisted_metadata_lock_mutex = threading.RLock()
self._persisted_metadata_locks = dict()
self._metadata_cache = pylru.lrucache(10)
@@ -564,7 +567,7 @@ class LocalFileStorage(StorageInterface):
path = os.path.join(self.basefolder, path)
def last_modified_for_path(p):
metadata = os.path.join(p, ".metadata.yaml")
metadata = os.path.join(p, ".metadata.json")
if os.path.exists(metadata):
return max(os.stat(p).st_mtime, os.stat(metadata).st_mtime)
else:
@@ -633,7 +636,7 @@ class LocalFileStorage(StorageInterface):
empty = True
for entry in scandir(folder_path):
if entry.name == ".metadata.yaml":
if entry.name == ".metadata.json" or entry.name == ".metadata.yaml":
continue
empty = False
break
@@ -882,6 +885,8 @@ class LocalFileStorage(StorageInterface):
if not name in metadata:
return
metadata = self._copied_metadata(metadata, name)
if not key in metadata[name] or overwrite:
metadata[name][key] = data
metadata_dirty = True
@@ -906,6 +911,7 @@ class LocalFileStorage(StorageInterface):
if not key in metadata[name]:
return
metadata = self._copied_metadata(metadata, name)
del metadata[name][key]
self._save_metadata(path, metadata)
@@ -1049,10 +1055,7 @@ class LocalFileStorage(StorageInterface):
##~~ internals
def _add_history(self, name, path, data):
metadata = self._get_metadata(path)
if not name in metadata:
metadata[name] = dict()
metadata = self._copied_metadata(self._get_metadata(path), name)
if not "hash" in metadata[name]:
metadata[name]["hash"] = self._create_hash(os.path.join(path, name))
@@ -1070,6 +1073,8 @@ class LocalFileStorage(StorageInterface):
if not name in metadata or not "history" in metadata[name]:
return
metadata = self._copied_metadata(metadata, name)
try:
metadata[name]["history"][index].update(data)
self._calculate_stats_from_history(name, path, metadata=metadata, save=False)
@@ -1083,6 +1088,8 @@ class LocalFileStorage(StorageInterface):
if not name in metadata or not "history" in metadata[name]:
return
metadata = self._copied_metadata(metadata, name)
try:
del metadata[name]["history"][index]
self._calculate_stats_from_history(name, path, metadata=metadata, save=False)
@@ -1092,9 +1099,9 @@ class LocalFileStorage(StorageInterface):
def _calculate_stats_from_history(self, name, path, metadata=None, save=True):
if metadata is None:
metadata = self._get_metadata(path)
metadata = self._copied_metadata(self._get_metadata(path), name)
if not name in metadata or not "history" in metadata[name]:
if not "history" in metadata[name]:
return
# collect data from history
@@ -1114,7 +1121,7 @@ class LocalFileStorage(StorageInterface):
try:
print_time = float(print_time)
except:
self._logger.warn("Invalid print time value found in print history for {} in {}/.metadata.yaml: {!r}".format(name, path, print_time))
self._logger.warn("Invalid print time value found in print history for {} in {}/.metadata.json: {!r}".format(name, path, print_time))
continue
if not printer_profile in former_print_times:
@@ -1163,12 +1170,9 @@ class LocalFileStorage(StorageInterface):
if file_type:
file_type = file_type[0]
metadata = self._get_metadata(path)
metadata = self._copied_metadata(self._get_metadata(path), name)
metadata_dirty = False
if not name in metadata:
metadata[name] = dict()
if not "hash" in metadata[name]:
metadata[name]["hash"] = self._create_hash(os.path.join(path, name))
@@ -1240,13 +1244,10 @@ class LocalFileStorage(StorageInterface):
self._save_metadata(path, metadata)
def _remove_links(self, name, path, links):
metadata = self._get_metadata(path)
metadata = self._copied_metadata(self._get_metadata(path), name)
metadata_dirty = False
if not name in metadata or not "hash" in metadata[name]:
hash = self._create_hash(os.path.join(path, name))
else:
hash = metadata[name]["hash"]
hash = metadata[name].get("hash", self._create_hash(os.path.join(path, name)))
for rel, data in links:
if (rel == "model" or rel == "machinecode") and "name" in data:
@@ -1254,6 +1255,7 @@ class LocalFileStorage(StorageInterface):
ref_rel = "model" if rel == "machinecode" else "machinecode"
for link in metadata[data["name"]]["links"]:
if link["rel"] == ref_rel and "name" in link and link["name"] == name and "hash" in link and link["hash"] == hash:
metadata[data["name"]] = copy.deepcopy(metadata[data["name"]])
metadata[data["name"]]["links"].remove(link)
metadata_dirty = True
@@ -1277,7 +1279,7 @@ class LocalFileStorage(StorageInterface):
if metadata_dirty:
self._save_metadata(path, metadata)
def _list_folder(self, path, base="", entry_filter=None, recursive=True, **kwargs):
def _list_folder(self, path, base="", entry_filter=None, recursive=True, include_children=True, **kwargs):
if entry_filter is None:
entry_filter = kwargs.get("filter", None)
@@ -1329,10 +1331,14 @@ class LocalFileStorage(StorageInterface):
if entry_name in metadata and isinstance(metadata[entry_name], dict):
entry_metadata = metadata[entry_name]
if not "display" in entry_metadata and entry_display != entry_name:
if not metadata_dirty:
metadata = self._copied_metadata(metadata, entry_name)
metadata[entry_name]["display"] = entry_display
entry_metadata["display"] = entry_display
metadata_dirty = True
else:
if not metadata_dirty:
metadata = self._copied_metadata(metadata, entry_name)
entry_metadata = self._add_basic_metadata(path, entry_name,
display_name=entry_display,
save=False,
@@ -1362,10 +1368,14 @@ class LocalFileStorage(StorageInterface):
if entry_name in metadata and isinstance(metadata[entry_name], dict):
entry_metadata = metadata[entry_name]
if not "display" in entry_metadata and entry_display != entry_name:
if not metadata_dirty:
metadata = self._copied_metadata(metadata, entry_name)
metadata[entry_name]["display"] = entry_display
entry_metadata["display"] = entry_display
metadata_dirty = True
elif entry_name != entry_display:
if not metadata_dirty:
metadata = self._copied_metadata(metadata, entry_name)
entry_metadata = self._add_basic_metadata(path, entry_name,
display_name=entry_display,
save=False,
@@ -1385,8 +1395,14 @@ class LocalFileStorage(StorageInterface):
sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter,
recursive=recursive)
entry_data["children"] = sub_result
elif include_children:
sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter,
recursive=False, include_children=False)
entry_data["children"] = sub_result
if not entry_filter or entry_filter(entry_name, entry_data):
# only add folders passing the optional filter
def get_size():
total_size = 0
for element in entry_data["children"].values():
@@ -1395,7 +1411,6 @@ class LocalFileStorage(StorageInterface):
return total_size
# only add folders passing the optional filter
extended_entry_data = dict()
extended_entry_data.update(entry_data)
if recursive:
@@ -1444,6 +1459,8 @@ class LocalFileStorage(StorageInterface):
entry_data["display"] = display_name
entry_data.update(additional_metadata)
metadata = copy.copy(metadata)
metadata[entry] = entry_data
if save:
@@ -1475,6 +1492,8 @@ class LocalFileStorage(StorageInterface):
if not name in metadata:
return
metadata = copy.copy(metadata)
if "hash" in metadata[name]:
hash = metadata[name]["hash"]
for m in metadata.values():
@@ -1488,7 +1507,7 @@ class LocalFileStorage(StorageInterface):
def _update_metadata_entry(self, path, name, data):
with self._get_metadata_lock(path):
metadata = self._get_metadata(path)
metadata = copy.copy(self._get_metadata(path))
metadata[name] = data
self._save_metadata(path, metadata)
@@ -1507,48 +1526,125 @@ class LocalFileStorage(StorageInterface):
with self._get_metadata_lock(destination_path):
self._update_metadata_entry(destination_path, destination_name, source_data)
def _get_metadata(self, path):
with self._get_metadata_lock(path):
if path in self._metadata_cache:
return deepcopy(self._metadata_cache[path])
def _get_metadata(self, path, force=False):
import json
metadata_path = os.path.join(path, ".metadata.yaml")
if not force:
metadata = self._metadata_cache.get(path)
if metadata:
return metadata
self._migrate_metadata(path)
metadata_path = os.path.join(path, ".metadata.json")
metadata = None
with self._get_persisted_metadata_lock(path):
if os.path.exists(metadata_path):
with open(metadata_path) as f:
try:
import yaml
metadata = yaml.safe_load(f)
metadata = json.load(f)
except:
self._logger.exception("Error while reading .metadata.yaml from {path}".format(**locals()))
else:
if isinstance(metadata, dict):
self._metadata_cache[path] = deepcopy(metadata)
return metadata
self._logger.exception("Error while reading .metadata.json from {path}".format(**locals()))
def valid_json(value):
try:
json.dumps(value, allow_nan=False)
return True
except:
return False
if isinstance(metadata, dict):
old_size = len(metadata)
metadata = { k: v for k, v in metadata.items() if valid_json(v) }
metadata = { k: v for k, v in metadata.items() if os.path.exists(os.path.join(path, k)) }
new_size = len(metadata)
if new_size != old_size:
self._logger.info("Deleted {} stale or invalid entries from metadata for path {}".format(old_size - new_size,
path))
self._save_metadata(path, metadata)
else:
with self._get_metadata_lock(path):
self._metadata_cache[path] = metadata
return metadata
else:
return dict()
def _save_metadata(self, path, metadata):
import json
with self._get_metadata_lock(path):
metadata_path = os.path.join(path, ".metadata.yaml")
self._metadata_cache[path] = metadata
with self._get_persisted_metadata_lock(path):
metadata_path = os.path.join(path, ".metadata.json")
try:
import yaml
with atomic_write(metadata_path) as f:
yaml.safe_dump(metadata, stream=f, default_flow_style=False, indent=" ", allow_unicode=True)
json.dump(metadata, f, indent=4, separators=(",", ": "))
except:
self._logger.exception("Error while writing .metadata.yaml to {path}".format(**locals()))
else:
self._metadata_cache[path] = deepcopy(metadata)
self._logger.exception("Error while writing .metadata.json to {path}".format(**locals()))
def _delete_metadata(self, path):
with self._get_metadata_lock(path):
metadata_path = os.path.join(path, ".metadata.yaml")
if os.path.exists(metadata_path):
try:
os.remove(metadata_path)
except:
self._logger.exception("Error while deleting .metadata.yaml from {path}".format(**locals()))
if path in self._metadata_cache:
del self._metadata_cache[path]
with self._get_persisted_metadata_lock(path):
metadata_files = (".metadata.json", ".metadata.yaml")
for metadata_file in metadata_files:
metadata_path = os.path.join(path, metadata_file)
if os.path.exists(metadata_path):
try:
os.remove(metadata_path)
except:
self._logger.exception("Error while deleting {metadata_file} from {path}".format(**locals()))
@staticmethod
def _copied_metadata(metadata, name):
metadata = copy.copy(metadata)
metadata[name] = copy.deepcopy(metadata.get(name, dict()))
return metadata
def _migrate_metadata(self, path):
# we switched to json in 1.3.9 - if we still have yaml here, migrate it now
import yaml
import json
with self._get_persisted_metadata_lock(path):
metadata_path_yaml = os.path.join(path, ".metadata.yaml")
metadata_path_json = os.path.join(path, ".metadata.json")
if not os.path.exists(metadata_path_yaml):
# nothing to migrate
return
if os.path.exists(metadata_path_json):
# already migrated
try:
os.remove(metadata_path_yaml)
except:
self._logger.exception("Error while removing .metadata.yaml from {path}".format(**locals()))
return
with open(metadata_path_yaml) as f:
try:
metadata = yaml.safe_load(f)
except:
self._logger.exception("Error while reading .metadata.yaml from {path}".format(**locals()))
return
if not isinstance(metadata, dict):
# looks invalid, ignore it
return
with atomic_write(metadata_path_json) as f:
json.dump(metadata, f, indent=4, separators=(",", ": "))
try:
os.remove(metadata_path_yaml)
except:
self._logger.exception("Error while removing .metadata.yaml from {path}".format(**locals()))
@contextmanager
def _get_metadata_lock(self, path):
with self._metadata_lock_mutex:
@@ -1560,11 +1656,33 @@ class LocalFileStorage(StorageInterface):
counter += 1
self._metadata_locks[path] = (counter, lock)
yield lock
yield lock
with self._metadata_lock_mutex:
counter = self._metadata_locks[path][0]
counter -= 1
if counter <= 0:
del self._metadata_locks[path]
else:
self._metadata_locks[path] = (counter, lock)
@contextmanager
def _get_persisted_metadata_lock(self, path):
with self._persisted_metadata_lock_mutex:
if path not in self._persisted_metadata_locks:
import threading
self._persisted_metadata_locks[path] = (0, threading.RLock())
counter, lock = self._persisted_metadata_locks[path]
counter += 1
self._persisted_metadata_locks[path] = (counter, lock)
yield lock
with self._persisted_metadata_lock_mutex:
counter = self._persisted_metadata_locks[path][0]
counter -= 1
if counter <= 0:
del self._persisted_metadata_locks[path]
else:
self._persisted_metadata_locks[path] = (counter, lock)
+10 -5
View File
@@ -3,6 +3,8 @@ from __future__ import absolute_import
from octoprint.logging import handlers
from typing import Union
def log_to_handler(logger, handler, level, msg, exc_info=None, extra=None, *args):
"""
Logs to the provided handler only.
@@ -137,14 +139,17 @@ def get_divider_line(c, message=None, length=78, indent=3):
return c * indent + " " + message
def prefix_multilines(text, prefix=": "):
def prefix_multilines(text, prefix=u": "):
# type: (Union[unicode, bytes], unicode) -> unicode
from octoprint.util import to_unicode
lines = text.splitlines()
if not lines:
return ""
return u""
if len(lines) == 1:
return lines[0]
return to_unicode(lines[0])
return lines[0] + "\n" + "\n".join(map(lambda line: prefix + line,
lines[1:]))
return to_unicode(lines[0]) + u"\n" + u"\n".join(map(lambda line: prefix + to_unicode(line),
lines[1:]))
+40 -18
View File
@@ -6,10 +6,30 @@ import os
import re
import time
# noinspection PyCompatibility
import concurrent.futures
class AsyncLogHandlerMixin(logging.Handler):
def __init__(self, *args, **kwargs):
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
super(AsyncLogHandlerMixin, self).__init__(*args, **kwargs)
def emit(self, record):
try:
self._executor.submit(self._emit, record)
except:
self.handleError(record)
def _emit(self, record):
# noinspection PyUnresolvedReferences
super(AsyncLogHandlerMixin, self).emit(record)
class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
def __init__(self, *args, **kwargs):
logging.handlers.TimedRotatingFileHandler.__init__(self, *args, **kwargs)
super(CleaningTimedRotatingFileHandler, self).__init__(*args, **kwargs)
# clean up old files on handler start
if self.backupCount > 0:
@@ -17,7 +37,7 @@ class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler
os.remove(s)
class OctoPrintLogHandler(CleaningTimedRotatingFileHandler):
class OctoPrintLogHandler(AsyncLogHandlerMixin, CleaningTimedRotatingFileHandler):
rollover_callbacks = []
@classmethod
@@ -25,32 +45,33 @@ class OctoPrintLogHandler(CleaningTimedRotatingFileHandler):
cls.rollover_callbacks.append((callback, args, kwargs))
def doRollover(self):
CleaningTimedRotatingFileHandler.doRollover(self)
super(OctoPrintLogHandler, self).doRollover()
for rcb in self.rollover_callbacks:
callback, args, kwargs = rcb
callback(*args, **kwargs)
class SerialLogHandler(logging.handlers.RotatingFileHandler):
class OctoPrintStreamHandler(AsyncLogHandlerMixin, logging.StreamHandler):
pass
_do_rollover = False
_suffix_template = "%Y-%m-%d_%H-%M-%S"
_file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$")
class SerialLogHandler(AsyncLogHandlerMixin, logging.handlers.RotatingFileHandler):
do_rollover = False
suffix_template = "%Y-%m-%d_%H-%M-%S"
file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$")
@classmethod
def on_open_connection(cls):
cls._do_rollover = True
cls.do_rollover = True
def __init__(self, *args, **kwargs):
logging.handlers.RotatingFileHandler.__init__(self, *args, **kwargs)
super(SerialLogHandler, self).__init__(*args, **kwargs)
self.cleanupFiles()
def emit(self, record):
logging.handlers.RotatingFileHandler.emit(self, record)
def shouldRollover(self, record):
return self.__class__._do_rollover
return self.do_rollover
def getFilesToDelete(self):
"""
@@ -64,7 +85,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
for fileName in fileNames:
if fileName[:plen] == prefix:
suffix = fileName[plen:]
if self.__class__._file_pattern.match(suffix):
if type(self).file_pattern.match(suffix):
result.append(os.path.join(dirName, fileName))
result.sort()
if len(result) < self.backupCount:
@@ -79,7 +100,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
os.remove(path)
def doRollover(self):
self.__class__._do_rollover = False
self.do_rollover = False
if self.stream:
self.stream.close()
@@ -88,7 +109,7 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
if os.path.exists(self.baseFilename):
# figure out creation date/time to use for file suffix
t = time.localtime(os.stat(self.baseFilename).st_mtime)
dfn = self.baseFilename + "." + time.strftime(self.__class__._suffix_template, t)
dfn = self.baseFilename + "." + time.strftime(type(self).suffix_template, t)
if os.path.exists(dfn):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
@@ -98,8 +119,8 @@ class SerialLogHandler(logging.handlers.RotatingFileHandler):
self.stream = self._open()
class RecordingLogHandler(logging.Handler):
def __init__(self, target=None, level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
def __init__(self, target=None, *args, **kwargs):
super(RecordingLogHandler, self).__init__(*args, **kwargs)
self._buffer = []
self._target = target
@@ -133,6 +154,7 @@ class RecordingLogHandler(logging.Handler):
return len(self._buffer)
# noinspection PyAbstractClass
class CombinedLogHandler(logging.Handler):
def __init__(self, *handlers):
logging.Handler.__init__(self)
+22 -17
View File
@@ -21,6 +21,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
import os
import logging
import threading
from octoprint.settings import settings as s
from octoprint.plugin.core import (PluginInfo, PluginManager, Plugin)
@@ -32,16 +33,6 @@ from octoprint.util import deprecated
_instance = None
def _validate_plugin(phase, plugin_info):
if phase == "after_load":
if plugin_info.implementation is not None and isinstance(plugin_info.implementation, AppPlugin):
# transform app plugin into hook
import warnings
warnings.warn("{name} uses deprecated plugin mixin AppPlugin, use octoprint.accesscontrol.appkey hook instead".format(name=plugin_info.key), DeprecationWarning)
hooks = plugin_info.hooks
if not "octoprint.accesscontrol.appkey" in hooks:
hooks["octoprint.accesscontrol.appkey"] = plugin_info.implementation.get_additional_apps
setattr(plugin_info.instance, PluginInfo.attr_hooks, hooks)
return True
def plugin_manager(init=False, plugin_folders=None, plugin_bases=None, plugin_entry_points=None, plugin_disabled_list=None,
@@ -94,7 +85,8 @@ def plugin_manager(init=False, plugin_folders=None, plugin_bases=None, plugin_en
if plugin_restart_needing_hooks is None:
plugin_restart_needing_hooks = ["octoprint.server.http.*",
"octoprint.printer.factory"]
"octoprint.printer.factory",
"octoprint.timelapse.extensions"]
if plugin_obsolete_hooks is None:
plugin_obsolete_hooks = ["octoprint.comm.protocol.gcode"]
@@ -167,7 +159,8 @@ def plugin_settings_for_settings_plugin(plugin_key, instance, settings=None):
return plugin_settings(plugin_key, get_preprocessors=get_preprocessors, set_preprocessors=set_preprocessors, settings=settings)
def call_plugin(types, method, args=None, kwargs=None, callback=None, error_callback=None, sorting_context=None, initialized=True):
def call_plugin(types, method, args=None, kwargs=None, callback=None, error_callback=None, sorting_context=None,
initialized=True):
"""
Helper method to invoke the indicated ``method`` on all registered plugin implementations implementing the
indicated ``types``. Allows providing method arguments and registering callbacks to call in case of success
@@ -203,9 +196,7 @@ def call_plugin(types, method, args=None, kwargs=None, callback=None, error_call
error_callback (function): A callback to invoke after the call of an implementation resulted in an exception.
Will be called with the three arguments ``name``, ``plugin`` and ``exc``. ``name`` will be the plugin
identifier, ``plugin`` the plugin implementation instance itself and ``exc`` the caught exception.
initialized (boolean): Whether the plugin needs to be initialized (True) or not (False). Initialization status
is determined be presence of injected ``_identifier`` property.
initialized (boolean): Ignored.
"""
if not isinstance(types, (list, tuple)):
@@ -215,18 +206,21 @@ def call_plugin(types, method, args=None, kwargs=None, callback=None, error_call
if kwargs is None:
kwargs = dict()
logger = logging.getLogger(__name__)
plugins = plugin_manager().get_implementations(*types, sorting_context=sorting_context)
for plugin in plugins:
if initialized and not hasattr(plugin, "_identifier"):
if not hasattr(plugin, "_identifier"):
continue
if hasattr(plugin, method):
logger.debug("Calling {} on {}".format(method, plugin._identifier))
try:
result = getattr(plugin, method)(*args, **kwargs)
if callback:
callback(plugin._identifier, plugin, result)
except Exception as exc:
logging.getLogger(__name__).exception("Error while calling plugin %s" % plugin._identifier)
logger.exception("Error while calling plugin %s" % plugin._identifier, extra=dict(plugin=plugin._identifier))
if error_callback:
error_callback(plugin._identifier, plugin, exc)
@@ -302,6 +296,17 @@ class PluginSettings(object):
.. method:: set_boolean(path, value, force=False)
Like :func:`set` but ensures the value is an ``boolean`` through attempted conversion before setting it.
.. method:: save(force=False, trigger_event=False)
Saves the settings to ``config.yaml`` if there are active changes. If ``force`` is set to ``True`` the settings
will be saved even if there are no changes. Settings ``trigger_event`` to ``True`` will cause a ``SettingsUpdated``
:ref:`event <sec-events-available_events-settings>` to get triggered.
:param force: Force saving to ``config.yaml`` even if there are no changes.
:type force: boolean
:param trigger_event: Trigger the ``SettingsUpdated`` :ref:`event <sec-events-available_events-settings>` on save.
:type trigger_event: boolean
"""
def __init__(self, settings, plugin_key, defaults=None, get_preprocessors=None, set_preprocessors=None):
+155 -134
View File
@@ -37,7 +37,9 @@ import inspect
import pkg_resources
import pkginfo
from past.builtins import basestring
from past.builtins import unicode
from octoprint.util import to_unicode
try:
from os import scandir
@@ -46,6 +48,7 @@ except ImportError:
EntryPointOrigin = namedtuple("EntryPointOrigin", "type, entry_point, module_name, package_name, package_version")
FolderOrigin = namedtuple("FolderOrigin", "type, folder")
ModuleOrigin = namedtuple("PackageOrigin", "type, module_name, folder")
class PluginInfo(object):
"""
@@ -207,13 +210,13 @@ class PluginInfo(object):
def __str__(self):
if self.version:
return "{name} ({version})".format(name=self.name, version=self.version)
return u"{name} ({version})".format(name=self.name, version=self.version)
else:
return self.name
return to_unicode(self.name)
def long_str(self, show_bundled=False, bundled_strs=(" [B]", ""),
show_location=False, location_str=" - {location}",
show_enabled=False, enabled_strs=("* ", " ", "X ")):
def long_str(self, show_bundled=False, bundled_strs=(u" [B]", u""),
show_location=False, location_str=u" - {location}",
show_enabled=False, enabled_strs=(u"* ", u" ", u"X ")):
"""
Long string representation of the plugin's information. Will return a string of the format ``<enabled><str(self)><bundled><location>``.
@@ -242,17 +245,19 @@ class PluginInfo(object):
str: The long string representation of the plugin as described above
"""
if show_enabled:
ret = enabled_strs[2] if self.blacklisted else (enabled_strs[0] if self.enabled else enabled_strs[1])
ret = to_unicode(enabled_strs[2]) if self.blacklisted \
else (to_unicode(enabled_strs[0]) if self.enabled
else to_unicode(enabled_strs[1]))
else:
ret = ""
ret = u""
ret += str(self)
ret += unicode(self)
if show_bundled:
ret += bundled_strs[0] if self.bundled else bundled_strs[1]
ret += to_unicode(bundled_strs[0]) if self.bundled else to_unicode(bundled_strs[1])
if show_location and self.location:
ret += location_str.format(location=self.location)
ret += to_unicode(location_str).format(location=self.location)
return ret
@@ -630,43 +635,62 @@ class PluginManager(object):
def plugin_hooks(self):
return {key: map(lambda v: (v[1], v[2]), value) for key, value in self._plugin_hooks.items()}
def find_plugins(self, existing=None, ignore_uninstalled=True):
def find_plugins(self, existing=None, ignore_uninstalled=True, incl_all_found=False):
added, found = self._find_plugins(existing=existing, ignore_uninstalled=ignore_uninstalled)
if incl_all_found:
return added, found
else:
return added
def _find_plugins(self, existing=None, ignore_uninstalled=True):
if existing is None:
existing = dict(self.plugins)
result = OrderedDict()
result_added = OrderedDict()
result_found = []
if self.plugin_folders:
try:
result.update(self._find_plugins_from_folders(self.plugin_folders,
existing,
ignored_uninstalled=ignore_uninstalled))
added, found = self._find_plugins_from_folders(self.plugin_folders,
existing,
ignored_uninstalled=ignore_uninstalled)
result_added.update(added)
result_found += found
except:
self.logger.exception("Error fetching plugins from folders")
self.logger.exception(u"Error fetching plugins from folders")
if self.plugin_entry_points:
existing.update(result)
existing.update(result_added)
try:
result.update(self._find_plugins_from_entry_points(self.plugin_entry_points,
existing,
ignore_uninstalled=ignore_uninstalled))
added, found = self._find_plugins_from_entry_points(self.plugin_entry_points,
existing,
ignore_uninstalled=ignore_uninstalled)
result_added.update(added)
result_found += found
except:
self.logger.exception("Error fetching plugins from entry points")
return result
self.logger.exception(u"Error fetching plugins from entry points")
return result_added, result_found
def _find_plugins_from_folders(self, folders, existing, ignored_uninstalled=True):
result = OrderedDict()
added = OrderedDict()
found = []
for folder in folders:
try:
flagged_readonly = False
package = None
if isinstance(folder, (list, tuple)):
if len(folder) == 2:
folder, flagged_readonly = folder
elif len(folder) == 3:
folder, package, flagged_readonly = folder
else:
continue
actual_readonly = not os.access(folder, os.W_OK)
if not os.path.exists(folder):
self.logger.warn("Plugin folder {folder} could not be found, skipping it".format(folder=folder))
self.logger.warn(u"Plugin folder {folder} could not be found, skipping it".format(folder=folder))
continue
for entry in scandir(folder):
@@ -691,27 +715,36 @@ class PluginManager(object):
# whatever this is, we ignore it
continue
if key in existing or key in result or (ignored_uninstalled and key in self.marked_plugins["uninstalled"]):
found.append(key)
if key in existing or key in added or (ignored_uninstalled and key in self.marked_plugins["uninstalled"]):
# plugin is already defined, ignore it
continue
bundled = flagged_readonly
plugin = self._import_plugin_from_module(key, folder=folder, bundled=bundled)
module_name = None
if package:
module_name = "{}.{}".format(package, key)
plugin = self._import_plugin_from_module(key, module_name=module_name, folder=folder, bundled=bundled)
if plugin:
plugin.origin = FolderOrigin("folder", folder)
if module_name:
plugin.origin = ModuleOrigin("module", module_name, folder)
else:
plugin.origin = FolderOrigin("folder", folder)
plugin.managable = not flagged_readonly and not actual_readonly
plugin.enabled = False
result[key] = plugin
added[key] = plugin
except:
self.logger.exception("Error processing folder entry {!r} from folder {}".format(entry, folder))
self.logger.exception(u"Error processing folder entry {!r} from folder {}".format(entry, folder))
except:
self.logger.exception("Error processing folder {}".format(folder))
self.logger.exception(u"Error processing folder {}".format(folder))
return result
return added, found
def _find_plugins_from_entry_points(self, groups, existing, ignore_uninstalled=True):
result = OrderedDict()
added = OrderedDict()
found = []
# let's make sure we have a current working set ...
working_set = pkg_resources.WorkingSet()
@@ -735,8 +768,8 @@ class PluginManager(object):
try:
yield entry
except:
self.logger.exception("Something went wrong while processing the entry points of a package in the "
"Python environment - broken entry_points.txt in some package?")
self.logger.exception(u"Something went wrong while processing the entry points of a package in the "
u"Python environment - broken entry_points.txt in some package?")
for group in groups:
for entry_point in wrapped(working_set.iter_entry_points(group=group, name=None)):
@@ -745,25 +778,25 @@ class PluginManager(object):
module_name = entry_point.module_name
version = entry_point.dist.version
if key in existing or key in result or (ignore_uninstalled and key in self.marked_plugins["uninstalled"]):
found.append(key)
if key in existing or key in added or (ignore_uninstalled and key in self.marked_plugins["uninstalled"]):
# plugin is already defined or marked as uninstalled, ignore it
continue
kwargs = dict(module_name=module_name, version=version)
package_name = None
package_name = entry_point.dist.project_name
try:
module_pkginfo = InstalledEntryPoint(entry_point)
entry_point_metadata = EntryPointMetadata(entry_point)
except:
self.logger.exception("Something went wrong while retrieving package info data for module %s" % module_name)
self.logger.exception(u"Something went wrong while retrieving metadata for module {}".format(module_name))
else:
kwargs.update(dict(
name=module_pkginfo.name,
summary=module_pkginfo.summary,
author=module_pkginfo.author,
url=module_pkginfo.home_page,
license=module_pkginfo.license
name=entry_point_metadata.name,
summary=entry_point_metadata.summary,
author=entry_point_metadata.author,
url=entry_point_metadata.home_page,
license=entry_point_metadata.license
))
package_name = module_pkginfo.name
plugin = self._import_plugin_from_module(key, **kwargs)
if plugin:
@@ -783,11 +816,11 @@ class PluginManager(object):
module_name,
plugin.location))
result[key] = plugin
added[key] = plugin
except:
self.logger.exception("Error processing entry point {!r} for group {}".format(entry_point, group))
self.logger.exception(u"Error processing entry point {!r} for group {}".format(entry_point, group))
return result
return added, found
def _import_plugin_from_module(self, key, folder=None, module_name=None, name=None, version=None, summary=None,
author=None, url=None, license=None, bundled=False):
@@ -800,7 +833,7 @@ class PluginManager(object):
else:
return None
except:
self.logger.warn("Could not locate plugin {key}".format(key=key))
self.logger.warn(u"Could not locate plugin {key}".format(key=key))
return None
# Create a simple dummy entry first ...
@@ -809,11 +842,11 @@ class PluginManager(object):
plugin.bundled = bundled
if self._is_plugin_disabled(key):
self.logger.info("Plugin {} is disabled.".format(plugin))
self.logger.info(u"Plugin {} is disabled.".format(plugin))
plugin.forced_disabled = True
if self._is_plugin_blacklisted(key) or (plugin.version is not None and self._is_plugin_version_blacklisted(key, plugin.version)):
self.logger.warn("Plugin {} is blacklisted.".format(plugin))
self.logger.warn(u"Plugin {} is blacklisted.".format(plugin))
plugin.blacklisted = True
if not plugin.validate("before_import", additional_validators=self.plugin_validators):
@@ -821,12 +854,15 @@ class PluginManager(object):
# ... then create and return the real one
return self._import_plugin(key, *module,
name=name, version=version, summary=summary, author=author, url=url,
module_name=module_name, name=name, version=version, summary=summary, author=author, url=url,
license=license, bundled=bundled, parsed_metadata=plugin.parsed_metadata)
def _import_plugin(self, key, f, filename, description, name=None, version=None, summary=None, author=None, url=None, license=None, bundled=False, parsed_metadata=None):
def _import_plugin(self, key, f, filename, description, module_name=None, name=None, version=None, summary=None, author=None, url=None, license=None, bundled=False, parsed_metadata=None):
try:
instance = imp.load_module(key, f, filename, description)
if module_name:
instance = imp.load_module(module_name, f, filename, description)
else:
instance = imp.load_module(key, f, filename, description)
plugin = PluginInfo(key, filename, instance,
name=name,
version=version,
@@ -837,13 +873,13 @@ class PluginManager(object):
parsed_metadata=parsed_metadata)
plugin.bundled = bundled
except:
self.logger.exception("Error loading plugin {key}".format(key=key))
self.logger.exception(u"Error loading plugin {key}".format(key=key))
return None
if plugin.check():
return plugin
else:
self.logger.warn("Plugin \"{plugin}\" did not pass check".format(plugin=str(plugin)))
self.logger.info(u"Plugin {plugin} did not pass check, not loading.".format(plugin=str(plugin)))
return None
def _is_plugin_disabled(self, key):
@@ -863,18 +899,33 @@ class PluginManager(object):
self.plugin_blacklist))
def reload_plugins(self, startup=False, initialize_implementations=True, force_reload=None):
self.logger.info("Loading plugins from {folders} and installed plugin packages...".format(
self.logger.info(u"Loading plugins from {folders} and installed plugin packages...".format(
folders=", ".join(map(lambda x: x[0] if isinstance(x, tuple) else str(x), self.plugin_folders))
))
if force_reload is None:
force_reload = []
plugins = self.find_plugins(existing=dict((k, v) for k, v in self.plugins.items() if not k in force_reload))
self.disabled_plugins.update(plugins)
added, found = self.find_plugins(existing=dict((k, v) for k, v in self.plugins.items() if not k in force_reload),
incl_all_found=True)
# let's clean everything we DIDN'T find first
removed = [key for key in self.enabled_plugins.keys() + self.disabled_plugins.keys() if key not in found]
for key in removed:
try:
del self.enabled_plugins[key]
except KeyError:
pass
try:
del self.disabled_plugins[key]
except KeyError:
pass
self.disabled_plugins.update(added)
# 1st pass: loading the plugins
for name, plugin in plugins.items():
for name, plugin in added.items():
try:
if not plugin.blacklisted and not plugin.forced_disabled:
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
@@ -888,11 +939,11 @@ class PluginManager(object):
force_reload=force_reload)
# 2nd pass: enabling those plugins that need enabling
for name, plugin in plugins.items():
for name, plugin in added.items():
try:
if plugin.loaded and not plugin.forced_disabled:
if plugin.blacklisted:
self.logger.warn("Plugin {} is blacklisted. Not enabling it.".format(plugin))
self.logger.warn(u"Plugin {} is blacklisted. Not enabling it.".format(plugin))
continue
self.enable_plugin(name, plugin=plugin, initialize_implementation=initialize_implementations, startup=startup)
except PluginNeedsRestart:
@@ -905,9 +956,9 @@ class PluginManager(object):
force_reload=force_reload)
if len(self.enabled_plugins) <= 0:
self.logger.info("No plugins found")
self.logger.info(u"No plugins found")
else:
self.logger.info("Found {count} plugin(s) providing {implementations} mixin implementations, {hooks} hook handlers".format(
self.logger.info(u"Found {count} plugin(s) providing {implementations} mixin implementations, {hooks} hook handlers".format(
count=len(self.enabled_plugins) + len(self.disabled_plugins),
implementations=len(self.plugin_implementations),
hooks=sum(map(lambda x: len(x), self.plugin_hooks.values()))
@@ -915,7 +966,7 @@ class PluginManager(object):
def mark_plugin(self, name, **kwargs):
if not name in self.plugins:
self.logger.debug("Trying to mark an unknown plugin {name}".format(**locals()))
self.logger.debug(u"Trying to mark an unknown plugin {name}".format(**locals()))
for key, value in kwargs.items():
if value is None:
@@ -934,7 +985,7 @@ class PluginManager(object):
def load_plugin(self, name, plugin=None, startup=False, initialize_implementation=True):
if not name in self.plugins:
self.logger.warn("Trying to load an unknown plugin {name}".format(**locals()))
self.logger.warn(u"Trying to load an unknown plugin {name}".format(**locals()))
return
if plugin is None:
@@ -949,15 +1000,15 @@ class PluginManager(object):
self.on_plugin_loaded(name, plugin)
plugin.loaded = True
self.logger.debug("Loaded plugin {name}: {plugin}".format(**locals()))
self.logger.debug(u"Loaded plugin {name}: {plugin}".format(**locals()))
except PluginLifecycleException as e:
raise e
except:
self.logger.exception("There was an error loading plugin %s" % name)
self.logger.exception(u"There was an error loading plugin %s" % name)
def unload_plugin(self, name):
if not name in self.plugins:
self.logger.warn("Trying to unload unknown plugin {name}".format(**locals()))
self.logger.warn(u"Trying to unload unknown plugin {name}".format(**locals()))
return
plugin = self.plugins[name]
@@ -977,11 +1028,11 @@ class PluginManager(object):
plugin.loaded = False
self.logger.debug("Unloaded plugin {name}: {plugin}".format(**locals()))
self.logger.debug(u"Unloaded plugin {name}: {plugin}".format(**locals()))
except PluginLifecycleException as e:
raise e
except:
self.logger.exception("There was an error unloading plugin {name}".format(**locals()))
self.logger.exception(u"There was an error unloading plugin {name}".format(**locals()))
# make sure the plugin is NOT in the list of enabled plugins but in the list of disabled plugins
if name in self.enabled_plugins:
@@ -991,7 +1042,7 @@ class PluginManager(object):
def enable_plugin(self, name, plugin=None, initialize_implementation=True, startup=False):
if not name in self.disabled_plugins:
self.logger.warn("Tried to enable plugin {name}, however it is not disabled".format(**locals()))
self.logger.warn(u"Tried to enable plugin {name}, however it is not disabled".format(**locals()))
return
if plugin is None:
@@ -1027,13 +1078,13 @@ class PluginManager(object):
plugin.implementation.on_plugin_enabled()
self.on_plugin_enabled(name, plugin)
self.logger.debug("Enabled plugin {name}: {plugin}".format(**locals()))
self.logger.debug(u"Enabled plugin {name}: {plugin}".format(**locals()))
return True
def disable_plugin(self, name, plugin=None):
if not name in self.enabled_plugins:
self.logger.warn("Tried to disable plugin {name}, however it is not enabled".format(**locals()))
self.logger.warn(u"Tried to disable plugin {name}, however it is not enabled".format(**locals()))
return
if plugin is None:
@@ -1048,7 +1099,7 @@ class PluginManager(object):
except PluginLifecycleException as e:
raise e
except:
self.logger.exception("There was an error while disabling plugin {name}".format(**locals()))
self.logger.exception(u"There was an error while disabling plugin {name}".format(**locals()))
return False
else:
if name in self.enabled_plugins:
@@ -1060,7 +1111,7 @@ class PluginManager(object):
plugin.implementation.on_plugin_disabled()
self.on_plugin_disabled(name, plugin)
self.logger.debug("Disabled plugin {name}: {plugin}".format(**locals()))
self.logger.debug(u"Disabled plugin {name}: {plugin}".format(**locals()))
return True
@@ -1072,7 +1123,7 @@ class PluginManager(object):
try:
callback, order = self._get_callback_and_order(definition)
except ValueError as e:
self.logger.warn("There is something wrong with the hook definition {} for plugin {}: {}".format(definition, name, str(e)))
self.logger.warn(u"There is something wrong with the hook definition {} for plugin {}: {}".format(definition, name, str(e)))
continue
self._plugin_hooks[hook].append((order, name, callback))
@@ -1091,7 +1142,7 @@ class PluginManager(object):
try:
callback, order = self._get_callback_and_order(definition)
except ValueError as e:
self.logger.warn("There is something wrong with the hook definition {} for plugin {}: {}".format(definition, name, str(e)))
self.logger.warn(u"There is something wrong with the hook definition {} for plugin {}: {}".format(definition, name, str(e)))
continue
try:
@@ -1238,7 +1289,7 @@ class PluginManager(object):
additional_pre_inits=additional_pre_inits,
additional_post_inits=additional_post_inits)
self.logger.info("Initialized {count} plugin implementation(s)".format(count=len(self.plugin_implementations)))
self.logger.info(u"Initialized {count} plugin implementation(s)".format(count=len(self.plugin_implementations)))
def initialize_implementation_of_plugin(self, name, plugin, additional_injects=None, additional_inject_factories=None, additional_pre_inits=None, additional_post_inits=None):
if plugin.implementation is None:
@@ -1293,7 +1344,7 @@ class PluginManager(object):
try:
return_value = factory(name, implementation)
except:
self.logger.exception("Exception while executing injection factory %r" % factory)
self.logger.exception(u"Exception while executing injection factory %r" % factory)
else:
if return_value is not None:
if isinstance(return_value, dict):
@@ -1317,12 +1368,12 @@ class PluginManager(object):
if isinstance(e, PluginLifecycleException):
raise e
else:
self.logger.exception("Exception while initializing plugin {name}, disabling it".format(**locals()))
self.logger.exception(u"Exception while initializing plugin {name}, disabling it".format(**locals()))
return False
else:
self.on_plugin_implementations_initialized(name, plugin)
self.logger.debug("Initialized plugin mixin implementation for plugin {name}".format(**locals()))
self.logger.debug(u"Initialized plugin mixin implementation for plugin {name}".format(**locals()))
return True
@@ -1339,7 +1390,7 @@ class PluginManager(object):
self.logger.log(level, message)
if len(all_plugins) <= 0:
_log("No plugins available")
_log(u"No plugins available")
else:
formatted_plugins = "\n".join(map(lambda x: "| " + x.long_str(show_bundled=show_bundled,
bundled_strs=bundled_str,
@@ -1347,9 +1398,9 @@ class PluginManager(object):
location_str=location_str,
show_enabled=show_enabled,
enabled_strs=enabled_str),
sorted(self.plugins.values(), key=lambda x: str(x).lower())))
_log("{count} plugin(s) registered with the system:\n{plugins}".format(count=len(all_plugins),
plugins=formatted_plugins))
sorted(self.plugins.values(), key=lambda x: unicode(x).lower())))
_log(u"{count} plugin(s) registered with the system:\n{plugins}".format(count=len(all_plugins),
plugins=formatted_plugins))
def get_plugin(self, identifier, require_enabled=True):
"""
@@ -1441,16 +1492,17 @@ class PluginManager(object):
try:
sorting_value = impl[1].get_sorting_key(sorting_context)
except:
self.logger.exception("Error while trying to retrieve sorting order for plugin {}".format(impl[0]))
self.logger.exception(u"Error while trying to retrieve sorting order for plugin {}".format(impl[0]))
if sorting_value is not None:
try:
int(sorting_value)
sorting_value = int(sorting_value)
except ValueError:
self.logger.warn("The order value returned by {} for sorting context {} is not a valid integer, ignoring it".format(impl[0], sorting_context))
self.logger.warn(u"The order value returned by {} for sorting context {} is not a valid integer, ignoring it".format(impl[0], sorting_context))
sorting_value = None
return sorting_value is None, sorting_value, impl[0]
plugin_info = self.get_plugin_info(impl[0], require_enabled=False)
return sorting_value is None, sorting_value, not plugin_info.bundled if plugin_info else True, impl[0]
return [impl[1] for impl in sorted(result, key=sort_func)]
@@ -1525,7 +1577,7 @@ class PluginManager(object):
for client in self.registered_clients:
try: client(plugin, data)
except: self.logger.exception("Exception while sending plugin data to client")
except: self.logger.exception(u"Exception while sending plugin data to client")
def _sort_hooks(self, hook):
self._plugin_hooks[hook] = sorted(self._plugin_hooks[hook],
@@ -1591,56 +1643,25 @@ def is_editable_install(install_dir, package, module, location):
return False
class InstalledEntryPoint(pkginfo.Installed):
def __init__(self, entry_point, metadata_version=None):
class EntryPointMetadata(pkginfo.Distribution):
def __init__(self, entry_point):
self.entry_point = entry_point
package = entry_point.module_name
pkginfo.Installed.__init__(self, package, metadata_version=metadata_version)
self.extractMetadata()
def read(self):
import sys
import glob
import warnings
opj = os.path.join
if self.package is not None:
package = self.package.__package__
if package is None:
package = self.package.__name__
metadata_files = ("METADATA", # wheel
"PKG-INFO") # egg
project = pkg_resources.to_filename(pkg_resources.safe_name(self.entry_point.dist.project_name))
if self.entry_point and self.entry_point.dist:
for metadata_file in metadata_files:
try:
return self.entry_point.dist.get_metadata(metadata_file)
except:
pass
package_pattern = '%s*.egg-info' % package
project_pattern = '%s*.egg-info' % project
file = getattr(self.package, '__file__', None)
if file is not None:
candidates = []
def _add_candidate(where):
candidates.extend(glob.glob(where))
for entry in sys.path:
if file.startswith(entry):
_add_candidate(opj(entry, 'EGG-INFO')) # egg?
for pattern in (package_pattern, project_pattern): # dist-installed?
_add_candidate(opj(entry, pattern))
dir, name = os.path.split(self.package.__file__)
for pattern in (package_pattern, project_pattern):
_add_candidate(opj(dir, pattern))
_add_candidate(opj(dir, '..', pattern))
for candidate in candidates:
if os.path.isdir(candidate):
path = opj(candidate, 'PKG-INFO')
else:
path = candidate
if os.path.exists(path):
with open(path) as f:
return f.read()
warnings.warn('No PKG-INFO found for package: %s' % self.package_name)
warnings.warn('No package metadata found for package: {}'.format(self.entry_point.module_name))
class Plugin(object):
+43 -27
View File
@@ -25,9 +25,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
from .core import (Plugin, RestartNeedingPlugin, SortablePlugin)
# noinspection PyCompatibility
from past.builtins import basestring
class OctoPrintPlugin(Plugin):
"""
The parent class of all OctoPrint plugin mixins.
@@ -159,6 +156,10 @@ class StartupPlugin(OctoPrintPlugin, SortablePlugin):
is not actually up yet and none of your plugin's APIs or blueprints will be reachable yet. If you need to be
externally reachable, use :func:`on_after_startup` instead or additionally.
.. warning::
Do not perform long-running or even blocking operations in your implementation or you **will** block and break the server.
The relevant sorting context is ``StartupPlugin.on_startup``.
:param string host: the host the server will listen on, may be ``0.0.0.0``
@@ -171,6 +172,10 @@ class StartupPlugin(OctoPrintPlugin, SortablePlugin):
"""
Called just after launch of the server, so when the listen loop is actually running already.
.. warning::
Do not perform long-running or even blocking operations in your implementation or you **will** block and break the server.
The relevant sorting context is ``StartupPlugin.on_after_startup``.
"""
@@ -191,6 +196,10 @@ class ShutdownPlugin(OctoPrintPlugin, SortablePlugin):
"""
Called upon the imminent shutdown of OctoPrint.
.. warning::
Do not perform long-running or even blocking operations in your implementation or you **will** block and break the server.
The relevant sorting context is ``ShutdownPlugin.on_shutdown``.
"""
pass
@@ -225,6 +234,8 @@ class AssetPlugin(OctoPrintPlugin, RestartNeedingPlugin):
js
JavaScript files, such as additional view models
jsclient
JavaScript files containing additional parts for the JS Client Library (since 1.3.10)
css
CSS files with additional styles, will be embedded into delivered pages when not running in LESS mode.
less
@@ -239,6 +250,7 @@ class AssetPlugin(OctoPrintPlugin, RestartNeedingPlugin):
def get_assets(self):
return dict(
js=['js/my_file.js', 'js/my_other_file.js'],
clientjs=['clientjs/my_file.js'],
css=['css/my_styles.css'],
less=['less/my_styles.less']
)
@@ -782,7 +794,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
def get_ui_custom_etag(self):
"""
Allows to use a custom way to calculate the ETag, instead of the default method (hashing
OctoPrint's version, current ``UI_API_KEY``, tracked file paths and ``LastModified`` value).
OctoPrint's version, tracked file paths and ``LastModified`` value).
Returns:
str: An alternatively calculated ETag value. Ignored if ``None`` is returned (default).
@@ -1379,8 +1391,9 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin):
# noinspection PyMethodMayBeStatic
def is_blueprint_protected(self):
"""
Whether a valid API key is needed to access the blueprint (the default) or not. Note that this only restricts
access to the blueprint's dynamic methods, static files are always accessible without API key.
Whether a login session is needed to access the blueprint if the forcelogin plugin is enabled or not. Requiring
a session is the default. Note that this only restricts access to the blueprint's dynamic methods, static files
are always accessible.
"""
return True
@@ -1443,7 +1456,7 @@ class SettingsPlugin(OctoPrintPlugin):
Make sure to protect sensitive information stored by your plugin that only logged in administrators (or users)
should have access to via :meth:`~octoprint.plugin.SettingsPlugin.get_settings_restricted_paths`. OctoPrint will
return its settings on the REST API even to anonymous clients, but will filter out fields it know are restricted,
return its settings on the REST API even to anonymous clients, but will filter out fields it knows are restricted,
therefore you **must** make sure that you specify sensitive information accordingly to limit access as required!
"""
@@ -1799,6 +1812,10 @@ class EventHandlerPlugin(OctoPrintPlugin):
"""
Called by OctoPrint upon processing of a fired event on the platform.
.. warning::
Do not perform long-running or even blocking operations in your implementation or you **will** block and break the server.
Arguments:
event (str): The type of event that got fired, see :ref:`the list of events <sec-events-available_events>`
for possible values
@@ -1837,8 +1854,9 @@ class SlicerPlugin(OctoPrintPlugin):
The human readable name of the slicer. This will be displayed to the user during slicer selection.
same_device
True if the slicer runs on the same device as OctoPrint, False otherwise. Slicers running on the same
device will not be allowed to slice while a print is running due to performance reasons. Slice requests
against slicers running on the same device will result in an error.
device will not be allowed to slice on systems with less than two CPU cores (or an unknown number) while a
print is running due to performance reasons. Slice requests against slicers running on the same device and
less than two cores will result in an error.
progress_report
``True`` if the slicer can report back slicing progress to OctoPrint ``False`` otherwise.
source_file_types
@@ -1861,6 +1879,21 @@ class SlicerPlugin(OctoPrintPlugin):
destination_extensions=["gco", "gcode", "g"]
)
# noinspection PyMethodMayBeStatic
def get_slicer_extension_tree(self):
"""
Fetch additional entries to put into the extension tree for accepted files
By default, a subtree for ``model`` files with ``stl`` extension is returned. Slicers who want to support
additional/other file types will want to override this.
For the extension tree format, take a look at the docs of the :ref:`octoprint.filemanager.extension_tree hook <sec-plugins-hook-filemanager-extensiontree>`.
Returns: (dict) a dictionary containing a valid extension subtree.
"""
from octoprint.filemanager import ContentTypeMapping
return dict(model=dict(stl=ContentTypeMapping(["stl"], "application/sla")))
def get_slicer_profiles(self, profile_path):
"""
Fetch all :class:`~octoprint.slicing.SlicingProfile` stored for this slicer.
@@ -1984,7 +2017,7 @@ class SlicerPlugin(OctoPrintPlugin):
For jobs that finished successfully, ``result`` should be a :class:`dict` containing additional information
about the slicing job under the following keys:
_analysis
analysis
Analysis result of the generated machine code as returned by the slicer itself. This should match the
data structure described for the analysis queue of the matching machine code format, e.g.
:class:`~octoprint.filemanager.analysis.GcodeAnalysisQueue` for GCODE files.
@@ -2043,20 +2076,3 @@ class ProgressPlugin(OctoPrintPlugin):
:param int progress: Current progress as a value between 0 and 100
"""
pass
class AppPlugin(OctoPrintPlugin):
"""
Using the :class:`AppPlugin mixin` plugins may register additional :ref:`App session key providers <sec-api-apps-sessionkey>`
within the system.
.. deprecated:: 1.2.0
Refer to the :ref:`octoprint.accesscontrol.appkey hook <sec-plugins-hook-accesscontrol-appkey>` instead.
"""
# noinspection PyMethodMayBeStatic
def get_additional_apps(self):
return []
+2 -1
View File
@@ -1 +1,2 @@
# make our plugins testable
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
@@ -0,0 +1,225 @@
# 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) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
import octoprint.plugin
from octoprint.server import user_permission
from octoprint.events import Events
import flask
from flask_babel import gettext
class Prompt(object):
def __init__(self, text):
self.text = text
self.choices = []
self._active = False
@property
def active(self):
return self._active
def add_choice(self, text):
self.choices.append(text)
def activate(self):
self._active = True
def validate_choice(self, choice):
return 0 <= choice < len(self.choices)
class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.plugin.SettingsPlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.TemplatePlugin):
COMMAND = "M876"
CAP_PROMPT_SUPPORT = "PROMPT_SUPPORT"
# noinspection PyMissingConstructor
def __init__(self):
self._prompt = None
self._enable = "detected"
self._command = None
self._enable_emergency_sending = False
self._enable_signal_support = False
self._cap_prompt_support = False
def initialize(self):
self._enable = self._settings.get([b"enable"])
self._command = self._settings.get([b"command"])
self._enable_emergency_sending = self._settings.get_boolean([b"enable_emergency_sending"])
self._enable_signal_support = self._settings.get_boolean([b"enable_signal_support"])
#~ AssetPlugin
def get_assets(self):
return dict(js=["js/action_command_prompt.js"],
clientjs=["clientjs/action_command_prompt.js"])
#~ EventHandlerPlugin
def on_event(self, event, payload):
if event == Events.CONNECTED and self._enable == "always" and self._enable_signal_support:
self._printer.commands(["{command} P1".format(command=self._command)])
elif event == Events.DISCONNECTED:
self._close_prompt()
#~ SettingsPlugin
def get_settings_defaults(self):
return dict(enable="detected",
command=self.COMMAND,
enable_emergency_sending=True,
enable_signal_support=True)
def on_settings_save(self, data):
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
self._enable = self._settings.get([b"enable"])
self._command = self._settings.get([b"command"])
self._enable_emergency_sending = self._settings.get_boolean([b"enable_emergency_sending"])
self._enable_signal_support = self._settings.get_boolean([b"enable_signal_support"])
#~ SimpleApiPlugin
def get_api_commands(self):
return dict(select=["choice"])
def on_api_command(self, command, data):
if command == "select":
if not user_permission.can():
return flask.abort(403, "Insufficient permissions")
if self._prompt is None:
return flask.abort(409, "No active prompt")
choice = data["choice"]
if not isinstance(choice, int) or not self._prompt.validate_choice(choice):
return flask.abort(400, "{!r} is not a valid value for choice".format(choice))
self._answer_prompt(choice)
def on_api_get(self, request):
if not user_permission.can():
return flask.abort(403, "Insufficient permissions")
if self._prompt is None:
return flask.jsonify()
else:
return flask.jsonify(text=self._prompt.text, choices=self._prompt.choices)
#~ TemplatePlugin
def get_template_configs(self):
return [dict(type="settings", name=gettext("Action Command Prompt"), custom_bindings=False)]
#~ action command handler
def action_command_handler(self, comm, line, action, *args, **kwargs):
if not action.startswith(b"prompt_"):
return
parts = action.split(None, 1)
if len(parts) == 1:
action = parts[0]
parameter = b""
else:
action, parameter = parts
if action == b"prompt_begin":
if self._prompt is not None and self._prompt.active:
self._logger.warn("Prompt is already defined")
return
self._prompt = Prompt(parameter.strip())
elif action == b"prompt_choice" or action == b"prompt_button":
if self._prompt is None:
return
if self._prompt.active:
self._logger.warn("Prompt is already active")
return
self._prompt.add_choice(parameter.strip())
elif action == b"prompt_show":
if self._prompt is None:
return
if self._prompt.active:
self._logger.warn("Prompt is already active")
return
self._show_prompt()
elif action == b"prompt_end":
if self._prompt is None:
return
self._close_prompt()
self._prompt = None
#~ queuing handling
def gcode_queuing_handler(self, comm_instance, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs):
if gcode != self._command:
return
if self._enable == "never" or (self._enable == "detected" and not self._cap_prompt_support) or not self._enable_emergency_sending:
return
if not "S" in cmd:
# we only force-send M876 Sx
return
# noinspection PyProtectedMember
return comm_instance._emergency_force_send(cmd, u"Force-sending {} to the printer".format(self._command), gcode=gcode)
#~ capability reporting
def firmware_capability_handler(self, comm_instance, capability, enabled, already_defined, *args, **kwargs):
if capability == self.CAP_PROMPT_SUPPORT and enabled:
self._cap_prompt_support = True
if self._enable == "detected" and self._enable_signal_support:
self._printer.commands(["{command} P1".format(command=self._command)])
#~ prompt handling
def _show_prompt(self):
if self._enable == "never" or (self._enable == "detected" and not self._cap_prompt_support):
return
self._prompt.activate()
self._plugin_manager.send_plugin_message(self._identifier, dict(action="show",
text=self._prompt.text,
choices=self._prompt.choices))
def _close_prompt(self):
if self._enable == "never" or (self._enable == "detected" and not self._cap_prompt_support):
return
self._prompt = None
self._plugin_manager.send_plugin_message(self._identifier, dict(action="close"))
def _answer_prompt(self, choice):
if self._enable == "never" or (self._enable == "detected" and not self._cap_prompt_support):
return
self._close_prompt()
self._printer.commands(["{command} S{choice}".format(command=self._command,
choice=choice)])
__plugin_name__ = "Action Command Prompt Support"
__plugin_description__ = "Allows your printer to trigger prompts via action commands on the connection"
__plugin_author__ = "Gina Häußge"
__plugin_disabling_discouraged__ = gettext("Without this plugin your printer will no longer be able to trigger"
" confirmation or selection prompts in OctoPrint")
__plugin_license__ = "AGPLv3"
__plugin_implementation__ = ActionCommandPromptPlugin()
__plugin_hooks__ = {
b"octoprint.comm.protocol.action": __plugin_implementation__.action_command_handler,
b"octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.gcode_queuing_handler,
b"octoprint.comm.protocol.firmware.capabilities": __plugin_implementation__.firmware_capability_handler
}
@@ -0,0 +1,25 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["OctoPrintClient"], factory);
} else {
factory(global.OctoPrintClient);
}
})(this, function(OctoPrintClient) {
var OctoPrintActionCommandPromptClient = function(base) {
this.base = base;
};
OctoPrintActionCommandPromptClient.prototype.get = function(refresh, opts) {
return this.base.get(this.base.getSimpleApiUrl("action_command_prompt"), opts);
};
OctoPrintActionCommandPromptClient.prototype.select = function(choice, opts) {
var data = {
choice: choice
};
return this.base.simpleApiCommand("action_command_prompt", "select", data, opts);
};
OctoPrintClient.registerPluginComponent("action_command_prompt", OctoPrintActionCommandPromptClient);
return OctoPrintActionCommandPromptClient;
});
@@ -0,0 +1,103 @@
$(function() {
function ActionCommandPromptViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
self.modal = ko.observable(undefined);
self.text = ko.observable();
self.buttons = ko.observableArray([]);
self.active = ko.pureComputed(function() {
return self.text() !== undefined;
});
self.visible = ko.pureComputed(function() {
return self.modal() !== undefined;
});
self.requestData = function() {
if (!self.loginState.isUser()) return;
OctoPrint.plugins.action_command_prompt.get()
.done(self.fromResponse);
};
self.fromResponse = function(data) {
if (data.hasOwnProperty("text") && data.hasOwnProperty("choices")) {
self.text(data.text);
self.buttons(data.choices);
self.showPrompt();
} else {
self.text(undefined);
self.buttons([]);
}
};
self.showPrompt = function() {
var text = self.text();
var buttons = self.buttons();
var opts = {
title: gettext("Message from your printer"),
message: text,
selections: buttons,
maycancel: true, // see #3171
onselect: function(index) {
if (index > -1) {
self._select(index);
}
},
onclose: function() {
self.modal(undefined);
}
};
self.modal(showSelectionDialog(opts));
};
self._select = function(index) {
OctoPrint.plugins.action_command_prompt.select(index);
};
self._closePrompt = function() {
var modal = self.modal();
if (modal) {
modal.modal("hide");
}
};
self.onStartupComplete = function() {
self.requestData();
};
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (!self.loginState.isUser()) return;
if (plugin !== "action_command_prompt") {
return;
}
switch (data.action) {
case "show": {
self.text(data.text);
self.buttons(data.choices);
self.showPrompt();
break;
}
case "close": {
self.text(undefined);
self.buttons([]);
self._closePrompt();
break;
}
}
}
}
OCTOPRINT_VIEWMODELS.push({
construct: ActionCommandPromptViewModel,
dependencies: ["loginStateViewModel"],
elements: ["#navbar_plugin_action_command_prompt"]
});
});
@@ -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')|edq }}">
<i class="fa fa-commenting-o"></i>
</a>
@@ -0,0 +1,44 @@
<h3>{{ _('Action Command Prompt Settings') }}</h3>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">{{ _('Enable support')}}</label>
<div class="controls">
<label class="radio">
<input type="radio" name="pluginActionCommandPromptEnableGroup" value="detected" data-bind="checked: settings.plugins.action_command_prompt.enable"> {{ _('If detected as supported by the firmware (<code>PROMPT_SUPPORT</code> capability)') }}
</label>
<label class="radio">
<input type="radio" name="pluginActionCommandPromptEnableGroup" value="always" data-bind="checked: settings.plugins.action_command_prompt.enable"> {{ _('Always') }}
</label>
<label class="radio">
<input type="radio" name="pluginActionCommandPromptEnableGroup" value="never" data-bind="checked: settings.plugins.action_command_prompt.enable"> {{ _('Never') }}
</label>
</div>
</div>
<div class="advanced_options">
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<div class="control-group">
<label class="control-label">{{ _('Dialog command') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.plugins.action_command_prompt.command">
<div class="help-block">{{ _('Use this to define the dialog command. Default is <code>M876</code>. You normally should not have to change this.') }}</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.action_command_prompt.enable_emergency_sending"> {{ _('Enable force sending of the configured command to bypass blocking firmware routines if detected as supported. You normally should not have to change this.') }}
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.action_command_prompt.enable_signal_support"> {{ _('Enable signaling to the firmware that we support <code>prompt_*</code> actions if detected as supported. You normally should not have to change this.') }}
</label>
</div>
</div>
</div>
</div>
</form>
@@ -22,7 +22,7 @@ from collections import OrderedDict
from octoprint.server import admin_permission
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
from octoprint.util import utmify
from octoprint.util import utmify, monotonic_time
from flask_babel import gettext
from octoprint import __version__ as OCTOPRINT_VERSION
@@ -351,10 +351,10 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
url = config["url"]
try:
start = time.time()
start = monotonic_time()
r = requests.get(url, timeout=30)
r.raise_for_status()
self._logger.info(u"Loaded channel {} from {} in {:.2}s".format(key, config["url"], time.time() - start))
self._logger.info(u"Loaded channel {} from {} in {:.2}s".format(key, config["url"], monotonic_time() - start))
except Exception as e:
self._logger.exception(
u"Could not fetch channel {} from {}: {}".format(key, config["url"], str(e)))
@@ -372,15 +372,24 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
result = []
if "entries" in feed:
for entry in feed["entries"]:
internal_entry = self._to_internal_entry(entry, read_until=read_until)
if internal_entry:
result.append(internal_entry)
try:
internal_entry = self._to_internal_entry(entry, read_until=read_until)
if internal_entry:
result.append(internal_entry)
except:
self._logger.exception("Error while converting entry from feed, skipping it")
return result
def _to_internal_entry(self, entry, read_until=None):
"""Convert feed entries to internal data structure."""
published = calendar.timegm(entry["published_parsed"])
timestamp = entry.get("published_parsed",
entry.get("updated_parsed",
None))
if timestamp is None:
return None
published = calendar.timegm(timestamp)
read = True
if read_until is not None:
@@ -66,9 +66,11 @@ $(function() {
return link;
};
self.markRead = function(channel, until) {
self.markRead = function(channel, until, reload) {
if (!self.loginState.isAdmin()) return;
reload = !!reload;
var url = PLUGIN_BASEURL + "announcements/channels/" + channel;
var payload = {
@@ -83,7 +85,9 @@ $(function() {
data: JSON.stringify(payload),
contentType: "application/json; charset=UTF-8",
success: function() {
self.retrieveData()
if (reload) {
self.retrieveData()
}
}
})
};
Loaded 100 of 369 files, more files were not shown because too many files have changed in this diff. Show more