Compare commits

...
Author SHA1 Message Date
Gina Häußge a012c41dad WIP: track heatup based on current temperatures
TODO: Doesn't yet distinguish between blocking heatups and any kind of
heatup. Those things need to be separated though in order to only block
the communication/make the timeout detection more lenient in case of
blocking heatups.
2018-10-31 13:33:55 +01: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 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
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 6d7f8a2a64 Don't raise error when trying to read from finished print
Could be caused by timing issues and one `continue_sending` too many, so
just ignore this but log a warning.
2018-04-09 15:56:35 +02:00
Gina Häußge 8869748ecc Don't trigger ok timeout while heating or in long running command
Workaround for printers that don't send busy:processing during heatups
like they should.
2018-04-09 15:53:25 +02:00
Gina Häußge e0b0f2ae18 Preparing release of 1.3.7 2018-04-09 12:38:56 +02:00
Gina Häußge 440ccf165e [Docs] Add missing image
Fixes #2557
2018-04-09 11:50:16 +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 e5caa3d0bf Preparing release of 1.3.7rc4 2018-04-04 11:10:45 +02:00
Gina Häußge a821346b07 Don't trigger PRINT_FAILED twice on disconnect
Fixes #2546
2018-04-04 11:10:43 +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 0ac9ea518c SWU: Update "How to use release channels" link 2018-04-03 17:47:23 +02:00
Gina Häußge 9f80aefcc9 thaw_frozendict should be fully recursive
So far it was only deep-diving into frozendicts, not dicts (which might
contain frozendicts).

In principle we probably should also dive into tuples and lists and
other containers, but in our current application we don't put
frozendicts into those so let's not overdo it.
2018-04-03 16:56:59 +02:00
Gina Häußge c1fe8f5a35 Fix RawWebsocketTransport of sockjs
Ran into issues due to session wrapping in order to support custom
Json encoding.

We now make sure to

  * only wrap non-raw sessions (since only those have send_jsonified
    defined which we overwrite)
  * overwrite tornado.escape.json_encode to use our custom encoder as
    fallback, since that is used for RawWebsocketTransport

Fixes an issue with the /sockjs/websocket endpoint hinted at in #2529
2018-04-03 16:45:14 +02:00
Gina Häußge fcecb5c0f0 Fix heatup flag not resetting on external SD print start
If the start of the SD print could only be verified after the blocking
heatup was through, the start time was reset to None and hence the
heatup flag was not cleared on receival of the first ok, causing no
commands to be sent out and things to run into a timeout.

Fixes #2536
2018-04-03 15:41:13 +02:00
Gina Häußge 25005b547c Virtual: Add some debug commands for sd printing 2018-04-03 15:38:43 +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 dbfe7fece1 staging/maintenance is now 1.3.7rc4.dev 2018-03-29 16:58:55 +02:00
Gina Häußge 9c5d996ea2 Preparing release of 1.3.7rc3 2018-03-29 15:47:35 +02:00
Gina Häußge b8e7cfb506 "Where to find versions" is not on the FAQ 2018-03-29 14:24:58 +02:00
Gina Häußge 822f757f9d Ignore wait if job is on hold
See #2524
2018-03-29 14:23:17 +02:00
Gina Häußge b04aff7d5e Fix command expansion for non-gcode commands 2018-03-28 15:24:50 +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 028425542f staging/maintenance is now 1.3.7rc3.dev 2018-03-23 16:28:47 +01:00
Gina Häußge 339d1df5a9 Preparing release of 1.3.7rc2 2018-03-23 15:29:00 +01:00
Gina Häußge 2abe67a24c Logging: Discourage disabling this plugin 2018-03-23 15:27:12 +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 47267abcd1 Fix HTTP 500 in case of unconfigured slicer
Fixes #2508
2018-03-23 14:24:10 +01:00
Gina Häußge 23f130da58 Fix "undefined" settings values not saving
Fixes #2494
2018-03-23 14:17:23 +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
Gina Häußge 9af6b42bdd Virtual: Fix queue clearing on reset 2018-03-22 17:50:48 +01:00
Gina Häußge 7cb910a69a Forgot a monotonic.monotonic 2018-03-22 17:10:06 +01:00
Gina Häußge c30db16085 Fire print failed event on error while printing
That will ensure to also stop timelapse
2018-03-22 16:17:25 +01:00
Gina Häußge 832a0c88aa Virtual: also reset autoreporting & fix heatup 2018-03-22 16:15:56 +01:00
Gina Häußge 972c2823a0 Add missing _sprintf wrapper around messages
Fixes #2499
2018-03-22 14:21:20 +01:00
Gina Häußge f10bfa67ca Use "import pip" method of calling pip only as last resort
Doing that poses too much risk with pip's general "no API support", as
seen in #2499.
2018-03-22 13:59:38 +01:00
Gina Häußge fb834f81ee Use pkg_resources to find out local pip version
Doing a "import pip; pip.__version__" or "from pip import __version__"
poses too much risk with pip's general "no API support", as seen in
#2499.
2018-03-22 13:46:38 +01:00
Gina Häußge 957ba43320 Virtual: Support for simulated reset 2018-03-22 13:36:12 +01:00
Gina Häußge 133850f61c Actually, make that a deepcopy 2018-03-22 13:08:01 +01:00
Gina Häußge f782cfe83f Thaw the frozendict on printer.get_current_data
We don't want calling code to run into trouble because of that.

Fixes #2506
2018-03-22 12:58:52 +01:00
Gina Häußge 70254e910c Use octoprint.util.monotonic_time instead of monotonic 2018-03-22 11:41:31 +01:00
Gina Häußge f981cca47e Forgot a "global"
Fixes #2501
2018-03-22 11:34:39 +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
Gina Häußge 0224037478 Have OctoPrintJsonEncoder fall back to flask encoder
That supports some types we want to keep just in case.
2018-03-20 16:19:06 +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
Gina Häußge e4914b8bd3 staging/maintenance is now 1.3.7rc2.dev 2018-03-19 17:18:39 +01:00
Gina Häußge da2c9632ea Preparing release of 1.3.7rc1 2018-03-19 13:46:19 +01:00
Gina Häußge 8a3a87efac Extract firmware safety check into bundled plugin 2018-03-19 13:22:59 +01:00
Gina Häußge 8cdae335a2 Fix typo in issue template 2018-03-19 10:50:56 +01:00
Gina Häußge 75ad9aeeb6 Merge branch 'pr/2491' into maintenance 2018-03-19 10:50:31 +01:00
Daniele Forsi 709f7a76f1 Remove unused or duplicated imports
Fixes the following pylint's warnings:
W:  9, 0: Unused import io (unused-import)
W: 33, 1: Unused walk imported from os (unused-import)
W:308, 4: Reimport 're' (imported line 16) (reimported)
W: 17, 1: Reimport 'os' (imported line 8) (reimported)
2018-03-19 10:49:03 +01:00
Gina Häußge c04fade9a7 docs: Fix two issues pointed out by @dforsi
Thanks!
2018-03-19 10:46:20 +01:00
Daniele Forsi 2ecbd9f8c8 Fix typos in docs 2018-03-19 10:43:08 +01:00
Gina Häußge 3e24b68b45 Attach additionalClasses to all custom controls
Fixes #2489
2018-03-19 10:36:26 +01:00
Gina Häußge 46a0c3057f Logging: At missing CSS file
Thanks @kantlivelong for the heads-up
2018-03-19 10:36:07 +01:00
Greg Sadetsky 902407ed92 typo fix 2018-03-19 00:44:04 -04:00
Gina Häußge ccbe9311d7 Add firmware safety warning
For now it only triggers for the Anet A8's stock firmware which for some
idiotic reason has thermal runaway protection disabled (it's 2018 ffs!)
2018-03-18 00:38:06 +01:00
Gina Häußge 82dffa50f7 Improve log output of PipHelper & LocalPipHelper
Should make it easier to detect the reason for a broken pip install in
the future (e.g. non writable install directories).
2018-03-16 17:23:56 +01:00
Gina Häußge 0d51e5bb1c Hide connection refresh button if panel is collapsed 2018-03-16 14:34:09 +01:00
Gina Häußge fd7fbcc113 CSS update 2018-03-16 14:12:52 +01:00
Gina Häußge 5791562c6a [Doc] Some changes on the index & a fix 2018-03-16 14:12:39 +01:00
Gina Häußge 6582740a1e http://faq... -> https://faq... 2018-03-16 11:15:22 +01:00
Gina Häußge 73ce6f43ab bit.ly/octoserial -> faq.octoprint.org/serialerror 2018-03-16 11:14:19 +01:00
Gina Häußge bc746a49e9 Merge branch 'master' into maintenance 2018-03-16 11:05:25 +01:00
Gina Häußge e8d5449a8f Adjust issue template for new GH layout
Apparently the "big yellow box" hinting the contribution guidelines
vanished some time ago and got replaced by a teeny tiny link to the
right under "Helpful resources". Ah well.
2018-03-15 16:30:54 +01:00
Gina Häußge 01f5a58709 Fix a typo 2018-03-15 16:20:33 +01:00
Gina Häußge 61769262f6 New meta git prefix for github meta md updates 2018-03-15 16:10:17 +01:00
Gina Häußge faa8174846 Link to community forum & new FAQ location
Also updated contribution guidelines & templates
2018-03-15 16:08:02 +01:00
Gina Häußge 0eb441058e Links to new forum & FAQ 2018-03-13 18:51:04 +01:00
Gina Häußge 32a31a7d4a Hook for defining custom atcommands 2018-03-13 11:06:52 +01:00
Gina Häußge 01bae0c95c _atcommand_abort_sending => _atcommand_abort_queuing 2018-03-12 18:37:43 +01:00
Gina Häußge ada873be1d First throw at native @ command support
For now the following commands are supported:

  * @pause: Pauses the print
  * @resume: Resumes the print
  * @cancel or @abort: Cancels the print

As discussed in #2414. Also implements #324.
2018-03-12 18:33:40 +01:00
Gina Häußge a95407c815 Fix flask_login._get_remote_addr
We can't easily upgrade to 0.3.0 right now due to backwards incompatible
changes in that version (some methods became properties). So for now
we simply backport the fix in question through a monkey patch.

Fixes #2296
2018-03-12 16:40:19 +01:00
Gina Häußge e0722e6c28 flask.ext.* => flask_*
And some refactoring in the server class
2018-03-12 16:39:35 +01:00
Gina Häußge e32aa3f2c8 text/plain mime type for log downloads 2018-03-12 12:38:39 +01:00
Gina Häußge 8e764e34ee SWU: Refer to console log on update failure 2018-03-12 12:25:17 +01:00
Gina Häußge cfb0eb84e2 Make sure that "method" is a function
It could be null or anything else really, so better be safe than sorry
;)

See comments in ntoff/OctoPrint-Estop#4
2018-03-09 19:12:26 +01:00
Gina Häußge effefffe74 SWU: Better detection if an update is already running 2018-03-09 16:06:50 +01:00
Gina Häußge 8148fd7679 SWU: Add sleep_a_bit updater for testing 2018-03-09 16:05:47 +01:00
Gina Häußge f8079c3f50 Fix unset error handling
No proper value was set if ignoreErrorsFromFirmware ==
disconnectOnErrors == false. Now falls back correctly to "cancel".

Closes #2472
2018-03-09 15:42:11 +01:00
Gina Häußge 4c3e44d50e Fix a method call
Thanks @FormerLurker for the heads-up!
2018-03-09 10:48:50 +01:00
Gina Häußge a2ccf414e6 comm: compat fix for pyserial 2.7 vs 3.4
Closes #2468
2018-03-09 10:40:02 +01:00
Gina Häußge 02c42ecdc0 [doc] Fix an error 2018-03-08 18:09:44 +01:00
Gina Häußge c6dfdf8d4b comm: custom readline implementation w/ buffer
We always read everything from the serial that is currently available in
our rx buffer but only return the first line in that. While that
increases our memory consumption slightly, it should hopefully not cause
issues and should greatly reduce the risk of buffer overflows making us
lose or receive corrupt data.

Possible solution for #2370 and #2454
2018-03-08 18:09:28 +01:00
Gina Häußge 10af43285b comm: fix job_on_hold & add further options for using it
* next command could be queued even if job was already on hold due to
    a check missing
  * context manager was too limiting, could lead to race conditions
    where the job_on_hold flag wasn't set in time when moved to a
    handler thread, introducing a dedicated set_job_on_hold method
    for that solves this (at the downside of requiring more care from
    plugin developers utilizing this)

Fixes #2467
2018-03-08 15:12:22 +01:00
Gina Häußge 25dc4528af comm: Add line & pos in file to command tags 2018-03-08 10:40:01 +01:00
Gina Häußge bb61bbb2b4 Add "Not SD printing" to sd status terminal filters
As noted in #2335
2018-03-07 17:49:49 +01:00
Gina Häußge e6ec48b8a1 Support SD status autoreport 2018-03-07 17:45:06 +01:00
Gina Häußge 98c7ad0c20 If current == total -> not SD printing 2018-03-07 17:07:21 +01:00
Gina Häußge 52bb94e272 Try to detect externally started SD prints
Strongly depends on the firmware:

  * Firmware must send a "File opened: ..." message on start of the
    print
  * Firmware must respond to an immediately sent M27 with "SD printing
    byte <current>/<total>"
  * Firmware must stay responsive during ongoing print to allow for
    regular M27 polls (or push those automatically) or M25 to pause/
    cancel the print through OctoPrint.
2018-03-07 16:35:18 +01:00
Gina Häußge e0f8ae8986 "SD printing byte 0/0" means we ain't printing
Newer versions of Marlin apparently now report it like that instead of
returning "Not SD printing".
2018-03-07 16:34:58 +01:00
Gina Häußge 291fa88a82 Merge branch 'pr/2444' into maintenance 2018-03-07 15:39:56 +01:00
Gina Häußge 88b622e282 customClass => additionalClasses 2018-03-07 15:39:36 +01:00
Gina Häußge 3fcd5adfbd Timelapse: Add snapshot imeout & SSL validation settings
Implements #2455 & #2362
2018-03-07 15:20:46 +01:00
Gina Häußge 1f9c9bed42 Timelapse: Remove post roll capturing from timed timelapses
As discussed in #2317 this option was confusing and frustrating too many
people. Instead of an actual capture we'll now just do the same as for
z-based timelapses and use the last image repeatedly.

No, using the live webstream and capturing real time image is NOT an
option and not going to happen here, see the discussion in #2317 on this
as well.
2018-03-07 14:56:10 +01:00
Gina Häußge f1401d3f1e Gcode viewer: Don't hiccup on GCODE subcodes
Implements #2378
2018-03-07 14:33:33 +01:00
Gina Häußge 5216729834 Add a regular server heartbeat to the log 2018-03-07 14:24:38 +01:00
Gina Häußge bab4782b8c Log comm states to application log
Should allow to better debug some things in the future
2018-03-07 14:09:55 +01:00
Gina Häußge eada72a4d9 Add __str__ for sockjs connection 2018-03-07 14:05:10 +01:00
Gina Häußge 088b4a8059 Use frozendict for printer state
Attempt to narrow down on #1951.

To be on the safe side, the use of frozendict here can be disabled by
settings devel.useFrozenDictForPrinterState to False in the config.
2018-03-07 14:04:20 +01:00
Gina Häußge 90aa5ed3d4 Custom json encoding for flask & sockjs
That will allow us to support encoding non-built in types by simply
adding them through octoprint.util.json.JsonEncoding.add_encoder
2018-03-07 14:01:42 +01:00
Gina Häußge 3c8d2f2df5 Remove a blank line so @ntoff can sleep again
Also reformatted the block of text a bit in code.
2018-03-07 13:46:24 +01:00
Gina Häußge 283c44e35e Better logging of printer callback errors 2018-03-07 13:41:29 +01:00
Gina Häußge 125673b846 Merge pull request #2466 from ntoff/improve/disconnectWarning
Add a confirmation if disconnecting while printing
2018-03-07 13:38:03 +01:00
ntoff fb6ff04013 Add a confirmation to disconnect while printing
Fullfills a feature request:
https://github.com/foosel/OctoPrint/issues/2287

Add a confirmation dialog if a user attempts to disconnect while a print
is in progress
2018-03-07 22:21:54 +10:00
Gina Häußge 6a3f1d28fb Reduce code duplication in error handling 2018-03-06 15:08:41 +01:00
Gina Häußge 2abff3b589 Fix broken unit test 2018-03-06 15:05:25 +01:00
Gina Häußge c84f49e852 Change presentation of serial error handling config
A set of radio controls is less confusing than two distinct checkboxes.
2018-03-06 14:49:30 +01:00
Gina Häußge de0660f678 Force disconnect on error state
Fixes #2461
2018-03-06 13:28:40 +01:00
Gina Häußge ee36e2abd3 Allow detection of firmware w/ broken resend
If firmware doesn't send an ok immediately after a resend request, we
will now be able to detect this (if enabled to do so) by starting a
timer that will simulate an ok after .5s if none has been received.

This should help with issues like prusa3d/Prusa-Firmware#331 where an ok
is only missing sometimes and not always, making the existing workaround
of always simulating an ok after a resend cause additional problems.
2018-03-06 12:48:24 +01:00
Gina Häußge 11eb731b3d Virtual printer: simulate broken resends w/o ok 2018-03-06 12:44:11 +01:00
Gina Häußge 01d37fc9ee PMGR: Reduce notification spam 2018-03-05 17:25:15 +01:00
Gina Häußge 59cbfaf8ff Introduce Cancelling/Pausing states before full cancel/pause
We so far switched immediately to "Operational" state, even while the M400/M114
combo and/or any post switch scripts were still being executed. That was confusing
and as witnessed in #2321 and also #2449 also could cause issues.
2018-03-05 16:12:33 +01:00
Gina Häußge b8e4ac21d0 Example and copy-paste-fix for new comm error handler hook 2018-02-28 17:14:06 +01:00
Gina Häußge 2db2532c2f Fix unit tests broken by implementation of #2208 2018-02-28 17:07:53 +01:00
Gina Häußge d42c74d34a Hook for custom error handling by plugins
Implements #2208
2018-02-28 16:50:08 +01:00
Gina Häußge 551d6aab68 Detect invalid tools according to firmware
Also don't send invalid tool commands (based on printer profile and
former responses from the firmware on the ongoing connection).

Closes #2302
2018-02-26 17:25:42 +01:00
Gina Häußge 2c87133f3d Virtual: Report invalid extruders on serial
For testing #2302
2018-02-26 17:05:18 +01:00
Gina Häußge 296af89b02 Fix two buggy sets of tags 2018-02-26 16:52:00 +01:00
Gina Häußge 18ad764ef5 Also detect plugins only provided as pyc
Implements #2448
2018-02-26 16:04:27 +01:00
Gina Häußge ec86b3328e Remove left-over parameter 2018-02-26 12:51:38 +01:00
Gina Häußge 820ad59539 Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance 2018-02-26 12:48:46 +01:00
Gina Häußge b3fff6e95f Fix firmware error reporting on job cancel
Closes #2364
2018-02-26 12:47:46 +01:00
Gina Häußge 763888e83a Allow slicers to manage their profiles themselves 2018-02-24 22:30:12 +01:00
Gina Häußge c6bb825f7e Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance 2018-02-24 22:09:56 +01:00
Gina Häußge c3ba9c8453 Fix upload_cli 2018-02-24 15:20:56 +01:00
Gina Häußge a3ba266a6b Some more work on the AST parsing
Also use version parsed from AST for blacklist check too.
2018-02-24 14:54:58 +01:00
electr0sheep 9a8b8d86d5 Extended "customControls_controlTemplate_command" 2018-02-23 18:00:54 -07:00
Gina Häußge b108fc939c Extract control property values from disabled plugins
By parsing the main plugin file into a Python AST we can still extract
the control property values (as long as they are simple string
assignments or calls to gettext with a string argument) without having
to execute them in any way.
2018-02-23 19:06:24 +01:00
Gina Häußge 40082456c1 Don't even import disabled plugins
We want to avoid disabled plugins interfering with our application
in any way at all.

Hence disabled plugins are now treated the same way as blacklisted ones.
The system will only create a dummy entry for them and not import them
at all. As a consequence, a restart of the platform will be necessary
for disabling plugins that were disabled.

The Plugin Manager has been adjusted accordingly.

Note that by no longer even importing the base file, plugin name,
version, description and other such metadata defined through control
properties won't be accessible.

Closes #2442
2018-02-23 19:05:34 +01:00
Gina Häußge 541844ce3c Add action:cancel
Closes #2367
2018-02-19 11:38:58 +01:00
Gina Häußge 33147b0305 Make terminal logging to log unicode safe
Closes #2426
2018-02-19 11:27:37 +01:00
Gina Häußge 55f5c472a0 [Docs] Some fixes 2018-02-16 22:03:54 +01:00
Gina Häußge d166bafa8d New context "job_on_hold" on printer object
Can be used to do some stuff while printing while ensuring that the file
won't continue to be streamed. Should be used sparingly and only for
very limited reasons since it can severely affect print results.
2018-02-16 22:03:45 +01:00
Gina Häußge 00e6a3856f Allow tagging of GCODE commands throughout their lifecycle
Commands injected/extended/rewritten through one of the phase hooks or
sent by a plugin through self._printer.commands will also be tagged with
"plugin:<plugin identifier>", allowing other code to detect these tags
and handle such commands differently.

That will be interesting for plugins that need to differentiate between
commands originating from the printed file vs the user vs the system vs
other plugins.
2018-02-16 18:41:17 +01:00
Gina Häußge 1587ee6402 Forgot to adjust migrated settings locs in comm layer 2018-02-16 10:24:13 +01:00
Gina Häußge eadb4a5bb6 [Docs] document new capabilities config settings 2018-02-15 17:10:15 +01:00
Gina Häußge 5c63e618b1 Refactor serial settings
* migrate several actually serial & protocol related settings from
    feature settings to serial settings
  * migrate terminal auto uppercase blacklist from serial settings to
    feature settings
  * restructure the serial settings dialog
  * adjust docs accordingly
2018-02-15 17:05:01 +01:00
Gina Häußge be3907c7d1 Allow disabling busy & autoreport support 2018-02-15 11:56:29 +01:00
Gina Häußge 8732ec9756 Introduce ok timeout to detect stalls in auto report scenarios
If a printer supports auto reporting the temperature but doesn't also
support sending "wait" if the command buffer runs dry, it can happen
that a lost "ok" never gets detected properly because no timeout is ever
triggered (the printer is in fact sending data after all), but we should
actually try to get comms running again.

Introducing a custom ok timeout solves this. We reset this every time we
see an "ok", "wait" or "busy", but if we run into it while printing we
perform the same steps as if we hadn't received any data at all from the
printer over the duration of the currently active communication timeout
value (whether to choose "communication" or "communicationBusy" here
depends on whether we also detected support of the busy protocol or
not).
2018-02-15 11:56:28 +01:00
Gina Häußge 7d3d3408eb Switch to lower comm timeouts on busy protocol detection
If the printer supports the busy protocol (which we should automatically
notice by it using it on the first blocking heatup or otherwise blocking
operation), it's safe reduce the communication timeout to a way way
lower value since the busy protocol should guarantee a heartbeat from
the printer at known intervals and so timeouts really should only happen
if something gets lost on the way.

We also set the interval on the printer to our configured busy timeout
minus 1s so we can be sure that we should always see a busy line from
the printer before we run into our own timeout. We do this via M113.
2018-02-15 11:56:28 +01:00
Gina Häußge 6afb291440 Merge pull request #2422 from koenkooi/balloon-maintenance
piptestballoon: fix typo in comment: intenional -> intentional
2018-02-13 10:41:01 +01:00
Koen Kooi 522ee49b5b piptestballoon: fix typo in comment: intenional -> intentional
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
2018-02-13 10:35:08 +01:00
Gina Häußge de9fdf79c4 Merge branch 'improve/trustBasicAuth' into maintenance 2018-02-12 15:27:24 +01:00
Gina Häußge 26dbf59251 Allow newer versions of pyserial
This will allow our fix for #2333 to become active even with OctoPrint
1.3.7 if the user manually upgrades pyserial to version 3.1 or newer.
2018-02-12 14:39:58 +01:00
Gina Häußge 8ad0aadb52 SWU: Workaround for pip problem with eggs
Starting with pip 7.x pip runs into an issue if a software package
formerly installed as a Python egg (= zip file stored in site-packages,
referenced through easy-install.pth, e.g. through a stand alone "python
setup.py install") is to be updated to a newer version.

The issue arises since the egg is still on the python path after the
replacement has taken place, and pip tries to read from it without error
handling for the fact that this file is now not longer existing. The
source of the problem appears to be with both the bundled as well as the
stock versions of pkg_resources and pip's usage of them to perform its
management duties. It's currently unclear if the problem is a bug or a
feature, even though it strongly looks like the first one.

In any case, during tests it was found that this problem can be worked
around by simply performing a second "pip install" with same parameters
right after the failed first one.

This patch detects this scenario based on the logged error message and
performs the second install if deemed necessary.

This is a preparational step to allow upgrade of the pyserial dependency
(and other dependencies currently installed as eggs as part of
OctoPrint's former "python setup.py install" installation procedure)
with OctoPrint 1.3.8, to finalize the fix for #2333.
2018-02-12 14:39:58 +01:00
Gina Häußge 87921061d9 SWU: New version checkers for debugging
* always_current: Always reports as current
  * never_current: Always reports as needing an update
2018-02-12 14:39:58 +01:00
Gina Häußge 6812001639 SWU: Point to log file by name in error messages 2018-02-12 14:39:58 +01:00
Gina Häußge 00616a3d73 Merge pull request #2411 from kantlivelong/terminal_autoscroll_enchancements
ENHANCEMENT: Terminal: Autoscroll Enhancements
2018-02-08 20:36:57 +01:00
Shawn Bruce a7a78c11d4 Terminal: Autoscroll Enhancements
* Disable autoscroll when scrolling up.
	* Scroll to bottom when autoscroll is toggled to enable.
2018-02-08 13:32:08 -05:00
Gina Häußge 60c7974aa4 Revert "Update to pyserial 3.4"
This is causing issues on update thanks to the PySerial installation
logging an error if the former version was installed through
dependency resolution during OctoPrint's python setup.py install run
(which is most likely the case for pretty much all live installations
out there).

Update (and hence activation of fix for #2333) postponed until a
solution for this issue is found.

This reverts commit 77989d2a76.
2018-02-08 16:53:45 +01:00
Gina Häußge 441db2dbbc Merge pull request #2409 from koenkooi/mkv-maintenance
timelapse: add m4v and mkv as supported container formats
2018-02-08 15:50:28 +01:00
Koen Kooi 066d3d7422 timelapse: add m4v and mkv as supported container formats
Not every player can handle non-mpeg2 codecs inside a .mpg. QuickTime
Player on OSX goes a step further and won't play h264-in-mp4, only
h264-in-m4v.
2018-02-08 15:44:55 +01:00
Gina Häußge 98b71a5870 Tell PySerial to cancel reads & writes on connection close
Only done if the methods needed for that exist and are callable though
(to prevent issues with custom serial port implementations provided
through hooks, or operating systems that don't have support for
cancel_read/cancel_write in PySerial.

Fixes #2333 (at least as far as we'll ever be able to fix it)
2018-02-08 15:17:12 +01:00
Gina Häußge 77989d2a76 Update to pyserial 3.4 2018-02-08 15:04:36 +01:00
Gina Häußge f35fe32a92 Better fix of "copy all" on Terminal tab
See also #2392
2018-02-08 12:36:31 +01:00
Gina Häußge b79f669351 Fix "copy all" on Terminal tab
Closes #2392
2018-02-08 12:28:36 +01:00
Gina Häußge 528bd90d02 Merge pull request #2406 from kantlivelong/about_showTab_fix
BUGFIX: Fix showTab function
2018-02-07 17:51:12 +01:00
Gina Häußge b8d23c8bc1 Logging: Fix a return value 2018-02-07 16:46:33 +01:00
Gina Häußge bb822fb9dd Logging: add/move docs for the plugin 2018-02-07 14:18:52 +01:00
Gina Häußge 77aeb6146e Logging: redirects for backwards compatibility 2018-02-07 14:18:51 +01:00
Gina Häußge de253e5086 Logging: some refactoring and fixes
* logs => logging
  * i18n
  * Add JS client & streamline API
  * Whitespace and metadata fix
  * Add LESS/CSS files
  * camelCase => snake_case
  * fix log deletion & add missing var
2018-02-07 14:17:53 +01:00
Shawn Bruce 986591aed4 Logging: extract log managment into bundled plugin 2018-02-07 14:11:49 +01:00
Shawn Bruce 48f87b2979 Fix showTab function 2018-02-06 11:20:55 -05:00
Gina Häußge ec12bd7cd4 Introduce CaseInsensitiveSet & use for valid boolean trues
Follow up to #2385
2018-02-06 10:15:57 +01:00
tedder b3b19dc136 add 'True' as a string as a boolean
This allows pythonic API clients to pass boolean values in:

requests.get('/api/printer', params={'history': True})

Previously this didn't work, as Octoprint doesn't see True as a boolean, it gets a sting. So it never matches True, it only matches "True".

Easy to test:
curl -H "X-Api-Key: x" http://octopi.local/api/printer?history=true | grep history
curl -H "X-Api-Key: x" http://octopi.local/api/printer?history=True | grep history
2018-02-06 09:48:49 +01:00
Gina Häußge 9f1abee023 Add refresh button to the connection panel 2018-02-06 09:31:48 +01:00
Gina Häußge fca7005bfa [Docs] Document basic auth config settings 2018-02-05 15:54:12 +01:00
Gina Häußge fcf7358855 BasicAuth: Check PW too by default
Also slightly refactored to deduplicate.
2018-02-05 15:37:46 +01:00
Gina Häußge c050bd15ac Merge branch 'basic_auth_autologin' of https://github.com/bzed/OctoPrint into maintenance 2018-02-05 12:31:26 +01:00
Gina Häußge 3e236dc57d Temperature graph: Small axis fixes
* remove "just now" X axis tick, we just don't show anything for less
    than a minute ago now
  * add unit to Y axis ticks

Closes #2371
2018-02-05 12:27:57 +01:00
Gina Häußge aa0ea299ea Docs for printer profile related bits and pieces 2018-02-01 18:26:13 +01:00
Bernd Zeimetz 57a58b3bd7 Trust basic authentication headers for user login.
This is my suggestion on how to handle basic authentication for users
mananaged by OctoPrint's UserManager.

In my opinion OctoPrint should not be doing Basic Authentication on its
own. The commen case is that it runs on some slow hardware which its not
able to handle stupid bots trying out thousands of passwords in short
time. Also you want to protect it as much as possible from the outside
to ensure that the basd internet can't break your 72h print after 71
hours by brute-forcing passwords.

So I'm introducing an
  accessControl: trustBasicAuthentication
config option. If enabled, it will take the user name from the
Authorization header, check if the user exists and is enabled - and if
so, just login the user.
2018-01-22 21:32:04 +01:00
Gina Häußge 67005577b7 Cura plugin: str to unicode
Closes #2368
2018-01-22 17:48:32 +01:00
Gina Häußge b1f9e070a4 Return 403 instead of 401 on missing/insufficient credentials
Closes #2297
2018-01-22 16:06:36 +01:00
Gina Häußge b5aae0b8fa Improve resilience against errors on file listing
Closes #2294
2018-01-22 13:51:32 +01:00
Gina Häußge 1b5b243760 Merge pull request #2338 from kantlivelong/octoprint_comm_protocol_scripts_enhancement
Allow plugins to define gcode script variables using the octoprint.comm.protocol.scripts hook
2018-01-22 12:07:13 +01:00
Shawn Bruce 6545f9a816 Allow plugins to define gcode script variables using the octoprint.comm.protocol.scripts hook 2018-01-12 13:05:45 -05:00
Gina Häußge c11288ff65 Merge pull request #2337 from kantlivelong/autoconnect_fix
BUGFIX: Fix autoconnect on start so that it works with the port set to AUTO (#2311)
2018-01-12 15:35:50 +01:00
tedder ed70944f69 grammatical fix in text
[It's a common error](https://brians.wsu.edu/2016/05/31/setup-set-up/); I'm not sure if it needs to be fixed in all three places or perhaps only in the .pot file.

(cherry picked from commit a77fbfe)
2018-01-12 15:34:05 +01:00
Gina Häußge 88cb28cec9 More resilience against possible None parameters 2018-01-12 15:29:06 +01:00
Shawn Bruce 15c390b199 Fix autoconnect on start so that it works with the port set to AUTO (#2311) 2018-01-03 00:08:44 -05:00
Shawn Bruce 8b09b11faa Check for valid queue entry before attempting to dequeue. 2017-12-27 11:31:42 -05:00
Gina Häußge bad3612ed2 Minimum temperature cutoff is now 1 min
Solves core reason of #2213
2017-12-14 18:10:41 +01:00
Gina Häußge b079978384 Fix missing line break in case of > 3 announcements 2017-12-14 14:06:48 +01:00
Gina Häußge 13558c01f9 Merge branch 'staging/maintenance' into maintenance 2017-12-12 13:09:24 +01:00
Gina Häußge 777c02135e Fixed a copy paste error in the changelog 2017-12-12 12:42:40 +01:00
Gina Häußge 793bb714eb Preparing release of 1.3.6 2017-12-12 10:36:33 +01:00
Gina Häußge 8229842334 Revert "Some long overdue == vs === view model cleanup"
This reverts commit 8a977e8777.

Was causing at least one regression, to be redone for 1.3.7
2017-12-12 10:09:27 +01:00
Gina Häußge ef6b39757b Merge branch 'maintenance' of github.com:foosel/OctoPrint into maintenance 2017-12-08 16:22:19 +01:00
Gina Häußge 2cae028d47 Merge branch 'staging/maintenance' into maintenance 2017-12-08 16:22:05 +01:00
Gina Häußge 38a711ac56 staging is now 1.3.6rc4 2017-12-08 16:21:05 +01:00
Gina Häußge a8747f7e36 Fix a bug with release vs dev version detection 2017-12-08 15:09:58 +01:00
Gina Häußge 17e6f5d508 Preparing release of 1.3.6rc3 2017-12-07 17:40:04 +01:00
Gina Häußge 133a4658ee Switch to https for (plugins.)octoprint.org
Also add utm tags to the two support-octoprint links so we have a chance
to see if anyone ever actually clicks on those.
2017-12-07 16:35:01 +01:00
Gina Häußge 0a2e2ed297 Don't write default update type & method to config
If we set method to pip in 1.3.6 and then roll back to 1.3.5 we will
need to a manual config.yaml update otherwise or we will no longer be
able to update.

Be removing the force parameter and using the actual default settings
instead of current ones, we don't do that anymore.
2017-12-07 11:15:43 +01:00
Gina Häußge 86934c8863 Support M114 response from RepRapFirmware
RRF uses format X:... Y:... Z:... E0:... E1:... instead of
X:... Y:... Z:... E:...
2017-12-06 16:03:19 +01:00
Gina Häußge 13eb5ec7ed Merge pull request #2250 from kantlivelong/resettable_timer
Added ResettableTimer class
2017-12-06 11:42:45 +01:00
Shawn Bruce 6ce6160f3d Added ResettableTimer class 2017-12-05 12:00:12 -05:00
Gina Häußge 9bdbb930ad Merge branch 'staging/maintenance' into maintenance 2017-12-05 16:01:28 +01:00
Gina Häußge 6b41dbc12b staging is 1.3.6rc3.dev 2017-12-05 16:00:58 +01:00
Gina Häußge 03d24ff3b9 maintenance is now 1.3.7.dev 2017-12-01 16:07:50 +01:00
339 changed files with 28322 additions and 10606 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
+54 -34
View File
@@ -1,29 +1,25 @@
<!--
READ THE FOLLOWING FIRST:
If not already done, please read the "guidelines for contributing"
aka the Contribution Guidelines that are linked ^-- just up there
in the big yellow box.
If not already done, please read the the Contribution Guidelines that
are linked to the right under "Helpful resources" > "Contributing".
Also read the FAQ: https://github.com/foosel/OctoPrint/wiki/FAQ.
Also read the FAQ: https://faq.octoprint.org
This is a bug and feature tracker, please only use it to report bugs
or request features within OctoPrint (not OctoPi, not any OctoPrint
plugins and not unofficial OctoPrint versions).
Do not seek support here ("I need help with ...", "I have a
question ..."), that belongs on the mailing list or the G+ community
(both linked in the "guidelines for contributing" linked above, read
them!), NOT here.
question ..."), that belongs on the community forum at
discourse.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
where to find some information - it's all described in the Contribution
Guidelines linked up there in the big yellow box).
When reporting a bug do NOT delete ANY lines from the template but
those enclosed in [ and ] - and those please DO delete, they are
only provided for your information and removing them makes your
ticket more readable :)
When reporting a bug do NOT delete ANY lines from the template.
Make sure any bug you want to report is still present with the CURRENT
OctoPrint version and that it does not vanish when you start OctoPrint
@@ -31,27 +27,26 @@ in safe mode - how to do that is also explained in the Contribution
Guidelines linked up there in the big yellow box.
Thank you!
(Before submitting your ticket, please delete this text up to and
including the line too - it's only here for you, we already know it
by heart ;))
----
-->
#### What were you doing?
[Please be as specific as possible here. The maintainers will need to
<!--
Please be as specific as possible here. The maintainers will need to
reproduce your issue in order to fix it and that is not possible if they
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. ...
<!--
If you encountered a problem with specific files of any sorts, make sure
to also include a link to a file with which to reproduce the problem.]
to also include a link to a file with which to reproduce the problem.
-->
#### What did you expect to happen?
@@ -59,50 +54,75 @@ to also include a link to a file with which to reproduce the problem.]
#### Did the same happen when running OctoPrint in safe mode?
[Try to reproduce your problem in safe mode. You can find information
on how to enable safe mode in the Contribution Guidelines.]
<!--
Test if you can reproduce your problem in safe mode. You can find information
on how to enable safe mode in the Contribution Guidelines.
If you can't reproduce in safe mode, this is a bug with one of your
installed third party plugins. Don't open a ticket here!
If you can't test this in safe mode, state why.
-->
#### Version of OctoPrint
[Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.]
<!--
Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.
-->
#### Operating System running OctoPrint
[OctoPi, Linux, Windows, MacOS, something else? With version please.
OctoPi's version can be found in /etc/octopi_version]
<!--
OctoPi, Linux, Windows, MacOS, something else? With version please.
OctoPi's version can be found in /etc/octopi_version or in the lower left
corner of the web interface.
-->
#### Printer model & used firmware incl. version
[If applicable, always include if unsure.]
<!--
If applicable, always include if unsure.
-->
#### Browser and Version of Browser, Operating System running Browser
#### Browser and version of browser, operating system running browser
[If applicable, always include if unsure.]
<!--
If applicable, always include if unsure.
-->
#### Link to octoprint.log
[On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
The Contribution Guidelines tell you where to find that.]
<!--
On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
The Contribution Guidelines tell you where to find that.
-->
#### Link to contents of terminal tab or serial.log
[On gist.github.com or pastebin.com. If applicable, always include if unsure or
<!--
On gist.github.com or pastebin.com. If applicable, always include if unsure or
reporting communication issues. Never truncate.
serial.log is usually not written due to performance reasons and must be
enabled explicitly. Provide at the very least the FULL contents of your
terminal tab at the time of the bug occurrence, even if you do not have
a serial.log (which the Contribution Guidelines tell you where to find).]
a serial.log (which the Contribution Guidelines tell you where to find).
-->
#### Link to contents of Javascript console in the browser
[On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
<!--
On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
always include if unsure or reporting UI issues.
The Contribution Guidelines tell you where to find that.]
The Contribution Guidelines tell you where to find that.
-->
#### Screenshot(s)/video(s) showing the problem:
[If applicable. Always include if unsure or reporting UI issues.]
<!--
If applicable. Always include if unsure or reporting UI issues.
-->
I have read the FAQ.
+10 -8
View File
@@ -1,3 +1,4 @@
<!--
Thank you for your interest into contributing to OctoPrint, it's
highly appreciated!
@@ -7,6 +8,7 @@ as well that contains important information.
As a summary, please make sure you have ticked all points on this
checklist:
-->
* [ ] Your changes are not possible to do through a plugin and relevant
to a large audience (ideally all users of OctoPrint)
@@ -16,12 +18,13 @@ checklist:
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
against master or anything else)
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),
e.g. dev/my_new_feature
e.g. dev/my_new_feature or fix/my_bugfix
* [ ] Your PR only contains relevant changes: no unrelated files,
no dead code, ideally only one commit - rebase your PR if necessary!
no dead code, ideally only one commit - rebase and squash your PR
if necessary!
* [ ] Your changes follow the existing coding style
* [ ] If your changes include style sheets: You have modified the
.less source files, not the .css files (those are generated with
@@ -32,11 +35,10 @@ checklist:
nothing broke
* [ ] You have added yourself to the AUTHORS.md file :)
Feel free to delete all this help text, then describe
your PR further. You may use the template provided below to do that.
The more details the better!
----
<!--
Describe your PR further using the template provided below. The more
details the better!
-->
#### What does this PR do and why is it necessary?
+10 -8
View File
@@ -7,25 +7,27 @@
# The file is processed from top to bottom, the first matching line wins. If <tag> or <reference commit> are left out,
# the lookup table does not apply to the matched branches
# master and rc shall not use the lookup table, only tags
# master, meta, rc and prerelease shall not use the lookup table, only tags
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.6
# maintenance is currently the branch for preparation of maintenance release 1.3.9
# so are any fix/... and improve/... branches
maintenance 1.3.6 1a6dbb3f4a5bef857cdeb13c031b9deca2cf30a2 pep440-dev
fix/.* 1.3.6 1a6dbb3f4a5bef857cdeb13c031b9deca2cf30a2 pep440-dev
improve/.* 1.3.6 1a6dbb3f4a5bef857cdeb13c031b9deca2cf30a2 pep440-dev
maintenance 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
fix/.* 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
improve/.* 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.3.6rc2
# staging/maintenance is currently the branch for preparation of 1.3.9rc5
# so is regressionfix/...
staging/maintenance 1.3.6rc2 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
regressionfix/.* 1.3.6rc2 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
staging/maintenance 1.3.9rc5 71b2cc87a36d403e09325c90134a002c5229b6aa pep440-dev
regressionfix/.* 1.3.9rc5 71b2cc87a36d403e09325c90134a002c5229b6aa 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
+6
View File
@@ -86,6 +86,12 @@ date of first contribution):
* [Peter Backx](https://github.com/pbackx)
* [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)
* [Brad Fisher](https://github.com/bradcfisher)
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
+276 -13
View File
@@ -1,25 +1,274 @@
# OctoPrint Changelog
## 1.3.6rc2 (2017-12-05)
## 1.3.9 (2018-07-25)
### Note for upgraders and plugin authors: Change in the bundling of JS assets can lead to issues in plugins
### Still running OctoPrint 1.3.6? Heads-up!
A change to solve issues with plugins bundling JS assets that cause interference with other plugins (e.g. through the declaration of `"use strict"`) and in general to add better isolation and error handling might cause errors for some plugins that go beyond your run-off-the-mill view model and also implicitly declare new globals.
OctoPrint 1.3.9 includes a couple of dependency updates whose update during switch to 1.3.9 are known to trigger an "update failed" message within OctoPrint's update dialog:
If you happen to run into any such issues, you can switch back to the old way of bundling JS assets via the newly introduced "Settings > Feature > Enable legacy plugin asset bundling" toggle (check it, save the settings, restart the server). This is provided to allow for a minimally invasive adjustment period until affected plugins have been updated.
![](https://i.imgur.com/BbEZTlc.png)
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](http://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
The update did in fact succeed and the issue lies with a change in the underlying update mechanism concerning the dependencies. This problem has been fixed in 1.3.7/1.3.8 and versions prior to 1.3.6 aren't yet affected, so there you won't ever see this message there. If you are still running 1.3.6 though and updating from it, **simply run the update a second time through Settings > Software Update > Check for updates and clicking "Update now" in the reshown update notification**.
### Running NGINX as reverse proxy? Be sure to configure HTTP protocol version 1.1!
OctoPrint 1.3.9 updates the internal webserver Tornado from 4.0.2 to 4.5.3. Among many many fixes and improvements this also includes a change (actually a fix) in the websocket implementation that requires you to tell your NGINX to use HTTP 1.1 instead of the default 1.0 to talk to OctoPrint. You can do this by simply adding
```
proxy_http_version 1.1;
```
to the `location` config. The [configuration examples](https://discourse.octoprint.org/t/reverse-proxy-configuration-examples/1107) have been adjusted accordingly. See also [#2526](https://github.com/foosel/OctoPrint/issues/2526).
### Disabled IPv6 and now there are issues with the server after the update? Bind to IPv4 addresses only!
Starting with this release OctoPrint natively supports IPv6 and will attempt to bind to such addresses if it detects support in the underlying OS. If for whatever reason your OS doesn't support IPv6 even though Python's `socket` says otherwise, you can tell OctoPrint to bind to an IPv4 address only either via the `--host` command line parameter or `server.host` in `config.yaml`. Use `127.0.0.1` for localhost only, `0.0.0.0` for all IPv4 addresses or whatever specific IPv4 address you want to bind to.
### Plugin author and still dependent on the legacy plugin bundling flag? Fix your plugin!
As [announced with the release of OctoPrint 1.3.6](https://octoprint.org/blog/2017/12/12/new-release-1.3.6/), the legacy plugin bundling flag has now been removed again. [Make sure to check and if necessary fix your plugins](https://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/) if you haven't done that so far!
### Improvements
* [#652](https://github.com/foosel/OctoPrint/issues/652) & [#1545](https://github.com/foosel/OctoPrint/issues/1545) - Added name of user who started a job to job info (see also [#2576](https://github.com/foosel/OctoPrint/pull/2576)).
* [#1203](https://github.com/foosel/OctoPrint/issues/1203) & [#1905](https://github.com/foosel/OctoPrint/issues/1905) & [#1797](https://github.com/foosel/OctoPrint/issues/1797) & [#2514](https://github.com/foosel/OctoPrint/issues/2514) - Added support for plugins to override GCODE analysis provider and live print time estimation with their own implementations through two new hooks [`octoprint.filemanager.analysis.factory`](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-filemanager-analysis-factory) and [`octoprint.printer.estimation.factory`](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-printer-estimation-factory).
* [#1217](https://github.com/foosel/OctoPrint/issues/1217) - Software Update Plugin: Block the UI in general when an update is in progress (even in browser windows that didn't start it and logged in as user) so that no prints can be accidentally started during that.
* [#1513](https://github.com/foosel/OctoPrint/issues/1513) - Option to allow sending `M0`/`M1` to the printer instead of swallowing it.
* [#2318](https://github.com/foosel/OctoPrint/issues/2318) - Gcode Viewer: Visualize "current" print head location with a marker.
* [#2351](https://github.com/foosel/OctoPrint/issues/2351) - Support for binding to IPv6 addresses. OctoPrint will now default to binding to `::` if IPv6 support is detected, and to `0.0.0.0` if not. Both the 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)
* [#2379](https://github.com/foosel/OctoPrint/issues/2379) - File and plugin list now use the browser's native scrollbar instead of slimscroll. Slimscroll is still bundled though, in case third party plugins might depend on it.
* [#2487](https://github.com/foosel/OctoPrint/issues/2487) - Improved documentation of system command configuration (see also [#2498](https://github.com/foosel/OctoPrint/pull/2498)).
* [#2495](https://github.com/foosel/OctoPrint/pull/2495) - Removed unneeded filter from a template.
* [#2498](https://github.com/foosel/OctoPrint/pull/2498) - Improved documentation of the `async` flags of custom system commands.
* [#2512](https://github.com/foosel/OctoPrint/issues/2512) - Log files will now contain client IP as provided by first entry in X-Forwarded-For header (or more if `server.reverseProxy.trustDownstream` is configured accordingly).
* [#2518](https://github.com/foosel/OctoPrint/issues/2518) - Display absolute file upload date and time on hover (see also [#2630](https://github.com/foosel/OctoPrint/pull/2630)).
* [#2522](https://github.com/foosel/OctoPrint/issues/2522) - Perform logging to disk asynchronously to avoid slow downs caused by it.
* [#2541](https://github.com/foosel/OctoPrint/pull/2541) - Added link to instructions to reset passwords. Part of solving [#1239](https://github.com/foosel/OctoPrint/issues/1239).
* [#2543](https://github.com/foosel/OctoPrint/pull/2543) - Added `--no-cache-dir` to pip calls to work around `MemoryErrors`. See also [#2535](https://github.com/foosel/OctoPrint/pull/2535) and [pypa/pip#2984](https://github.com/pypa/pip/issues/2984) for more details.
* [#2558](https://github.com/foosel/OctoPrint/issues/2558) - Have the watched folder processor ignore hidden files.
* [#2572](https://github.com/foosel/OctoPrint/issues/2572) - More error resilience in `ItemListHelper` against empty child elements.
* [#2573](https://github.com/foosel/OctoPrint/pull/2573) - Added `M118` to commands to never automatically upper case.
* [#2583](https://github.com/foosel/OctoPrint/issues/2583) - Handle scripts that are part of a job like other lines coming from a job and thus allow them to be kept back using `job_on_hold`.
* [#2597](https://github.com/foosel/OctoPrint/issues/2597) - Disabled animation on cancel print confirmation.
* [#2463](https://github.com/foosel/OctoPrint/issues/2463) - Added documentation for `printingarea` and `dimensions` in `gcodeAnalysis` data model (see also [#2540](https://github.com/foosel/OctoPrint/pull/2540)).
* [#2615](https://github.com/foosel/OctoPrint/issues/2615) - Allowed more granular control over components to be upgraded through the software update plugin in its settings dialog.
* [#2620](https://github.com/foosel/OctoPrint/pull/2620) - Save `ItemListHelper` page sizes to local storage.
* [#2642](https://github.com/foosel/OctoPrint/pull/2642) - Added methods for adding and updating items to `ItemListHelper`.
* [#2644](https://github.com/foosel/OctoPrint/issues/2644) - Detect broken symlinks in configured folders on startup (see also further below).
* [#2648](https://github.com/foosel/OctoPrint/pull/2648) - Allowed class methods as callbacks in view models.
* A new API endpoint [`/api/settings/templates`](http://docs.octoprint.org/en/maintenance/api/settings.html#fetch-template-data) allows (admin only) access to information regarding the loaded templates and their order in the UI. That should allow plugins wishing to offer modification of ordering of tabs, sidebar components and so on to retrieve the data they need for that.
* Have the watched folder processor handle vanished files gracefully.
* Removed [`legacyPluginAssets` flag](https://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
* Improved requirement detection in `octoprint_setuptools`, added unit tests for that.
* Bundled `sockjs-tornado` dependency. It hasn't been updated by the author in a while although there exist a number of issues plus patches for them, so we now vendor it.
* Disabled position logging on cancel by default. If you need this, please explicitly enable it, it is causing too many issues in the field with misbehaving firmware.
* Extended URL test API to allow whitelist/blacklist check for the returned content type, used that to verify that the webcam snapshot URL actually returns images.
* Added timeout for position logging on pause/cancel. This should work around firmware which doesn't provide a proper `M114` resport that might be unparseable so we won't get stuck in those cases.
* Migrated file storage metadata to json instead of YAML since it performs way way better.
* Added `missing linenumber` to recognized non-fatal error messages.
* Got rid of some Python 2 only code.
* Added sanity checks for configured folders (see also [#2644](https://github.com/foosel/OctoPrint/issues/2644)):
* 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
* Never send referrers with links
* Confirmation dialog helper now supports an HTML body.
* Sort serial ports naturally (e.g. `tty1`, `tty2`, ..., `tty10` instead of `tty1`, `tty10`, ...)
* Added `paused` and `resumed` action commands, [see here for details](http://docs.octoprint.org/en/maintenance/features/action_commands.html).
* Added two new hooks for firmware information, [`octoprint.comm.firmware.info`](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-comm-firmware-info) and [`octoprint.comm.firmware.capabilities`](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-comm-firmware-capabilities).
* Added view model list to `OctoPrint.coreui` UI module.
* Improved logging of `FatalStartupError`s.
* Add sanity check for disabled plugin list (see also [#2687 (comment)](https://github.com/foosel/OctoPrint/issues/2687#issuecomment-399797596)).
* Improve logging of exceptions triggered inside the state update worker (see also [#2715](https://github.com/foosel/OctoPrint/issues/2715)).
* Workaround for a potential `pip` issue when updating components through the Software Update plugin.
* Fix resend and timeout handling during an active `job_on_hold`.
* Updated some dependencies:
* Tornado to 4.5. Version 5 sadly has issues with web socket handling when access behind `haproxy`. So far no solution has been found, so we stay at 4.5 for now.
* jQuery to 3.3.1
* Several other Python dependencies
* Announcement Plugin: Don't reload all notifications if one is marked as read.
* Printer Safety Plugin: Added new detected firmwares:
* Anycubic Mega
* Malyan M200
* CR-10S
* all Repetier firmware versions prior to 0.92
* any firmware that reports the `THERMAL_PROTECTION` capability as disabled to thermal protection warning (see also [MarlinFirmware/Marlin#10465](https://github.com/MarlinFirmware/Marlin/pull/10465))
* Software Update Plugin: Default to `force_base = False` for version checks.
* Virtual Printer Plugin: Allow defining custom `M114` response formats.
### Bug fixes
* [#2262](https://github.com/foosel/OctoPrint/issues/2262) - Fixed a bug causing `Error:checksum mismatch, Last Line: ...` errors from the firmware to be handled incorrectly.
* [#2267](https://github.com/foosel/OctoPrint/issues/2267) - Fixed a bug causing the GCODE viewer to not get properly initialized due to a JS error on load if "Also show next layer" was selected.
* [#2268](https://github.com/foosel/OctoPrint/issues/2268) - Fixed a bug causing a display error with the temperature offsets. If one offset was changed, all others seemed to revert back to 0.
* Fixed ordering of plugin assets, should be alphabetical based on the plugin identifier.
* [#2333](https://github.com/foosel/OctoPrint/issues/2333) (Part 3/3) - Updated to PySerial 3.4 and utilize read and write cancelling to work around disconnect delays.
* [#2355](https://github.com/foosel/OctoPrint/issues/2355) - Fixed non deterministic sorting of files with missing fields (e.g. date for SD card files) in OctoPrint's frontend.
* [#2496](https://github.com/foosel/OctoPrint/issues/2496) - Fixed files API not allowing to walk through the directory tree unless fetching the full listing recursively by making sure that first level children nodes are always provided.
* [#2502](https://github.com/foosel/OctoPrint/pull/2502) - Fixed some invalid HTML
* [#2504](https://github.com/foosel/OctoPrint/pull/2504) & [#2532](https://github.com/foosel/OctoPrint/pull/2532) & [#2552](https://github.com/foosel/OctoPrint/pull/2552) - Fixed various typos
* [#2505](https://github.com/foosel/OctoPrint/issues/2505) - Fixed user switch to `_api` user on use of the global API key inside the browser.
* [#2509](https://github.com/foosel/OctoPrint/issues/2509) - Properly handle a printer reset while printing and don't get stuck in "Cancelling" state
* [#2517](https://github.com/foosel/OctoPrint/issues/2517) - Fixed baudrate negotiation with printers that need a bit of a delay between connection establishment and probing (e.g. Prusa MK3).
* [#2520](https://github.com/foosel/OctoPrint/issues/2520) - Fixed temperature presets being saved as strings instead of numbers.
* [#2533](https://github.com/foosel/OctoPrint/pull/2533) - Fixed API key copy button being enabled and generate button being disabled when no API key is set.
* [#2534](https://github.com/foosel/OctoPrint/issues/2534) - Fixed stale data in API key/user editor. See also [#2604](https://github.com/foosel/OctoPrint/pull/2604).
* [#2539](https://github.com/foosel/OctoPrint/issues/2539) - Made serial and baud rate lists consistent between connection panel and settings (see also [#2606](https://github.com/foosel/OctoPrint/pull/2606)).
* [#2547](https://github.com/foosel/OctoPrint/issues/2547) - Fixed `PrintFailed` being triggered in case of an error while processing the `afterPrintJobDone` GCODE script through introduction of `Resuming` and `Finishing` states.
* [#2549](https://github.com/foosel/OctoPrint/issues/2549) - Fixed "uninstall plugin" icon in Plugin Manager staying clickable even if disabled.
* [#2549](https://github.com/foosel/OctoPrint/issues/2549) - Fixed issue with detection uninstallation of disabled plugins (see also [#2650](https://github.com/foosel/OctoPrint/pull/2650)).
* [#2551](https://github.com/foosel/OctoPrint/issues/2551) - Fixed `0` being allowed for various intervals and timeouts where that values doesn't make sense.
* [#2554](https://github.com/foosel/OctoPrint/pull/2554) - Fixed a JSON example in the docs.
* [#2568](https://github.com/foosel/OctoPrint/pull/2568) - Fixed a dead link in the plugin hooks documentation in the docs.
* [#2579](https://github.com/foosel/OctoPrint/issues/2579) - Fixed print time left of "a couple of seconds" even after the print job has finished.
* [#2581](https://github.com/foosel/OctoPrint/issues/2581) & [#2587](https://github.com/foosel/OctoPrint/issues/2587) - Fixed OctoPrint getting stuck in "Pausing" or "Cancelling" state due to a race condition.
* [#2589](https://github.com/foosel/OctoPrint/issues/2589) - Added missing `typePath` field on API response for files on the printer's SD card.
* [#2591](https://github.com/foosel/OctoPrint/pull/2591) - Fixed markup of some HTML labels.
* [#2595](https://github.com/foosel/OctoPrint/pull/2595) - Fixed some UI appearance issues.
* [#2601](https://github.com/foosel/OctoPrint/issues/2601) - Properly handle relative paths for selection via `printer.select_file`.
* [#2621](https://github.com/foosel/OctoPrint/issues/2621) - Fixed framerate not being read from config for rendering unrendered timelapses.
* [#2625](https://github.com/foosel/OctoPrint/issues/2625) - Fixed incompatibility of OctoPrint's plugin subsystem with Python wheels, which are the default mode of installing plugins from pip version 10.0.0 onward.
* [#2632](https://github.com/foosel/OctoPrint/issues/2632) - Fixed race condition in resend handling on missing `ok`s.
* [#2675](https://github.com/foosel/OctoPrint/issues/2675) - Fixed a possible division by zero on SD upload.
* [#2677](https://github.com/foosel/OctoPrint/issues/2677) (regression) - Fix a deadlock when `job_on_hold` is utilized (causing issues at least with Octolapse)
* [#2683](https://github.com/foosel/OctoPrint/pull/2683) - Fixed two missing spaces in the german translation.
* [#2715](https://github.com/foosel/OctoPrint/issues/2715) (regression) - Fix broken estimator initialization on SD print start and resulting crash of the state update worker.
* [#2719](https://github.com/foosel/OctoPrint/issues/2719) (regression) - Fix live print time estimation
* [#2737](https://github.com/foosel/OctoPrint/issues/2737) (regression) - Fix print button being enabled even though no file is selected.
* [#2738](https://github.com/foosel/OctoPrint/issues/2738) (regression) - Limit the use of the `--no-cache-dir` argument added to `pip` calls to such versions of `pip` that already support it (anything newer than 1.5.6).
* Properly handle absolute paths for recovery data comparison.
* Fixed snapshot test button not resetting on error.
* Fixed decoupling of metadata logs in the file manager.
* Fixed "remember me" and IPv4/IPv6 sessions. This might also solve [#1881](https://github.com/foosel/OctoPrint/issues/1881).
* Removed Repetier resend repetition detection and handling code. It was buggy and introducing issues.
* Fixed script order: `beforePrint*` should always precede any commands from the print job.
* Only perform write tests on directories where necessary. Especially avoid them on page rendition to prevent misconfigured folders from triggering an HTTP 500. (regression)
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.6rc1...1.3.6rc2))
### Special thanks to all the contributors!
## 1.3.6rc1 (2017-12-01)
Special thanks to everyone who contributed to this release, especially [@benlye](https://github.com/benlye), [@dadosch](https://github.com/dadosch), [@dforsi](https://github.com/dforsi), [@ganey](https://github.com/ganey),[@malnvenshorn](https://github.com/malnvenshorn), [@ntoff](https://github.com/ntoff), [@tedder](https://github.com/tedder) and [@vitormhenrique](https://github.com/vitormhenrique) for their PRs.
### More information
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.8...1.3.9)
* Release Candidates:
* [1.3.9rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.9rc1)
* [1.3.9rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.9rc2)
* [1.3.9rc3](https://github.com/foosel/OctoPrint/releases/tag/1.3.9rc3)
* [1.3.9rc4](https://github.com/foosel/OctoPrint/releases/tag/1.3.9rc4)
* A big **Thank you!** to everyone who reported back on these release candidates this time:
[arhi](https://github.com/arhi), [b-morgan](https://github.com/b-morgan), [brandstaetter](https://github.com/brandstaetter), [buchnoun](https://github.com/buchnoun), [CapnBry](https://github.com/CapnBry), [chatrat12](https://github.com/chatrat12), [ChrisHeerschap](https://github.com/ChrisHeerschap), [christianlupus](https://github.com/christianlupus), [chrisWhyTea](https://github.com/chrisWhyTea), [Crowlord](https://github.com/Crowlord), [ctgreybeard](https://github.com/ctgreybeard), [Cyberwizzard](https://github.com/Cyberwizzard), [DrJuJu](https://github.com/DrJuJu), [ejjenkins](https://github.com/ejjenkins), [fieldOfView](https://github.com/fieldOfView), [FormerLurker](https://github.com/FormerLurker), [four-of-four](https://github.com/four-of-four), [Galfinite](https://github.com/Galfinite), [gege2b](https://github.com/gege2b), [HFMan](https://github.com/HFMan), [jjlink](https://github.com/jjlink), [jneilliii](https://github.com/jneilliii), [JohnOCFII](https://github.com/JohnOCFII), [jwg3](https://github.com/jwg3), [kazibole](https://github.com/kazibole), [larp-welt](https://github.com/larp-welt), [McFly99](https://github.com/McFly99), [mod38](https://github.com/mod38), [ntoff](https://github.com/ntoff), [OutsourcedGuru](https://github.com/OutsourcedGuru), [paukstelis](https://github.com/paukstelis), [pingywon](https://github.com/pingywon), [pscrespo](https://github.com/pscrespo), [Rapsey](https://github.com/Rapsey), [tech-rat](https://github.com/tech-rat), [tedder](https://github.com/tedder), [thess](https://github.com/thess), [Thisismydigitalself](https://github.com/Thisismydigitalself), [tibmeister](https://github.com/tibmeister)
## 1.3.8 (2018-04-13)
### Bug fixes
* [#2577](https://github.com/foosel/OctoPrint/issues/2577) - Pin `psutil` dependency to version 5.4.3 since 5.4.4 as released today introduces a breaking change.
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.7...1.3.8))
## 1.3.7 (2018-04-09)
### Improvements
* [#324](https://github.com/foosel/OctoPrint/issues/324) & [#2414](https://github.com/foosel/OctoPrint/issues/2414) - Native support for the following [@ commands](http://docs.octoprint.org/en/maintenance/features/atcommands.html): `@pause` (pauses the print), `@resume` (resumes the print), `@cancel` or `@abort` (cancels the print). More commands can be added through the plugin hooks [`octoprint.comm.protocol.atcommand.*`](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-comm-protocol-atcommand-phase).
* [#1951](http://github.com/foosel/OctoPrint/issues/1951) - Fixed plugins being able to modify internal state data (e.g. progress, job), causing concurrent modification and resulting run time errors in the printer state processing.
* [#2208](https://github.com/foosel/OctoPrint/issues/2208) - New plugin hook [`octoprint.comm.protocol.gcode.error`](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-comm-protocol-gcode-error) to allow plugins to override OctoPrint's handling of `Error:`/`!!` messages reported by the firmware. Can be used to "downgrade" errors that aren't actually fatal errors that make the printer halt.
* [#2213](https://github.com/foosel/OctoPrint/issues/2213) - Made sure to prevent accidental configuration of a temperature cutoff value less than 1min for the temperature graph.
* [#2250](https://github.com/foosel/OctoPrint/pull/2250) - Added [`octoprint.util.ResettableTimer`](http://docs.octoprint.org/en/maintenance/modules/util.html#octoprint.util.ResettableTimer) helper class.
* [#2287](https://github.com/foosel/OctoPrint/issues/2287) - Added confirmation for attempting to disconnect during an ongoing print. See also [#2466](https://github.com/foosel/OctoPrint/pull/2466).
* [#2302](https://github.com/foosel/OctoPrint/issues/2302) - Detect invalid tools as reported by firmware and blacklist them for `T` commands.
* [#2317](https://github.com/foosel/OctoPrint/issues/2317) - Removed capturing of post roll images for time based timelapses, was causing too much confusion and surprise.
* [#2335](https://github.com/foosel/OctoPrint/issues/2335) - First throw at detecting if a print from the printer's SD was started outside of OctoPrint via the printer's control panel. Requires some specific requirements to be fulfilled by the printer's firmware to function properly:
* Firmware must send a "File opened: ..." message on start of the print
* Firmware must respond to an immediately sent `M27` with `SD printing byte <current>/<total>`
* Firmware must stay responsive during ongoing print to allow for regular M27 polls (or push those automatically) or M25 to pause/cancel the print through OctoPrint.
* Firmware must send `Done printing file` or respond to `M27` with `Not SD printing` when SD printing finishes (either due to being done or to having been cancelled by the user).
* [#2362](https://github.com/foosel/OctoPrint/issues/2362) - Added option to configure timelapse snapshot timeout.
* [#2367](https://github.com/foosel/OctoPrint/issues/2367) - Added support for `//action:cancel` action command.
* [#2378](https://github.com/foosel/OctoPrint/issues/2378) - Made GCODE viewer gracefully handle GCODE subcodes.
* [#2385](https://github.com/foosel/OctoPrint/pull/2385) - Made valid boolean trues check case insensitive.
* [#2304](https://github.com/foosel/OctoPrint/pull/2304) & [#2405](https://github.com/foosel/OctoPrint/pull/2405) - Added support to trust Basic Authentication headers for user login. Currently requires [manual configuration through `config.yaml`](http://docs.octoprint.org/en/maintenance/configuration/config_yaml.html#access-control), see the `accessControl.trustBasicAuthentication` and `accessControl.checkBasicAuthenticationPassword` settings.
* [#2338](https://github.com/foosel/OctoPrint/pull/2338) - Allowed plugins to define GCODE script variables using the `octoprint.comm.protocol.scripts` hook.
* [#2406](https://github.com/foosel/OctoPrint/pull/2406) - Extracted log management into its own bundled plugin and allow fine tuning of log levels.
* [#2409](https://github.com/foosel/OctoPrint/pull/2409) - Added `m4v` and `mkv` to the list of accepted timelapse extensions.
* [#2444](https://github.com/foosel/OctoPrint/pull/2444) - Support additional CSS classes on custom control buttons.
* [#2448](https://github.com/foosel/OctoPrint/issues/2448) - Also detect plugins in `~/.octoprint/plugins` that are provided as bytecode `pyc` instead of source `py` files.
* [#2455](https://github.com/foosel/OctoPrint/issues/2455) - Added option to configure SSL validation for snapshot URL.
* Support `M114` response format of RepRapFirmware (uses `X:... Y:... Z:... E0:... E1:...` instead of
`X:... Y:... Z:... E:...`)
* Added refresh button to connection panel for easy refresh of the available ports to connect to without having to reload the whole page.
* Increased upper bound of PySerial dependency from 2.7 to 3.4. See also [#2333](https://github.com/foosel/OctoPrint/issues/2333).
* Switch to lower communication timeouts if support of the `busy` protocol by the firmware is detected.
* Refactored serial settings dialog, now has sub tabs and more explanations.
* Allow to disable support for certain firmware capabilities, even if reported as supported by the firmware: `busy` protocol, temperature auto reporting, SD status auto reporting
* Attached tags to GCODE commands moving through the comm layer and allowed plugins to access and extend these tags through the GCODE hooks. Makes it possible for plugins to detect the origin of a command (streamed file vs. GCODE script vs. user input vs. plugin), the point where it entered the system and so on. Also added a new logger `octoprint.util.comm.command_phases` that if set to `DEBUG` will log the lifecycle of commands through the comm layer including tags to `octoprint.log`. See also [the docs here](http://docs.octoprint.org/en/maintenance/plugins/hooks.html#octoprint-comm-protocol-gcode-phase).
* Added new [`job_on_hold`](http://docs.octoprint.org/en/maintenance/modules/printer.html#octoprint.printer.PrinterInterface.job_on_hold) and [`set_job_on_hold`](http://docs.octoprint.org/en/maintenance/modules/printer.html#octoprint.printer.PrinterInterface.set_job_on_hold) methods on the printer instance, allowing plugins to quickly stall the streaming of a queue. This should be used sparingly - abuse will have significant negative effects on the print job. Read the docs if you plan to utilize this.
* Support extraction of plugin metadata even from disabled and blacklisted plugins through the AST of the module.
* Better logging of printer callback errors and utilization of `frozendict` for internal printer state propagation in an attempt to narrow down on [#1951](https://github.com/foosel/OctoPrint/issues/1951). Should `frozendict` cause issues it can be disabled through the settings in `config.yaml`, just set `devel.useFrozenDictForPrinterState` to `false`
* Log comm state changes to `octoprint.log`.
* Added a regular server heartbeat to the log (every 15min).
* Support SD status auto report by the firmware.
* Added `Not SD printing` to default "SD status" terminal filters.
* Added custom `readline` implementation for the serial port. Instead of relying on PySerial's `readline` that depending on the installed version might only read from the port one byte at the time, we now wait for one byte and then read everything available into a persistent buffer which then is used to fetch lines from.
* Ensure that `callViewModelIf` doesn't try to call null or uncallable `method`s.
* Added links to the new [Community Forum](https://discourse.octoprint.org) and the new location of the [FAQ](https://faq.octoprint.org).
* Improved pip utility logging, `LocalPipHelper` wasn't producing output, making it hard to debug such non writable install directories.
* Added a new bundled plugin "Printer Safety Check" that will try to identify printer/printer firmware with known safety issues such as missing thermal runaway protection.
* Plugin Manager: Reduce notification spam. See also [#2260](https://github.com/foosel/OctoPrint/issues/2260).
* Software Update Plugin: Better detection if an update is already running.
* Software Update Plugin: Refer to `plugin_softwareupdate_console.log` on update errors in log and notification.
### Bugfixes
* [#2294](https://github.com/foosel/OctoPrint/issues/2294) - Improved resilience against errors during gathering the file list (e.g. permission errors)
* [#2296](https://github.com/foosel/OctoPrint/issues/2296) - Fixed `X-Forwarded-For` handling in Flask Login through monkey patched backport.
* [#2297](https://github.com/foosel/OctoPrint/issues/2297) - Return `403` instead of `401` on missing/insufficient credentials.
* [#2311](https://github.com/foosel/OctoPrint/issues/2311) - Fixed server not auto connecting on startup if port is set to `AUTO` (see also [#2311](https://github.com/foosel/OctoPrint/pull/2337)).
* [#2316](https://github.com/foosel/OctoPrint/issues/2316) - Check for valid queue entry in file analysis queue before trying to dequeue, fix for a HTTP `500` on upload of a file not supported for analysis.
* [#2321](https://github.com/foosel/OctoPrint/issues/2321) & [#2449](https://github.com/foosel/OctoPrint/issues/2449) - Fixed wrong queuing order of cancel script & first line from printed file on quick start-cancel-start scenarios by introducing a two new states "Cancelling" and "Pausing".
* [#2324](https://github.com/foosel/OctoPrint/pull/2324) - Fixed 500 error when
* [#2333](https://github.com/foosel/OctoPrint/issues/2333) (Part 1/3) - Workaround for an update problem caused by interaction of `pip` with dependencies formerly installed as eggs through `python setup.py install`.
* [#2333](https://github.com/foosel/OctoPrint/issues/2333) (Part 2/3) - If supported by the underlying PySerial version, cancel all reads and writes on disconnect if possible for a faster connection release. Part 3 (forcing an upgrade of PySerial to 3.4 so this should work in more cases) will in OctoPrint 1.3.8.
* [#2364](https://github.com/foosel/OctoPrint/issues/2364) - Fixed firmware error reporting in case of cancelling a print due to a firmware error.
* [#2368](https://github.com/foosel/OctoPrint/issues/2368) - Fixed for incorrect handling of unicode filenames in cura slicer profiles
* [#2371](https://github.com/foosel/OctoPrint/issues/2371) - Removed "just now"/"gerade eben" label from temperature graph to work around a graph resize issue caused by that.
* [#2392](https://github.com/foosel/OctoPrint/issues/2392) - Fixed "Copy all" on terminal tab only working the first time.
* [#2406](https://github.com/foosel/OctoPrint/pull/2406) - Fixed `showTab` JS function of about dialog.
* [#2426](https://github.com/foosel/OctoPrint/issues/2426) - Made resend logging to `octoprint.log` unicode safe
* [#2442](https://github.com/foosel/OctoPrint/issues/2442) - Don't even import disabled plugins, use a dummy entry for them just like for backlisted plugins. More resilience against misbehaving plugins.
* [#2461](https://github.com/foosel/OctoPrint/issues/2461) - Fixed OctoPrint not properly disconnecting in case of a firmware error.
* [#2494](https://github.com/foosel/OctoPrint/issues/2494) - Fixed `undefined` values not saving in the settings.
* [#2499](https://github.com/foosel/OctoPrint/issues/2499) (regression) - Fixed communication error notification lacking the actual error message.
* [#2501](https://github.com/foosel/OctoPrint/issues/2501) (regression) - Fixed a bug causing log downloads to fail with an HTTP 500 error.
* [#2506](https://github.com/foosel/OctoPrint/issues/2506) (regression) - Fixed `printer.get_current_data` and `printer.get_current_job` returning `frozendict` instead of `dict` instances, causing issues with plugins relying on being able to modify the returned data (e.g. [dattas/OctoPrint-DetailedProgress#26](https://github.com/dattas/OctoPrint-DetailedProgress/issues/26)).
* [#2508](https://github.com/foosel/OctoPrint/issues/2508) (regression) - Fixed HTTP 500 error on `/api/slicing` in case of an unconfigured slicer.
* [#2524](https://github.com/foosel/OctoPrint/issues/2524) - Ignore `wait` while job is on hold.
* [#2536](https://github.com/foosel/OctoPrint/issues/2536) - Fix a wrong state tracking when starting an SD print through the controller, causing a disconnect due to a timeout.
* [#2544](https://github.com/foosel/OctoPrint/issues/2544) (regression) - Fix an exception when connecting to the raw websocket at `/sockjs/websocket` (instead of `/sockjs/<server_id>/<session_id>/websocket`).
* [#2546](https://github.com/foosel/OctoPrint/issues/2546) (regression) - Fix the `PRINT_FAILED` event getting triggered twice on print failure due to disconnect
* Use `pkg_resources` to determine pip version during environment check instead of `import pip; pip.__version__` since the latter causes issues with pip version 9.0.2. In the same spirit make `pip.main` approach of calling `pip` in the PipCaller the last resort during auto detection, only after trying `pip` or `pip.exe` inside the same folder as the Python executable.
* Use `octoprint.util.monotonic_time` instead of `monotonic.monotonic` in comm layer.
* Fixed timelapse not stopping on print failure due to firmware error due to missing `PrintFailed` event.
* Announcement Plugin: Fixed a missing line break in case of more than three announcements in a notification.
* Docs: Documentation for printer profile related bits and pieces
* Docs: Various fixes of typos and grammar.
* Have `OctoPrintJsonEncoder` fall back to regular flask JSON encoder, otherwise we might not be able to serialize some data types we need to be able to serialize. (regression)
### Known bugs
* [#2547](https://github.com/foosel/OctoPrint/issues/2547) - Error during processing of afterPrintJobDone script will trigger PRINT_FAILED event even though PRINT_DONE event was already triggered
### More Information
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.6...1.3.7)
* Release Candidates:
* [1.3.7rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.7rc1)
* [1.3.7rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.7rc2)
* [1.3.7rc3](https://github.com/foosel/OctoPrint/releases/tag/1.3.7rc3)
* [1.3.7rc4](https://github.com/foosel/OctoPrint/releases/tag/1.3.7rc4)
* A special **Thank you!** to everyone who reported back on these release candidates this time:
[aaronkeck](https://github.com/aaronkeck), [akurz42](https://github.com/akurz42), [andrivet](https://github.com/andrivet), [anthonyst91](https://github.com/anthonyst91), [arhi](https://github.com/arhi), [b-morgan](https://github.com/b-morgan), [BryanSmithDev](https://github.com/BryanSmithDev), [chippypilot](https://github.com/chippypilot), [ChrisHeerschap](https://github.com/ChrisHeerschap), [Crowlord](https://github.com/Crowlord), [dforsi](https://github.com/dforsi), [drdelaney](https://github.com/drdelaney), [FormerLurker](https://github.com/FormerLurker), [goeland86](https://github.com/goeland86), [inspiredbylife](https://github.com/inspiredbylife), [jbjones27](https://github.com/jbjones27), [jesasi](https://github.com/jesasi), [jneilliii](https://github.com/jneilliii), [JohnOCFII](https://github.com/JohnOCFII), [kantlivelong](https://github.com/kantlivelong), [lnx13](https://github.com/lnx13), [makaper](https://github.com/makaper), [markwal](https://github.com/markwal), [MiquelAdell](https://discourse.octoprint.org/u/MiquelAdell), [ml0w](https://github.com/ml0w), [mmotley999](https://github.com/mmotley999), [mrhanman](https://github.com/mrhanman), [SCiunczyk](https://github.com/SCiunczyk), [tdub415](https://github.com/tdub415), [tedder42](https://discourse.octoprint.org/u/tedder42), [thatjoshguy](https://github.com/thatjoshguy), [wescrockett](https://github.com/wescrockett)
## 1.3.6 (2017-12-12)
### Note for upgraders and plugin authors: Change in the bundling of JS assets can lead to issues in plugins
@@ -27,7 +276,7 @@ A change to solve issues with plugins bundling JS assets that cause interference
If you happen to run into any such issues, you can switch back to the old way of bundling JS assets via the newly introduced "Settings > Feature > Enable legacy plugin asset bundling" toggle (check it, save the settings, restart the server). This is provided to allow for a minimally invasive adjustment period until affected plugins have been updated.
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](http://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](https://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
### Improvements
@@ -86,6 +335,7 @@ You can find out more about the change, how to know if a plugin is even affected
* Docs: Added information on how to run the test suite.
* Various refactorings
* Various documentation updates
* Fetch plugin blacklist (and also announcements, plugin notices and plugin repository) via https instead of http.
### Bug fixes
@@ -108,6 +358,9 @@ You can find out more about the change, how to know if a plugin is even affected
* [#2226](https://github.com/foosel/OctoPrint/issues/2226) - Handle `No Line Number with checksum, Last Line: ...` errors from the firmware.
* [#2233](https://github.com/foosel/OctoPrint/pull/2233) - Respond with `411 Length Required` when content length is missing on file uploads.
* [#2242](https://github.com/foosel/OctoPrint/issues/2242) - Fixed an issue where print time left could show "1 days" instead of "1 day".
* [#2262](https://github.com/foosel/OctoPrint/issues/2262) (regression) - Fixed a bug causing `Error:checksum mismatch, Last Line: ...` errors from the firmware to be handled incorrectly.
* [#2267](https://github.com/foosel/OctoPrint/issues/2267) (regression) - Fixed a bug causing the GCODE viewer to not get properly initialized due to a JS error on load if "Also show next layer" was selected.
* [#2268](https://github.com/foosel/OctoPrint/issues/2268) (regression) - Fixed a bug causing a display error with the temperature offsets. If one offset was changed, all others seemed to revert back to 0.
* Fixed cleanup of unrendered timelapses with certain names.
* Fixed a caching issue with the file list API and the slicing API.
* Fixed initial sizing of the temperature graph.
@@ -125,8 +378,18 @@ You can find out more about the change, how to know if a plugin is even affected
* Virtual printer: Fix resend simuation.
* Docs: Fixed CSS of line numbered listings.
* Docs: Updated mermaid to fix a deprecation warning.
* Fixed ordering of plugin assets, should be alphabetical based on the plugin identifier. (regression)
* Fixed an issue causing redundant software update configuration settings to be written to `config.yaml`, in turn causing issues when downgrading to <1.3.5. (regression)
* Fixed an issue detecting whether the installed version is a release version or a development version. (regression)
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.5...1.3.6rc1))
### More Information
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.5...1.3.6)
* Release Candidates:
* [1.3.6rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.6rc1)
* [1.3.6rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.6rc2)
* [1.3.6rc3](https://github.com/foosel/OctoPrint/releases/tag/1.3.6rc3)
* A special **Thank you!** to everyone who reported back on these release candidates this time: [andrivet](https://github.com/andrivet), [b-morgan](https://github.com/b-morgan), [bjarchi](https://github.com/bjarchi), [chippypilot](https://github.com/chippypilot), [ChrisHeerschap](https://github.com/ChrisHeerschap), [cosmith71](https://github.com/cosmith71), [Crowlord](https://github.com/Crowlord), [ctgreybeard](https://github.com/ctgreybeard), [fiveangle](https://github.com/fiveangle), [goeland86](https://github.com/goeland86), [jbjones27](https://github.com/jbjones27), [jneilliii](https://github.com/jneilliii), [JohnOCFII](https://github.com/JohnOCFII), [Kunsi](https://github.com/Kunsi), [Lordxv](https://github.com/Lordxv), [malnvenshorn](https://github.com/malnvenshorn), [mcp5500](https://github.com/mcp5500), [ntoff](https://github.com/ntoff), [ripp2003](https://github.com/ripp2003) and [schorsch3000](https://github.com/schorsch3000)
## 1.3.5 (2017-10-16)
+151 -119
View File
@@ -21,45 +21,41 @@ or **[creating pull requests](#pull-requests)**.
## Issues, Tickets, however you may call them
Please read the following short instructions fully and follow them. You can
Please read the following instructions fully and follow them. You can
help the project tremendously this way: not only do you help the maintainers
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](http://i.imgur.com/qYSZyuw.png)
![Ticket flow chart](https://i.imgur.com/cw19qHX.png)
- **[Read the FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)**
- **[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)
and *[use the provided template](#what-should-i-include-in-a-ticket)*.
You do not need to do anything else with your ticket.
- 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
[Mailinglist](https://groups.google.com/group/octoprint) or the
[Google+ Community](https://plus.google.com/communities/102771308349328485741) for
[community forum at discourse.octoprint.org](https://discourse.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 discourse.octoprint.org](https://discourse.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 [Mailinglist](https://groups.google.com/group/octoprint) or the
[Google+ Community](https://plus.google.com/communities/102771308349328485741) instead.
Consult the [community forum at discourse.octoprint.org](https://discourse.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.
----
**Note**: 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 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.
----
> 👉 **Note**
>
> 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]` 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.
## How to file a bug report
@@ -72,22 +68,25 @@ following section *completely* and also follow the instructions in the
### What should I do before submitting a bug report?
1. **Make sure you are at the right location**. This is the Github repository
1. **Make sure you are at the right location**. This is the bug tracker
of the official version of OctoPrint, which is the 3D print server and
corresponding web interface itself.
**This is not the Github respository of OctoPi**, which is the preconfigured
**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).
**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
[here](https://github.com/guysoft/OctoPi). Please note that while we do have
some entries regarding OctoPi in the FAQ, any bugs should be reported in the
[proper bug tracker](https://github.com/guysoft/OctoPi/issues) which - again -
is not here.
[here](https://github.com/guysoft/OctoPi). If you have any kind of specific
issue with how the OctoPi system is setup, go there please.
**This is also not the Github repository of any OctoPrint Plugins you
**This is also not the bug tracker of any OctoPrint Plugins you
might have installed**. Report any issues with those in their corresponding
bug tracker (probably linked to from the plugin's homepage).
Finally, **this is also not the right issue tracker if you are running a
Finally, **this is also not the right bug tracker if you are running a
forked version of OctoPrint**. Seek help for such unofficial versions from
the people maintaining them instead.
@@ -101,7 +100,7 @@ following section *completely* and also follow the instructions in the
more about safe mode in the [docs](http://docs.octoprint.org/en/master/features/safemode.html).
You might also want to try the current development version of OctoPrint
(if you aren't already). Refer to the [FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)
(if you aren't already). Refer to the [FAQ](https://faq.octoprint.org)
for information on how to do this.
3. The problem still exists? Then please **look through the
@@ -111,8 +110,8 @@ following section *completely* and also follow the instructions in the
Sorting through duplicates of the same issue sometimes causes more work than
fixing it. Take the time to filter through possible duplicates and be really
sure that your problem definitely is a new one. Try more than one search query
(e.g. do not only search for "webcam" if you happen to run into an issue
with your webcam, also search for "timelapse" etc). Do not only read the subject lines
(e.g. do not only search for "timelapse" if you happen to run into an issue
with your webcam, also search for "recording" etc). Do not only read the subject lines
of tickets that look like they might be related, but also read the ticket itself!
**Very important:** Please make absolutely sure that if you find a bug that looks like
@@ -126,84 +125,149 @@ following section *completely* and also follow the instructions in the
makes it more difficult due to on top of having to figure out the original problem
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)
instead of opening a ticket here. If you are actually running into a bug, we'll figure it out together
there.
### What should I include in a bug report?
First of all make sure your use **a descriptive title**. "It doesn't work"
and similar unspecific complaints are NOT descriptive titles.
**Always use the following template** (please remove what's within `[...]`, that's
only provided here as some additional information for you), **even if only adding a
"me too" to an existing ticket**:
**Always use the following template, even if only adding a "me too" to an
existing ticket**:
#### What were you doing?
```
<!--
READ THE FOLLOWING FIRST:
[Please be as specific as possible here. The maintainers will need to
reproduce your issue in order to fix it and that is not possible if they
don't know what you did to get it to happen in the first place.
If not already done, please read the the Contribution Guidelines that
are linked to the right under "Helpful resources" > "Contributing".
Ideally provide exact steps to follow in order to reproduce your problem:
Also read the FAQ: https://faq.octoprint.org
1. ...
2. ...
3. ...
This is a bug and feature tracker, please only use it to report bugs
or request features within OctoPrint (not OctoPi, not any OctoPrint
plugins and not unofficial OctoPrint versions).
If you encountered a problem with specific files of any sorts, make sure
to also include a link to a file with which to reproduce the problem.]
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.
#### What did you expect to happen?
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
where to find some information - it's all described in the Contribution
Guidelines linked up there in the big yellow box).
#### What happened instead?
When reporting a bug do NOT delete ANY lines from the template.
#### Did the same happen when running OctoPrint in safe mode?
Make sure any bug you want to report is still present with the CURRENT
OctoPrint version and that it does not vanish when you start OctoPrint
in safe mode - how to do that is also explained in the Contribution
Guidelines linked up there in the big yellow box.
[Try to reproduce your problem in safe mode. You can find information
on how to enable safe mode in the Contribution Guidelines.]
Thank you!
-->
#### Version of OctoPrint
#### What were you doing?
[Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.]
<!--
Please be as specific as possible here. The maintainers will need to
reproduce your issue in order to fix it and that is not possible if they
don't know what you did to get it to happen in the first place.
#### Operating System running OctoPrint
Ideally provide exact steps to follow in order to reproduce your problem:
-->
[OctoPi, Linux, Windows, MacOS, something else? With version please,
OctoPi's version can be found in /etc/octopi_version]
1. ...
2. ...
3. ...
#### Printer model & used firmware incl. version
<!--
If you encountered a problem with specific files of any sorts, make sure
to also include a link to a file with which to reproduce the problem.
-->
[If applicable, always include if unsure.]
#### What did you expect to happen?
#### Browser and Version of Browser, Operating System running Browser
#### What happened instead?
[If applicable, always include if unsure.]
#### Did the same happen when running OctoPrint in safe mode?
#### Link to octoprint.log
<!--
Test if you can reproduce your problem in safe mode. You can find information
on how to enable safe mode in the Contribution Guidelines.
[On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
The Contribution Guidelines tell you where to find that.]
If you can't reproduce in safe mode, this is a bug with one of your
installed third party plugins. Don't open a ticket here!
#### Link to contents of terminal tab or serial.log
If you can't test this in safe mode, state why.
-->
[On gist.github.com or pastebin.com. If applicable, always include if unsure or
reporting communication issues. Never truncate.
#### Version of OctoPrint
serial.log is usually not written due to performance reasons and must be
enabled explicitly. Provide at the very least the FULL contents of your
terminal tab at the time of the bug occurrence, even if you do not have
a serial.log.]
<!--
Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.
-->
#### Link to contents of Javascript console in the browser
#### Operating System running OctoPrint
[On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
always include if unsure or reporting UI issues.
<!--
OctoPi, Linux, Windows, MacOS, something else? With version please.
OctoPi's version can be found in /etc/octopi_version or in the lower left
corner of the web interface.
-->
The Contribution Guidelines tell you where to find that.]
#### Printer model & used firmware incl. version
#### Screenshot(s)/video(s) showing the problem:
<!--
If applicable, always include if unsure.
-->
[If applicable. Always include if unsure or reporting UI issues.]
#### Browser and version of browser, operating system running browser
I have read the FAQ.
<!--
If applicable, always include if unsure.
-->
#### Link to octoprint.log
<!--
On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
The Contribution Guidelines tell you where to find that.
-->
#### Link to contents of terminal tab or serial.log
<!--
On gist.github.com or pastebin.com. If applicable, always include if unsure or
reporting communication issues. Never truncate.
serial.log is usually not written due to performance reasons and must be
enabled explicitly. Provide at the very least the FULL contents of your
terminal tab at the time of the bug occurrence, even if you do not have
a serial.log (which the Contribution Guidelines tell you where to find).
-->
#### Link to contents of Javascript console in the browser
<!--
On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
always include if unsure or reporting UI issues.
The Contribution Guidelines tell you where to find that.
-->
#### Screenshot(s)/video(s) showing the problem:
<!--
If applicable. Always include if unsure or reporting UI issues.
-->
I have read the FAQ.
```
Copy-paste this template **completely** (or use the version that gets pre-filled
into the "new issue" form). Do not skip any lines or the bot *will* complain! Provide
@@ -211,50 +275,11 @@ all requested information or your ticket will be closed.
### Where can I find which version and branch I'm on?
You can find out all of them by taking a look into the lower left corner of the
OctoPrint UI:
![Current version and git branch info in OctoPrint's UI](http://i.imgur.com/HyHMlY2.png)
If you don't have access to the UI you can find out that information via the
command line as well. Either `octoprint --version` or `python setup.py version`
in OctoPrint's folder will tell you the version of OctoPrint you are running
(note: if it doesn't then you are running a version older than 1.1.0,
*upgrade now*). A `git branch` in your OctoPrint installation folder will mark
the branch you are on with a little *. `git rev-parse HEAD` will tell you the
current commit.
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).
### Where can I find those log files you keep talking about?
OctoPrint by default provides two log outputs, a third one can be enabled if
more information is needed.
One is contained in the **"Terminal" tab** within OctoPrint's UI and is a log
of the last 300 lines of communication with the printer. Please copy-paste
this *completely* somewhere (disable auto scroll to make copying the contents easier) -
e.g. http://pastebin.com or http://gist.github.com - and include a link in
your bug report.
There is also **OctoPrint's application log file** or in short `octoprint.log`,
which is by default located at `~/.octoprint/logs/octoprint.log` on Linux,
`%APPDATA%\OctoPrint\logs\octoprint.log` on Windows and
`~/Library/Application Support/OctoPrint/logs/octoprint.log` on MacOS. You can
also access it directly through OctoPrint via Settings > Logs. Please
copy-paste this *completely* to pastebin or gist as well and include a link in your bug
report.
It might happen that you are asked to provide a more **thorough log of the
communication with the printer** if you haven't already done so, the `serial.log`.
This is not written by default due to performance reasons, but you can enable
it in the settings dialog. After enabling that log, please reproduce the problem
again (connect to the printer, do whatever triggers it), then copy-paste
`~/.octoprint/logs/serial.log` (Windows: `%APPDATA%\OctoPrint\logs\serial.log`,
MacOS: `~/Library/Application Support/OctoPrint/logs/serial.log`) to pastebin
or gist and include the link in the bug report.
You might also be asked to provide a log with an increased log level. You can
find information on how to do just that in the
[docs](http://docs.octoprint.org/en/master/configuration/logging_yaml.html).
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299/1).
### Where can I find my browser's error console?
@@ -276,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://discourse.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
@@ -286,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
@@ -445,6 +472,11 @@ the local version identifier to allow for an exact determination of the active c
by OctoPrint itself and not a misbehaving plugin.
* 2017-03-27: Added safe mode section to ticket template.
* 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-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.
+29 -20
View File
@@ -1,35 +1,47 @@
# 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/discourse.octoprint.org/users.svg)](https://discourse.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](http://octoprint.org).
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 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).
The documentation is located at [docs.octoprint.org](http://docs.octoprint.org).
The official plugin repository can be reached at [plugins.octoprint.org](http://plugins.octoprint.org).
The official plugin repository can be reached at [plugins.octoprint.org](https://plugins.octoprint.org/?utm_source=github&utm_medium=readme).
OctoPrint's development wouldn't be possible without the [financial support by its community](http://octoprint.org/support-octoprint/).
If you enjoy OctoPrint, please consider becoming a regular supporter!
**OctoPrint's development wouldn't be possible without the [financial support by its community](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
If you enjoy OctoPrint, please consider becoming a regular supporter!**
![Screenshot](http://i.imgur.com/dF3noFp.png)
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 [the mailing list](https://groups.google.com/group/octoprint)
or the [G+ Community](https://plus.google.com/communities/102771308349328485741) 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 discourse.octoprint.org](https://discourse.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), support
of other users in the [bug tracker](https://github.com/foosel/OctoPrint/issues),
[the Mailinglist](https://groups.google.com/group/octoprint) or
[the G+ Community](https://plus.google.com/communities/102771308349328485741) and also [financially](http://octoprint.org/support-octoprint/).
[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)
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
in any way to make it better instead of just complaining about it -- this is an Open Source Project
@@ -54,23 +66,20 @@ 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`
4. Install OctoPrint *into that virtual environment*: `./venv/bin/python setup.py install`
4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .`
You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage)
for details.
After installation, please make sure you follow the first-run wizard and set up
access control as necessary. If you want to not only be notified about new
releases, but also be able to automatically upgrade to them from within
OctoPrint, take a look [at the documentation of the Software Update Plugin](https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update#making-octoprint-updateable-on-existing-installations)
and at its settings.
access control as necessary.
## Dependencies
OctoPrint depends on a few python modules to do its job. Those are automatically installed when installing
OctoPrint via `setup.py`:
OctoPrint via `pip`:
python setup.py install
pip install .
You should do this every time after pulling from the repository, since the dependencies may have changed.
@@ -78,9 +87,9 @@ OctoPrint currently only supports Python 2.7.
## Usage
Running the `setup.py` script via
Running the pip install via
python setup.py install
pip install .
installs the `octoprint` script in your Python installation's scripts folder
(which, depending on whether you installed OctoPrint globally or into a virtual env, will be in your `PATH` or not). The
+17 -16
View File
@@ -1,62 +1,63 @@
# 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
* 3D Moniak
* Aleph Objects, Inc.
* Andrew Moorby
* Arnljot Arntsen
* BEEVERYCREATIVE
* Boris Hussein
* Brad Jackson
* Brian E. Tyler
* Christian Petropolis
* Christian Wolf
* COLLE+McVOY
* CreativeTools
* D Brian Kimmel
* DeltaMaker 3D Printers
* E3D BigBox
* Ernesto Martinez
* F. Kunsmann
* Frank Sander
* Gary Deen
* Gary N McKinney
* George Robles
* günter weber
* Hydra Research LLC
* James Seigel
* Jason Lawrence
* Jeff Moe
* Jeff Renfer
* Jefferson Hunt
* Jeremiah Avery
* Joseph Payne
* Josh Daniels
* Joshua Wills
* Justin Kaufman
* Kaile Riser
* Kale Stedman
* Kazuhiro Ogura
* Kodama Inc.
* Lewis Newby
* LulzBot®
* Makespace Madrid
* Marcus Ackermann
* Mark Qvist
* Mark Walker
* Martin Beattie
* Michael Aumock
* Miles Flavel
* mitchell hirsch
* Mohammed khorakiwala
* Noe Ruiz
* Patrick McGinnis
* Peter Schmehl
* PRINT3Dforum.com
* Randy C. Will
* Robert Gusek
* Roger Strolz
* Roy Cortes
* Rudolff Vang
* Samer Najia
* Simon Hallam
* Stefan Krister
* Stephane Schittly
* Sven Mueller
* Symbiotic Devices
* Thomas Hatley
* Timeshell.ca
* Timothy D Hoogland
* Trent Shumay
and 1144 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1351 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
-1
View File
@@ -71,7 +71,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
+64 -9
View File
@@ -44,6 +44,14 @@ Printer State
- 1
- Boolean
- ``true`` if the printer is currently printing, ``false`` otherwise
* - ``flags.pausing``
- 1
- Boolean
- ``true`` if the printer is currently printing and in the process of pausing, ``false`` otherwise
* - ``flags.cancelling``
- 1
- Boolean
- ``true`` if the printer is currently printing and in the process of pausing, ``false`` otherwise
* - ``flags.sdReady``
- 1
- Boolean
@@ -255,8 +263,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
'''''''
@@ -272,13 +283,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
'''''
@@ -377,14 +389,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:
@@ -413,4 +469,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.
+98 -4
View File
@@ -12,8 +12,11 @@ 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.
configured one, a user specific one if "Access Control" is enabled 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,7 +26,7 @@ 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`.
If it is missing or included but invalid, OctoPrint will directly return a response with status :http:statuscode:`403`.
For testing purposes it is also possible to supply the API key via a query parameter ``apikey``, e.g.
@@ -65,7 +68,7 @@ Please be advised that clients should use the header field variant if at all pos
Content Type
============
If not otherwise stated OctoPrint's API expects request bodies and issues response bodies as ``Content-Type: application/json``.
If not otherwise stated, OctoPrint's API expects request bodies and issues response bodies as ``Content-Type: application/json``.
.. _sec-api-general-encoding:
@@ -120,3 +123,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.
+5 -168
View File
@@ -4,172 +4,9 @@
Log file management
*******************
.. note::
Log file management (and logging configuration) was moved into a bundled plugin in OctoPrint 1.3.7. Refer to
:ref:`the Logging's plugins API <sec-bundledplugins-logging-api>` for the API documentation.
All log file management operations require admin rights.
.. contents::
.. _sec-api-logs-list:
Retrieve a list of available log files
======================================
.. http:get:: /api/logs
Retrieve information regarding all log files currently available and regarding the disk space still available
in the system on the location the log files are being stored.
Returns a :ref:`Logfile Retrieve response <sec-api-logs-datamodel-retrieveresponse>`.
**Example**
.. sourcecode:: http
GET /api/logs HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"files" : [
{
"date" : 1393158814,
"name" : "octoprint.log",
"size" : 43712,
"refs": {
"resource": "http://example.com/api/logs/octoprint.log",
"download": "http://example.com/downloads/logs/octoprint.log"
}
},
{
"date" : 1392628936,
"name" : "octoprint.log.2014-02-17",
"size" : 13205,
"refs": {
"resource": "http://example.com/api/logs/octoprint.log.2014-02-17",
"download": "http://example.com/downloads/logs/octoprint.log.2014-02-17"
}
},
{
"date" : 1393158814,
"name" : "serial.log",
"size" : 1798419,
"refs": {
"resource": "http://example.com/api/logs/serial.log",
"download": "http://example.com/downloads/logs/serial.log"
}
}
],
"free": 12237201408
}
:statuscode 200: No error
:statuscode 403: If the given API token did not have admin rights associated with it
.. _sec-api-logs-delete:
Delete a specific logfile
=========================
.. http:delete:: /api/logs/(path:filename)
Delete the selected log file with name `filename`.
Returns a :http:statuscode:`204` after successful deletion.
**Example Request**
.. sourcecode:: http
DELETE /api/logs/octoprint.log.2014-02-17 HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
:param filename: The filename of the log file to delete
:statuscode 204: No error
:statuscode 403: If the given API token did not have admin rights associated with it
:statuscode 404: If the file was not found
.. _sec-api-logs-datamodel:
Data model
==========
.. _sec-api-logs-datamodel-retrieveresponse:
Logfile Retrieve Response
-------------------------
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``files``
- 0..*
- Array of :ref:`File information items <sec-api-logs-datamodel-fileinfo>`
- The list of requested files. Might be an empty list if no files are available
* - ``free``
- 1
- String
- The amount of disk space in bytes available in the local disk space (refers to OctoPrint's ``logs`` folder).
.. _sec-api-logs-datamodel-fileinfo:
File information
----------------
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``name``
- 1
- String
- The name of the file
* - ``size``
- 1
- Number
- The size of the file in bytes.
* - ``date``
- 1
- Unix timestamp
- The timestamp when this file was last modified.
* - ``refs``
- 1
- :ref:`sec-api-logs-datamodel-ref`
- References relevant to this file
.. _sec-api-logs-datamodel-ref:
References
----------
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``resource``
- 1
- URL
- The resource that represents the file (e.g. for deleting)
* - ``download``
- 1
- URL
- The download URL for the file
The former endpoints ``/api/logs`` and ``api/logs/<path>`` are marked as deprecated but still work for now. New
client implementations should directly use the new endpoints provided by the bundled plugin. Existing implementations
should adapt their endpoints as soon as possible.
+53 -9
View File
@@ -37,7 +37,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
@@ -149,6 +149,8 @@ Retrieve the current printer state
"operational": true,
"paused": false,
"printing": false,
"cancelling": false,
"pausing": false,
"sdReady": true,
"error": false,
"ready": true,
@@ -179,6 +181,8 @@ Retrieve the current printer state
"operational": true,
"paused": false,
"printing": false,
"cancelling": false,
"pausing": false,
"sdReady": true,
"error": false,
"ready": true,
@@ -213,7 +217,7 @@ Issue a print head command
* ``z``: Optional. Amount/coordinate to jog print head on z axis, must be a valid number corresponding to the distance to travel in mm.
* ``absolute``: Optional. Boolean value specifying whether to move relative to current position (provided
axes values are relative amounts) or to absolute position (provided axes values are coordinates)
* ``speed``: Optiona. Speed at which to move. If not provided, minimum speed for all selected axes from printer
* ``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.
@@ -223,9 +227,9 @@ Issue a print head command
* ``axes``: A list of axes which to home, valid values are one or more of ``x``, ``y``, ``z``.
feedrate
Changes the feedrate factor to apply to the movement's of the axes.
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.
@@ -276,9 +280,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
@@ -296,6 +300,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.
@@ -342,7 +366,7 @@ Issue a tool 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.
@@ -457,9 +481,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
@@ -477,6 +501,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}``.
+1 -1
View File
@@ -581,7 +581,7 @@ Profile
* - ``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_cura",
"name": "CuraEngine (<= 15.04)",
"plugin_id": "cura",
"plugin_name": "CuraEngine (<= 15.04)"
}
],
"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``
-
+1 -1
View File
@@ -139,7 +139,7 @@ Execute a registered system command
.. http:post:: /api/system/commands/(string:source)/(string:action)
Execute the system command ``action`` on defined in ``source``.
Execute the system command ``action`` defined in ``source``.
**Example**
+2 -2
View File
@@ -128,7 +128,7 @@ Rendered timelapse
* - ``date``
- 1
- string
- Formatted timestamp of the the timelapse creation date
- Formatted timestamp of the timelapse creation date
* - ``url``
- 1
- string
@@ -162,7 +162,7 @@ Unrendered timelapse
* - ``date``
- 1
- string
- Formatted timestamp of the the timelapse job creation date
- Formatted timestamp of the timelapse job creation date
* - ``recording``
- 1
- bool
+35 -15
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
@@ -38,13 +46,15 @@ Test paths or URLs
.. _sec-api-util-test-url:
url
Tests whether a provided url responds. Request method and expected status codes can
Tests whether a provided URL responds. Request method and expected status codes can
optionally be specified as well. Supported parameters are:
* ``url``: The url to test. Mandatory.
* ``url``: The URL to test. Mandatory.
* ``method``: The request method to use for the test. Optional, defaults to ``HEAD``.
* ``timeout``: A timeout for the request, in seconds. If no reply from the tested URL has been
received within this time frame, the check will be considered a failure. Optional, defaults to 3 seconds.
* ``validSsl``: Whether to validate the SSL connection if the ``url`` happens to be an HTTPS URL or not. Optional,
defaults to ``True``.
* ``status``: The status code(s) or named status range(s) to test for. Can be either a single
value or a list of either HTTP status codes or any of the following named status ranges:
@@ -63,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
@@ -270,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:
@@ -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``.
+511
View File
@@ -0,0 +1,511 @@
.. _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 sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
authorization process.
3. 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`.
4. 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.
5. 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.
6. 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
User->>App: enters URL of instance to connect to
alt Limit to specific user
User->>App: enters user_id
App->>Server: POST /plugin/appkeys/request, (app_name, user_id)
else
App->>Server: POST /plugin/appkeys/request, (app_name)
end
note over User, Server: Step 3
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 4
loop
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 202
end
note over User, Server: Step 5 & 6
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
.. _sec-bundledplugins-appkeys-api:
API
---
.. _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.
.. note::
If this endpoint produces an HTTP :http:statuscode:`404` and the instance URL is correct, the bundled
Application Keys Plugin has in all likelihood been disabled by the user. Fall back on manual API key copy-pasting
by the user.
: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.
: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.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 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.
**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.
+4 -12
View File
@@ -1,4 +1,4 @@
.. _sec-bundledplugins_cura:
.. _sec-bundledplugins-cura:
Cura
====
@@ -57,18 +57,10 @@ path to that in the plugin settings.
Compiling for Raspbian
++++++++++++++++++++++
.. note::
Raspbian Jessie and later
~~~~~~~~~~~~~~~~~~~~~~~~~
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::
Building on Raspbian Jessie and later 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
+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
View File
@@ -7,7 +7,14 @@ Bundled Plugins
.. toctree::
:maxdepth: 2
action_command_prompt.rst
announcements.rst
appkeys.rst
backup.rst
cura.rst
discovery.rst
forcelogin.rst
logging.rst
pluginmanager.rst
printer_safety_check.rst
softwareupdate.rst
+238
View File
@@ -0,0 +1,238 @@
.. _sec-bundledplugins-logging:
Logging
=======
The OctoPrint Logging plugin comes bundled with OctoPrint starting with version 1.3.7.
It implements the log management functionality that was formerly part of the core application and adds features to
configure logging levels for sub modules through the included settings dialog.
.. _fig-bundledplugins-logging-settings:
.. figure:: ../images/bundledplugins-logging-settings.png
:align: center
:alt: Logging plugin
The settings dialog of the Logging plugin
.. _sec-bundledplugins-logging-api:
API
---
.. note::
All log file management operations require admin rights.
.. _sec-bundledplugins-logging-api-list_logs:
Retrieve a list of available log files
++++++++++++++++++++++++++++++++++++++
.. http:get:: /plugin/logging/logs
Retrieve information regarding all log files currently available and regarding the disk space still available
in the system on the location the log files are being stored.
Returns a :ref:`Logfile Retrieve response <sec-bundledplugins-logging-api-datamodel-retrieveresponse>`.
**Example**
.. sourcecode:: http
GET /plugin/logging/logs HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
.. sourcecode:: http
HTTP/1.1 200 OK
Content-Type: application/json
{
"files" : [
{
"date" : 1393158814,
"name" : "octoprint.log",
"size" : 43712,
"refs": {
"resource": "http://example.com/plugin/logging/logs/octoprint.log",
"download": "http://example.com/downloads/logs/octoprint.log"
}
},
{
"date" : 1392628936,
"name" : "octoprint.log.2014-02-17",
"size" : 13205,
"refs": {
"resource": "http://example.com/plugin/logging/logs/octoprint.log.2014-02-17",
"download": "http://example.com/downloads/logs/octoprint.log.2014-02-17"
}
},
{
"date" : 1393158814,
"name" : "serial.log",
"size" : 1798419,
"refs": {
"resource": "http://example.com/plugin/logging/logs/serial.log",
"download": "http://example.com/downloads/logs/serial.log"
}
}
],
"free": 12237201408
}
:statuscode 200: No error
:statuscode 403: If the given API token did not have admin rights associated with it
.. _sec-bundledplugins-logging-api-delete_logs:
Delete a specific logfile
+++++++++++++++++++++++++
.. http:delete:: /plugin/logging/logs/(path:filename)
Delete the selected log file with name `filename`.
Returns a :http:statuscode:`204` after successful deletion.
**Example Request**
.. sourcecode:: http
DELETE /plugin/logging/logs/octoprint.log.2014-02-17 HTTP/1.1
Host: example.com
X-Api-Key: abcdef...
:param filename: The filename of the log file to delete
:statuscode 204: No error
:statuscode 403: If the given API token did not have admin rights associated with it
:statuscode 404: If the file was not found
.. _sec-bundledplugins-logging-api-datamodel:
Data model
++++++++++
.. _sec-bundledplugins-logging-api-datamodel-retrieveresponse:
Logfile Retrieve Response
~~~~~~~~~~~~~~~~~~~~~~~~~
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``files``
- 0..*
- Array of :ref:`File information items <sec-bundledplugins-logging-api-datamodel-fileinfo>`
- The list of requested files. Might be an empty list if no files are available
* - ``free``
- 1
- String
- The amount of disk space in bytes available in the local disk space (refers to OctoPrint's ``logs`` folder).
.. _sec-bundledplugins-logging-api-datamodel-fileinfo:
File information
~~~~~~~~~~~~~~~~
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``name``
- 1
- String
- The name of the file
* - ``size``
- 1
- Number
- The size of the file in bytes.
* - ``date``
- 1
- Unix timestamp
- The timestamp when this file was last modified.
* - ``refs``
- 1
- :ref:`References <sec-bundledplugins-logging-api-datamodel-ref>`
- References relevant to this file
.. _sec-bundledplugins-logging-api-datamodel-ref:
References
~~~~~~~~~~
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``resource``
- 1
- URL
- The resource that represents the file (e.g. for deleting)
* - ``download``
- 1
- URL
- The download URL for the file
.. _sec-bundledplugins-logging-jsclientlib:
JS Client Library
-----------------
:mod:`OctoPrintClient.plugins.logging`
--------------------------------------
.. note::
All methods here require that the used API token or the existing browser session
has admin rights.
.. js:function:: OctoPrintClient.plugins.logging.listLogs(opts)
Retrieves a list of log files.
See :ref:`Retrieve a list of available log files <sec-bundledplugins-logging-api-list_logs>` 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.plugins.logging.deleteLog(path, opts)
Deletes the specified log ``path``.
See :ref:`Delete a specific log file <sec-bundledplugins-logging-api-delete_logs>` for details.
:param string path: The path to the log file to delete
: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.logging.downloadLog(path, opts)
Downloads the specified log ``file``.
See :js:func:`OctoPrint.download` for more details on the underlying library download mechanism.
:param string path: The path to the log file to download
: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-logging-sourcecode:
Source Code
-----------
The source of the Logging plugin is bundled with OctoPrint and can be found in its source repository under ``src/octoprint/plugins/logging``.
@@ -0,0 +1,38 @@
.. _sec-bundledplugins-printer_safety_check:
Printer Safety Check
====================
The Printer Safety Check plugin comes bundled with OctoPrint starting with version 1.3.7.
It tries to identify printers or rather printer firmwares with known safety issues, such as
disabled thermal runaway protection, and displays a warning box to logged in users on
such identification.
.. _fig-bundledplugins-printer_safety_check-example:
.. figure:: ../images/bundledplugins-printer_safety_check-example.png
:align: center
:alt: Printer Safety Check warning example
An example of a warning generated by the Printer Safety Check
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>`_.
.. note::
Feel free to disable the plugin in OctoPrint's Plugin Manager if you feel like it is unnecessary. Be advised though
that even if your printer might be running totally fine with a known unsafe configuration, that might change
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-source:
Source Code
-----------
The source of the Printer Safety Check plugin is bundled with OctoPrint and can be
found in its source repository under ``src/octoprint/plugins/printer_safety_check``.
+22 -8
View File
@@ -46,7 +46,7 @@ There you can adjust the following settings:
for the various components registered with the plugin, so that they don't have to be queried from the internet every time
you load the page. Defaults to 24h, you usually shouldn't need to change that value.
More settings are available by :ref:`editing the correspondi.. _section in config.yaml <sec-bundledplugins-softwareupdate-configuration>`.
More settings are available by :ref:`editing the corresponding section in config.yaml <sec-bundledplugins-softwareupdate-configuration>`.
That restart commands for OctoPrint and the whole server can be configured under Settings > Server.
@@ -56,9 +56,9 @@ Command line usage
------------------
The functionality of the Software Update Plugin is also available on OctoPrint's command line interface under the
``plugins`` sub command. It's is possible to check for updates via ``octoprint plugins softwareupdate:check``
and to apply available updates via ``octoprint plugins softwareupdate:update``. Please the corresponding
``--help`` pages on details:
``plugins`` sub command. It's possible to check for updates via ``octoprint plugins softwareupdate:check``
and to apply available updates via ``octoprint plugins softwareupdate:update``. Please see the corresponding
``--help`` pages for details:
.. code-block:: none
@@ -126,7 +126,7 @@ Configuring the Plugin
checks:
# "octoprint" is reserved for OctoPrint
octoprint:
# this defines an version check that will check against releases
# this defines a version check that will check against releases
# published on OctoPrint's Github repository and pip as update method
# against the release archives on Github - this is the default
type: github_release
@@ -135,7 +135,7 @@ Configuring the Plugin
method: pip
pip: 'https://github.com/foosel/OctoPrint/archive/{target_version}.zip'
# further checks may be define here
# further checks may be defined here
# pip command, if another one than the automatically detected one should be
# used - should normally NOT be necessary and hence set
@@ -209,10 +209,21 @@ Version checks
:ref:`hook <sec-bundledplugins-softwareupdate-hooks>`. Additional config
parameters:
* ``python_checker``: (mandatory) A python callable which returns version
* ``python_checker``: (mandatory) A Python callable which returns version
information and whether the current version is up-to-date or not, see
below for details.
* ``always_current``: Always reports that no update is necessary. Useful for debugging
software update mechanisms during development. Additional config parameters:
* ``current_version``: Version to report for both local and remote version.
* ``never_current``: Always reports that an update is necessary. Useful for debugging
software update mechanisms during development. Additional config parameters:
* ``local_version``: Current local version. Defaults to ``1.0.0``.
* ``remote_version``: Remote version to offer update to. Defaults to ``1.0.1``.
.. _sec-bundledplugins-softwareupdate-configuration-updatemethods:
Update methods
@@ -230,8 +241,11 @@ Update methods
``update_folder`` setting or if the ``git_commit`` check is used its
``checkout_folder`` setting.
* ``python_updater``: Can only be specified by plugins through the
:ref:`hook <sec-bundledplugins-softwareupdate-hooks>`. A python callable
:ref:`hook <sec-bundledplugins-softwareupdate-hooks>`. A Python callable
which performs the update, see below for details.
* ``sleep_a_bit``: Does nothing but block for a configurable ``duration`` and log
a countdown in the meantime. Useful for debugging software update mechanisms
during development.
.. note::
+123 -82
View File
@@ -36,7 +36,7 @@ Use the following settings to enable access control:
# If set to true, will automatically log on clients originating from any of the networks defined in
# "localNetworks" as the user defined in "autologinAs". Defaults to false.
autologinLocal: true
autologinLocal: false
# The name of the user to automatically log on clients originating from "localNetworks" as. Must
# be the name of one of your configured users.
@@ -51,6 +51,17 @@ Use the following settings to enable access control:
- 127.0.0.0/8
- 192.168.1.0/24
# Whether to trust Basic Authentication headers. If you have setup Basic 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 user during Basic Authentication. Your should ONLY ENABLE THIS if your
# OctoPrint instance is only accessible through a connection locked down through Basic Authentication!
trustBasicAuthentication: false
# Whether to also check the password provided through Basic Authentication if the Basic Authentication
# header is to be trusted. Disabling this will only match the user name in the Basic Authentication
# header and login the user without further checks. Use with caution.
checkBasicAuthenticationPassword: true
.. _sec-configuration-config_yaml-api:
API
@@ -140,7 +151,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
@@ -198,7 +209,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.
@@ -443,7 +454,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.
@@ -522,52 +533,16 @@ Use the following settings to enable or disable OctoPrint features:
.. code-block:: yaml
feature:
# Whether to enable the gcode viewer in the UI or not
gCodeVisualizer: true
# Whether to enable the temperature graph in the UI or not
temperatureGraph: true
# Specifies whether OctoPrint should wait for the start response from the printer before trying to send commands
# during connect.
waitForStartOnConnect: false
# Specifies whether OctoPrint should send linenumber + checksum with every printer command. Needed for
# successful communication with Repetier firmware
alwaysSendChecksum: false
# Specifies whether OctoPrint should also send linenumber + checksum with commands that are *not*
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
sendChecksumWithUnknownCommands: false
# Specifies whether OctoPrint should also use up acknowledgments ("ok") for commands that are *not*
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
unknownCommandsNeedAck: false
# Whether to ignore the first ok after a resend response. Needed for successful communication with
# Repetier firmware
swallowOkAfterResend: false
# Specifies whether support for SD printing and file management should be enabled
sdSupport: true
# Specifies whether firmware expects relative paths for selecting SD files
sdRelativePath: false
# Whether to always assume that an SD card is present in the printer.
# Needed by some firmwares which don't report the SD card status properly.
sdAlwaysAvailable: false
# Whether the printer sends repetier style target temperatures in the format
# TargetExtr0:<temperature>
# instead of attaching that information to the regular M105 responses
repetierTargetTemp: false
# Whether to enable external heatup detection (to detect heatup triggered e.g. through the printer's LCD panel or
# while printing from SD) or not. Causes issues with Repetier's "first ok then response" approach to
# communication, so disable for printers running Repetier firmware.
externalHeatupDetection: true
# Whether to enable the keyboard control feature in the control tab
keyboardControl: true
@@ -575,28 +550,17 @@ Use the following settings to enable or disable OctoPrint features:
# notifications instead (false)
pollWatched: false
# Whether to ignore identical resends from the printer (true, repetier) or not (false)
ignoreIdenticalResends: false
# If ignoredIdenticalResends is true, how many consecutive identical resends to ignore
identicalResendsCount: 7
# Whether to support F on its own as a valid GCODE command (true) or not (false)
supportFAsCommand: false
# Whether to enable model size detection and warning (true) or not (false)
modelSizeDetection: true
# Whether to attempt to auto detect the firmware of the printer and adjust settings
# accordingly (true) or not and rely on manual configuration (false)
firmwareDetection: true
# Whether to show a confirmation on print cancelling (true) or not (false)
printCancelConfirmation: true
# Whether to block all sending to the printer while a G4 (dwell) command is active (true, repetier)
# or not (false)
blockWhileDwelling: false
# Commands that should never be auto-uppercased when sent to the printer through the Terminal tab.
# Defaults to only M117.
autoUppercaseBlacklist:
- M117
- M118
.. _sec-configuration-config_yaml-folder:
@@ -653,15 +617,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:
@@ -672,16 +637,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:
@@ -800,6 +766,10 @@ Use the following settings to configure the serial connection to the printer:
# Defaults to 30 sec
communication: 30
# Timeout during serial communication when busy protocol support is detected, in seconds.
# Defaults to 3 sec
communicationBusy: 3
# Timeout after which to query temperature when no target is set
temperature: 5
@@ -824,7 +794,7 @@ Use the following settings to configure the serial connection to the printer:
# Maximum number of write attempts to serial during which nothing can be written before the communication
# with the printer is considered dead and OctoPrint will disconnect with an error
maxWritePasses:
maxWritePasses: 5
# Use this to define additional patterns to consider for serial port listing. Must be a valid
# "glob" pattern (see http://docs.python.org/2/library/glob.html). Defaults to not set.
@@ -858,10 +828,6 @@ Use the following settings to configure the serial connection to the printer:
helloCommand:
- M110 N0
# Commands that should never be auto-uppercased when sent to the printer. Defaults to only M117.
autoUppercaseBlacklist:
- M117
# Whether to disconnect on errors or not
disconnectOnErrors: true
@@ -872,13 +838,75 @@ Use the following settings to configure the serial connection to the printer:
# impact, leave on if possible please
logResends: true
# Specifies whether OctoPrint should wait for the start response from the printer before trying to send commands
# during connect.
waitForStartOnConnect: false
# Specifies whether OctoPrint should send linenumber + checksum with every printer command. Needed for
# successful communication with Repetier firmware
alwaysSendChecksum: false
# Specifies whether OctoPrint should also send linenumber + checksum with commands that are *not*
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
sendChecksumWithUnknownCommands: false
# Specifies whether OctoPrint should also use up acknowledgments ("ok") for commands that are *not*
# detected as valid GCODE (as in, they do not match the regular expression "^\s*([GM]\d+|T)").
unknownCommandsNeedAck: false
# Whether to ignore the first ok after a resend response. Needed for successful communication with
# Repetier firmware
swallowOkAfterResend: false
# Specifies whether firmware expects relative paths for selecting SD files
sdRelativePath: false
# Whether to always assume that an SD card is present in the printer.
# Needed by some firmwares which don't report the SD card status properly.
sdAlwaysAvailable: false
# Whether the printer sends repetier style target temperatures in the format
# TargetExtr0:<temperature>
# instead of attaching that information to the regular M105 responses
repetierTargetTemp: false
# Whether to enable external heatup detection (to detect heatup triggered e.g. through the printer's LCD panel or
# while printing from SD) or not. Causes issues with Repetier's "first ok then response" approach to
# communication, so disable for printers running Repetier firmware.
externalHeatupDetection: true
# Whether to ignore identical resends from the printer (true, repetier) or not (false)
ignoreIdenticalResends: false
# If ignoredIdenticalResends is true, how many consecutive identical resends to ignore
identicalResendsCount: 7
# Whether to support F on its own as a valid GCODE command (true) or not (false)
supportFAsCommand: false
# Whether to attempt to auto detect the firmware of the printer and adjust settings
# accordingly (true) or not and rely on manual configuration (false)
firmwareDetection: true
# Whether to block all sending to the printer while a G4 (dwell) command is active (true, repetier)
# or not (false)
blockWhileDwelling: false
# Whether to support resends without follow-up ok or not
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:
# Whether to enable temperature autoreport in the firmware if its support is detected
autoreport_temp: true
# Whether to shorten the communication timeout if the firmware seems to support the busy protocol
busy_protocol: true
.. _sec-configuration-config_yaml-server:
Server
@@ -909,7 +937,7 @@ Use the following settings to configure the server:
# 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
@@ -943,6 +971,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
@@ -1067,7 +1103,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
@@ -1082,7 +1123,7 @@ OctoPrint is running is allowed to do this without password entry:
command: sudo shutdown -h now
confirm: You are about to shutdown the system.
You can also add an divider by setting action to divider like this:
You can also add a divider by setting action to divider like this:
.. code-block:: yaml
@@ -1124,7 +1165,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
+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.
+16 -6
View File
@@ -207,8 +207,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 +220,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::
@@ -265,7 +265,7 @@ MetadataAnalysisFinished
* ``name``: the file's name
* ``path``: the file's path within its storage location
* ``origin``: the file's origin storage location
* ``result``: the analysis result -- this is a python object currently only available for internal use
* ``result``: the analysis result -- this is a Python object currently only available for internal use
.. deprecated:: 1.3.0
@@ -363,8 +363,18 @@ PrintDone
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
PrintCancelling
The print is about to be cancelled.
Payload:
* ``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``
* ``firmwareError``: the firmware error that caused cancelling the print job, if any
PrintCancelled
The print has been cancelled via the cancel button.
The print has been cancelled.
Payload:
+8 -2
View File
@@ -31,7 +31,13 @@ Internet!).
.. 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:
@@ -39,7 +45,7 @@ Rerunning the wizard
--------------------
In case Access Control was disabled in the configuration wizard, it is
possibly to re-run it by editing ``config.yaml`` [#f1]_ and setting ``firstRun``
possible to re-run it by editing ``config.yaml`` [#f1]_ and setting ``firstRun``
in the ``server`` section and ``enabled`` in the ``accessControl`` section to
``true``:
+22 -3
View File
@@ -21,16 +21,35 @@ Action commands are a feature defined for the GCODE based RepRap communication p
OctoPrint out of the box supports handling of the above mentioned commands:
cancel
When this command is received from the printer, OctoPrint will cancel a current print job like if the
"Cancel" button had been clicked.
pause
When this command is received from the printer, OctoPrint will pause streaming of a current print job just like if the
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 streaming of a current print job just like if
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.
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.
+30
View File
@@ -0,0 +1,30 @@
.. _sec-features-atcommands:
@ Commands
==========
@ commands (also known as host commands elsewhere) are special commands you may include in GCODE files streamed
through OctoPrint to your printer or send as part of GCODE scripts, through the Terminal Tab, the API or plugins.
Contrary to other commands they will never be sent to the printer but instead trigger functions inside OctoPrint.
They are always of the form ``@<command>[ <parameters>]``, e.g. ``@pause`` or ``@custom_command with some parameters``.
Out of the box OctoPrint supports handling of these commands starting with version 1.3.7:
@cancel
OctoPrint will cancel the current print job like if the "Cancel" button had been clicked. This command doesn't
take any parameters.
@abort
Same as ``cancel``.
@pause
OctoPrint will pause the current print job just like if the "Pause" button had been clicked. This command doesn't
take any parameters.
@resume
OctoPrint will resume the current print job just like if the "Resume" button had been clicked. This command doesn't
take any parameters.
Support for additional commands may be added by plugins by implementing a handler for one of the
:ref:`octoprint.comm.protocol.atcommand <sec-plugins-hook-comm-protocol-atcommand-phase>` hooks.
+4
View File
@@ -166,6 +166,10 @@ Controls
clicked. This allows to override the direct sending of the command or commands to the printer with more
sophisticated behaviour. The JavaScript snippet is ``eval``'d and processed in a context where the control
it is part of is provided as local variable ``data`` and the ``ControlViewModel`` is available as ``self``.
* - ``additionalClasses``
- (Optional) Additional classes to apply to the button of a ``command``, ``commands``, ``script`` or ``javascript``
control, other than the default ``btn``. Can be used to visually style the button, e.g. set to ``btn-danger`` to
turn the button red.
* - ``enabled``
- (Optional) A JavaScript snippet returning either ``true`` or ``false`` determining whether the control
should be enabled or not. This allow to override the default logic for this (disabled if printer is offline
+3 -2
View File
@@ -66,7 +66,7 @@ Context
All GCODE scripts have access to the following template variables through the template context:
* ``printer_profile``: The currently selected Printer Profile, including
* ``printer_profile``: The currently selected :ref:`Printer Profile <sec-modules-printer-profile>`, including
information such as the extruder count, the build volume size, the filament diameter etc.
* ``last_position``: Last position reported by the printer via `M114` (might be unset if no `M114` was sent so far!).
Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and
@@ -75,11 +75,12 @@ 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``
and ``script.name`` respectively.
* ``plugins``: An object containing variables provided by plugins (e.g ``plugins.myplugin.myvariable``)
There are a few additional template variables available for the following specific scripts:
+1
View File
@@ -15,5 +15,6 @@ Features
custom_controls.rst
gcode_scripts.rst
action_commands.rst
atcommands.rst
plugins.rst
safemode.rst
+1 -1
View File
@@ -46,7 +46,7 @@ Manual Installation
If you don't want or can't use the Plugin Manager, plugins may also be installed manually either by copying and
unpacking them into one of the configured plugin folders (regularly those are ``<octoprint source root>/plugins`` and
``<octoprint config folder>/plugins`` [#f1]_ or by installing them as regular python modules via ``pip`` [#f2]_.
``<octoprint config folder>/plugins`` [#f1]_ or by installing them as regular Python modules via ``pip`` [#f2]_.
For a plugin available on the Python Package Index (PyPi), the process is as simple as issuing a
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.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

+18 -3
View File
@@ -6,9 +6,24 @@ Welcome to OctoPrint's documentation!
:alt: The OctoPrint Logo
:align: right
This documentation is still in the process of being migrated from
`OctoPrint's wiki <https://github.com/foosel/OctoPrint/wiki>`_, so also take
a look there!
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/>`_.
The community forum is available at `discourse.octoprint.org <https://discourse.octoprint.org/>`_.
The FAQ can be accessed by following `faq.octoprint.org <https://faq.octoprint.org/>`_.
The official plugin repository can be reached at `plugins.octoprint.org <https://plugins.octoprint.org/>`_.
OctoPrint's development wouldn't be possible without the `financial support by its community <https://octoprint.org/support-octoprint/>`_.
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/>`_!
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
+9 -5
View File
@@ -32,7 +32,7 @@ correct URL prefix:
-->
<script type="text/javascript" src="{{ url_for("static", filename="js/app/client/<component>.js") }}"></script>
Regardless of which way you use to include the library, you'll also need to make sure you included JQuery and lodash,
Regardless of which way you use to include the library, you'll also need to make sure you included jQuery and lodash,
because the library depends on those to be available (as ``$`` and ``_``). You can embed those like this:
.. code-block:: html+jinja
@@ -45,7 +45,7 @@ number of components, make sure to at the very least include that one to be able
When you import the client library as described above, a global variable ``OctoPrint`` will become available, which is
a prepared instance of the ``OctoPrintClient`` class the library assembles from registered components. You can directly
used that singular ``OctoPrint`` instance if you only need to talk to one OctoPrint server:
use that singular ``OctoPrint`` instance if you only need to talk to one OctoPrint server:
.. code-block:: javascript
@@ -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
+1 -1
View File
@@ -64,7 +64,7 @@
.. js:function:: OctoPrintClient.job.resume(opts)
Resumes the current job if it's currently pause, does nothing if it's running.
Resumes the current job if it's currently paused, does nothing if it's running.
See :ref:`Issue a job command <sec-api-jobs-command>` for details.
+1 -1
View File
@@ -5,7 +5,7 @@
.. note::
All methods here require that the used API token or a the existing browser session
All methods here require that the used API token or the existing browser session
has admin rights.
.. js:function:: OctoPrintClient.languages.list(opts)
+5 -33
View File
@@ -3,37 +3,9 @@
:mod:`OctoPrintClient.logs`
---------------------------
.. note::
All methods here require that the used API token or a the existing browser session
has admin rights.
.. js:function:: OctoPrintClient.logs.list(opts)
Retrieves a list of log files.
See :ref:`Retrieve a list of available log files <sec-api-logs-list>` 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.logs.delete(path, opts)
Deletes the specified log ``path``.
See :ref:`Delete a specific log file <sec-api-logs-delete>` for details.
:param string path: The path to the log file to delete
: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.logs.download(path, opts)
Downloads the specified log ``file``.
See :js:func:`OctoPrint.download` for more details on the underlying library download mechanism.
:param string path: The path to the log file to download
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
Log file management (and logging configuration) was moved into a bundled plugin in OctoPrint 1.3.7. Refer to
:ref:`the Logging's plugins JS Client Library <sec-bundledplugins-logging-jsclientlib>` for the JS Client documentation.
The former module ``OctoPrintClient.logs`` and its methods are marked as deprecated but still work for now. New
client implementations should directly use the new module provided by the bundled plugin. Existing implementations
should adapt their used module as soon as possible.
+1 -1
View File
@@ -174,7 +174,7 @@
Sets the given temperature on the printer's heated bed (if available).
``target`` is expected to be a the target temperature as a float value.
``target`` is expected to be the target temperature as a float value.
**Example:**
+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
+2 -2
View File
@@ -5,7 +5,7 @@
.. note::
All methods here require that the used API token or a the existing browser session
All methods here require that the used API token or the existing browser session
has admin rights.
.. js:function:: OctoPrintClient.system.getCommands(opts)
@@ -35,4 +35,4 @@
.. seealso::
:ref:`System API <sec-api-system>`
Documentation of the underlying system API
Documentation of the underlying system API.
+1 -1
View File
@@ -15,7 +15,7 @@
.. js:function:: OctoPrintClient.timelapse.list(opts)
Get the lists of rendered and unrendered timelapses. The returned promis
Get the lists of rendered and unrendered timelapses. The returned promise
will be resolved with an object containing the properties ``rendered``
which will have the list of rendered timelapses, and ``unrendered`` which
will have the list of unrendered timelapses.
+1 -1
View File
@@ -5,7 +5,7 @@
.. note::
Most methods here require that the used API token or a the existing browser session
Most methods here require that the used API token or the existing browser session
has admin rights *or* corresponds to the user to be modified. Some methods
definitely require admin rights.
+2 -2
View File
@@ -5,7 +5,7 @@
.. note::
All methods here require that the used API token or a the existing browser session
All methods here require that the used API token or the existing browser session
has admin rights.
.. js:function:: OctoPrintClient.util.test(command, parameters, opts)
@@ -206,4 +206,4 @@
.. seealso::
:ref:`Util API <sec-api-util>`
Documentation of the underlying util API
Documentation of the underlying util API.
+1 -1
View File
@@ -5,7 +5,7 @@
.. note::
All methods here require that the used API token or a the existing browser session
All methods here require that the used API token or the existing browser session
has admin rights.
.. js:function:: OctoPrintClient.wizard.get(opts)
+7
View File
@@ -4,3 +4,10 @@ octoprint.printer
-----------------
.. automodule:: octoprint.printer
.. _sec-modules-printer-profile:
octoprint.printer.profile
-------------------------
.. automodule:: octoprint.printer.profile
+3 -3
View File
@@ -23,9 +23,9 @@ Lifecycle
There are three sources of installed plugins that OctoPrint will check during start up:
* it's own ``octoprint/plugins`` folder (this is where the bundled plugins reside),
* its own ``octoprint/plugins`` folder (this is where the bundled plugins reside),
* the ``plugins`` folder in its configuration directory (e.g. ``~/.octoprint/plugins`` on Linux),
* any python packages registered for the entry point ``octoprint.plugin``.
* any Python packages registered for the entry point ``octoprint.plugin``.
Each plugin that OctoPrint finds it will first load, then enable. On enabling a plugin, OctoPrint will
register its declared :ref:`hook handlers <sec-plugins-hooks>` and :ref:`helpers <sec-plugins-helpers>`, apply
@@ -36,7 +36,7 @@ any :ref:`settings overlays <sec-plugins-controlproperties-plugin_settings_overl
On disabling a plugin, its hook handlers, helpers, mixin implementations and settings overlays will be de-registered again.
Some plugin types require a reload of the frontend or a restart of OctoPrint for enabling/disabling them. You
can recognized such plugins by their implementations implementing :class:`~octoprint.plugin.ReloadNeedingPlugin` or
can recognize such plugins by their implementations implementing :class:`~octoprint.plugin.ReloadNeedingPlugin` or
:class:`~octoprint.plugin.RestartNeedingPlugin` or providing handlers for one of the hooks marked correspondingly.
.. image:: ../images/plugins_lifecycle.png
+5 -5
View File
@@ -134,7 +134,7 @@ as a simple python file following the naming convention ``<plugin identifier>.py
``~/.octoprint/plugins`` folder. You already know how that works. But let's say you have more than just a simple plugin
that can be done in one file. Distributing multiple files and getting your users to install them in the right way
so that OctoPrint will be able to actually find and load them is certainly not impossible, but we want to do it in the
best way possible, meaning we want to make our plugin a fully installable python module that your users will be able to
best way possible, meaning we want to make our plugin a fully installable Python module that your users will be able to
install directly via `OctoPrint's built-in Plugin Manager <https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager>`_
or alternatively manually utilizing Python's standard package manager ``pip`` directly.
@@ -282,7 +282,7 @@ of information now defined twice:
plugin_version = "1.0.0"
plugin_description = "A quick \"Hello World\" example plugin for OctoPrint"
The nice thing about our plugin now being a proper python package is that OctoPrint can and will access the metadata defined
The nice thing about our plugin now being a proper Python package is that OctoPrint can and will access the metadata defined
within ``setup.py``! So, we don't really need to define all this data twice. Remove ``__plugin_name__``, ``__plugin_version__``
and ``__plugin_description__`` from ``__init__.py``:
@@ -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)
+2 -2
View File
@@ -3,12 +3,12 @@
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
`Discovery Plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Discovery>`_,
which provides it's SSDP browsing and Zeroconf browsing and publishing functions as helper methods.
which provides its SSDP browsing and Zeroconf browsing and publishing functions as helper methods.
.. code-block:: python
:linenos:
+429 -17
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.
@@ -380,6 +380,66 @@ octoprint.cli.commands
OctoPrint's CLI.
:rtype: list
.. _sec-plugins-hook-comm-firmware-info:
octoprint.comm.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-firmware-capabilities:
octoprint.comm.firmware.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 +449,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.
@@ -408,6 +475,52 @@ octoprint.comm.protocol.action
:param str action: The parsed out action command, so for a ``line`` like ``// action:some_command`` this will be
``some_command``
.. _sec-plugins-hook-comm-protocol-atcommand-phase:
octoprint.comm.protocol.atcommand.<phase>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This describes actually two hooks:
* ``octoprint.comm.protocol.atcommand.queuing``
* ``octoprint.comm.protocol.atcommand.sending``
.. py:function:: protocol_atcommandphase_hook(comm_instance, phase, command, parameters, tags=None, *args, **kwargs)
Trigger on :ref:`@ commands <sec-features-atcommands>` as they progress through the ``queuing`` and ``sending``
phases of the comm layer. See :ref:`the gcode phase hook <sec-plugins-hook-comm-protocol-gcode-phase>` for a
detailed description of each of these phases.
Hook handlers may use this to react to arbitrary :ref:`@ commands <sec-features-atcommands>` included in GCODE files
streamed to the printer or sent as part of GCODE scripts, through the API or plugins.
Please note that these hooks do not allow to rewrite, suppress or expand @ commands, they are merely callbacks to
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
different name).
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/custom_atcommand.py
:linenos:
:tab-width: 4
:caption: `custom_action_command.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/custom_atcommand.py>`__
:param object comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str phase: The current phase in the command progression, either ``queuing`` or ``sending``. Will always
match the ``<phase>`` of the hook.
:param str cmd: The @ command without the leading @
:param str parameters: Any parameters provided to the @ command. If none were provided this will be an empty string.
.. _sec-plugins-hook-comm-protocol-gcode-phase:
octoprint.comm.protocol.gcode.<phase>
@@ -420,7 +533,7 @@ This describes actually four hooks:
* ``octoprint.comm.protocol.gcode.sending``
* ``octoprint.comm.protocol.gcode.sent``
.. py:function:: protocol_gcodephase_hook(comm_instance, phase, cmd, cmd_type, gcode, subcode=None, *args, **kwargs)
.. py:function:: protocol_gcodephase_hook(comm_instance, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs)
Pre- and postprocess commands as they progress through the various phases of being sent to the printer. The phases
are the following:
@@ -443,7 +556,39 @@ This describes actually four hooks:
the communication layer or before they are actually sent over the serial port, or to react to the queuing or sending
of commands after the fact. The hook handler will be called with the processing ``phase``, the ``cmd`` to be sent to
the printer as well as the ``cmd_type`` parameter used for enqueuing (OctoPrint will make sure that the send queue
will never contain more than one line with the same ``cmd_type``) and the detected gcode command (if it is one).
will never contain more than one line with the same ``cmd_type``) and the detected ``gcode`` command (if it is one)
as well as its ``subcode`` (if it has one). OctoPrint will also provide any ``tags`` attached to the command throughout
its lifecycle.
Tags are arbitrary strings that can be attached to a command as it moves through the various phases and can be used to e.g.
distinguish between commands that originated in a printed file (``source:file``) vs. a configured GCODE script
(``source:script``) vs. an API call (``source:api``) vs. a plugin (``source:plugin`` or ``source:rewrite`` and
``plugin:<plugin identifier>``). If during development you want to get an idea of the various possible tags, set
the logger ``octoprint.util.comm.command_phases`` to ``DEBUG``, connect to a printer (real or virtual) and take a
look at your ``octoprint.log`` during serial traffic:
.. code-block:: none
2018-02-16 18:20:31,213 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
2018-02-16 18:20:31,216 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: M117 Before T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
2018-02-16 18:20:31,217 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: M117 Before T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
2018-02-16 18:20:31,217 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
2018-02-16 18:20:31,219 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: M117 After T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
2018-02-16 18:20:31,220 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: M117 Before T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
2018-02-16 18:20:31,230 - tornado.access - INFO - 204 POST /api/printer/command (127.0.0.1) 23.00ms
2018-02-16 18:20:31,232 - tornado.access - INFO - 200 POST /api/printer/command (127.0.0.1) 25.00ms
2018-02-16 18:20:31,232 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
2018-02-16 18:20:31,234 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: T0 | gcode: T | tags: [ api:printer.command, source:api, trigger:printer.commands ]
2018-02-16 18:20:31,242 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: M117 After T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
2018-02-16 18:20:31,243 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: M117 After T! | gcode: M117 | tags: [ api:printer.command, phase:queuing, plugin:multi_gcode_test, source:api, source:rewrite, trigger:printer.commands ]
2018-02-16 18:20:38,552 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,552 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,553 - octoprint.util.comm.command_phases - DEBUG - phase: sending | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,553 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: G1 X10 F6000 | gcode: G1 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,555 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: G1 X10 F6000 | gcode: G1 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,556 - octoprint.util.comm.command_phases - DEBUG - phase: sent | command: G91 | gcode: G91 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,556 - octoprint.util.comm.command_phases - DEBUG - phase: queuing | command: G90 | gcode: G90 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
2018-02-16 18:20:38,558 - octoprint.util.comm.command_phases - DEBUG - phase: queued | command: G90 | gcode: G90 | tags: [ api:printer.printhead, source:api, trigger:printer.commands, trigger:printer.jog ]
Defining a ``cmd_type`` other than None will make sure OctoPrint takes care of only having one command of that type
in its sending queue. Predefined types are ``temperature_poll`` for temperature polling via ``M105`` and
@@ -482,6 +627,8 @@ This describes actually four hooks:
should use this option.
* A 2-tuple consisting of a rewritten version of the ``cmd`` and the ``cmd_type``, e.g. ``return "M105", "temperature_poll"``.
Handlers which wish to rewrite both the command and the command type should use this option.
* A 3-tuple consisting of a rewritten version of the ``cmd``, the ``cmd_type`` and any additional ``tags`` you might
want to attach to the lifecycle of the command in a set, e.g. ``return "M105", "temperature_poll", {"my_custom_tag"}``
* **"queuing" phase only**: A list of any of the above to allow for expanding one command into
many. The following example shows how any queued command could be turned into a sequence of a temperature query,
line number reset, display of the ``gcode`` on the printer's display and finally the actual command (this example
@@ -489,7 +636,7 @@ This describes actually four hooks:
.. code-block:: python
def rewrite_foo(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
def rewrite_foo(self, comm_instance, phase, cmd, cmd_type, gcode, subcode=None, tags=None *args, **kwargs):
if gcode or not cmd.startswith("@foo"):
return
@@ -504,6 +651,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
@@ -524,6 +678,7 @@ This describes actually four hooks:
:param str gcode: Parsed GCODE command, e.g. ``G0`` or ``M110``, may also be None if no known command could be parsed
:param str subcode: Parsed subcode of the GCODE command, e.g. ``1`` for ``M80.1``. Will be None if no subcode was provided
or no command could be parsed.
:param tags: Tags attached to the command
:return: None, 1-tuple, 2-tuple or string, see the description above for details.
.. _sec-plugins-hook-comm-protocol-gcode-received:
@@ -534,10 +689,17 @@ octoprint.comm.protocol.gcode.received
.. py:function:: gcode_received_hook(comm_instance, line, *args, **kwargs)
Get the returned lines sent by the printer. Handlers should return the received line or in any case, the modified
version of it. If the the handler returns None, processing will be aborted and the communication layer will get an
version of it. If the handler returns None, processing will be aborted and the communication layer will get an
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.
@@ -552,6 +714,43 @@ octoprint.comm.protocol.gcode.received
:return: The received line or in any case, a modified version of it.
:rtype: str
.. _sec-plugins-hook-comm-protocol-gcode-error:
octoprint.comm.protocol.gcode.error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: gcode_error_hook(comm_instance, error_message, *args, **kwargs)
Get the messages of any errors messages sent by the printer, with the leading ``Error:`` or ``!!`` already
stripped. Handlers should return True if they handled that error internally and it should not be processed by
the system further. Normal processing of these kinds of errors - depending on the configuration of error
handling - involves canceling the ongoing print and possibly also disconnecting.
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
plugin.
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/comm_error_handler_test.py
:linenos:
:tab-width: 4
:caption: `comm_error_handler_test.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/comm_error_handler_test.py>`_
:param MachineCom comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str error_message: The error message received from the printer.
:return: True if the error was handled in the plugin and should not be processed further, False (or None) otherwise.
:rtype: bool
.. _sec-plugins-hook-comm-protocol-scripts:
octoprint.comm.protocol.scripts
@@ -559,19 +758,19 @@ octoprint.comm.protocol.scripts
.. py:function:: protocol_scripts_hook(comm_instance, script_type, script_name, *args, **kwargs)
Return a prefix to prepend and a postfix to append to the script ``script_name`` of type ``type``. Handlers should
Return a prefix to prepend, postfix to append, and optionally a dictionary of variables to provide to the script ``script_name`` of type ``type``. Handlers should
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, with the first entry
defining the prefix (what to *prepend* to the script in question) and the last entry defining the postfix (what to
*append* to the script in question). Both prefix and postfix can be None to signify that nothing should be prepended
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
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
respectively appended.
The returned entries may be either iterables of script lines or a string including newlines of the script lines (which
The returned prefix and postfix entries may be either iterables of script lines or a string including newlines of the script lines (which
will be split by the caller if necessary).
**Example:**
**Example 1:**
Appends an ``M117 OctoPrint connected`` to the configured ``afterPrinterConnected`` GCODE script.
@@ -580,10 +779,19 @@ octoprint.comm.protocol.scripts
:tab-width: 4
:caption: `message_on_connect.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/message_on_connect.py>`_
**Example 2:**
Provides the variable ``myvariable`` to the configured ``beforePrintStarted`` GCODE script.
.. onlineinclude:: https://raw.githubusercontent.com/OctoPrint/Plugin-Examples/master/gcode_script_variables.py
:linenos:
:tab-width: 4
:caption: `gcode_script_variables.py <https://github.com/OctoPrint/Plugin-Examples/blob/master/gcode_script_variables.py>`_
:param MachineCom comm_instance: The :class:`~octoprint.util.comm.MachineCom` instance which triggered the hook.
:param str script_type: The type of the script for which the hook was called, currently only "gcode" is supported here.
:param str script_name: The name of the script for which the hook was called.
:return: A 2-tuple in the form ``(prefix, postfix)`` or None
:return: A 2-tuple in the form ``(prefix, postfix)``, 3-tuple in the form ``(prefix, postfix, variables)``, or None
:rtype: tuple or None
.. _sec-plugins-hook-comm-protocol-temperatures-received:
@@ -603,6 +811,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.
@@ -688,6 +903,44 @@ 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-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
@@ -738,7 +991,7 @@ octoprint.filemanager.preprocessor
``file_object`` will be a subclass of :class:`~octoprint.filemanager.util.AbstractFileWrapper`. Handlers may
access the raw data of the file via :func:`~octoprint.filemanager.util.AbstractFileWrapper.stream`, e.g.
to wrap it further. Handlers which do not wish to handle the `file_object`
to wrap it further. Handlers which do not wish to handle the `file_object` should just return it untouched.
**Example**
@@ -783,13 +1036,107 @@ octoprint.printer.factory
If the factory returns anything but ``None``, it will be assigned to the global ``printer`` instance.
If no of the registered factories return a printer instance, the default :class:`~octoprint.printer.standard.Printer`
If none of the registered factories return a printer instance, the default :class:`~octoprint.printer.standard.Printer`
class will be instantiated.
:param dict components: System components to use for printer instance initialization
: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-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
@@ -885,12 +1232,77 @@ octoprint.server.http.routes
that allows delivery of the requested resource as attachment and access validation through an optional callback.
:class:`~octoprint.server.util.tornado.UrlForwardHandler`
`tornado.web.RequestHandler <http://tornado.readthedocs.org/en/branch4.0/web.html#request-handlers>`_ that proxies
requests to a preconfigured url and returns the response.
requests to a preconfigured URL and returns the response.
:param list server_routes: read-only list of the currently configured server routes
:return: a list of 3-tuples with additional routes as defined above
:rtype: list
.. _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
@@ -1028,7 +1440,7 @@ octoprint.users.factory
If the factory returns anything but ``None``, it will be assigned to the global ``userManager`` instance.
If no of the registered factories return a user manager instance, the class referenced by the ``config.yaml``
If none of the registered factories return a user manager instance, the class referenced by the ``config.yaml``
entry ``accessControl.userManager`` will be initialized if possible, otherwise a stock
:class:`~octoprint.users.FilebasedUserManager` will be instantiated, linked to the default user storage
file ``~/.octoprint/users.yaml``.
+1 -1
View File
@@ -51,7 +51,7 @@ An overview of these properties follows.
.. seealso::
:class:`~octoprint.plugin.core.Plugin` and :class:`~octoprint.plugin.types.OctoPrintPlugin`
Class documentation also containing the properties shared among all mixing implementations.
Class documentation also containing the properties shared among all mixin implementations.
:ref:`Available Mixins <sec-plugins-mixins-available>`
Some mixin types trigger the injection of additional properties.
+1 -1
View File
@@ -153,7 +153,7 @@ An overview of these properties can be found in the section :ref:`Injected Prope
.. seealso::
:class:`~octoprint.plugin.core.Plugin` and :class:`~octoprint.plugin.types.OctoPrintPlugin`
Class documentation also containing the properties shared among all mixing implementations.
Class documentation also containing the properties shared among all mixin implementations.
.. _sec-plugins-mixins-available:
+5 -5
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,
@@ -125,7 +125,7 @@ gcodeFilesViewModel
logViewModel
View model for the logfile settings dialog.
loginStateViewModel
View model for the current loginstate of the user, very interesting for plugins that need to
View model for the current login state of the user, very interesting for plugins that need to
evaluate the current login state or information about the current user, e.g. associated roles.
navigationViewModel
View model for the navigation bar.
@@ -168,7 +168,7 @@ OctoPrint's web application will call several callbacks on all registered view m
Those are listed below:
onStartup()
Called when the first initialization has been done: All view models are constructed and hence their dependencies
Called when the first initialization has been done. All view models are constructed and hence their dependencies
resolved, no bindings have been done yet.
onBeforeBinding()
@@ -210,7 +210,7 @@ onDataUpdaterPluginMessage(plugin, message)
Called when a plugin message is pushed from the server with the identifier of the calling plugin as first
and the actual message as the second parameter. Note that the latter might be a full fledged object, depending
on the plugin sending the message. You can use this method to asynchronously push data from your plugin's server
component to it's frontend component.
component to its frontend component.
onUserLoggedIn(user)
Called when a user gets logged into the web app, either passively (upon initial load of the page due to a valid
+1 -1
View File
@@ -1,5 +1,5 @@
[metadata]
description-file = README.md
license_file = LICENSE.txt
[versioneer]
VCS = git
+75 -64
View File
@@ -12,47 +12,53 @@ import octoprint_setuptools
#-----------------------------------------------------------------------------------------------------------------------
# Supported python versions
PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11
# 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,<2.8",
"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
# 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.14.1,<0.15",
"PyYAML>=3.13,<4",
"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.7,<0.11",
"pylru>=1.1,<1.2",
"rsa>=4.0,<5",
"pkginfo>=1.4.2,<1.5",
"requests>=2.20.0,<3",
"semantic_version>=2.6,<2.7",
"psutil>=5.4.8,<5.5",
"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"
"future>=0.17,<0.18",
"scandir>=1.9,<1.10",
"websocket-client>=0.53,<0.54",
"python-dateutil>=2.7.5,<2.8",
"wrapt>=1.10.11,<1.11",
"futures>=3.2,<3.3",
"emoji>=0.5.1,<0.6",
"monotonic>=1.5,<1.6",
"frozendict>=1.2,<1.3"
]
if sys.platform == "darwin":
@@ -64,34 +70,35 @@ 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
"sphinx>=1.6,<1.7",
"sphinx>=1.8.1,<1.9",
"sphinxcontrib-httpdomain",
"sphinxcontrib-mermaid>=0.3",
"sphinx_rtd_theme",
# PyPi upload related
"pypandoc"
],
# 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()
@@ -147,45 +154,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://discourse.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 = {
+62 -31
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,80 @@ 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
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 settings 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 +232,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"
@@ -322,12 +356,9 @@ def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connecti
plugin_validators = []
if safe_mode:
def validator(phase, plugin_info):
if phase == "after_load":
if phase in ("before_import", "before_load", "before_enable"):
setattr(plugin_info, "safe_mode_victim", not plugin_info.bundled)
setattr(plugin_info, "safe_mode_enabled", False)
elif phase == "before_enable":
if not plugin_info.bundled:
setattr(plugin_info, "safe_mode_enabled", True)
return False
return True
plugin_validators.append(validator)
@@ -440,7 +471,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
result.append((entry["plugin"], version))
else:
logger.debug("Blacklisted plugin: {}".format(entry["plugin"]))
result.append(entry["key"])
result.append(entry["plugin"])
return result
-1
View File
@@ -305,7 +305,6 @@ def git_parse_lookup_file(path):
if not os.path.exists(path):
return []
import re
lookup = []
with open(path, "r") as f:
for line in f:
+3
View File
@@ -71,3 +71,6 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
click.echo("DONE:{}s".format(time.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()
+7 -3
View File
@@ -82,12 +82,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,
+1 -1
View File
@@ -6,7 +6,7 @@ Originally from http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon
"""
from __future__ import absolute_import, division, print_function
import sys, os, time, signal, io
import sys, os, time, signal
class Daemon:
"""
+2 -2
View File
@@ -83,8 +83,8 @@ class EnvironmentDetector(object):
# try to find pip version
try:
import pip
result["pip"] = pip.__version__
import pkg_resources
result["pip"] = pkg_resources.get_distribution("pip").version
except:
self._logger.exception("Error detecting pip version")
+2
View File
@@ -69,6 +69,7 @@ class Events(object):
PRINT_STARTED = "PrintStarted"
PRINT_DONE = "PrintDone"
PRINT_FAILED = "PrintFailed"
PRINT_CANCELLING = "PrintCancelling"
PRINT_CANCELLED = "PrintCancelled"
PRINT_PAUSED = "PrintPaused"
PRINT_RESUMED = "PrintResumed"
@@ -87,6 +88,7 @@ class Events(object):
EJECT = "Eject"
E_STOP = "EStop"
POSITION_UPDATE = "PositionUpdate"
FIRMWARE_DATA = "FirmwareData"
TOOL_CHANGE = "ToolChange"
REGISTERED_MESSAGE_RECEIVED = "RegisteredMessageReceived"
+9 -10
View File
@@ -256,7 +256,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
@@ -470,16 +470,15 @@ class FileManager(object):
file_object = hook_file_object
queue_entry = self._analysis_queue_entry(destination, path)
self._analysis_queue.dequeue(queue_entry)
if queue_entry is not None:
self._analysis_queue.dequeue(queue_entry)
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,
@@ -698,7 +697,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()
@@ -707,6 +706,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
+39 -9
View File
@@ -20,7 +20,7 @@ from octoprint.events import Events, eventManager
from octoprint.settings import settings
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 +33,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 +51,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 +61,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)
@@ -76,6 +76,9 @@ class AnalysisQueue(object):
self._callbacks.remove(callback)
def enqueue(self, entry, high_priority=False):
if entry is None:
return False
if not entry.type in self._queues:
return False
@@ -83,6 +86,9 @@ class AnalysisQueue(object):
return True
def dequeue(self, entry):
if entry is None:
return False
if not entry.type in self._queues:
return False
@@ -293,7 +299,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.
@@ -301,6 +307,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):
@@ -314,6 +342,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"])
@@ -337,7 +367,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
+155 -105
View File
@@ -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`.
@@ -564,7 +565,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 +634,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
@@ -695,7 +696,7 @@ class LocalFileStorage(StorageInterface):
display = destination_data["display"]
else:
display = None
destination_meta = self._get_metadata_entry(destination_data["path"], destination_data["name"],
default=dict())
if display:
@@ -712,14 +713,14 @@ class LocalFileStorage(StorageInterface):
shutil.copytree(source_data["fullpath"], destination_data["fullpath"])
except Exception as e:
raise StorageError("Could not copy %s in %s to %s in %s" % (source_data["name"], source_data["path"], destination_data["name"], destination_data["path"]), cause=e)
self._set_display_metadata(destination_data, source_data=source_data)
return self.path_in_storage(destination_data["fullpath"])
def move_folder(self, source, destination):
source_data, destination_data = self._get_source_destination_data(source, destination)
# only a display rename? Update that and bail early
if source_data["fullpath"] == destination_data["fullpath"]:
self._set_display_metadata(destination_data)
@@ -839,7 +840,7 @@ class LocalFileStorage(StorageInterface):
destination_data["path"], destination_data["name"],
delete_source=True)
self._set_display_metadata(destination_data, source_data=source_data)
return self.path_in_storage(destination_data["fullpath"])
def has_analysis(self, path):
@@ -988,7 +989,7 @@ class LocalFileStorage(StorageInterface):
absolute path including leading ``basefolder`` path.
"""
path = to_unicode(path)
if len(path):
if path[0] == u"/":
path = path[1:]
@@ -1114,7 +1115,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:
@@ -1277,7 +1278,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)
@@ -1316,91 +1317,101 @@ class LocalFileStorage(StorageInterface):
path_in_location = entry_name if not base else base + entry_name
# file handling
if entry_is_file:
type_path = octoprint.filemanager.get_file_type(entry_name)
if not type_path:
# only supported extensions
continue
else:
file_type = type_path[0]
try:
# file handling
if entry_is_file:
type_path = octoprint.filemanager.get_file_type(entry_name)
if not type_path:
# only supported extensions
continue
else:
file_type = type_path[0]
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:
metadata[entry_name]["display"] = entry_display
entry_metadata["display"] = entry_display
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:
metadata[entry_name]["display"] = entry_display
entry_metadata["display"] = entry_display
metadata_dirty = True
else:
entry_metadata = self._add_basic_metadata(path, entry_name,
display_name=entry_display,
save=False,
metadata=metadata)
metadata_dirty = True
else:
entry_metadata = self._add_basic_metadata(path, entry_name,
display_name=entry_display,
save=False,
metadata=metadata)
metadata_dirty = True
# TODO extract model hash from source if possible to recreate link
# TODO extract model hash from source if possible to recreate link
if not entry_filter or entry_filter(entry_name, entry_metadata):
# only add files passing the optional filter
extended_entry_data = dict()
extended_entry_data.update(entry_metadata)
extended_entry_data["name"] = entry_name
extended_entry_data["display"] = entry_metadata.get("display", entry_name)
extended_entry_data["path"] = path_in_location
extended_entry_data["type"] = file_type
extended_entry_data["typePath"] = type_path
stat = entry_stat
if stat:
extended_entry_data["size"] = stat.st_size
extended_entry_data["date"] = int(stat.st_mtime)
if not entry_filter or entry_filter(entry_name, entry_metadata):
# only add files passing the optional filter
extended_entry_data = dict()
extended_entry_data.update(entry_metadata)
extended_entry_data["name"] = entry_name
extended_entry_data["display"] = entry_metadata.get("display", entry_name)
extended_entry_data["path"] = path_in_location
extended_entry_data["type"] = file_type
extended_entry_data["typePath"] = type_path
stat = entry_stat
if stat:
extended_entry_data["size"] = stat.st_size
extended_entry_data["date"] = int(stat.st_mtime)
result[entry_name] = extended_entry_data
result[entry_name] = extended_entry_data
# folder recursion
elif entry_is_dir:
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:
metadata[entry_name]["display"] = entry_display
entry_metadata["display"] = entry_display
# folder recursion
elif entry_is_dir:
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:
metadata[entry_name]["display"] = entry_display
entry_metadata["display"] = entry_display
metadata_dirty = True
elif entry_name != entry_display:
entry_metadata = self._add_basic_metadata(path, entry_name,
display_name=entry_display,
save=False,
metadata=metadata)
metadata_dirty = True
elif entry_name != entry_display:
entry_metadata = self._add_basic_metadata(path, entry_name,
display_name=entry_display,
save=False,
metadata=metadata)
metadata_dirty = True
else:
entry_metadata = dict()
else:
entry_metadata = dict()
entry_data = dict(
name=entry_name,
display=entry_metadata.get("display", entry_name),
path=path_in_location,
type="folder",
typePath=["folder"]
)
if recursive:
sub_result = self._list_folder(entry_path, base=path_in_location + "/", entry_filter=entry_filter,
recursive=recursive)
entry_data["children"] = sub_result
if not entry_filter or entry_filter(entry_name, entry_data):
def get_size():
total_size = 0
for element in entry_data["children"].values():
if "size" in element:
total_size += element["size"]
return total_size
# only add folders passing the optional filter
extended_entry_data = dict()
extended_entry_data.update(entry_data)
entry_data = dict(
name=entry_name,
display=entry_metadata.get("display", entry_name),
path=path_in_location,
type="folder",
typePath=["folder"]
)
if recursive:
extended_entry_data["size"] = get_size()
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
result[entry_name] = extended_entry_data
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():
if "size" in element:
total_size += element["size"]
return total_size
extended_entry_data = dict()
extended_entry_data.update(entry_data)
if recursive:
extended_entry_data["size"] = get_size()
result[entry_name] = extended_entry_data
except:
# So something went wrong somewhere while processing this file entry - log that and continue
self._logger.exception("Error while processing entry {}".format(entry_path))
continue
# TODO recreate links if we have metadata less entries
@@ -1507,14 +1518,16 @@ class LocalFileStorage(StorageInterface):
if path in self._metadata_cache:
return deepcopy(self._metadata_cache[path])
metadata_path = os.path.join(path, ".metadata.yaml")
self._migrate_metadata(path)
metadata_path = os.path.join(path, ".metadata.json")
if os.path.exists(metadata_path):
with open(metadata_path) as f:
try:
import yaml
metadata = yaml.safe_load(f)
import json
metadata = json.load(f)
except:
self._logger.exception("Error while reading .metadata.yaml from {path}".format(**locals()))
self._logger.exception("Error while reading .metadata.json from {path}".format(**locals()))
else:
if isinstance(metadata, dict):
self._metadata_cache[path] = deepcopy(metadata)
@@ -1523,27 +1536,63 @@ class LocalFileStorage(StorageInterface):
def _save_metadata(self, path, metadata):
with self._get_metadata_lock(path):
metadata_path = os.path.join(path, ".metadata.yaml")
metadata_path = os.path.join(path, ".metadata.json")
try:
import yaml
import json
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()))
self._logger.exception("Error while writing .metadata.json to {path}".format(**locals()))
else:
self._metadata_cache[path] = deepcopy(metadata)
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()))
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()))
if path in self._metadata_cache:
del self._metadata_cache[path]
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_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
# TODO 1.3.10 Remove ".metadata.yaml" files
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=(",", ": "))
# TODO 1.3.10 Remove ".metadata.yaml" files
@contextmanager
def _get_metadata_lock(self, path):
with self._metadata_lock_mutex:
@@ -1555,8 +1604,9 @@ 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:
+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)
+2 -1
View File
@@ -94,7 +94,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"]
+232 -125
View File
@@ -137,13 +137,14 @@ class PluginInfo(object):
attr_disable = '__plugin_disable__'
""" Module attribute which to call when disabling the plugin. """
def __init__(self, key, location, instance, name=None, version=None, description=None, author=None, url=None, license=None):
def __init__(self, key, location, instance, name=None, version=None, description=None, author=None, url=None, license=None, parsed_metadata=None):
self.key = key
self.location = location
self.instance = instance
self.origin = None
self.enabled = True
self.blacklisted = False
self.forced_disabled = False
self.bundled = False
self.loaded = False
self.managable = True
@@ -156,10 +157,17 @@ class PluginInfo(object):
self._url = url
self._license = license
self._logger = logging.getLogger(__name__)
self._cached_parsed_metadata = parsed_metadata
def validate(self, phase, additional_validators=None):
result = True
if phase == "before_load":
if phase == "before_import":
result = not self.forced_disabled and not self.blacklisted and result
elif phase == "before_load":
# if the plugin still uses __plugin_init__, log a deprecation warning and move it to __plugin_load__
if hasattr(self.instance, self.__class__.attr_init):
if not hasattr(self.instance, self.__class__.attr_load):
@@ -193,7 +201,7 @@ class PluginInfo(object):
if additional_validators is not None:
for validator in additional_validators:
result = result and validator(phase, self)
result = validator(phase, self) and result
return result
@@ -288,7 +296,9 @@ class PluginInfo(object):
Returns:
str: Name of the plugin, fallback is the plugin's identifier.
"""
return self._get_instance_attribute(self.__class__.attr_name, defaults=(self._name, self.key))
return self._get_instance_attribute(self.__class__.attr_name,
defaults=(self._name, self.key),
incl_metadata=True)
@property
def description(self):
@@ -300,7 +310,9 @@ class PluginInfo(object):
Returns:
str or None: Description of the plugin.
"""
return self._get_instance_attribute(self.__class__.attr_description, default=self._description)
return self._get_instance_attribute(self.__class__.attr_description,
default=self._description,
incl_metadata=True)
@property
def disabling_discouraged(self):
@@ -324,7 +336,9 @@ class PluginInfo(object):
Returns:
str or None: Version of the plugin.
"""
return self._version if self._version is not None else self._get_instance_attribute(self.__class__.attr_version, default=self._version)
return self._version if self._version is not None else self._get_instance_attribute(self.__class__.attr_version,
default=self._version,
incl_metadata=True)
@property
def author(self):
@@ -335,7 +349,9 @@ class PluginInfo(object):
Returns:
str or None: Author of the plugin.
"""
return self._get_instance_attribute(self.__class__.attr_author, default=self._author)
return self._get_instance_attribute(self.__class__.attr_author,
default=self._author,
incl_metadata=True)
@property
def url(self):
@@ -346,7 +362,9 @@ class PluginInfo(object):
Returns:
str or None: Website URL for the plugin.
"""
return self._get_instance_attribute(self.__class__.attr_url, default=self._url)
return self._get_instance_attribute(self.__class__.attr_url,
default=self._url,
incl_metadata=True)
@property
def license(self):
@@ -357,7 +375,9 @@ class PluginInfo(object):
Returns:
str or None: License of the plugin.
"""
return self._get_instance_attribute(self.__class__.attr_license, default=self._license)
return self._get_instance_attribute(self.__class__.attr_license,
default=self._license,
incl_metadata=True)
@property
def hooks(self):
@@ -448,15 +468,79 @@ class PluginInfo(object):
"""
return self._get_instance_attribute(self.__class__.attr_disable, default=lambda: True)
def _get_instance_attribute(self, attr, default=None, defaults=None):
def _get_instance_attribute(self, attr, default=None, defaults=None, incl_metadata=False):
if self.instance is None or not hasattr(self.instance, attr):
if defaults is not None:
if incl_metadata and attr in self.parsed_metadata:
return self.parsed_metadata[attr]
elif defaults is not None:
for value in defaults:
if callable(value):
value = value()
if value is not None:
return value
return default
return getattr(self.instance, attr)
@property
def parsed_metadata(self):
if self._cached_parsed_metadata is None:
self._cached_parsed_metadata = self._parse_metadata()
return self._cached_parsed_metadata
def _parse_metadata(self):
result = dict()
path = self.location
if not path:
return result
if os.path.isdir(path):
path = os.path.join(self.location, "__init__.py")
if not os.path.isfile(path):
return result
if not path.endswith(".py"):
# we only support parsing plain text source files
return result
self._logger.debug("Parsing plugin metadata for {} from AST of {}".format(self.key, path))
try:
import ast
with open(path, "rb") as f:
root = ast.parse(f.read())
assignments = filter(lambda x: isinstance(x, ast.Assign) and x.targets,
root.body)
def extract_target_ids(node):
return map(lambda x: x.id,
filter(lambda x: isinstance(x, ast.Name), node.targets))
for key in (self.__class__.attr_name, self.__class__.attr_version, self.__class__.attr_author,
self.__class__.attr_description, self.__class__.attr_url, self.__class__.attr_license):
for a in reversed(assignments):
targets = extract_target_ids(a)
if key in targets:
if isinstance(a.value, ast.Str):
result[key] = a.value.s
elif isinstance(a.value, ast.Call) and hasattr(a.value, "func") \
and a.value.func.id == "gettext" and a.value.args \
and isinstance(a.value.args[0], ast.Str):
result[key] = a.value.args[0].s
break
except:
pass
return result
class PluginManager(object):
"""
@@ -546,30 +630,46 @@ 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")
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
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:
@@ -587,39 +687,49 @@ class PluginManager(object):
for entry in scandir(folder):
try:
if entry.is_dir() and os.path.isfile(os.path.join(entry.path, "__init__.py")):
key = entry.name
elif entry.is_file() and entry.name.endswith(".py"):
key = entry.name[:-3] # strip off the .py extension
if key.startswith("__"):
# might be an __init__.py in our plugins folder, or something else we don't want
# to handle
if entry.is_dir():
init_py = os.path.join(entry.path, "__init__.py")
init_pyc = os.path.join(entry.path, "__init__.pyc")
if not os.path.isfile(init_py) and not os.path.isfile(init_pyc):
# neither does exist, we ignore this
continue
key = entry.name
elif entry.is_file():
key, ext = os.path.splitext(entry.name)
if ext not in (".py", ".pyc") or key.startswith("__"):
# neither py nor pyc, or starts with __ (like __init__), we ignore this
continue
else:
# 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
plugin = self._import_plugin_from_module(key, folder=folder)
bundled = flagged_readonly
plugin = self._import_plugin_from_module(key, folder=folder, bundled=bundled)
if plugin:
plugin.origin = FolderOrigin("folder", folder)
plugin.managable = not flagged_readonly and not actual_readonly
plugin.bundled = flagged_readonly
plugin.enabled = False
result[key] = plugin
added[key] = plugin
except:
self.logger.exception("Error processing folder entry {!r} from folder {}".format(entry, folder))
except:
self.logger.exception("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()
@@ -653,29 +763,30 @@ 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("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:
plugin.origin = EntryPointOrigin("entry_point", group, module_name, package_name, version)
plugin.enabled = False
# plugin is manageable if its location is writable and OctoPrint
# is either not running from a virtual env or the plugin is
@@ -685,19 +796,19 @@ class PluginManager(object):
plugin.managable = os.access(plugin.location, os.W_OK) \
and (not self._python_virtual_env
or is_sub_path_of(plugin.location, self._python_prefix)
or is_editable_install(self._python_install_dir,
package_name,
module_name,
plugin.location))
or is_editable_install(self._python_install_dir,
package_name,
module_name,
plugin.location))
plugin.enabled = False
result[key] = plugin
added[key] = plugin
except:
self.logger.exception("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):
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):
# TODO error handling
try:
if folder:
@@ -710,29 +821,47 @@ class PluginManager(object):
self.logger.warn("Could not locate plugin {key}".format(key=key))
return None
if self._is_plugin_blacklisted(key) or (version is not None and self._is_plugin_version_blacklisted(key, version)):
plugin = PluginInfo(key, module[1], None, name=name, version=version, description=summary, author=author, url=url, license=license)
# Create a simple dummy entry first ...
plugin = PluginInfo(key, module[1], None, name=name, version=version, description=summary, author=author,
url=url, license=license)
plugin.bundled = bundled
if self._is_plugin_disabled(key):
self.logger.info("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))
plugin.blacklisted = True
self.logger.warn("Plugin {} is blacklisted. Not importing it, only registering a dummy entry.".format(plugin))
if not plugin.validate("before_import", additional_validators=self.plugin_validators):
return plugin
plugin = self._import_plugin(key, *module, name=name, version=version, summary=summary, author=author, url=url, license=license)
if plugin is None:
# ... then create and return the real one
return self._import_plugin(key, *module,
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):
try:
instance = imp.load_module(key, f, filename, description)
plugin = PluginInfo(key, filename, instance,
name=name,
version=version,
description=summary,
author=author,
url=url,
license=license,
parsed_metadata=parsed_metadata)
plugin.bundled = bundled
except:
self.logger.exception("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)))
return None
def _import_plugin(self, key, f, filename, description, name=None, version=None, summary=None, author=None, url=None, license=None):
try:
instance = imp.load_module(key, f, filename, description)
return PluginInfo(key, filename, instance, name=name, version=version, description=summary, author=author, url=url, license=license)
except:
self.logger.exception("Error loading plugin {key}".format(key=key))
self.logger.info("Plugin {plugin} did not pass check, not loading.".format(plugin=str(plugin)))
return None
def _is_plugin_disabled(self, key):
@@ -759,13 +888,28 @@ class PluginManager(object):
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:
if not plugin.blacklisted and not plugin.forced_disabled:
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
except PluginNeedsRestart:
pass
@@ -777,9 +921,9 @@ 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 self._is_plugin_disabled(name):
if plugin.loaded and not plugin.forced_disabled:
if plugin.blacklisted:
self.logger.warn("Plugin {} is blacklisted. Not enabling it.".format(plugin))
continue
@@ -836,14 +980,8 @@ class PluginManager(object):
plugin.load()
plugin.validate("after_load", additional_validators=self.plugin_validators)
self.on_plugin_loaded(name, plugin)
plugin.loaded = True
# we might only now have a version, so check again if we are blacklisted
if not plugin.blacklisted and plugin.version and self._is_plugin_version_blacklisted(plugin.key,
plugin.version):
plugin.blacklisted = True
self.logger.debug("Loaded plugin {name}: {plugin}".format(**locals()))
except PluginLifecycleException as e:
raise e
@@ -1486,56 +1624,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):
+47 -3
View File
@@ -225,6 +225,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 +241,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']
)
@@ -1443,7 +1446,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!
"""
@@ -1481,7 +1484,7 @@ class SettingsPlugin(OctoPrintPlugin):
:return: the current settings of the plugin, as a dictionary
"""
from flask.ext.login import current_user
from flask_login import current_user
import copy
data = copy.deepcopy(self._settings.get_all_data(merged=True))
@@ -1861,6 +1864,47 @@ class SlicerPlugin(OctoPrintPlugin):
destination_extensions=["gco", "gcode", "g"]
)
def get_slicer_profiles(self, profile_path):
"""
Fetch all :class:`~octoprint.slicing.SlicingProfile` stored for this slicer.
For compatibility reasons with existing slicing plugins this method defaults to returning profiles parsed from
.profile files in the plugin's ``profile_path``, utilizing the :func:`SlicingPlugin.get_slicer_profile` method
of the plugin implementation.
Arguments:
profile_path (str): The base folder where OctoPrint stores this slicer plugin's profiles
"""
try:
from os import scandir
except ImportError:
from scandir import scandir
import octoprint.util
profiles = dict()
for entry in scandir(profile_path):
if not entry.name.endswith(".profile") or octoprint.util.is_hidden_path(entry.name):
# we are only interested in profiles and no hidden files
continue
profile_name = entry.name[:-len(".profile")]
profiles[profile_name] = self.get_slicer_profile(entry.path)
return profiles
# noinspection PyMethodMayBeStatic
def get_slicer_profiles_lastmodified(self, profile_path):
import os
try:
from os import scandir
except ImportError:
from scandir import scandir
lms = [os.stat(profile_path).st_mtime]
lms += [os.stat(entry.path).st_mtime for entry in scandir(profile_path) if entry.name.endswith(".profile")]
return max(lms)
# noinspection PyMethodMayBeStatic
def get_slicer_default_profile(self):
"""
@@ -1943,7 +1987,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.
@@ -0,0 +1,167 @@
# 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
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.SettingsPlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.TemplatePlugin):
# noinspection PyMissingConstructor
def __init__(self):
self._prompt = None
self._selection_command = None
def initialize(self):
self._selection_command = self._settings.get([b"selection_command"])
#~ AssetPlugin
def get_assets(self):
return dict(js=["js/action_command_prompt.js"],
clientjs=["clientjs/action_command_prompt.js"])
#~ SettingsPlugin
def get_settings_defaults(self):
return dict(selection_command=None)
def on_settings_save(self, data):
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
self._selection_command = self._settings.get([b"selection_command"])
#~ 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
if self._selection_command is None:
self._logger.info("Got a prompt command from the printer but no selection command is defined")
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
#~ prompt handling
def _show_prompt(self):
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):
self._prompt = None
self._plugin_manager.send_plugin_message(self._identifier, dict(action="close"))
def _answer_prompt(self, choice):
self._close_prompt()
self._printer.commands([self._selection_command.format(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
}
@@ -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,78 @@
$(function() {
function ActionCommandPromptViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
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._showPrompt(data.text, data.choices);
}
};
self._showPrompt = function(text, buttons) {
var opts = {
title: gettext("Message from your printer"),
message: text,
selections: buttons,
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() {
if (self._modal) {
self._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._showPrompt(data.text, data.choices);
break;
}
case "close": {
self._closePrompt();
break;
}
}
}
}
OCTOPRINT_VIEWMODELS.push({
construct: ActionCommandPromptViewModel,
dependencies: ["loginStateViewModel"]
});
});
@@ -0,0 +1,11 @@
<h3>{{ _('Action Command Prompt Settings') }}</h3>
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">{{ _('Selection Command') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.plugins.action_command_prompt.selection_command">
<div class="help-block">{{ _('Use this to define the command to tell the printer about the selection. OctoPrint will replace <code>{choice}</code> with the index of the selected choice. E.g. <code>M876 S{choice}</code> will become <code>M123 S1</code>') }}</div>
</div>
</div>
</form>
+19 -10
View File
@@ -23,7 +23,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 flask.ext.babel import gettext
from flask_babel import gettext
from octoprint import __version__ as OCTOPRINT_VERSION
class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
@@ -60,27 +60,27 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
description="Important announcements about OctoPrint.",
priority=1,
type="rss",
url="http://octoprint.org/feeds/important.xml"),
url="https://octoprint.org/feeds/important.xml"),
_releases=dict(name="Release Announcements",
description="Announcements of new releases and release candidates of OctoPrint.",
priority=2,
type="rss",
url="http://octoprint.org/feeds/releases.xml"),
url="https://octoprint.org/feeds/releases.xml"),
_blog=dict(name="On the OctoBlog",
description="Development news, community spotlights, OctoPrint On Air episodes and more from the official OctoBlog.",
priority=2,
type="rss",
url="http://octoprint.org/feeds/octoblog.xml"),
url="https://octoprint.org/feeds/octoblog.xml"),
_plugins=dict(name="New Plugins in the Repository",
description="Announcements of new plugins released on the official Plugin Repository.",
priority=2,
type="rss",
url="http://plugins.octoprint.org/feed.xml"),
url="https://plugins.octoprint.org/feed.xml"),
_octopi=dict(name="OctoPi News",
description="News around OctoPi, the Raspberry Pi image including OctoPrint.",
priority=2,
type="rss",
url="http://octoprint.org/feeds/octopi.xml")),
url="https://octoprint.org/feeds/octopi.xml")),
enabled_channels=[],
forced_channels=["_important"],
channel_order=["_important", "_releases", "_blog", "_plugins", "_octopi"],
@@ -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()
}
}
})
};
@@ -256,7 +260,7 @@ $(function() {
text += "</ul>";
if (rest) {
text += gettext(_.sprintf("... and %(rest)d more.", {rest: rest}));
text += "<p>" + gettext(_.sprintf("... and %(rest)d more.", {rest: rest})) + "</p>";
}
text += "<small>" + gettext("You can edit your announcement subscriptions under Settings > Announcements.") + "</small>";
@@ -28,7 +28,7 @@
<div class="content" data-bind="html: $data.summary"></div>
<div class="actions">
<span class="articlelink"><small><a data-bind="text: $root.cleanedLink($data), attr: {href: $data.link}" target="_blank" rel="noreferrer noopener"></a></small></span>
<span class="markread"><small><a href="javascript:void(0)" data-bind="click: function() { $root.markRead($parent.key, $data.published) }"><i class="fa fa-eye"></i> {{ _('Mark as last read') }}</a></small></span>
<span class="markread"><small><a href="javascript:void(0)" data-bind="click: function() { $root.markRead($parent.key, $data.published, true) }"><i class="fa fa-eye"></i> {{ _('Mark as last read') }}</a></small></span>
</div>
</article>
<!-- /ko -->
+371
View File
@@ -0,0 +1,371 @@
# coding=utf-8
from __future__ import absolute_import
import flask
import threading
import os
import yaml
import codecs
import time
from binascii import hexlify
from collections import defaultdict
from flask_babel import gettext
import octoprint.plugin
from octoprint.settings import valid_boolean_trues
from octoprint.server.util.flask import restricted_access, no_firstrun_access
from octoprint.server import NO_CONTENT, current_user, admin_permission
from octoprint.util import atomic_write, monotonic_time
CUTOFF_TIME = 10 * 60 # 10min
class AppAlreadyExists(Exception):
pass
class PendingDecision(object):
def __init__(self, app_id, app_token, user_id, user_token):
self.app_id = app_id
self.app_token = app_token
self.user_id = user_id
self.user_token = user_token
self.created = monotonic_time()
def external(self):
return dict(app_id=self.app_id,
user_id=self.user_id,
user_token=self.user_token)
class ReadyDecision(object):
def __init__(self, app_id, app_token, user_id):
self.app_id = app_id
self.app_token = app_token
self.user_id = user_id
@classmethod
def for_pending(cls, pending, user_id):
return cls(pending.app_id, pending.app_token, user_id)
class ActiveKey(object):
def __init__(self, app_id, api_key, user_id):
self.app_id = app_id
self.api_key = api_key
self.user_id = user_id
def external(self):
return dict(app_id=self.app_id,
api_key=self.api_key,
user_id=self.user_id)
def internal(self):
return dict(app_id=self.app_id,
api_key=self.api_key)
@classmethod
def for_internal(cls, internal, user_id):
return cls(internal["app_id"], internal["api_key"], user_id)
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.BlueprintPlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.TemplatePlugin):
def __init__(self):
self._pending_decisions = []
self._pending_lock = threading.RLock()
self._ready_decisions = []
self._ready_lock = threading.RLock()
self._keys = defaultdict(list)
self._keys_lock = threading.RLock()
self._key_path = None
def initialize(self):
self._key_path = os.path.join(self.get_plugin_data_folder(), "keys.yaml")
self._load_keys()
##~~ TemplatePlugin
def get_template_configs(self):
return [dict(type="usersettings", name=gettext("Application Keys")),
dict(type="settings", name=gettext("Application Keys"))]
##~~ AssetPlugin
def get_assets(self):
return dict(js=["js/appkeys.js"],
clientjs=["clientjs/appkeys.js"],
less=["less/appkeys.less"],
css=["css/appkeys.css"])
##~~ BlueprintPlugin mixin
@octoprint.plugin.BlueprintPlugin.route("/request", methods=["POST"])
@no_firstrun_access
def handle_request(self):
data = flask.request.json
if not "app" in data:
return flask.make_response("No app name provided", 400)
app_name = data["app"]
user_id = None
if "user" in data:
user_id = data["user"]
app_token, user_token = self._add_pending_decision(app_name, user_id=user_id)
self._plugin_manager.send_plugin_message(self._identifier, dict(type="request_access",
app_name=app_name,
user_token=user_token,
user_id=user_id))
response = flask.jsonify(app_token=app_token)
response.status_code = 202
response.headers["Location"] = flask.url_for(".handle_decision_poll", app_token=app_token, _external=True)
return response
@octoprint.plugin.BlueprintPlugin.route("/request/<app_token>")
@no_firstrun_access
def handle_decision_poll(self, app_token):
if self._is_pending(app_token):
response = flask.jsonify(message="Awaiting decision")
response.status_code = 202
return response
result = self._get_decision(app_token)
if result:
return flask.jsonify(api_key=result)
return flask.abort(404)
@octoprint.plugin.BlueprintPlugin.route("/decision/<user_token>", methods=["POST"])
@restricted_access
def handle_decision(self, user_token):
data = flask.request.json
if not "decision" in data:
return flask.make_response("No decision provided", 400)
decision = data["decision"] in valid_boolean_trues
user_id = current_user.get_name()
result = self._set_decision(user_token, decision, user_id)
if not result:
return flask.abort(404)
return NO_CONTENT
def is_blueprint_protected(self):
return False # No API key required to request API access
##~~ SimpleApiPlugin mixin
def get_api_commands(self):
return dict(generate=["app"],
revoke=["key"])
def on_api_get(self, request):
user_id = current_user.get_name()
if not user_id:
return flask.abort(403)
if request.values.get("all") in valid_boolean_trues and admin_permission.can():
keys = self._all_api_keys()
else:
keys = self._api_keys_for_user(user_id)
return flask.jsonify(keys=map(lambda x: x.external(), keys),
pending=dict((x.user_token, x.external()) for x in self._get_pending(user_id)))
def on_api_command(self, command, data):
user_id = current_user.get_name()
if not user_id:
return flask.abort(403)
if command == "revoke":
api_key = data.get("key")
if not api_key:
return flask.abort(400)
if not admin_permission.can():
user_for_key = self._user_for_api_key(api_key)
if user_for_key is None or user_for_key.user_id != user_id:
return flask.abort(403)
self._delete_api_key(api_key)
elif command == "generate":
# manual generateKey
app_name = data.get("app")
if not app_name:
return flask.abort(400)
self._add_api_key(user_id, app_name.strip())
return NO_CONTENT
##~~ key validator hook
def validate_api_key(self, api_key, *args, **kwargs):
return self._user_for_api_key(api_key)
##~~ Helpers
def _add_pending_decision(self, app_name, user_id=None):
app_token = self._generate_key()
user_token = self._generate_key()
with self._pending_lock:
self._remove_stale_pending()
self._pending_decisions.append(PendingDecision(app_name, app_token, user_id, user_token))
return app_token, user_token
def _is_pending(self, app_token):
with self._pending_lock:
self._remove_stale_pending()
for data in self._pending_decisions:
if data.app_token == app_token:
return True
return False
def _get_pending(self, user_id):
result = []
with self._pending_lock:
self._remove_stale_pending()
for data in self._pending_decisions:
if data.user_id == user_id or data.user_id is None:
result.append(data)
return result
def _remove_stale_pending(self):
with self._pending_lock:
cutoff = monotonic_time() - CUTOFF_TIME
len_before = len(self._pending_decisions)
self._pending_decisions = filter(lambda x: x.created >= cutoff,
self._pending_decisions)
len_after = len(self._pending_decisions)
if len_after < len_before:
self._logger.info("Deleted {} stale pending authorization requests".format(len_before - len_after))
def _set_decision(self, user_token, decision, user_id):
with self._pending_lock:
self._remove_stale_pending()
for data in self._pending_decisions:
if data.user_token == user_token and (data.user_id == user_id or data.user_id is None):
pending = data
break
else:
return False # not found
if decision:
with self._ready_lock:
self._ready_decisions.append(ReadyDecision.for_pending(pending, user_id))
with self._pending_lock:
self._pending_decisions = filter(lambda x: x.user_token != user_token, self._pending_decisions)
return True
def _get_decision(self, app_token):
self._remove_stale_pending()
with self._ready_lock:
for data in self._ready_decisions:
if data.app_token == app_token:
decision = data
break
else:
return False # not found
api_key = self._add_api_key(decision.user_id, decision.app_id)
with self._ready_lock:
self._ready_decisions = filter(lambda x: x.app_token != app_token, self._ready_decisions)
return api_key
def _add_api_key(self, user_id, app_name):
with self._keys_lock:
for key in self._keys[user_id]:
if key.app_id.lower() == app_name.lower():
return key.api_key
key = ActiveKey(app_name, self._generate_key(), user_id)
self._keys[user_id].append(key)
self._save_keys()
return key.api_key
def _delete_api_key(self, api_key):
with self._keys_lock:
for user_id, data in self._keys.items():
self._keys[user_id] = filter(lambda x: x.api_key != api_key, data)
self._save_keys()
def _user_for_api_key(self, api_key):
with self._keys_lock:
for user_id, data in self._keys.items():
if filter(lambda x: x.api_key == api_key, data):
return self._user_manager.findUser(userid=user_id)
return None
def _api_keys_for_user(self, user_id):
with self._keys_lock:
return self._keys[user_id]
def _all_api_keys(self):
with self._keys_lock:
result = []
for user_id, keys in self._keys.items():
result += keys
return result
def _generate_key(self):
return hexlify(os.urandom(16))
def _load_keys(self):
with self._keys_lock:
if not os.path.exists(self._key_path):
return
try:
with codecs.open(self._key_path, "rb", encoding="utf-8", errors="strict") as f:
persisted = yaml.safe_load(f)
except:
self._logger.exception("Could not load application keys from {}".format(self._key_path))
return
if not isinstance(persisted, dict):
return
keys = defaultdict(list)
for user_id, persisted_keys in persisted.items():
keys[user_id] = [ActiveKey.for_internal(x, user_id) for x in persisted_keys]
self._keys = keys
def _save_keys(self):
with self._keys_lock:
to_persist = dict()
for user_id, keys in self._keys.items():
to_persist[user_id] = [x.internal() for x in keys]
try:
with atomic_write(self._key_path) as f:
yaml.safe_dump(to_persist, f)
except:
self._logger.exception("Could not write application keys to {}".format(self._key_path))
__plugin_name__ = u"Application Keys Plugin"
__plugin_description__ = u"Implements a workflow for third party clients to obtain API keys"
__plugin_author__ = u"Gina Häußge, Aldo Hoeben"
__plugin_disabling_discouraged__ = gettext(u"Without this plugin third party clients will no longer be able to "
u"obtain an API key without you manually copy-pasting it.")
__plugin_implementation__ = AppKeysPlugin()
__plugin_hooks__ = {
"octoprint.accesscontrol.keyvalidator": __plugin_implementation__.validate_api_key
}
Loaded 100 of 339 files, more files were not shown because too many files have changed in this diff. Show more