Merge branch 'maintenance' into devel
# Conflicts: # AUTHORS.md # setup.py # src/octoprint/plugins/announcements/static/js/announcements.js # src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js # src/octoprint/server/api/__init__.py # src/octoprint/static/css/octoprint.css # src/octoprint/static/js/app/dataupdater.js # src/octoprint/static/js/app/viewmodels/printerstate.js
This commit is contained in:
commit
58d8deefcd
37 files changed
+3020
-1904
No files matched your search
+5
-5
@@ -20,14 +20,14 @@ HEAD
|
||||
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.3.9
|
||||
# so are any fix/... and improve/... branches
|
||||
maintenance 1.3.9 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev
|
||||
fix/.* 1.3.9 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 pep440-dev
|
||||
improve/.* 1.3.9 da2c9632ea54fd1b3c8ae34f8f26bab29dbaf3c6 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.7rc5
|
||||
# so is regressionfix/...
|
||||
staging/maintenance 1.3.7rc5 e5caa3d0bf77ed23f04c1d96ab0fa997d19d2006 pep440-dev
|
||||
regressionfix/.* 1.3.7rc5 e5caa3d0bf77ed23f04c1d96ab0fa997d19d2006 pep440-dev
|
||||
staging/maintenance 1.3.9rc2 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
||||
regressionfix/.* 1.3.9rc2 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 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
|
||||
@@ -91,6 +91,7 @@ date of first contribution):
|
||||
* [Daniele Forsi](https://github.com/dforsi)
|
||||
* [Ganey](https://github.com/ganey)
|
||||
* [Sven Lohrmann](https://github.com/malnvenshorn)
|
||||
* [Andy Castille](https://github.com/klikini)
|
||||
* [Zachary Nofzinger](https://github.com/ZachNo)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
|
||||
+128
@@ -1,5 +1,133 @@
|
||||
# OctoPrint Changelog
|
||||
|
||||
## 1.3.9rc1 (2018-06-20)
|
||||
|
||||
### Note for upgraders running NGINX as reverse proxy: Be sure to configure HTTP protocol version 1.1
|
||||
|
||||
OctoPrint 1.3.8 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://github.com/foosel/OctoPrint/wiki/Reverse-proxy-configuration-examples) have been adjusted accordingly. See also [#2526](https://github.com/foosel/OctoPrint/issues/2526).
|
||||
|
||||
### Note for plugin authors
|
||||
|
||||
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 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.
|
||||
* 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
|
||||
|
||||
* [#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.
|
||||
* [#2683](https://github.com/foosel/OctoPrint/pull/2683) - Fixed two missing spaces in the german translation.
|
||||
* 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.
|
||||
|
||||
### Special thanks to all the contributors!
|
||||
|
||||
Special thanks to everyone who contributed to this release candidate, 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.9rc1)
|
||||
|
||||
## 1.3.8 (2018-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
+7
-4
@@ -12,6 +12,7 @@ thanks to everyone who contributed!
|
||||
* Brad Jackson
|
||||
* Brian E. Tyler
|
||||
* Christian Petropolis
|
||||
* Christian Wolf
|
||||
* COLLE+McVOY
|
||||
* D Brian Kimmel
|
||||
* DeltaMaker 3D Printers
|
||||
@@ -19,14 +20,16 @@ thanks to everyone who contributed!
|
||||
* Ernesto Martinez
|
||||
* F. Kunsmann
|
||||
* Frank Sander
|
||||
* Gary Deen
|
||||
* George Robles
|
||||
* günter weber
|
||||
* Hydra Research LLC
|
||||
* James Seigel
|
||||
* Jeff Moe
|
||||
* Jeff Renfer
|
||||
* Jefferson Hunt
|
||||
* Jeremiah Avery
|
||||
* Josh Daniels
|
||||
* Joshua Wills
|
||||
* Kaile Riser
|
||||
* Kale Stedman
|
||||
* Kazuhiro Ogura
|
||||
@@ -38,14 +41,13 @@ thanks to everyone who contributed!
|
||||
* Michael Aumock
|
||||
* Miles Flavel
|
||||
* mitchell hirsch
|
||||
* Mohammed khorakiwala
|
||||
* Noe Ruiz
|
||||
* Patrick McGinnis
|
||||
* Peter Schmehl
|
||||
* Randy C. Will
|
||||
* Robert Gusek
|
||||
* Roger Strolz
|
||||
* Roy Cortes
|
||||
* Rudolff Vang
|
||||
* Samer Najia
|
||||
* Simon Hallam
|
||||
* Stefan Krister
|
||||
@@ -53,6 +55,7 @@ thanks to everyone who contributed!
|
||||
* Sven Mueller
|
||||
* Symbiotic Devices
|
||||
* Thomas Hatley
|
||||
* Timothy D Hoogland
|
||||
* Trent Shumay
|
||||
|
||||
and 1233 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
and 1334 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
@@ -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
|
||||
|
||||
@@ -209,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.
|
||||
|
||||
|
||||
@@ -617,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:
|
||||
|
||||
@@ -636,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:
|
||||
|
||||
|
||||
@@ -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,8 +16,8 @@ import octoprint_setuptools
|
||||
INSTALL_REQUIRES = [
|
||||
"flask>=0.12,<0.13",
|
||||
"werkzeug>=0.11.1,<0.12",
|
||||
"tornado>=4.5.3,<5",
|
||||
"Jinja2>=2.8,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
|
||||
"tornado==4.5.3",
|
||||
"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
|
||||
#"sockjs-tornado>=1.0.3,<1.1", # current version is incompatible to tornado 5, we use a
|
||||
@@ -29,25 +29,26 @@ INSTALL_REQUIRES = [
|
||||
"Flask-Assets>=0.12,<0.13",
|
||||
"markdown>=2.6.4,<2.7",
|
||||
"pyserial>=3.4,<3.5",
|
||||
"netaddr>=0.7.17,<0.8",
|
||||
"netaddr>=0.7.19,<0.8",
|
||||
"watchdog>=0.8.3,<0.9",
|
||||
"sarge>=0.1.4,<0.2",
|
||||
"netifaces>=0.10,<0.11",
|
||||
"sarge==0.1.4", # 0.1.5 introduced a breaking change with regards to the async keyword. Pinning
|
||||
# to 0.1.4 for now to work around this.
|
||||
"netifaces>=0.10.6,<0.11",
|
||||
"pylru>=1.0.9,<1.1",
|
||||
"rsa>=3.4,<3.5",
|
||||
"pkginfo>=1.4.2,<1.5",
|
||||
"requests>=2.18.4,<3",
|
||||
"semantic_version>=2.6.0,<2.7",
|
||||
"psutil>=5.4.5,<5.5",
|
||||
"psutil>=5.4.6,<5.5",
|
||||
"Click>=6.7,<6.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",
|
||||
"future>=0.15.2,<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",
|
||||
"websocket-client>=0.40.0,<0.41",
|
||||
"python-dateutil>=2.6.1,<2.7",
|
||||
"wrapt>=1.10.11,<1.11",
|
||||
"futures>=3.1.1,<3.2",
|
||||
"emoji>=0.4.5,<0.5",
|
||||
"monotonic>=1.3,<1.4",
|
||||
|
||||
+59
-25
@@ -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)
|
||||
|
||||
|
||||
@@ -86,8 +86,13 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
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,
|
||||
|
||||
@@ -7,6 +7,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
import octoprint.plugin
|
||||
|
||||
from octoprint.server import user_permission
|
||||
from octoprint.access import USER_GROUP
|
||||
|
||||
import flask
|
||||
from flask_babel import gettext
|
||||
@@ -46,6 +47,17 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
|
||||
def initialize(self):
|
||||
self._selection_command = self._settings.get([b"selection_command"])
|
||||
|
||||
# Additional permissions hook
|
||||
|
||||
def get_additional_permissions(self):
|
||||
return [
|
||||
dict(key="INTERACT",
|
||||
name="Interact with printer prompts",
|
||||
description=gettext("Allows to see and interact with printer prompts"),
|
||||
default_groups=[USER_GROUP],
|
||||
roles=["interact"])
|
||||
]
|
||||
|
||||
#~ AssetPlugin
|
||||
|
||||
def get_assets(self):
|
||||
@@ -162,5 +174,6 @@ __plugin_disabling_discouraged__ = gettext("Without this plugin your printer wil
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = ActionCommandPromptPlugin()
|
||||
__plugin_hooks__ = {
|
||||
b"octoprint.comm.protocol.action": __plugin_implementation__.action_command_handler
|
||||
b"octoprint.comm.protocol.action": __plugin_implementation__.action_command_handler,
|
||||
b"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions
|
||||
}
|
||||
@@ -29,11 +29,12 @@ $(function() {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
self.access = parameters[1];
|
||||
|
||||
self._modal = undefined;
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.loginState.isUser()) return;
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ACTION_COMMAND_PROMPT_INTERACT)) return;
|
||||
|
||||
OctoPrint.plugins.action_command_prompt.get()
|
||||
.done(self.fromResponse);
|
||||
@@ -78,7 +79,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onDataUpdaterPluginMessage = function(plugin, data) {
|
||||
if (!self.loginState.isUser()) return;
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ACTION_COMMAND_PROMPT_INTERACT)) return;
|
||||
if (plugin !== "action_command_prompt") {
|
||||
return;
|
||||
}
|
||||
@@ -99,6 +100,6 @@ $(function() {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ActionCommandPromptViewModel,
|
||||
dependencies: ["loginStateViewModel"]
|
||||
dependencies: ["loginStateViewModel", "accessViewModel"]
|
||||
});
|
||||
});
|
||||
@@ -67,9 +67,11 @@ $(function() {
|
||||
return link;
|
||||
};
|
||||
|
||||
self.markRead = function(channel, until) {
|
||||
self.markRead = function(channel, until, reload) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ANNOUNCEMENTS_READ)) return;
|
||||
|
||||
reload = !!reload;
|
||||
|
||||
var url = PLUGIN_BASEURL + "announcements/channels/" + channel;
|
||||
|
||||
var payload = {
|
||||
@@ -84,7 +86,9 @@ $(function() {
|
||||
data: JSON.stringify(payload),
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
success: function() {
|
||||
self.retrieveData()
|
||||
if (reload) {
|
||||
self.retrieveData()
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
@@ -400,8 +400,6 @@ $(function() {
|
||||
};
|
||||
|
||||
self.performCheck = function(showIfNothingNew, force, ignoreSeen) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_SOFTWAREUPDATE_CHECK) && !self.settings.settings.plugins.softwareupdate.notify_users()) return;
|
||||
|
||||
self.checking(true);
|
||||
OctoPrint.plugins.softwareupdate.check(force)
|
||||
.done(function(data) {
|
||||
@@ -582,7 +580,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self._showWorkingDialog = function(title) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_SOFTWAREUPDATE_UPDATE)) {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_SOFTWAREUPDATE_CHECK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,9 @@
|
||||
<h3 data-bind="text: workingTitle"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre id="settings_plugin_softwareupdate_workingdialog_output" class="pre-scrollable pre-output" style="height: 170px" data-bind="foreach: loglines"><span data-bind="text: line, css: {stdout: stream == 'stdout', stderr: stream == 'stderr', call: stream == 'call', message: stream == 'message'}"></span></pre>
|
||||
<pre id="settings_plugin_softwareupdate_workingdialog_output" class="pre-scrollable pre-output" style="height: 170px; display: none" data-bind="visible: loginState.isAdmin, foreach: loglines"><span data-bind="text: line, css: {stdout: stream == 'stdout', stderr: stream == 'stderr', call: stream == 'call', message: stream == 'message'}"></span></pre>
|
||||
<p style="display: none" data-bind="visible: !loginState.isAdmin() && $root.working()"><i class="fa fa-spinner fa-spin"></i> {{ _('Update in progress, please wait.') }}</p>
|
||||
<p style="display: none" data-bind="visible: !loginState.isAdmin() && !$root.working()">{{ _('Update done, please close this window.') }}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" data-bind="enable: !$root.working()" aria-hidden="true">{{ _('Close') }}</button>
|
||||
|
||||
@@ -30,6 +30,7 @@ class VirtualPrinter(object):
|
||||
send_regex = re.compile("send (.*)")
|
||||
set_ambient_regex = re.compile("set_ambient ([-+]?[0-9]*\.?[0-9]+)")
|
||||
start_sd_regex = re.compile("start_sd (.*)")
|
||||
select_sd_regex = re.compile("select_sd (.*)")
|
||||
|
||||
def __init__(self, seriallog_handler=None, read_timeout=5.0, write_timeout=10.0):
|
||||
import logging
|
||||
@@ -168,72 +169,73 @@ class VirtualPrinter(object):
|
||||
.format(read_timeout=self._read_timeout, write_timeout=self._write_timeout, options=settings().get(["devel", "virtualPrinter"]))
|
||||
|
||||
def _reset(self):
|
||||
self._clearQueue(self.incoming)
|
||||
self._clearQueue(self.outgoing)
|
||||
self._clearQueue(self.buffered)
|
||||
with self._incoming_lock:
|
||||
self._relative = True
|
||||
self._lastX = 0.0
|
||||
self._lastY = 0.0
|
||||
self._lastZ = 0.0
|
||||
self._lastE = [0.0] * self.extruderCount
|
||||
self._lastF = 200
|
||||
|
||||
self._relative = True
|
||||
self._lastX = 0.0
|
||||
self._lastY = 0.0
|
||||
self._lastZ = 0.0
|
||||
self._lastE = [0.0] * self.extruderCount
|
||||
self._lastF = 200
|
||||
self._unitModifier = 1
|
||||
self._feedrate_multiplier = 100
|
||||
self._flowrate_multiplier = 100
|
||||
|
||||
self._unitModifier = 1
|
||||
self._feedrate_multiplier = 100
|
||||
self._flowrate_multiplier = 100
|
||||
|
||||
self._sdCardReady = True
|
||||
self._sdPrinting = False
|
||||
if self._sdPrinter:
|
||||
self._sdCardReady = True
|
||||
self._sdPrinting = False
|
||||
self._sdPrintingSemaphore.set()
|
||||
self._sdPrinter = None
|
||||
self._selectedSdFile = None
|
||||
self._selectedSdFileSize = None
|
||||
self._selectedSdFilePos = None
|
||||
if self._sdPrinter:
|
||||
self._sdPrinting = False
|
||||
self._sdPrintingSemaphore.set()
|
||||
self._sdPrinter = None
|
||||
self._selectedSdFile = None
|
||||
self._selectedSdFileSize = None
|
||||
self._selectedSdFilePos = None
|
||||
|
||||
if self._writingToSdHandle:
|
||||
try:
|
||||
self._writingToSdHandle.close()
|
||||
except:
|
||||
pass
|
||||
self._writingToSd = False
|
||||
self._writingToSdHandle = None
|
||||
self._newSdFilePos = None
|
||||
if self._writingToSdHandle:
|
||||
try:
|
||||
self._writingToSdHandle.close()
|
||||
except:
|
||||
pass
|
||||
self._writingToSd = False
|
||||
self._writingToSdHandle = None
|
||||
self._newSdFilePos = None
|
||||
|
||||
self._heatingUp = False
|
||||
self._heatingUp = False
|
||||
|
||||
self.currentLine = 0
|
||||
self.lastN = 0
|
||||
self.currentLine = 0
|
||||
self.lastN = 0
|
||||
|
||||
self._debug_awol = False
|
||||
self._debug_sleep = None
|
||||
self._sleepAfterNext.clear()
|
||||
self._sleepAfter.clear()
|
||||
self._debug_awol = False
|
||||
self._debug_sleep = None
|
||||
self._sleepAfterNext.clear()
|
||||
self._sleepAfter.clear()
|
||||
|
||||
self._dont_answer = False
|
||||
self._dont_answer = False
|
||||
|
||||
self._debug_drop_connection = False
|
||||
self._debug_drop_connection = False
|
||||
|
||||
self._killed = False
|
||||
self._killed = False
|
||||
|
||||
self._triggerResendAt100 = True
|
||||
self._triggerResendWithTimeoutAt105 = True
|
||||
self._triggerResendWithMissingLinenoAt110 = True
|
||||
self._triggerResendWithChecksumMismatchAt115 = True
|
||||
self._triggerResendAt100 = True
|
||||
self._triggerResendWithTimeoutAt105 = True
|
||||
self._triggerResendWithMissingLinenoAt110 = True
|
||||
self._triggerResendWithChecksumMismatchAt115 = True
|
||||
|
||||
if self._temperature_reporter is not None:
|
||||
self._temperature_reporter.cancel()
|
||||
self._temperature_reporter = None
|
||||
if self._temperature_reporter is not None:
|
||||
self._temperature_reporter.cancel()
|
||||
self._temperature_reporter = None
|
||||
|
||||
if self._sdstatus_reporter is not None:
|
||||
self._sdstatus_reporter.cancel()
|
||||
self._sdstatus_reporter = None
|
||||
if self._sdstatus_reporter is not None:
|
||||
self._sdstatus_reporter.cancel()
|
||||
self._sdstatus_reporter = None
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "simulateReset"]):
|
||||
for item in settings().get(["devel", "virtualPrinter", "resetLines"]):
|
||||
self._send(item + "\n")
|
||||
self._clearQueue(self.incoming)
|
||||
self._clearQueue(self.outgoing)
|
||||
self._clearQueue(self.buffered)
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "simulateReset"]):
|
||||
for item in settings().get(["devel", "virtualPrinter", "resetLines"]):
|
||||
self._send(item + "\n")
|
||||
|
||||
@property
|
||||
def timeout(self):
|
||||
@@ -679,8 +681,6 @@ class VirtualPrinter(object):
|
||||
if not self._brokenResend:
|
||||
self._sendOk()
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleResends"]):
|
||||
request_resend()
|
||||
request_resend()
|
||||
|
||||
def _debugTrigger(self, data):
|
||||
@@ -737,7 +737,10 @@ class VirtualPrinter(object):
|
||||
# SD printing
|
||||
|
||||
start_sd <str:file>
|
||||
| Start printing file <file> from SD
|
||||
| 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
|
||||
|
||||
@@ -794,6 +797,7 @@ class VirtualPrinter(object):
|
||||
send_match = VirtualPrinter.send_regex.match(data)
|
||||
set_ambient_match = VirtualPrinter.set_ambient_regex.match(data)
|
||||
start_sd_match = VirtualPrinter.start_sd_regex.match(data)
|
||||
select_sd_match = VirtualPrinter.select_sd_regex.match(data)
|
||||
|
||||
if sleep_match is not None:
|
||||
interval = int(sleep_match.group(1))
|
||||
@@ -823,8 +827,10 @@ class VirtualPrinter(object):
|
||||
self._ambient_temperature = float(set_ambient_match.group(1))
|
||||
self._send("// set ambient temperature to {}".format(self._ambient_temperature))
|
||||
elif start_sd_match is not None:
|
||||
self._selectSdFile(start_sd_match.group(1))
|
||||
self._selectSdFile(start_sd_match.group(1), check_already_open=True)
|
||||
self._startSdPrint()
|
||||
elif select_sd_match is not None:
|
||||
self._selectSdFile(select_sd_match.group(1))
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -844,10 +850,14 @@ class VirtualPrinter(object):
|
||||
self._send(item)
|
||||
self._send("End file list")
|
||||
|
||||
def _selectSdFile(self, filename):
|
||||
def _selectSdFile(self, filename, check_already_open=False):
|
||||
if filename.startswith("/"):
|
||||
filename = filename[1:]
|
||||
|
||||
file = os.path.join(self._virtualSd, filename.lower())
|
||||
if self._selectedSdFile == file and check_already_open:
|
||||
return
|
||||
|
||||
if not os.path.exists(file) or not os.path.isfile(file):
|
||||
self._send("open failed, File: %s." % filename)
|
||||
else:
|
||||
@@ -1159,10 +1169,10 @@ class VirtualPrinter(object):
|
||||
def _finishSdPrint(self):
|
||||
if not self._killed:
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._output("Done printing file")
|
||||
self._selectedSdFilePos = 0
|
||||
self._sdPrinting = False
|
||||
self._sdPrinter = None
|
||||
self._output("Done printing file")
|
||||
|
||||
def _waitForHeatup(self, heater, only_wait_if_higher):
|
||||
delta = 1
|
||||
|
||||
@@ -290,7 +290,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
for command in commands:
|
||||
self._comm.sendCommand(command, tags=kwargs.get("tags", set()) | {"trigger:printer.commands"})
|
||||
|
||||
def script(self, name, context=None, must_be_set=True, *args, **kwargs):
|
||||
def script(self, name, context=None, must_be_set=True, part_of_job=False, *args, **kwargs):
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
@@ -298,6 +298,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
raise ValueError("name must be set")
|
||||
|
||||
result = self._comm.sendGcodeScript(name,
|
||||
part_of_job=part_of_job,
|
||||
replacements=context,
|
||||
tags=kwargs.get("tags", set()) | {"trigger:printer.script"})
|
||||
if not result and must_be_set:
|
||||
@@ -444,8 +445,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._validateJob(path, sd)
|
||||
|
||||
origin = FileDestinations.SDCARD if sd else FileDestinations.LOCAL
|
||||
path_on_disk = self._fileManager.path_on_disk(origin, path)
|
||||
path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk)
|
||||
if sd:
|
||||
path_on_disk = "/" + path
|
||||
path_in_storage = path
|
||||
else:
|
||||
path_on_disk = self._fileManager.path_on_disk(origin, path)
|
||||
path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk)
|
||||
|
||||
recovery_data = self._fileManager.get_recovery_data()
|
||||
if recovery_data:
|
||||
@@ -1045,6 +1050,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not suppress_script:
|
||||
self.script("beforePrintStarted",
|
||||
context=dict(event=payload),
|
||||
part_of_job=True,
|
||||
must_be_set=False)
|
||||
|
||||
def on_comm_print_job_done(self, suppress_script=False):
|
||||
@@ -1063,6 +1069,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not suppress_script:
|
||||
self.script("afterPrintDone",
|
||||
context=dict(event=payload),
|
||||
part_of_job=True,
|
||||
must_be_set=False)
|
||||
|
||||
def log_print():
|
||||
@@ -1106,6 +1113,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not suppress_script:
|
||||
self.script("afterPrintCancelled",
|
||||
context=dict(event=payload),
|
||||
part_of_job=True,
|
||||
must_be_set=False)
|
||||
|
||||
def finalize():
|
||||
@@ -1128,6 +1136,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not suppress_script:
|
||||
self.script("afterPrintPaused",
|
||||
context=dict(event=payload),
|
||||
part_of_job=True,
|
||||
must_be_set=False)
|
||||
|
||||
def on_comm_print_job_resumed(self, suppress_script=False):
|
||||
@@ -1137,6 +1146,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if not suppress_script:
|
||||
self.script("beforePrintResumed",
|
||||
context=dict(event=payload),
|
||||
part_of_job=True,
|
||||
must_be_set=False)
|
||||
|
||||
def on_comm_file_transfer_started(self, filename, filesize, user=None):
|
||||
|
||||
@@ -247,7 +247,7 @@ def _logout(user):
|
||||
@api.route("/util/test", methods=["POST"])
|
||||
@require_firstrun
|
||||
@Permissions.ADMIN.require(403)
|
||||
def utilTestPath():
|
||||
def utilTest():
|
||||
valid_commands = dict(
|
||||
path=["path"],
|
||||
url=["url"],
|
||||
@@ -259,221 +259,242 @@ def utilTestPath():
|
||||
return response
|
||||
|
||||
if command == "path":
|
||||
import os
|
||||
from octoprint.util.paths import normalize
|
||||
return _test_path(data)
|
||||
elif command == "url":
|
||||
return _test_url(data)
|
||||
elif command == "server":
|
||||
return _test_server(data)
|
||||
|
||||
path = normalize(data["path"])
|
||||
if not path:
|
||||
return jsonify(path=path, exists=False, typeok=False, access=False, result=False)
|
||||
def _test_path(data):
|
||||
import os
|
||||
from octoprint.util.paths import normalize
|
||||
|
||||
check_type = None
|
||||
check_access = []
|
||||
path = normalize(data["path"], real=False)
|
||||
if not path:
|
||||
return jsonify(path=path, exists=False, typeok=False, broken_symlink=False, access=False, result=False)
|
||||
|
||||
if "check_type" in data and data["check_type"] in ("file", "dir"):
|
||||
check_type = data["check_type"]
|
||||
unreal_path = path
|
||||
path = os.path.realpath(path)
|
||||
|
||||
if "check_access" in data:
|
||||
request_check_access = data["check_access"]
|
||||
if not isinstance(request_check_access, list):
|
||||
request_check_access = list(request_check_access)
|
||||
check_type = None
|
||||
check_access = []
|
||||
|
||||
check_access = [check for check in request_check_access if check in ("r", "w", "x")]
|
||||
if "check_type" in data and data["check_type"] in ("file", "dir"):
|
||||
check_type = data["check_type"]
|
||||
|
||||
allow_create_dir = data.get("allow_create_dir", False) and check_type == "dir"
|
||||
check_writable_dir = data.get("check_writable_dir", False) and check_type == "dir"
|
||||
if check_writable_dir and "w" not in check_access:
|
||||
check_access.append("w")
|
||||
if "check_access" in data:
|
||||
request_check_access = data["check_access"]
|
||||
if not isinstance(request_check_access, list):
|
||||
request_check_access = list(request_check_access)
|
||||
|
||||
# check if path exists
|
||||
exists = os.path.exists(path)
|
||||
if not exists and check_type == "dir" and allow_create_dir:
|
||||
check_access = [check for check in request_check_access if check in ("r", "w", "x")]
|
||||
|
||||
allow_create_dir = data.get("allow_create_dir", False) and check_type == "dir"
|
||||
check_writable_dir = data.get("check_writable_dir", False) and check_type == "dir"
|
||||
if check_writable_dir and "w" not in check_access:
|
||||
check_access.append("w")
|
||||
|
||||
# check if path exists
|
||||
exists = os.path.exists(path)
|
||||
if not exists:
|
||||
if os.path.islink(unreal_path):
|
||||
# broken symlink, see #2644
|
||||
logging.getLogger(__name__).error("{} is a broken symlink pointing at non existing {}".format(unreal_path, path))
|
||||
return jsonify(path=unreal_path, exists=False, typeok=False, broken_symlink=True, access=False, result=False)
|
||||
|
||||
elif check_type == "dir" and allow_create_dir:
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Error while trying to create {}".format(path))
|
||||
return jsonify(path=path, exists=False, typeok=False, access=False, result=False)
|
||||
return jsonify(path=path, exists=False, typeok=False, broken_symlink=False, access=False, result=False)
|
||||
else:
|
||||
exists = True
|
||||
|
||||
# check path type
|
||||
type_mapping = dict(file=os.path.isfile, dir=os.path.isdir)
|
||||
if check_type:
|
||||
typeok = type_mapping[check_type](path)
|
||||
else:
|
||||
typeok = exists
|
||||
# check path type
|
||||
type_mapping = dict(file=os.path.isfile, dir=os.path.isdir)
|
||||
if check_type:
|
||||
typeok = type_mapping[check_type](path)
|
||||
else:
|
||||
typeok = exists
|
||||
|
||||
# check if path allows requested access
|
||||
access_mapping = dict(r=os.R_OK, w=os.W_OK, x=os.X_OK)
|
||||
if check_access:
|
||||
mode = 0
|
||||
for a in map(lambda x: access_mapping[x], check_access):
|
||||
mode |= a
|
||||
access = os.access(path, mode)
|
||||
else:
|
||||
access = exists
|
||||
# check if path allows requested access
|
||||
access_mapping = dict(r=os.R_OK, w=os.W_OK, x=os.X_OK)
|
||||
if check_access:
|
||||
mode = 0
|
||||
for a in map(lambda x: access_mapping[x], check_access):
|
||||
mode |= a
|
||||
access = os.access(path, mode)
|
||||
else:
|
||||
access = exists
|
||||
|
||||
if check_writable_dir and check_type == "dir":
|
||||
try:
|
||||
test_path = os.path.join(path, ".testballoon.txt")
|
||||
with open(test_path, "wb") as f:
|
||||
f.write("Test")
|
||||
os.remove(test_path)
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Error while testing if {} is really writable".format(path))
|
||||
return jsonify(path=path, exists=exists, typeok=typeok, access=False, result=False)
|
||||
|
||||
return jsonify(path=path, exists=exists, typeok=typeok, access=access, result=exists and typeok and access)
|
||||
|
||||
elif command == "url":
|
||||
import requests
|
||||
|
||||
class StatusCodeRange(object):
|
||||
def __init__(self, start=None, end=None):
|
||||
self.start = start
|
||||
self.end = end
|
||||
|
||||
def __contains__(self, item):
|
||||
if not isinstance(item, int):
|
||||
return False
|
||||
if self.start and self.end:
|
||||
return self.start <= item < self.end
|
||||
elif self.start:
|
||||
return self.start <= item
|
||||
elif self.end:
|
||||
return item < self.end
|
||||
else:
|
||||
return False
|
||||
|
||||
def as_dict(self):
|
||||
return dict(
|
||||
start=self.start,
|
||||
end=self.end
|
||||
)
|
||||
|
||||
status_ranges = dict(
|
||||
informational=StatusCodeRange(start=100,end=200),
|
||||
success=StatusCodeRange(start=200,end=300),
|
||||
redirection=StatusCodeRange(start=300,end=400),
|
||||
client_error=StatusCodeRange(start=400,end=500),
|
||||
server_error=StatusCodeRange(start=500,end=600),
|
||||
normal=StatusCodeRange(end=400),
|
||||
error=StatusCodeRange(start=400,end=600),
|
||||
any=StatusCodeRange(start=100),
|
||||
timeout=StatusCodeRange(start=0, end=1)
|
||||
)
|
||||
|
||||
url = data["url"]
|
||||
method = data.get("method", "HEAD")
|
||||
timeout = 3.0
|
||||
valid_ssl = True
|
||||
check_status = [status_ranges["normal"]]
|
||||
content_type_whitelist = None
|
||||
content_type_blacklist = None
|
||||
|
||||
if "timeout" in data:
|
||||
try:
|
||||
timeout = float(data["timeout"])
|
||||
except:
|
||||
return make_response("{!r} is not a valid value for timeout (must be int or float)".format(data["timeout"]), 400)
|
||||
|
||||
if "validSsl" in data:
|
||||
valid_ssl = data["validSsl"] in valid_boolean_trues
|
||||
|
||||
if "status" in data:
|
||||
request_status = data["status"]
|
||||
if not isinstance(request_status, list):
|
||||
request_status = [request_status]
|
||||
|
||||
check_status = []
|
||||
for rs in request_status:
|
||||
if isinstance(rs, int):
|
||||
check_status.append([rs])
|
||||
else:
|
||||
if rs in status_ranges:
|
||||
check_status.append(status_ranges[rs])
|
||||
else:
|
||||
code = requests.codes[rs]
|
||||
if code is not None:
|
||||
check_status.append([code])
|
||||
|
||||
if "content_type_whitelist" in data:
|
||||
if not isinstance(data["content_type_whitelist"], (list, tuple)):
|
||||
return make_response("content_type_whitelist must be a list of mime types")
|
||||
content_type_whitelist = map(util.parse_mime_type, data["content_type_whitelist"])
|
||||
if "content_type_blacklist" in data:
|
||||
if not isinstance(data["content_type_whitelist"], (list, tuple)):
|
||||
return make_response("content_type_blacklist must be a list of mime types")
|
||||
content_type_blacklist = map(util.parse_mime_type, data["content_type_blacklist"])
|
||||
|
||||
response_result = None
|
||||
outcome = True
|
||||
status = 0
|
||||
if check_writable_dir and check_type == "dir":
|
||||
try:
|
||||
with requests.request(method=method, url=url, timeout=timeout, verify=valid_ssl, stream=True) as response:
|
||||
status = response.status_code
|
||||
outcome = outcome and any(map(lambda x: status in x, check_status))
|
||||
content_type = response.headers.get("content-type")
|
||||
|
||||
response_result = dict(headers=dict(response.headers),
|
||||
content_type=content_type)
|
||||
|
||||
parsed_content_type = util.parse_mime_type(content_type)
|
||||
in_whitelist = content_type_whitelist is None or any(map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_whitelist))
|
||||
in_blacklist = content_type_blacklist is not None and any(map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_blacklist))
|
||||
|
||||
if not in_whitelist or in_blacklist:
|
||||
# we don't support this content type
|
||||
response.close()
|
||||
outcome = False
|
||||
|
||||
elif "response" in data and (data["response"] in valid_boolean_trues or data["response"] in ("json", "bytes")):
|
||||
if data["response"] == "json":
|
||||
content = response.json()
|
||||
|
||||
else:
|
||||
import base64
|
||||
content = base64.standard_b64encode(response.content)
|
||||
|
||||
response_result["content"] = content
|
||||
test_path = os.path.join(path, ".testballoon.txt")
|
||||
with open(test_path, "wb") as f:
|
||||
f.write("Test")
|
||||
os.remove(test_path)
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Error while running a test {} request on {}".format(method, url))
|
||||
outcome = False
|
||||
logging.getLogger(__name__).exception("Error while testing if {} is really writable".format(path))
|
||||
return jsonify(path=path, exists=exists, typeok=typeok, broken_symlink=False, access=False, result=False)
|
||||
|
||||
result = dict(
|
||||
url=url,
|
||||
status=status,
|
||||
result=outcome
|
||||
)
|
||||
if response_result:
|
||||
result["response"] = response_result
|
||||
return jsonify(path=path, exists=exists, typeok=typeok, broken_symlink=False, access=access, result=exists and typeok and access)
|
||||
|
||||
return jsonify(**result)
|
||||
|
||||
elif command == "server":
|
||||
host = data["host"]
|
||||
def _test_url(data):
|
||||
import requests
|
||||
|
||||
class StatusCodeRange(object):
|
||||
def __init__(self, start=None, end=None):
|
||||
self.start = start
|
||||
self.end = end
|
||||
|
||||
def __contains__(self, item):
|
||||
if not isinstance(item, int):
|
||||
return False
|
||||
if self.start and self.end:
|
||||
return self.start <= item < self.end
|
||||
elif self.start:
|
||||
return self.start <= item
|
||||
elif self.end:
|
||||
return item < self.end
|
||||
else:
|
||||
return False
|
||||
|
||||
def as_dict(self):
|
||||
return dict(
|
||||
start=self.start,
|
||||
end=self.end
|
||||
)
|
||||
|
||||
status_ranges = dict(
|
||||
informational=StatusCodeRange(start=100, end=200),
|
||||
success=StatusCodeRange(start=200, end=300),
|
||||
redirection=StatusCodeRange(start=300, end=400),
|
||||
client_error=StatusCodeRange(start=400, end=500),
|
||||
server_error=StatusCodeRange(start=500, end=600),
|
||||
normal=StatusCodeRange(end=400),
|
||||
error=StatusCodeRange(start=400, end=600),
|
||||
any=StatusCodeRange(start=100),
|
||||
timeout=StatusCodeRange(start=0, end=1)
|
||||
)
|
||||
|
||||
url = data["url"]
|
||||
method = data.get("method", "HEAD")
|
||||
timeout = 3.0
|
||||
valid_ssl = True
|
||||
check_status = [status_ranges["normal"]]
|
||||
content_type_whitelist = None
|
||||
content_type_blacklist = None
|
||||
|
||||
if "timeout" in data:
|
||||
try:
|
||||
port = int(data["port"])
|
||||
timeout = float(data["timeout"])
|
||||
except:
|
||||
return make_response("{!r} is not a valid value for port (must be int)".format(data["port"]), 400)
|
||||
return make_response("{!r} is not a valid value for timeout (must be int or float)".format(data["timeout"]),
|
||||
400)
|
||||
|
||||
timeout = 3.05
|
||||
if "timeout" in data:
|
||||
try:
|
||||
timeout = float(data["timeout"])
|
||||
except:
|
||||
return make_response("{!r} is not a valid value for timeout (must be int or float)".format(data["timeout"]), 400)
|
||||
if "validSsl" in data:
|
||||
valid_ssl = data["validSsl"] in valid_boolean_trues
|
||||
|
||||
protocol = data.get("protocol", "tcp")
|
||||
if protocol not in ("tcp", "udp"):
|
||||
return make_response("{!r} is not a valid value for protocol, must be tcp or udp".format(protocol), 400)
|
||||
if "status" in data:
|
||||
request_status = data["status"]
|
||||
if not isinstance(request_status, list):
|
||||
request_status = [request_status]
|
||||
|
||||
from octoprint.util import server_reachable
|
||||
reachable = server_reachable(host, port, timeout=timeout, proto=protocol)
|
||||
check_status = []
|
||||
for rs in request_status:
|
||||
if isinstance(rs, int):
|
||||
check_status.append([rs])
|
||||
else:
|
||||
if rs in status_ranges:
|
||||
check_status.append(status_ranges[rs])
|
||||
else:
|
||||
code = requests.codes[rs]
|
||||
if code is not None:
|
||||
check_status.append([code])
|
||||
|
||||
result = dict(host=host,
|
||||
port=port,
|
||||
protocol=protocol,
|
||||
result=reachable)
|
||||
if "content_type_whitelist" in data:
|
||||
if not isinstance(data["content_type_whitelist"], (list, tuple)):
|
||||
return make_response("content_type_whitelist must be a list of mime types")
|
||||
content_type_whitelist = map(util.parse_mime_type, data["content_type_whitelist"])
|
||||
if "content_type_blacklist" in data:
|
||||
if not isinstance(data["content_type_whitelist"], (list, tuple)):
|
||||
return make_response("content_type_blacklist must be a list of mime types")
|
||||
content_type_blacklist = map(util.parse_mime_type, data["content_type_blacklist"])
|
||||
|
||||
return jsonify(**result)
|
||||
response_result = None
|
||||
outcome = True
|
||||
status = 0
|
||||
try:
|
||||
with requests.request(method=method, url=url, timeout=timeout, verify=valid_ssl, stream=True) as response:
|
||||
status = response.status_code
|
||||
outcome = outcome and any(map(lambda x: status in x, check_status))
|
||||
content_type = response.headers.get("content-type")
|
||||
|
||||
response_result = dict(headers=dict(response.headers),
|
||||
content_type=content_type)
|
||||
|
||||
parsed_content_type = util.parse_mime_type(content_type)
|
||||
in_whitelist = content_type_whitelist is None or any(
|
||||
map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_whitelist))
|
||||
in_blacklist = content_type_blacklist is not None and any(
|
||||
map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_blacklist))
|
||||
|
||||
if not in_whitelist or in_blacklist:
|
||||
# we don't support this content type
|
||||
response.close()
|
||||
outcome = False
|
||||
|
||||
elif "response" in data and (
|
||||
data["response"] in valid_boolean_trues or data["response"] in ("json", "bytes")):
|
||||
if data["response"] == "json":
|
||||
content = response.json()
|
||||
|
||||
else:
|
||||
import base64
|
||||
content = base64.standard_b64encode(response.content)
|
||||
|
||||
response_result["content"] = content
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Error while running a test {} request on {}".format(method, url))
|
||||
outcome = False
|
||||
|
||||
result = dict(
|
||||
url=url,
|
||||
status=status,
|
||||
result=outcome
|
||||
)
|
||||
if response_result:
|
||||
result["response"] = response_result
|
||||
|
||||
return jsonify(**result)
|
||||
|
||||
def _test_server(data):
|
||||
host = data["host"]
|
||||
try:
|
||||
port = int(data["port"])
|
||||
except:
|
||||
return make_response("{!r} is not a valid value for port (must be int)".format(data["port"]), 400)
|
||||
|
||||
timeout = 3.05
|
||||
if "timeout" in data:
|
||||
try:
|
||||
timeout = float(data["timeout"])
|
||||
except:
|
||||
return make_response("{!r} is not a valid value for timeout (must be int or float)".format(data["timeout"]),
|
||||
400)
|
||||
|
||||
protocol = data.get("protocol", "tcp")
|
||||
if protocol not in ("tcp", "udp"):
|
||||
return make_response("{!r} is not a valid value for protocol, must be tcp or udp".format(protocol), 400)
|
||||
|
||||
from octoprint.util import server_reachable
|
||||
reachable = server_reachable(host, port, timeout=timeout, proto=protocol)
|
||||
|
||||
result = dict(host=host,
|
||||
port=port,
|
||||
protocol=protocol,
|
||||
result=reachable)
|
||||
|
||||
return jsonify(**result)
|
||||
@@ -153,8 +153,16 @@ def _getFileList(origin, path=None, filter=None, recursive=False, allow_from_cac
|
||||
files = []
|
||||
if sdFileList is not None:
|
||||
for sdFile, sdSize in sdFileList:
|
||||
type_path = octoprint.filemanager.get_file_type(sdFile)
|
||||
if not type_path:
|
||||
# only supported extensions
|
||||
continue
|
||||
else:
|
||||
file_type = type_path[0]
|
||||
|
||||
file = {
|
||||
"type": "machinecode",
|
||||
"type": file_type,
|
||||
"typePath": type_path,
|
||||
"name": sdFile,
|
||||
"display": sdFile,
|
||||
"path": sdFile,
|
||||
|
||||
@@ -14,7 +14,7 @@ from werkzeug.exceptions import BadRequest
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.settings import settings, valid_boolean_trues
|
||||
|
||||
from octoprint.server import admin_permission, printer
|
||||
from octoprint.server import admin_permission, printer, pluginManager
|
||||
from octoprint.server.api import api, NO_CONTENT
|
||||
from octoprint.server.util.flask import require_firstrun, with_revalidation_checking
|
||||
from octoprint.access.permissions import Permissions
|
||||
@@ -318,6 +318,38 @@ def deleteApiKey():
|
||||
settings().deleteApiKey()
|
||||
return NO_CONTENT
|
||||
|
||||
@api.route("/settings/templates", methods=["GET"])
|
||||
@require_firstrun
|
||||
@admin_permission.require(403)
|
||||
def fetchTemplateData():
|
||||
from octoprint.server.views import fetch_template_data
|
||||
|
||||
refresh = request.values.get("refresh", "false") in valid_boolean_trues
|
||||
templates, _, _ = fetch_template_data(refresh=refresh)
|
||||
|
||||
result = dict()
|
||||
for tt in templates:
|
||||
result[tt] = []
|
||||
for key in templates[tt]["order"]:
|
||||
entry = templates[tt]["entries"].get(key)
|
||||
if not entry:
|
||||
continue
|
||||
|
||||
if isinstance(entry, dict):
|
||||
name = key
|
||||
else:
|
||||
name, entry = entry
|
||||
|
||||
data = dict(id=key, name=name)
|
||||
|
||||
if entry and "_plugin" in entry:
|
||||
plugin = pluginManager.get_plugin_info(entry["_plugin"], require_enabled=False)
|
||||
data["plugin_id"] = plugin.key
|
||||
data["plugin_name"] = plugin.name
|
||||
|
||||
result[tt].append(data)
|
||||
|
||||
return jsonify(order=result)
|
||||
|
||||
def _saveSettings(data):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -174,8 +174,7 @@ def index():
|
||||
force_refresh = util.flask.cache_check_headers() or "_refresh" in request.values or wizard_active(_templates.get(locale))
|
||||
|
||||
# if we need to refresh our template cache or it's not yet set, process it
|
||||
if force_refresh or _templates.get(locale) is None or _plugin_names is None or _plugin_vars is None:
|
||||
_templates[locale], _plugin_names, _plugin_vars = _process_templates()
|
||||
fetch_template_data(refresh=force_refresh)
|
||||
|
||||
now = datetime.datetime.utcnow()
|
||||
|
||||
@@ -443,7 +442,14 @@ def _get_render_kwargs(templates, plugin_names, plugin_vars, now):
|
||||
return render_kwargs
|
||||
|
||||
|
||||
def _process_templates():
|
||||
def fetch_template_data(refresh=False):
|
||||
global _templates, _plugin_names, _plugin_vars
|
||||
|
||||
locale = g.locale.language if g.locale else "en"
|
||||
|
||||
if not refresh and _templates.get(locale) is not None and _plugin_names is not None and _plugin_vars is not None:
|
||||
return _templates[locale], _plugin_names, _plugin_vars
|
||||
|
||||
first_run = settings().getBoolean(["server", "firstRun"])
|
||||
|
||||
##~~ prepare templates
|
||||
@@ -743,6 +749,10 @@ def _process_templates():
|
||||
templates[t]["entries"].update(template_sorting[t]["custom_insert_entries"](sorted_missing))
|
||||
templates[t]["order"] = template_sorting[t]["custom_insert_order"](templates[t]["order"], sorted_missing)
|
||||
|
||||
_templates[locale] = templates
|
||||
_plugin_names = plugin_names
|
||||
_plugin_vars = plugin_vars
|
||||
|
||||
return templates, plugin_names, plugin_vars
|
||||
|
||||
|
||||
@@ -830,6 +840,8 @@ def _process_template_config(name, implementation, rule, config=None, counter=1)
|
||||
if "suffix" in data:
|
||||
data["_key"] += data["suffix"]
|
||||
|
||||
data["_plugin"] = name
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
@@ -387,7 +387,6 @@ default_settings = {
|
||||
"includeFilenameInOpened": True,
|
||||
"hasBed": True,
|
||||
"repetierStyleTargetTemperature": False,
|
||||
"repetierStyleResends": False,
|
||||
"okBeforeCommandOutput": False,
|
||||
"smoothieTemperatureReporting": False,
|
||||
"reprapfwM114": False,
|
||||
@@ -627,7 +626,7 @@ class Settings(object):
|
||||
|
||||
self._script_env = self._init_script_templating()
|
||||
|
||||
self._sanity_check_folders()
|
||||
self.sanity_check_folders(folders=["logs", ])
|
||||
|
||||
def _init_basedir(self, basedir):
|
||||
if basedir is not None:
|
||||
@@ -643,8 +642,10 @@ class Settings(object):
|
||||
"can't run without a writable base folder.".format(self._basedir), exc_info=1)
|
||||
raise
|
||||
|
||||
def _sanity_check_folders(self):
|
||||
for folder in default_settings["folder"].keys():
|
||||
def sanity_check_folders(self, folders=None):
|
||||
if folders is None:
|
||||
folders = default_settings["folder"].keys()
|
||||
for folder in folders:
|
||||
self.getBaseFolder(folder, log_error=True)
|
||||
|
||||
def _get_default_folder(self, type):
|
||||
@@ -1755,15 +1756,23 @@ def _validate_folder(folder, create=True, writable=True, log_error=False):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if not os.path.exists(folder):
|
||||
if create:
|
||||
if os.path.islink(folder):
|
||||
# broken symlink, see #2644
|
||||
raise IOError("Folder at {} appears to be a broken symlink".format(folder))
|
||||
|
||||
elif create:
|
||||
# non existing, but we are allowed to create it
|
||||
try:
|
||||
os.makedirs(folder)
|
||||
except:
|
||||
if log_error:
|
||||
logger.exception("Could not create {}".format(folder))
|
||||
raise IOError("Folder for type {} at {} does not exist and creation failed".format(type, folder))
|
||||
|
||||
else:
|
||||
# not extisting, not allowed to create it
|
||||
raise IOError("No such folder: {}".format(folder))
|
||||
|
||||
elif os.path.isfile(folder):
|
||||
# hardening against misconfiguration, see #1953
|
||||
raise IOError("Expected a folder at {} but found a file instead".format(folder))
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
@@ -230,6 +230,9 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
});
|
||||
};
|
||||
|
||||
self._printerErrorCancelNotification = undefined;
|
||||
self._printerErrorDisconnectNotification = undefined;
|
||||
self._printerResetNotification = undefined;
|
||||
self._onEvent = function(event) {
|
||||
self._ifInitialized(function() {
|
||||
var type = event.data["type"];
|
||||
@@ -238,7 +241,10 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
log.debug("Got event " + type + " with payload: " + JSON.stringify(payload));
|
||||
|
||||
if (type === "PrintCancelling" && payload.firmwareError) {
|
||||
new PNotify({
|
||||
if (self._printerErrorCancelNotification !== undefined) {
|
||||
self._printerErrorCancelNotification.remove();
|
||||
}
|
||||
self._printerErrorCancelNotification = new PNotify({
|
||||
title: gettext("Error reported by printer"),
|
||||
text: _.sprintf(gettext("Your printer's firmware reported an error. Due to that the ongoing print job will be cancelled. Reported error: %(firmwareError)s"), payload),
|
||||
type: "error",
|
||||
@@ -283,7 +289,10 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
}
|
||||
|
||||
if (title && text) {
|
||||
new PNotify({
|
||||
if (self._printerErrorDisconnectNotification !== undefined) {
|
||||
self._printerErrorDisconnectNotification.remove();
|
||||
}
|
||||
self._printerErrorDisconnectNotification = new PNotify({
|
||||
title: title,
|
||||
text: text,
|
||||
type: "error",
|
||||
@@ -291,9 +300,23 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
|
||||
});
|
||||
}
|
||||
} else if (type === "PrinterReset") {
|
||||
new PNotify({
|
||||
var severity = undefined,
|
||||
text = undefined;
|
||||
if (payload.idle) {
|
||||
text = gettext("It looks like your printer reset while a connection was active. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD.");
|
||||
severity = "alert";
|
||||
} else {
|
||||
text = gettext("It looks like your printer reset while a connection was active. Due to this the ongoing job was aborted. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD.");
|
||||
severity = "error";
|
||||
}
|
||||
|
||||
if (self._printerResetNotification !== undefined) {
|
||||
self._printerResetNotification.remove();
|
||||
}
|
||||
self._printerResetNotification = new PNotify({
|
||||
title: gettext("Printer reset detected"),
|
||||
text: gettext("It looks like your printer reset while a connection was active. If this was intentional you may safely ignore this message. Otherwise you should investigate why your printer reset itself, since this will interrupt prints and also file transfers to your printer's SD."),
|
||||
text: text,
|
||||
type: severity,
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
|
||||
@@ -674,7 +674,6 @@ function showMessageDialog(msg, options) {
|
||||
if (onclose && _.isFunction(onclose)) {
|
||||
onclose();
|
||||
}
|
||||
modal.remove();
|
||||
});
|
||||
|
||||
if (onshow) {
|
||||
@@ -749,7 +748,6 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
onproceed(e);
|
||||
}
|
||||
modal.modal("hide");
|
||||
modal.remove();
|
||||
});
|
||||
|
||||
return modal;
|
||||
@@ -834,7 +832,6 @@ function showSelectionDialog(options) {
|
||||
if (onclose && _.isFunction(onclose)) {
|
||||
onclose(event);
|
||||
}
|
||||
modal.remove();
|
||||
});
|
||||
modal.modal("show");
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ $(function() {
|
||||
|
||||
mobile: false,
|
||||
desktop: false
|
||||
}
|
||||
},
|
||||
viewmodels: {}
|
||||
};
|
||||
|
||||
var browserVisibilityCallbacks = [];
|
||||
@@ -428,6 +429,7 @@ $(function() {
|
||||
pass++;
|
||||
}
|
||||
log.info("... dependency resolution done");
|
||||
OctoPrint.coreui.viewmodels = viewModelMap;
|
||||
|
||||
//~~ some additional hooks and initializations
|
||||
|
||||
|
||||
@@ -479,7 +479,9 @@ $(function() {
|
||||
OctoPrint.util.testPath(path, opts)
|
||||
.done(function(response) {
|
||||
if (!response.result) {
|
||||
if (!response.exists) {
|
||||
if (response.broken_symlink) {
|
||||
self.testFolderConfigText[folder](gettext("The path is a broken symlink."));
|
||||
} else if (!response.exists) {
|
||||
self.testFolderConfigText[folder](gettext("The path does not exist and cannot be created."));
|
||||
} else if (!response.typeok) {
|
||||
self.testFolderConfigText[folder](gettext("The path is not a folder."));
|
||||
|
||||
@@ -715,6 +715,10 @@ ul.dropdown-menu li a {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.uploaded *[title] {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.internal {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<script type="text/html" id="files_template_machinecode">
|
||||
<div class="title clickable" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: $root.getSuccessClass($data), style: { 'font-weight': $root.listHelper.isSelected($data) ? 'bold' : 'normal' }, text: display"></div>
|
||||
<div class="internal" data-bind="visible: display && name != display">{{ _('Internal') }}: <span data-bind="text: name"></span></div>
|
||||
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date)"></span></div>
|
||||
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date), attr: {title: formatDate(date)}"></span></div>
|
||||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
||||
<div class="additionalInfo hide" data-bind="html: $root.getAdditionalData($data)"></div>
|
||||
<div class="btn-group action-buttons">
|
||||
@@ -29,7 +29,7 @@
|
||||
<script type="text/html" id="files_template_model">
|
||||
<div class="title muted" data-bind="text: display"></div>
|
||||
<div class="internal" data-bind="visible: name != display">{{ _('Internal') }}: <span data-bind="text: name"></span></div>
|
||||
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date)"></span></div>
|
||||
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date), attr: {title: formatDate(date)}"></span></div>
|
||||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
||||
<div class="btn-group action-buttons">
|
||||
<a class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DOWNLOAD), attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}" title="{{ _('Download') }}"><i class="fa fa-download"></i></a>
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
+242
-128
@@ -383,7 +383,7 @@ class MachineCom(object):
|
||||
self._baudrateDetectRetry = 0
|
||||
self._temperatureTargetSetThreshold = 25
|
||||
self._tempOffsets = dict()
|
||||
self._command_queue = TypedQueue()
|
||||
self._command_queue = CommandQueue()
|
||||
self._currentZ = None
|
||||
self._currentF = None
|
||||
self._heatupWaitStartTime = None
|
||||
@@ -446,8 +446,6 @@ class MachineCom(object):
|
||||
self._lastCommError = None
|
||||
self._lastResendNumber = None
|
||||
self._currentResendCount = 0
|
||||
self._resendSwallowRepetitions = settings().getBoolean(["serial", "ignoreIdenticalResends"])
|
||||
self._resendSwallowRepetitionsCounter = 0
|
||||
|
||||
self._firmware_detection = settings().getBoolean(["serial", "firmwareDetection"])
|
||||
self._firmware_info_received = not self._firmware_detection
|
||||
@@ -484,6 +482,8 @@ class MachineCom(object):
|
||||
self._temperature_timer = None
|
||||
self._sd_status_timer = None
|
||||
|
||||
self._job_queue = JobQueue()
|
||||
|
||||
# hooks
|
||||
self._pluginManager = octoprint.plugin.plugin_manager()
|
||||
|
||||
@@ -885,7 +885,7 @@ class MachineCom(object):
|
||||
def fakeOk(self):
|
||||
self._handle_ok()
|
||||
|
||||
def sendCommand(self, cmd, cmd_type=None, processed=False, force=False, on_sent=None, tags=None):
|
||||
def sendCommand(self, cmd, cmd_type=None, part_of_job=False, processed=False, force=False, on_sent=None, tags=None):
|
||||
if not isinstance(cmd, QueueMarker):
|
||||
cmd = to_unicode(cmd, errors="replace")
|
||||
if not processed:
|
||||
@@ -893,7 +893,13 @@ class MachineCom(object):
|
||||
if not cmd:
|
||||
return False
|
||||
|
||||
if self.isPrinting() and not self.isSdFileSelected() and not self.job_on_hold and not force:
|
||||
if tags is None:
|
||||
tags = set()
|
||||
|
||||
if part_of_job:
|
||||
self._job_queue.put((cmd, cmd_type, on_sent, tags | {"source:job"}))
|
||||
return True
|
||||
elif self.isPrinting() and not self.isSdFileSelected() and not self.job_on_hold and not force:
|
||||
try:
|
||||
self._command_queue.put((cmd, cmd_type, on_sent, tags), item_type=cmd_type)
|
||||
return True
|
||||
@@ -969,13 +975,14 @@ class MachineCom(object):
|
||||
scriptLines))
|
||||
|
||||
|
||||
def sendGcodeScript(self, scriptName, replacements=None, tags=None):
|
||||
def sendGcodeScript(self, scriptName, replacements=None, tags=None, part_of_job=False):
|
||||
if tags is None:
|
||||
tags = set()
|
||||
|
||||
scriptLines = self._getGcodeScript(scriptName, replacements=replacements)
|
||||
tags_to_use = tags | {"trigger:comm.send_gcode_script", "source:script", "script:{}".format(scriptName)}
|
||||
for line in scriptLines:
|
||||
self.sendCommand(line, tags=tags | {"trigger:comm.send_gcode_script", "source:script", "script:{}".format(scriptName)})
|
||||
self.sendCommand(line, part_of_job=part_of_job, tags=tags_to_use)
|
||||
return "\n".join(scriptLines)
|
||||
|
||||
def startPrint(self, pos=None, tags=None, external_sd=False):
|
||||
@@ -1000,42 +1007,46 @@ class MachineCom(object):
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
|
||||
if not self.isSdFileSelected():
|
||||
self.resetLineNumbers(tags={"trigger:comm.start_print"})
|
||||
self.resetLineNumbers(part_of_job=True, tags={"trigger:comm.start_print"})
|
||||
|
||||
self._callback.on_comm_print_job_started()
|
||||
|
||||
if self.isSdFileSelected():
|
||||
if not external_sd:
|
||||
# make sure to ignore the "file selected" later on, otherwise we'll reset our progress data
|
||||
self._ignore_select = True
|
||||
self.sendCommand("M23 {filename}".format(filename=self._currentFile.getFilename()),
|
||||
tags=tags | {"trigger:comm.start_print",})
|
||||
if pos is not None and isinstance(pos, int) and pos > 0:
|
||||
self._currentFile.pos = pos
|
||||
self.sendCommand("M26 S{}".format(pos), tags=tags | {"trigger:comm.start_print",})
|
||||
else:
|
||||
self._currentFile.pos = 0
|
||||
|
||||
self.sendCommand("M24", tags=tags | {"trigger:comm.start_print",})
|
||||
|
||||
interval = self._timeout_intervals.get("sdStatus", 1.0)
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
self._sd_status_timer = RepeatedTimer(interval, self._poll_sd_status, run_first=True)
|
||||
self._sd_status_timer.start()
|
||||
|
||||
if not external_sd:
|
||||
# make sure to ignore the "file selected" later on, otherwise we'll reset our progress data
|
||||
self._ignore_select = True
|
||||
|
||||
self.sendCommand("M23 {filename}".format(filename=self._currentFile.getFilename()),
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.start_print",})
|
||||
if pos is not None and isinstance(pos, int) and pos > 0:
|
||||
self._currentFile.pos = pos
|
||||
self.sendCommand("M26 S{}".format(pos),
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.start_print",})
|
||||
else:
|
||||
self._currentFile.pos = 0
|
||||
|
||||
def start_polling():
|
||||
self._sd_status_timer.start()
|
||||
|
||||
self.sendCommand("M24",
|
||||
on_sent=start_polling,
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.start_print",})
|
||||
else:
|
||||
self._sd_status_timer.start()
|
||||
else:
|
||||
if pos is not None and isinstance(pos, int) and pos > 0:
|
||||
self._currentFile.seek(pos)
|
||||
|
||||
line, pos, lineno = self._getNext()
|
||||
if line is not None:
|
||||
self.sendCommand(line, tags=tags | {"trigger:comm.start_print",
|
||||
"source:file",
|
||||
"filepos:{}".format(pos),
|
||||
"fileline:{}".format(lineno)})
|
||||
|
||||
# now make sure we actually do something, up until now we only filled up the queue
|
||||
self._sendFromQueue()
|
||||
self._continue_sending()
|
||||
except:
|
||||
self._logger.exception("Error while trying to start printing")
|
||||
self._trigger_error(get_exception_string(), "start_print")
|
||||
@@ -1149,7 +1160,7 @@ class MachineCom(object):
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self.sendCommand(SendQueueMarker(finalize), part_of_job=True)
|
||||
self._continue_sending()
|
||||
|
||||
def cancelPrint(self, firmware_error=None, disable_log_position=False, tags=None, external_sd=False):
|
||||
@@ -1178,11 +1189,11 @@ class MachineCom(object):
|
||||
if self._cancel_position_timer is not None:
|
||||
self._cancel_position_timer.cancel()
|
||||
self._cancel_position_timer = ResettableTimer(self._timeout_intervals.get("positionLogWait", 10.0),
|
||||
self._cancel_preparation_done)
|
||||
self._cancel_preparation_failed)
|
||||
self._cancel_position_timer.daemon = True
|
||||
self._cancel_position_timer.start()
|
||||
self.sendCommand("M114", tags=tags | {"trigger:comm.cancel",
|
||||
"trigger:record_position"})
|
||||
self.sendCommand("M114", part_of_job=True, tags=tags | {"trigger:comm.cancel",
|
||||
"trigger:record_position"})
|
||||
|
||||
self._callback.on_comm_print_job_cancelling(firmware_error=firmware_error)
|
||||
|
||||
@@ -1191,9 +1202,9 @@ class MachineCom(object):
|
||||
|
||||
if self.isSdFileSelected():
|
||||
if not external_sd:
|
||||
self.sendCommand("M25", tags=tags | {"trigger:comm.cancel",}) # pause print
|
||||
self.sendCommand("M27", tags=tags | {"trigger:comm.cancel",}) # get current byte position in file
|
||||
self.sendCommand("M26 S0", tags=tags | {"trigger:comm.cancel",}) # reset position in file to byte 0
|
||||
self.sendCommand("M25", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # pause print
|
||||
self.sendCommand("M27", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # get current byte position in file
|
||||
self.sendCommand("M26 S0", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # reset position in file to byte 0
|
||||
if self._sd_status_timer is not None:
|
||||
try:
|
||||
self._sd_status_timer.cancel()
|
||||
@@ -1202,9 +1213,10 @@ class MachineCom(object):
|
||||
|
||||
if self._log_position_on_cancel and not disable_log_position:
|
||||
self.sendCommand("M400",
|
||||
on_sent=_on_M400_sent,
|
||||
tags=tags | {"trigger:comm.cancel",
|
||||
"trigger:record_position"})
|
||||
on_sent=_on_M400_sent,
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.cancel",
|
||||
"trigger:record_position"})
|
||||
self._continue_sending()
|
||||
else:
|
||||
self._cancel_preparation_done(check_timer=False)
|
||||
@@ -1234,7 +1246,7 @@ class MachineCom(object):
|
||||
|
||||
def finalize():
|
||||
self._changeState(self.STATE_PAUSED)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self.sendCommand(SendQueueMarker(finalize), part_of_job=True)
|
||||
self._continue_sending()
|
||||
|
||||
def setPause(self, pause, local_handling=True, tags=None):
|
||||
@@ -1255,26 +1267,19 @@ class MachineCom(object):
|
||||
|
||||
self._changeState(self.STATE_RESUMING)
|
||||
self._callback.on_comm_print_job_resumed(suppress_script=not local_handling)
|
||||
self.sendCommand(SendQueueMarker(lambda: self._changeState(self.STATE_PRINTING)))
|
||||
self.sendCommand(SendQueueMarker(lambda: self._changeState(self.STATE_PRINTING)), part_of_job=True)
|
||||
|
||||
if self.isSdFileSelected():
|
||||
if local_handling:
|
||||
self.sendCommand("M24", tags=tags | {"trigger:comm.set_pause","trigger:resume"})
|
||||
self.sendCommand("M27", tags=tags | {"trigger:comm.set_pause", "trigger:resume"})
|
||||
else:
|
||||
line, pos, lineno = self._getNext()
|
||||
if line is not None:
|
||||
if not tags:
|
||||
tags = set()
|
||||
tags_to_use = tags | {"trigger:comm.set_pause",
|
||||
"trigger:resume",
|
||||
"source:file",
|
||||
"filepos:{}".format(pos),
|
||||
"fileline:{}".format(lineno)}
|
||||
self.sendCommand(line, tags=tags_to_use)
|
||||
self.sendCommand("M24",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause","trigger:resume"})
|
||||
self.sendCommand("M27",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause", "trigger:resume"})
|
||||
|
||||
# now make sure we actually do something, up until now we only filled up the queue
|
||||
self._sendFromQueue()
|
||||
self._continue_sending()
|
||||
|
||||
elif pause and self.isPrinting():
|
||||
if not self._pauseWaitStartTime:
|
||||
@@ -1282,7 +1287,9 @@ class MachineCom(object):
|
||||
|
||||
self._changeState(self.STATE_PAUSING)
|
||||
if self.isSdFileSelected() and local_handling:
|
||||
self.sendCommand("M25", tags=tags | {"trigger:comm.set_pause", "trigger:pause"}) # pause print
|
||||
self.sendCommand("M25",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause", "trigger:pause"}) # pause print
|
||||
|
||||
if not local_handling:
|
||||
with self._suppress_scripts_mutex:
|
||||
@@ -1302,16 +1309,19 @@ class MachineCom(object):
|
||||
self._pause_preparation_failed)
|
||||
self._pause_position_timer.daemon = True
|
||||
self._pause_position_timer.start()
|
||||
self.sendCommand("M114", tags=tags | {"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position"})
|
||||
self.sendCommand("M114",
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position"})
|
||||
|
||||
if self._log_position_on_pause:
|
||||
self.sendCommand("M400",
|
||||
on_sent=_on_M400_sent,
|
||||
tags=tags | {"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position"})
|
||||
on_sent=_on_M400_sent,
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.set_pause",
|
||||
"trigger:pause",
|
||||
"trigger:record_position"})
|
||||
self._continue_sending()
|
||||
else:
|
||||
self._pause_preparation_done(check_timer=False, suppress_script=not local_handling)
|
||||
@@ -1388,14 +1398,16 @@ class MachineCom(object):
|
||||
self.sendCommand(self._hello_command, force=True, tags=tags | {"trigger:comm.say_hello",})
|
||||
self._clear_to_send.set()
|
||||
|
||||
def resetLineNumbers(self, number=0, tags=None):
|
||||
def resetLineNumbers(self, number=0, part_of_job=False, tags=None):
|
||||
if not self.isOperational():
|
||||
return
|
||||
|
||||
if tags is None:
|
||||
tags = set()
|
||||
|
||||
self.sendCommand("M110 N%d" % number, tags=tags | {"trigger:comm.reset_line_numbers",})
|
||||
self.sendCommand("M110 N{}".format(number),
|
||||
part_of_job=part_of_job,
|
||||
tags=tags | {"trigger:comm.reset_line_numbers",})
|
||||
|
||||
##~~ record aborted file positions
|
||||
|
||||
@@ -1623,7 +1635,7 @@ class MachineCom(object):
|
||||
|
||||
# process resends
|
||||
elif lower_line.startswith("resend") or lower_line.startswith("rs"):
|
||||
self._handleResendRequest(line)
|
||||
self._handle_resend_request(line)
|
||||
handled = True
|
||||
|
||||
# process timeouts
|
||||
@@ -1766,7 +1778,6 @@ class MachineCom(object):
|
||||
self._logger.info("Detected Repetier firmware, enabling relevant features for issue free communication")
|
||||
|
||||
self._alwaysSendChecksum = True
|
||||
self._resendSwallowRepetitions = True
|
||||
self._blockWhileDwelling = True
|
||||
supportRepetierTargetTemp = True
|
||||
disable_external_heatup_detection = True
|
||||
@@ -1886,7 +1897,7 @@ class MachineCom(object):
|
||||
self._currentFile.size = total
|
||||
self._callback.on_comm_progress()
|
||||
|
||||
elif 'Not SD printing' in line and self.isSdFileSelected() and self.isPrinting():
|
||||
elif 'Not SD printing' in line and self.isSdFileSelected() and self.isPrinting() and not self.isFinishing():
|
||||
# something went wrong, printer is reporting that we actually are not printing right now...
|
||||
self.cancelPrint(external_sd=True)
|
||||
elif 'File opened' in line and not self._ignore_select:
|
||||
@@ -1929,6 +1940,8 @@ class MachineCom(object):
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
elif 'Done printing file' in line and self.isSdPrinting():
|
||||
# printer is reporting file finished printing
|
||||
self._changeState(self.STATE_FINISHING)
|
||||
|
||||
self._currentFile.done = True
|
||||
self._currentFile.pos = 0
|
||||
|
||||
@@ -1938,11 +1951,12 @@ class MachineCom(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
self._changeState(self.STATE_FINISHING)
|
||||
self.sendCommand("M400", part_of_job=True)
|
||||
self._callback.on_comm_print_job_done()
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self.sendCommand(SendQueueMarker(finalize))
|
||||
self.sendCommand(SendQueueMarker(finalize), part_of_job=True)
|
||||
self._continue_sending()
|
||||
elif 'Done saving file' in line:
|
||||
if self._trigger_ok_for_m29:
|
||||
# workaround for most versions of Marlin out in the wild
|
||||
@@ -2003,23 +2017,27 @@ class MachineCom(object):
|
||||
self.STATE_PAUSED,
|
||||
self.STATE_TRANSFERING_FILE):
|
||||
if line == "start": # exact match, to be on the safe side
|
||||
if self._state in (self.STATE_OPERATIONAL,):
|
||||
message = "Printer sent 'start' while already operational. External reset? " \
|
||||
"Resetting line numbers to be on the safe side"
|
||||
self._log(message)
|
||||
self._logger.warn(message)
|
||||
self._onExternalReset()
|
||||
with self.job_put_on_hold():
|
||||
idle = self._state in (self.STATE_OPERATIONAL,)
|
||||
if idle:
|
||||
message = "Printer sent 'start' while already operational. External reset? " \
|
||||
"Resetting line numbers to be on the safe side"
|
||||
self._log(message)
|
||||
self._logger.warn(message)
|
||||
|
||||
else:
|
||||
verb = "streaming to SD" if self.isStreaming() else "printing"
|
||||
message = "Printer sent 'start' while {}. External reset? " \
|
||||
"Aborting job since printer lost state.".format(verb)
|
||||
self._log(message)
|
||||
self._logger.warn(message)
|
||||
self.cancelPrint(disable_log_position=True)
|
||||
self._onExternalReset()
|
||||
self._on_external_reset()
|
||||
|
||||
eventManager().fire(Events.PRINTER_RESET)
|
||||
else:
|
||||
verb = "streaming to SD" if self.isStreaming() else "printing"
|
||||
message = "Printer sent 'start' while {}. External reset? " \
|
||||
"Aborting job since printer lost state.".format(verb)
|
||||
self._log(message)
|
||||
self._logger.warn(message)
|
||||
|
||||
self._on_external_reset()
|
||||
self.cancelPrint(disable_log_position=True)
|
||||
|
||||
eventManager().fire(Events.PRINTER_RESET, payload=dict(idle=idle))
|
||||
|
||||
except:
|
||||
self._logger.exception("Something crashed inside the serial connection loop, please report this in OctoPrint's bug tracker:")
|
||||
@@ -2171,26 +2189,29 @@ class MachineCom(object):
|
||||
|
||||
def _continue_sending(self):
|
||||
while self._active:
|
||||
job_active = self._state == self.STATE_PRINTING and not (self._currentFile is None or self._currentFile.done or self.isSdPrinting())
|
||||
|
||||
if self._state == self.STATE_PRINTING and not (self._currentFile is None or self._currentFile.done or self.isSdPrinting()):
|
||||
# we are printing, we really want to send either something from the command
|
||||
# queue or the next line from our file, so we only return here if we actually DO
|
||||
# send something
|
||||
if self._sendFromQueue():
|
||||
# we found something in the queue to send
|
||||
return True
|
||||
if self._send_from_command_queue():
|
||||
# we found something in the command queue to send
|
||||
return True
|
||||
|
||||
elif self.job_on_hold:
|
||||
return False
|
||||
elif self.job_on_hold:
|
||||
# job is on hold, that means we must not send from either script queue or file
|
||||
return False
|
||||
|
||||
elif self._sendNext():
|
||||
# we sent the next line from the file
|
||||
return True
|
||||
elif self._send_from_job_queue():
|
||||
# we found something in the script queue to send
|
||||
return True
|
||||
|
||||
self._logger.debug("No command sent on ok while printing, doing another iteration")
|
||||
else:
|
||||
# just send stuff from the command queue and be done with it
|
||||
return self._sendFromQueue()
|
||||
elif job_active and self._send_from_job():
|
||||
# we sent the next line from the file
|
||||
return True
|
||||
|
||||
elif not job_active:
|
||||
# nothing sent but also no job active, so we can just return false
|
||||
return False
|
||||
|
||||
self._logger.debug("No command sent on ok while printing, doing another iteration")
|
||||
|
||||
def _process_registered_message(self, line, feedback_matcher, feedback_controls, feedback_errors):
|
||||
feedback_match = feedback_matcher.search(line)
|
||||
@@ -2292,7 +2313,19 @@ class MachineCom(object):
|
||||
eventManager().fire(Events.CONNECTED, payload)
|
||||
self.sendGcodeScript("afterPrinterConnected", replacements=dict(event=payload))
|
||||
|
||||
def _onExternalReset(self):
|
||||
def _on_external_reset(self):
|
||||
# hold queue processing, clear queues and acknowledgements, reset line number and last lines
|
||||
with self._send_queue.blocked():
|
||||
self._clear_to_send.clear(completely=True)
|
||||
with self._command_queue.blocked():
|
||||
self._command_queue.clear()
|
||||
self._send_queue.clear()
|
||||
|
||||
with self._line_mutex:
|
||||
self._currentLine = 0
|
||||
self._lastLines.clear()
|
||||
|
||||
self.sayHello(tags={"trigger:comm.on_external_reset"})
|
||||
self.resetLineNumbers(tags={"trigger:comm.on_external_reset"})
|
||||
|
||||
if self._temperature_autoreporting:
|
||||
@@ -2326,7 +2359,7 @@ class MachineCom(object):
|
||||
|
||||
return get("temperature", busy_default)
|
||||
|
||||
def _sendFromQueue(self):
|
||||
def _send_from_command_queue(self):
|
||||
# We loop here to make sure that if we do NOT send the first command
|
||||
# from the queue, we'll send the second (if there is one). We do not
|
||||
# want to get stuck here by throwing away commands.
|
||||
@@ -2572,9 +2605,9 @@ class MachineCom(object):
|
||||
|
||||
return ret
|
||||
|
||||
def _getNext(self):
|
||||
def _get_next_from_job(self):
|
||||
if self._currentFile is None:
|
||||
return None
|
||||
return None, None, None
|
||||
|
||||
line, pos, lineno = self._currentFile.getNext()
|
||||
if line is None:
|
||||
@@ -2582,13 +2615,14 @@ class MachineCom(object):
|
||||
self._finishFileTransfer()
|
||||
else:
|
||||
self._changeState(self.STATE_FINISHING)
|
||||
self.sendCommand("M400", part_of_job=True)
|
||||
self._callback.on_comm_print_job_done()
|
||||
def finalize():
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
return SendQueueMarker(finalize), None, None
|
||||
return line, pos, lineno
|
||||
|
||||
def _sendNext(self):
|
||||
def _send_from_job(self):
|
||||
with self._jobLock:
|
||||
while self._active:
|
||||
# we loop until we've actually enqueued a line for sending
|
||||
@@ -2600,9 +2634,9 @@ class MachineCom(object):
|
||||
# job is on hold, return false
|
||||
return False
|
||||
|
||||
line, pos, lineno = self._getNext()
|
||||
line, pos, lineno = self._get_next_from_job()
|
||||
if isinstance(line, QueueMarker):
|
||||
self.sendCommand(line)
|
||||
self.sendCommand(line, part_of_job=True)
|
||||
self._callback.on_comm_progress()
|
||||
|
||||
# end of file, return false so that the next round in continue_sending will process
|
||||
@@ -2616,18 +2650,36 @@ class MachineCom(object):
|
||||
result = self._sendCommand(line, tags={"source:file", "filepos:{}".format(pos), "fileline:{}".format(lineno)})
|
||||
self._callback.on_comm_progress()
|
||||
if result:
|
||||
# line sent, return true
|
||||
# line from file sent, return true
|
||||
return True
|
||||
|
||||
self._logger.debug("Command \"{}\" from file not enqueued, doing another iteration".format(line))
|
||||
|
||||
def _handleResendRequest(self, line):
|
||||
def _send_from_job_queue(self):
|
||||
try:
|
||||
line, cmd_type, on_sent, tags = self._job_queue.get_nowait()
|
||||
result = self._sendCommand(line, cmd_type=cmd_type, on_sent=on_sent, tags=tags)
|
||||
if result:
|
||||
# line from script sent, return true
|
||||
return True
|
||||
except queue.Empty:
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
def _handle_resend_request(self, line):
|
||||
try:
|
||||
lineToResend = parse_resend_line(line)
|
||||
if lineToResend is None:
|
||||
return False
|
||||
|
||||
if self._resendDelta is None and lineToResend == self._currentLine:
|
||||
if self._resendDelta is None and lineToResend == self._currentLine == 1:
|
||||
# We probably just handled a resend and this request originates from lines sent before that
|
||||
self._logger.info("Got a resend request for line 1 which is also our current line. It looks "
|
||||
"like we just handled a reset and this is a left over of this")
|
||||
return False
|
||||
|
||||
elif self._resendDelta is None and lineToResend == self._currentLine:
|
||||
# We don't expect to have an active resend request and the printer is requesting a resend of
|
||||
# a line we haven't yet sent.
|
||||
#
|
||||
@@ -2648,26 +2700,16 @@ class MachineCom(object):
|
||||
if lastCommError is not None \
|
||||
and ("line number" in lastCommError.lower() or "expected line" in lastCommError.lower()) \
|
||||
and lineToResend == self._lastResendNumber \
|
||||
and self._resendDelta is not None and self._currentResendCount < self._resendDelta:
|
||||
and self._resendDelta is not None and self._currentResendCount < resendDelta:
|
||||
self._logger.info("Ignoring resend request for line %d, that still originates from lines we sent "
|
||||
"before we got the first resend request" % lineToResend)
|
||||
self._currentResendCount += 1
|
||||
return True
|
||||
|
||||
# If we ignore resend repetitions (Repetier firmware...), check if we
|
||||
# need to do this now. If the same line number has been requested we
|
||||
# already saw and resent, we'll ignore it up to <counter> times.
|
||||
if self._resendSwallowRepetitions and lineToResend == self._lastResendNumber and self._resendSwallowRepetitionsCounter > 0:
|
||||
self._logger.info("Ignoring resend request for line %d, that is probably a repetition sent by the "
|
||||
"firmware to ensure it arrives, not a real request" % lineToResend)
|
||||
self._resendSwallowRepetitionsCounter -= 1
|
||||
return True
|
||||
|
||||
self._resendActive = True
|
||||
self._resendDelta = resendDelta
|
||||
self._lastResendNumber = lineToResend
|
||||
self._currentResendCount = 0
|
||||
self._resendSwallowRepetitionsCounter = settings().getInt(["serial", "identicalResendsCountdown"])
|
||||
|
||||
if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0:
|
||||
error_text = "Printer requested line %d but no sufficient history is available, can't resend" % lineToResend
|
||||
@@ -3760,11 +3802,13 @@ class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
|
||||
|
||||
def _report_stats(self):
|
||||
duration = time.time() - self._start_time
|
||||
stats = dict(lines=self._read_lines,
|
||||
rate=float(self._read_lines) / duration,
|
||||
time_per_line=duration * 1000.0 / float(self._read_lines),
|
||||
duration=duration)
|
||||
self._logger.info("Finished in {duration:.3f} s. Approx. transfer rate of {rate:.3f} lines/s or {time_per_line:.3f} ms per line".format(**stats))
|
||||
read_lines = self._read_lines
|
||||
if duration > 0 and read_lines > 0:
|
||||
stats = dict(lines=read_lines,
|
||||
rate=float(read_lines) / duration,
|
||||
time_per_line=duration * 1000.0 / float(read_lines),
|
||||
duration=duration)
|
||||
self._logger.info("Finished in {duration:.3f} s. Approx. transfer rate of {rate:.3f} lines/s or {time_per_line:.3f} ms per line".format(**stats))
|
||||
|
||||
|
||||
class SpecialStreamingGcodeFileInformation(StreamingGcodeFileInformation):
|
||||
@@ -3783,12 +3827,55 @@ class SpecialStreamingGcodeFileInformation(StreamingGcodeFileInformation):
|
||||
return None
|
||||
return line
|
||||
|
||||
class JobQueue(PrependableQueue):
|
||||
pass
|
||||
|
||||
class CommandQueue(TypedQueue):
|
||||
def __init__(self, *args, **kwargs):
|
||||
TypedQueue.__init__(self, *args, **kwargs)
|
||||
self._unblocked = threading.Event()
|
||||
self._unblocked.set()
|
||||
|
||||
def block(self):
|
||||
self._unblocked.clear()
|
||||
|
||||
def unblock(self):
|
||||
self._unblocked.set()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def blocked(self):
|
||||
self.block()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
self.unblock()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
self._unblocked.wait()
|
||||
return TypedQueue.get(self, *args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
self._unblocked.wait()
|
||||
return TypedQueue.put(self, *args, **kwargs)
|
||||
|
||||
def clear(self):
|
||||
cleared = []
|
||||
while True:
|
||||
try:
|
||||
cleared.append(TypedQueue.get(self, False))
|
||||
TypedQueue.task_done(self)
|
||||
except queue.Empty:
|
||||
break
|
||||
return cleared
|
||||
|
||||
class SendQueue(PrependableQueue):
|
||||
|
||||
def __init__(self, maxsize=0):
|
||||
PrependableQueue.__init__(self, maxsize=maxsize)
|
||||
|
||||
self._unblocked = threading.Event()
|
||||
self._unblocked.set()
|
||||
|
||||
self._resend_queue = PrependableQueue()
|
||||
self._send_queue = PrependableQueue()
|
||||
self._lookup = set()
|
||||
@@ -3804,16 +3891,43 @@ class SendQueue(PrependableQueue):
|
||||
with self.mutex:
|
||||
self._resend_active = resend_active
|
||||
|
||||
def block(self):
|
||||
self._unblocked.clear()
|
||||
|
||||
def unblock(self):
|
||||
self._unblocked.set()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def blocked(self):
|
||||
self.block()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
self.unblock()
|
||||
|
||||
def prepend(self, item, item_type=None, target=None, block=True, timeout=None):
|
||||
self._unblocked.wait()
|
||||
PrependableQueue.prepend(self, (item, item_type, target), block=block, timeout=timeout)
|
||||
|
||||
def put(self, item, item_type=None, target=None, block=True, timeout=None):
|
||||
self._unblocked.wait()
|
||||
PrependableQueue.put(self, (item, item_type, target), block=block, timeout=timeout)
|
||||
|
||||
def get(self, block=True, timeout=None):
|
||||
self._unblocked.wait()
|
||||
item, _, _ = PrependableQueue.get(self, block=block, timeout=timeout)
|
||||
return item
|
||||
|
||||
def clear(self):
|
||||
cleared = []
|
||||
while True:
|
||||
try:
|
||||
cleared.append(PrependableQueue.get(self, False))
|
||||
PrependableQueue.task_done(self)
|
||||
except queue.Empty:
|
||||
break
|
||||
return cleared
|
||||
|
||||
def _put(self, item):
|
||||
_, item_type, target = item
|
||||
if item_type is not None:
|
||||
|
||||
@@ -5,7 +5,7 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
def normalize(path, expand_user=True, expand_vars=True, **kwargs):
|
||||
def normalize(path, expand_user=True, expand_vars=True, real=True, **kwargs):
|
||||
import os
|
||||
|
||||
if path is None:
|
||||
@@ -15,5 +15,7 @@ def normalize(path, expand_user=True, expand_vars=True, **kwargs):
|
||||
path = os.path.expanduser(path)
|
||||
if expand_vars:
|
||||
path = os.path.expandvars(path)
|
||||
path = os.path.realpath(os.path.abspath(path))
|
||||
path = os.path.abspath(path)
|
||||
if real:
|
||||
path = os.path.realpath(path)
|
||||
return path
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
+614
-487
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user