Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
536bb31965 | ||
|
|
ef46a49430 | ||
|
|
8e28ddd6a4 | ||
|
|
ab8b0230bd | ||
|
|
754ef428a0 | ||
|
|
455474841e | ||
|
|
ae4e4f22c4 | ||
|
|
96fc70bdb2 | ||
|
|
8ed0befd62 | ||
|
|
766c0c21d4 | ||
|
|
7d50563666 | ||
|
|
4011f60ff9 | ||
|
|
37950cb466 | ||
|
|
2824b967ff | ||
|
|
7b8bf2cf5c | ||
|
|
9299cb54a4 | ||
|
|
b965d4cbde | ||
|
|
7d922f3c77 | ||
|
|
7e894d2ac2 | ||
|
|
948e20b269 | ||
|
|
0e863ad776 | ||
|
|
13d7d5f2f6 | ||
|
|
ac8faf7910 | ||
|
|
bf049ddee4 | ||
|
|
e435d55cb1 | ||
|
|
2c50237699 | ||
|
|
93763a5563 | ||
|
|
7a74f5348d | ||
|
|
b25c2220d1 | ||
|
|
57161dd9c3 | ||
|
|
1343a4a253 | ||
|
|
6de7eabca2 | ||
|
|
2247f30c87 | ||
|
|
ba6a6723a6 | ||
|
|
f9a0cb94f7 | ||
|
|
e689a2c733 | ||
|
|
d07c81f312 | ||
|
|
32f4f8d95b | ||
|
|
7f2e0161a8 | ||
|
|
59993bfca4 | ||
|
|
0782dda20f | ||
|
|
8c1a79558b | ||
|
|
0705a7054c | ||
|
|
54bd7766b9 | ||
|
|
ed215fc5fa | ||
|
|
5f53b704dd | ||
|
|
e8ef0ba8a4 | ||
|
|
49f62bc655 | ||
|
|
0ff43def3a | ||
|
|
cc14b77487 | ||
|
|
7f10c317f1 | ||
|
|
ba1f8c58b4 | ||
|
|
273bb45741 | ||
|
|
e33f69917f | ||
|
|
4b8bdd244e | ||
|
|
202f93426a | ||
|
|
c538604cd5 | ||
|
|
0c44762f6f | ||
|
|
6df57bc1d1 | ||
|
|
e328695100 | ||
|
|
738c699a6e | ||
|
|
8a28220e63 | ||
|
|
5808c1bd8a | ||
|
|
8bbb642a56 | ||
|
|
1f0dbf8f7f | ||
|
|
9a6099ffc2 | ||
|
|
25de95dc93 | ||
|
|
57f6e1e1bc | ||
|
|
edf9c40941 | ||
|
|
4dd4a2cc9c | ||
|
|
81bc8c784a | ||
|
|
294e7fc2db | ||
|
|
6e632d02a0 | ||
|
|
50ff0d810f | ||
|
|
d4be7f18e2 | ||
|
|
6d24a46e88 | ||
|
|
db866d2310 | ||
|
|
bb7e15be84 | ||
|
|
7a007a6417 | ||
|
|
96aad9d34f | ||
|
|
4d3334caf1 | ||
|
|
2745f49d28 | ||
|
|
5470aaaa3a | ||
|
|
f89cbc9133 | ||
|
|
5dfffc36e3 | ||
|
|
3761995aff | ||
|
|
e62cef590b | ||
|
|
677e583345 | ||
|
|
abbf937e7f | ||
|
|
8d14ea6093 | ||
|
|
97826b2f3b | ||
|
|
a1e0078ce5 | ||
|
|
a5bf3c3be1 | ||
|
|
19a5613e59 | ||
|
|
ced286854c | ||
|
|
811ffc760f | ||
|
|
549b60edb1 | ||
|
|
8735b10653 | ||
|
|
29d49179a9 | ||
|
|
19b4a0f403 | ||
|
|
d854b41ffb | ||
|
|
329a575031 | ||
|
|
85ad85bdfa | ||
|
|
95c26a7850 | ||
|
|
885e6f916c | ||
|
|
d7a86a4d28 | ||
|
|
7b3e0563cc | ||
|
|
50a62bf00a |
No files matched your search
+6
-3
@@ -10,10 +10,13 @@
|
|||||||
# master shall not use the lookup table, only tags
|
# master shall not use the lookup table, only tags
|
||||||
master
|
master
|
||||||
|
|
||||||
# maintenance is currently the branch for preparation of maintenance release 1.2.2
|
# maintenance is currently the branch for preparation of maintenance release 1.2.6
|
||||||
# so are any fix/... branches
|
# so are any fix/... branches
|
||||||
maintenance 1.2.2-dev 9f8d30a66c2fcc5cd0e8984c72dc36f7e84fde10
|
maintenance 1.2.6-dev 96fc70bdb2dd74ba04c3071f70da385b0408904a
|
||||||
fix/.* 1.2.2-dev 9f8d30a66c2fcc5cd0e8984c72dc36f7e84fde10
|
fix/.* 1.2.6-dev 96fc70bdb2dd74ba04c3071f70da385b0408904a
|
||||||
|
|
||||||
|
# Special case disconnected checkouts, e.g. 'git checkout <tag>'
|
||||||
|
\(detached.*
|
||||||
|
|
||||||
# every other branch is a development branch and thus gets resolved to 1.3.0-dev for now
|
# every other branch is a development branch and thus gets resolved to 1.3.0-dev for now
|
||||||
.* 1.3.0-dev 198d3450d94be1a2
|
.* 1.3.0-dev 198d3450d94be1a2
|
||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
# Authors
|
||||||
|
|
||||||
|
The following people have contributed to OctoPrint's code base (ordered by
|
||||||
|
date of first contribution):
|
||||||
|
|
||||||
|
* [Gina Häußge](https://github.com/foosel)
|
||||||
|
* [Thomas Sanladerer](https://github.com/imitation)
|
||||||
|
* [Alex Ustyantsev](https://github.com/hudbrog)
|
||||||
|
* [Andrew Dalgleish](https://github.com/ajd4096)
|
||||||
|
* [Dale Price](https://github.com/daprice)
|
||||||
|
* [Václav "ax" Hůla](https://github.com/AxTheB)
|
||||||
|
* [Tom Perry](https://github.com/daftscience)
|
||||||
|
* [Andreas Gohr](https://github.com/splitbrain)
|
||||||
|
* [Lars Norpchen](https://github.com/norpchen)
|
||||||
|
* [Marlon Wünnemann](https://github.com/marwue)
|
||||||
|
* ["algspd"](https://github.com/algspd)
|
||||||
|
* [Peter Uithoven](https://github.com/peteruithoven)
|
||||||
|
* [Bryan Mayland](https://github.com/CapnBry)
|
||||||
|
* [Ross Hendrickson](https://github.com/savorywatt)
|
||||||
|
* [Dan Lipsitt](https://github.com/DanLipsitt)
|
||||||
|
* [James Gao](https://github.com/jamesgao)
|
||||||
|
* [Tonnerre Lombard](https://github.com/tonnerre)
|
||||||
|
* [Marc Hannappel](https://github.com/Salandora)
|
||||||
|
* [Brad Pitcher](https://github.com/brad)
|
||||||
|
* [Gabe Rosenhouse](https://github.com/rosenhouse)
|
||||||
|
* [chriskoz](https://github.com/chriskoz)
|
||||||
|
* [Ilya Novoselov](https://github.com/nullie)
|
||||||
|
* [Corey C](https://github.com/C-o-r-E)
|
||||||
|
* [Jarek Szczepanski](https://github.com/imrahil)
|
||||||
|
* [Jon Nordby](https://github.com/jonnor)
|
||||||
|
* [Aaron Bieber](https://github.com/qbit)
|
||||||
|
* [Guy Sheffer](https://github.com/guysoft)
|
||||||
|
* [Dattas Moonchaser](https://github.com/dattas)
|
||||||
|
* [Pim Rutgers](https://github.com/Booli)
|
||||||
|
* [Koen Kooi](https://github.com/koenkooi)
|
||||||
|
* [Colin Wallace](https://github.com/Wallacoloo)
|
||||||
|
* [Michael Ang](https://github.com/mangtronix)
|
||||||
|
* [Philipp Engel](https://github.com/nosyjoe)
|
||||||
|
* [Giles Hall](https://github.com/vishnubob)
|
||||||
|
* [Bevaz](https://github.com/Bevaz)
|
||||||
|
* [Bortek](https://github.com/bortek)
|
||||||
|
* [Rob Speed](https://github.com/rspeed)
|
||||||
|
* [Renha](https://github.com/Renha)
|
||||||
|
* [Antoine Bertin](https://github.com/Diaoul)
|
||||||
|
* [Teja Philipp](https://github.com/hungerpirat)
|
||||||
|
* ["matobago"](https://github.com/matobago)
|
||||||
|
* ["nophead"](https://github.com/nophead)
|
||||||
|
* [Bob Clough](https://github.com/thinkl33t)
|
||||||
|
* [Mikk Kiilaspää](https://github.com/Mikk36)
|
||||||
|
* [Jack Minardi](https://github.com/jminardi)
|
||||||
|
* [Mark Walker](https://github.com/markwal)
|
||||||
|
* [Lucas Clemente](https://github.com/lucas-clemente)
|
||||||
|
* [Andrew Erickson](https://github.com/aerickson)
|
||||||
|
* [Nicanor Romero Venier](https://github.com/nicanor-romero)
|
||||||
|
* [Thomas Hou](https://github.com/masterhou)
|
||||||
|
|
||||||
|
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||||
|
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||||
|
the server side GCODE interpreter are still based on Cura's code base from
|
||||||
|
December 2012 and hence on the work of its authors up until then.
|
||||||
+154
@@ -1,5 +1,159 @@
|
|||||||
# OctoPrint Changelog
|
# OctoPrint Changelog
|
||||||
|
|
||||||
|
## 1.2.6 (2015-09-02)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* Added support for version reporting on detached checkouts
|
||||||
|
(see [#1041](https://github.com/foosel/OctoPrint/pull/1041))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Pinned requirement for [psutil](https://pypi.python.org/pypi/psutil)
|
||||||
|
dependency to version 3.1.1 of that library due to an issue when
|
||||||
|
installing version 3.2.0 of that library released on 2015-09-02 through
|
||||||
|
a `python setup.py install` on OctoPrint. Also pinned all other requirements
|
||||||
|
to definitive versions that definitely work while at it to keep that from
|
||||||
|
happening again.
|
||||||
|
|
||||||
|
([Commits](https://github.com/foosel/OctoPrint/compare/1.2.5...1.2.6))
|
||||||
|
|
||||||
|
## 1.2.5 (2015-08-31)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* [#986](https://github.com/foosel/OctoPrint/issues/986) - Added tooltip for
|
||||||
|
"additional data" button in file list.
|
||||||
|
* [#1028](https://github.com/foosel/OctoPrint/issues/1028) - Hint about why
|
||||||
|
timelapse configuration is disabled.
|
||||||
|
* New central configuration option for commands to restart OctoPrint and to
|
||||||
|
restart and shut down the system OctoPrint is running on. This allows plugins
|
||||||
|
(like the Software Update Plugin or the Plugin Manager) and core functionality
|
||||||
|
to perform these common administrative tasks without the user needing to define
|
||||||
|
everything redundantly.
|
||||||
|
* Settings dialog now visualizes when settings are saving and when they being
|
||||||
|
retrieved. Also the Send/Cancel buttons are disabled while settings are saving
|
||||||
|
to prevent duplicated requests and concurrent retrieval of the settings by
|
||||||
|
multiple viewmodels is disabled as well.
|
||||||
|
* Better protection against rendering errors from templates provided by third
|
||||||
|
party plugins.
|
||||||
|
* Better protection against corrupting the configuration by using a temporary
|
||||||
|
file as intermediate buffer.
|
||||||
|
* Added warning to UI regarding Z timelapses and spiralized objects.
|
||||||
|
* Better compatibility with Repetier firmware:
|
||||||
|
* Added "Format Error" to whitelisted recoverable communication errors
|
||||||
|
(see also [#1032](https://github.com/foosel/OctoPrint/pull/1032)).
|
||||||
|
* Added option to ignore repeated resend requests for the same line (see
|
||||||
|
also discussion in [#1015](https://github.com/foosel/OctoPrint/pull/1015)).
|
||||||
|
* Software Update Plugin:
|
||||||
|
* Adjusted to utilize new centralized restart commands (see above).
|
||||||
|
* Allow configuration of checkout folder and version tracking type via
|
||||||
|
Plugin Configuration.
|
||||||
|
* Display message to user if OctoPrint's checkout folder is not configured
|
||||||
|
or a non-release version is running and version tracking against releases
|
||||||
|
is enabled.
|
||||||
|
* Clear version cache when a change in the check configuration is detected.
|
||||||
|
* Mark check configurations for which an update is not possible.
|
||||||
|
* Made disk space running low a bit more obvious through visual warning on
|
||||||
|
configurable thresholds.
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* [#985](https://github.com/foosel/OctoPrint/issues/985) - Do not hiccup on
|
||||||
|
unset `Content-Type` part headers for multipart file uploads.
|
||||||
|
* [#1001](https://github.com/foosel/OctoPrint/issues/1001) - Fixed connection
|
||||||
|
tab not unfolding properly (see also [#1002](https://github.com/foosel/OctoPrint/pull/1002)).
|
||||||
|
* [#1012](https://github.com/foosel/OctoPrint/issues/1012) - All API
|
||||||
|
responses now set no-cache headers, making the Edge browser behave a bit better
|
||||||
|
* [#1019](https://github.com/foosel/OctoPrint/issues/1019) - Better error
|
||||||
|
handling of problems when trying to write the webassets cache.
|
||||||
|
* [#1021](https://github.com/foosel/OctoPrint/issues/1021) - Properly handle
|
||||||
|
serial close on Macs.
|
||||||
|
* [#1031](https://github.com/foosel/OctoPrint/issues/1031) - Special
|
||||||
|
handling of `M112` (emergency stop) command:
|
||||||
|
* Jump send queue
|
||||||
|
* In case the printer's firmware doesn't understand it yet, at least
|
||||||
|
shutdown all of the heaters
|
||||||
|
* Disconnect
|
||||||
|
* Properly reset job progress to 0% when restarting a previously completed
|
||||||
|
printjob (see [#998](https://github.com/foosel/OctoPrint/pull/998)).
|
||||||
|
* Report an update as failed if the `pip` command returns a return code that
|
||||||
|
indicates failure.
|
||||||
|
* Fixed sorting of templates: could only be sorted by name, individual
|
||||||
|
configurations were ignored (see [#1022](https://github.com/foosel/OctoPrint/pull/1022)).
|
||||||
|
* Fixed positioning of custom context menus: were offset due to changes in
|
||||||
|
overall positioning settings (see [#1023](https://github.com/foosel/OctoPrint/pull/1023)).
|
||||||
|
* Software Update: Don't use display version for comparison of git commit
|
||||||
|
hashs.
|
||||||
|
* Fixed temperature parsing for multi extruder setups.
|
||||||
|
* Fixed nested vertical and horizontal custom control layouts.
|
||||||
|
|
||||||
|
([Commits](https://github.com/foosel/OctoPrint/compare/1.2.4...1.2.5))
|
||||||
|
|
||||||
|
## 1.2.4 (2015-07-23)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* `RepeatedTimer` now defaults to `daemon` set to `True`. This makes sure
|
||||||
|
plugins using it don't have to remember to set that flag themselves in
|
||||||
|
order for the server to properly shut down when timers are still active.
|
||||||
|
* Fixed a typo in the docs about `logging.yaml` (top level element is
|
||||||
|
`loggers`, not `logger`).
|
||||||
|
* Support for plugins with external dependencies (`dependency_links` in
|
||||||
|
setuptools), interesting for plugin authors who need to depend on Python
|
||||||
|
libraries that are (not yet) available on PyPI.
|
||||||
|
* Better resilience against errors within plugins.
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Do not cache web page when running for the first time, to avoid caching
|
||||||
|
the first run dialog popup along side with it. This should solve issues
|
||||||
|
people were having when configuring OctoPrint for the first time, then
|
||||||
|
reloading the page without clearing the cache, being again prompted with
|
||||||
|
the dialog with no chance to clear it.
|
||||||
|
* Fix/workaround for occasional white panes in settings dialog on Safari 8,
|
||||||
|
which appears to have an issue with fixed positioning.
|
||||||
|
* Fixed form field truncation in upload requests that could lead to problems
|
||||||
|
when trying to import Cura profiles with names longer than 28 characters.
|
||||||
|
* Fixed webcam rotation for timelapse rendering.
|
||||||
|
* Fixed user settings not reaching the editor in the frontend.
|
||||||
|
* Notifications that are in process of being closed don't open again on
|
||||||
|
mouse over (that was actually more of an unwanted feature).
|
||||||
|
|
||||||
|
([Commits](https://github.com/foosel/OctoPrint/compare/1.2.3...1.2.4))
|
||||||
|
|
||||||
|
## 1.2.3 (2015-07-09)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* New option to actively poll the watched folder. This should make it work also
|
||||||
|
if it is mounted on a filesystem that doesn't allow getting notifications
|
||||||
|
about added files through notification by the operating system (e.g.
|
||||||
|
network shares).
|
||||||
|
* Better resilience against senseless temperature/SD-status-polling intervals
|
||||||
|
(such as 0).
|
||||||
|
* Log exceptions during writing to the serial port to `octoprint.log`.
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* [#961](https://github.com/foosel/OctoPrint/pull/961) - Fixed a JavaScript error that caused an error to be logged when "enter" was pressed in file or plugin search.
|
||||||
|
* [#962](https://github.com/foosel/OctoPrint/pull/962) - ``url(...)``s in packed CSS and LESS files should now be rewritten properly too to refer to correct paths
|
||||||
|
* Update notifications were not vanishing properly after updating:
|
||||||
|
* Only use version cache for update notifications if the OctoPrint version still is the same to make sure the cache gets invalidated after an external update of OctoPrint.
|
||||||
|
* Do not persist version information when saving settings of the Software Update plugin
|
||||||
|
* Always delete files from the ``watched`` folder after importing then. Using file preprocessor plugins could lead to the files staying there.
|
||||||
|
* Fixed an encoding problem causing OctoPrint's Plugin Manager and Software Update plugins to choke on UTF-8 characters in the update output.
|
||||||
|
* Fixed sorting by file size in file list
|
||||||
|
* More resilience against missing plugin assets:
|
||||||
|
* Asset existence will now be checked before they get included
|
||||||
|
in the assets to bundle by webassets, logging a warning if a
|
||||||
|
file isn't present.
|
||||||
|
* Monkey-patched webassets filter chain to not die when a file
|
||||||
|
doesn't exist, but to log an error instead and just return
|
||||||
|
an empty file instead.
|
||||||
|
|
||||||
|
([Commits](https://github.com/foosel/OctoPrint/compare/1.2.2...1.2.3))
|
||||||
|
|
||||||
## 1.2.2 (2015-06-30)
|
## 1.2.2 (2015-06-30)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|||||||
+3
-1
@@ -38,12 +38,14 @@ Pull Requests
|
|||||||
6. Create **one pull request per feature/bug fix**.
|
6. Create **one pull request per feature/bug fix**.
|
||||||
7. Create a **custom branch** for your feature/bug fix and use that as base for your pull request. Pull requests directly
|
7. Create a **custom branch** for your feature/bug fix and use that as base for your pull request. Pull requests directly
|
||||||
against your version of `devel` will be closed.
|
against your version of `devel` will be closed.
|
||||||
7. In your pull request's description, **state what your pull request is doing**, as in, what feature does it implement, what
|
8. In your pull request's description, **state what your pull request is doing**, as in, what feature does it implement, what
|
||||||
bug does it fix. The more thoroughly you explain your intent behind the PR here, the higher the chances it will get merged
|
bug does it fix. The more thoroughly you explain your intent behind the PR here, the higher the chances it will get merged
|
||||||
fast.
|
fast.
|
||||||
|
9. Don't forget to **add yourself to the [AUTHORS](../AUTHORS.md) file** :)
|
||||||
|
|
||||||
History
|
History
|
||||||
-------
|
-------
|
||||||
|
|
||||||
* 2015-01-23: More guidelines for creating pull requests, support/questions redirected to Mailinglist/G+ community
|
* 2015-01-23: More guidelines for creating pull requests, support/questions redirected to Mailinglist/G+ community
|
||||||
* 2015-01-27: Added another explicit link to the FAQ
|
* 2015-01-27: Added another explicit link to the FAQ
|
||||||
|
* 2015-07-07: Added step to add yourself to AUTHORS when creating a PR :)
|
||||||
@@ -1,17 +1,39 @@
|
|||||||
OctoPrint
|
OctoPrint
|
||||||
=========
|
=========
|
||||||
|
|
||||||
[](https://flattr.com/submit/auto?user_id=foosel&url=https://github.com/foosel/OctoPrint&title=OctoPrint&language=&tags=github&category=software)
|
OctoPrint provides a snappy web interface for controlling a 3D printer (RepRap, Ultimaker, ...). It is Free Software
|
||||||
|
|
||||||
OctoPrint provides a responsive web interface for controlling a 3D printer (RepRap, Ultimaker, ...). It is Free Software
|
|
||||||
and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html).
|
and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
Its website can be found at [octoprint.org](http://octoprint.org).
|
Its website can be found at [octoprint.org](http://octoprint.org).
|
||||||
|
|
||||||
|
The documentation is located at [docs.octoprint.org](http://docs.octoprint.org).
|
||||||
|
|
||||||
|
The official plugin repository can be reached at [plugins.octoprint.org](http://plugins.octoprint.org).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
You are currently looking at the source code repository of OctoPrint. If you already installed it
|
||||||
|
(e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only
|
||||||
|
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
|
||||||
|
might be of more interest for you. You might also want to subscribe to [the mailing list](https://groups.google.com/group/octoprint)
|
||||||
|
or the [G+ Community](https://plus.google.com/communities/102771308349328485741) where there are other active users who might be
|
||||||
|
able to help you with any questions you might have.
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Please see the project's [Contribution Guidelines](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md).
|
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
|
||||||
|
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), support
|
||||||
|
of other users in the [bug tracker](https://github.com/foosel/OctoPrint/issues),
|
||||||
|
[the Mailinglist](https://groups.google.com/group/octoprint) or
|
||||||
|
[the G+ Community](https://plus.google.com/communities/102771308349328485741).
|
||||||
|
|
||||||
|
If you think something is bad as it is about OctoPrint or its documentation the way it is, please help
|
||||||
|
in any way to make it better instead of just complaining about it -- this is an Open Source Project
|
||||||
|
after all :)
|
||||||
|
|
||||||
|
For information about how to go about contributions of any kind, please see the project's
|
||||||
|
[Contribution Guidelines](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md).
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
@@ -21,6 +43,12 @@ Installation instructions for installing from source for different operating sys
|
|||||||
If you want to run OctoPrint on a Raspberry Pi you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
If you want to run OctoPrint on a Raspberry Pi you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
||||||
which is a custom SD card image that includes OctoPrint plus dependencies.
|
which is a custom SD card image that includes OctoPrint plus dependencies.
|
||||||
|
|
||||||
|
After installation, please make sure you follow the first-run wizard and set up
|
||||||
|
access control as necessary. If you want to not only be notified about new
|
||||||
|
releases but also be able to automatically upgrade to them from within
|
||||||
|
OctoPrint, take a look [at the documentation of the Software Update Plugin](https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update#making-octoprint-updateable-on-existing-installations)
|
||||||
|
and at its settings.
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
@@ -36,7 +64,11 @@ OctoPrint currently only supports Python 2.7.
|
|||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Running the `setup.py` script installs the `octoprint` script in your Python installation's scripts folder
|
Running the `setup.py` script via
|
||||||
|
|
||||||
|
python setup.py install
|
||||||
|
|
||||||
|
installs the `octoprint` script in your Python installation's scripts folder
|
||||||
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
||||||
following usage examples assume that said `octoprint` script is on your `PATH`.
|
following usage examples assume that said `octoprint` script is on your `PATH`.
|
||||||
|
|
||||||
@@ -77,5 +109,13 @@ which is located at `~/.octoprint` on Linux, at `%APPDATA%/OctoPrint` on Windows
|
|||||||
at `~/Library/Application Support/OctoPrint` on MacOS.
|
at `~/Library/Application Support/OctoPrint` on MacOS.
|
||||||
|
|
||||||
A comprehensive overview of all available configuration settings can be found
|
A comprehensive overview of all available configuration settings can be found
|
||||||
[on the wiki](https://github.com/foosel/OctoPrint/wiki/Configuration). Please note that the most commonly used
|
[in the docs](http://docs.octoprint.org/en/master/configuration/config_yaml.html).
|
||||||
configuration settings can also easily be edited from OctoPrint's settings dialog.
|
Please note that the most commonly used configuration settings can also easily
|
||||||
|
be edited from OctoPrint's settings dialog.
|
||||||
|
|
||||||
|
Special Thanks
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The development of OctoPrint is sponsored and maintained by [BQ](http://www.bq.com/).
|
||||||
|
Cross-browser testing services are kindly provided by [BrowserStack](http://www.browserstack.com/).
|
||||||
|
Profiling is done with the help of [PyVmMonitor](http://www.pyvmmonitor.com).
|
||||||
@@ -621,7 +621,8 @@ Use the following settings to configure the server:
|
|||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
server:
|
server:
|
||||||
# Use this option to define the host to which to bind the server, defaults to "0.0.0.0" (= all interfaces)
|
# Use this option to define the host to which to bind the server, defaults to "0.0.0.0" (= all
|
||||||
|
# interfaces)
|
||||||
host: 0.0.0.0
|
host: 0.0.0.0
|
||||||
|
|
||||||
# Use this option to define the port to which to bind the server, defaults to 5000
|
# Use this option to define the port to which to bind the server, defaults to 5000
|
||||||
@@ -691,6 +692,18 @@ Use the following settings to configure the server:
|
|||||||
# Maximum size of requests other than file uploads in bytes, defaults to 100KB.
|
# Maximum size of requests other than file uploads in bytes, defaults to 100KB.
|
||||||
maxSize: 102400
|
maxSize: 102400
|
||||||
|
|
||||||
|
# Commands to restart/shutdown octoprint or the system it's running on
|
||||||
|
commands:
|
||||||
|
|
||||||
|
# Command to restart OctoPrint, defaults to being unset
|
||||||
|
serverRestartCommand: sudo service octoprint restart
|
||||||
|
|
||||||
|
# Command to restart the system OctoPrint is running on, defaults to being unset
|
||||||
|
systemRestartCommand: sudo shutdown -r now
|
||||||
|
|
||||||
|
# Command to shut down the system OctoPrint is running on, defaults to being unset
|
||||||
|
systemShutdownCommand: sudo shutdown -h now
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Changing log levels
|
|||||||
If you need to change the default logging level within OctoPrint, create the file with a text editor of your choice
|
If you need to change the default logging level within OctoPrint, create the file with a text editor of your choice
|
||||||
(it's usually not there). The general format is this::
|
(it's usually not there). The general format is this::
|
||||||
|
|
||||||
logger:
|
loggers:
|
||||||
<component>:
|
<component>:
|
||||||
level: <loglevel>
|
level: <loglevel>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ new log level to set. An example for increasing the log level of the events and
|
|||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
logger:
|
loggers:
|
||||||
octoprint.events:
|
octoprint.events:
|
||||||
level: DEBUG
|
level: DEBUG
|
||||||
octoprint.filemanager:
|
octoprint.filemanager:
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
.. _sec-features-access_control:
|
||||||
|
|
||||||
|
Access Control
|
||||||
|
==============
|
||||||
|
|
||||||
|
When Access Control is enabled, anonymous users (not logged in) will only see
|
||||||
|
the read-only parts of the UI which are the following:
|
||||||
|
|
||||||
|
* printer state
|
||||||
|
* available gcode files and stats (upload is disabled)
|
||||||
|
* temperature
|
||||||
|
* webcam
|
||||||
|
* gcode viewer
|
||||||
|
* terminal output (sending commands is disabled)
|
||||||
|
* available timelapse movies
|
||||||
|
* any components provided through plugins which are enabled for anonymous
|
||||||
|
users
|
||||||
|
|
||||||
|
Logged in users will get access to everything besides the Settings and System
|
||||||
|
Commands, which are admin-only.
|
||||||
|
|
||||||
|
If Access Control is disabled, everything is directly accessible. **That also
|
||||||
|
includes all administrative functionality as well as full control over the
|
||||||
|
printer!**
|
||||||
|
|
||||||
|
Upon first start a configuration wizard is provided which allows configuration
|
||||||
|
of the first administrator account or alternatively disabling Access Control
|
||||||
|
(which is **NOT** recommended for systems that are directly accessible via the
|
||||||
|
Internet!).
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
|
||||||
|
If you plan to have your OctoPrint instance accessible over the internet,
|
||||||
|
**always enable Access Control**.
|
||||||
|
|
||||||
|
.. _sec-features-access_control-rerunning_wizard:
|
||||||
|
|
||||||
|
Rerunning the wizard
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
In case Access Control was disabled in the configuration wizard, it is
|
||||||
|
possibly to re-run it by editing ``config.yaml`` [#f1]_ and setting ``firstRun``
|
||||||
|
in the ``server`` section and ``enabled`` in the ``accessControl`` section to
|
||||||
|
``true``:
|
||||||
|
|
||||||
|
.. code-block-ext:: yaml
|
||||||
|
|
||||||
|
accessControl:
|
||||||
|
enabled: true
|
||||||
|
# ...
|
||||||
|
server:
|
||||||
|
firstRun: true
|
||||||
|
|
||||||
|
Then restart the server and connect to the web interface - the wizard should
|
||||||
|
be shown again.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
If user accounts were created prior to disabling Access Control and those
|
||||||
|
user accounts are not to be used any more, remove ``.octoprint/users.yaml``.
|
||||||
|
If you don't remove this file, the above changes won't lead to the
|
||||||
|
configuration being shown again, instead Access Control will just be
|
||||||
|
enabled using the already existing login data. This is to prevent you from
|
||||||
|
resetting access control by accident.
|
||||||
|
|
||||||
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
|
.. [#f1] For Linux that will be ``~/.octoprint/config.yaml``, for Windows it will be ``%APPDATA%/OctoPrint/config.yaml`` and for
|
||||||
|
Mac ``~/Library/Application Support/OctoPrint/config.yaml``
|
||||||
@@ -10,7 +10,7 @@ buttons which trigger sending of one or more lines of GCODE to the printer over
|
|||||||
parameterization of these commands with values entered by the user to full blown GCODE script templates backed by
|
parameterization of these commands with values entered by the user to full blown GCODE script templates backed by
|
||||||
`Jinja2 <http://jinja.pocoo.org/>`_.
|
`Jinja2 <http://jinja.pocoo.org/>`_.
|
||||||
|
|
||||||
Custom controls are configured within :ref:`config.yaml <sec-configuration-config_yaml>` in a ``controls`` section which
|
Custom controls are configured within :ref:`config.yaml <sec-configuration-config_yaml>` [#f1]_ in a ``controls`` section which
|
||||||
basically represents a hierarchical structure of all configured custom controls of various types.
|
basically represents a hierarchical structure of all configured custom controls of various types.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -94,6 +94,13 @@ button that sends one or more commands to the printer when clicked, displaying o
|
|||||||
controls that just serve as *container* for other controls, the latter being identified by having a ``children``
|
controls that just serve as *container* for other controls, the latter being identified by having a ``children``
|
||||||
attribute wrapping more controls.
|
attribute wrapping more controls.
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
|
||||||
|
Take a look at the `Custom Control Editor plugin <http://plugins.octoprint.org/plugins/customControl/>`_
|
||||||
|
which allows you configuring your Custom Controls through OctoPrint's
|
||||||
|
settings interface without the need to manually edit the configuration
|
||||||
|
file.
|
||||||
|
|
||||||
.. _sec-features-custom_controls-types:
|
.. _sec-features-custom_controls-types:
|
||||||
|
|
||||||
Types
|
Types
|
||||||
@@ -279,3 +286,8 @@ Parameterized GCODE Script
|
|||||||
|
|
||||||
Note the usage of the ``parameters.repetitions`` template variable in the GCODE script template, which will contain
|
Note the usage of the ``parameters.repetitions`` template variable in the GCODE script template, which will contain
|
||||||
the value selected by the user for the "Go arounds" slider.
|
the value selected by the user for the "Go arounds" slider.
|
||||||
|
|
||||||
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
|
.. [#f1] For Linux that will be ``~/.octoprint/config.yaml``, for Windows it will be ``%APPDATA%/OctoPrint/config.yaml`` and for
|
||||||
|
Mac ``~/Library/Application Support/OctoPrint/config.yaml``
|
||||||
@@ -7,6 +7,7 @@ Features
|
|||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
accesscontrol.rst
|
||||||
custom_controls.rst
|
custom_controls.rst
|
||||||
gcode_scripts.rst
|
gcode_scripts.rst
|
||||||
action_commands.rst
|
action_commands.rst
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ See :ref:`Developing Plugins <sec-plugins>`.
|
|||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
.. [#f1] For Linux that will be ``~/.octoprint/plugins``, for Windows it will be ``%APPDATA%/OctoPrint/plugins`` and for
|
.. [#f1] For Linux that will be ``~/.octoprint/plugins``, for Windows it will be ``%APPDATA%/OctoPrint/plugins`` and for
|
||||||
Mac ``~/Library/Application Support/OctoPrint``
|
Mac ``~/Library/Application Support/OctoPrint/plugins``
|
||||||
.. [#f2] Make sure to use the exact same Python installation for installing the plugin that you also used for
|
.. [#f2] Make sure to use the exact same Python installation for installing the plugin that you also used for
|
||||||
installing & running OctoPrint. For OctoPi this means using ``~/oprint/bin/pip`` for installing plugins
|
installing & running OctoPrint. For OctoPi this means using ``~/oprint/bin/pip`` for installing plugins
|
||||||
instead of just ``pip``.
|
instead of just ``pip``.
|
||||||
@@ -6,6 +6,10 @@ Welcome to OctoPrint's documentation!
|
|||||||
:alt: The OctoPrint Logo
|
:alt: The OctoPrint Logo
|
||||||
:align: right
|
:align: right
|
||||||
|
|
||||||
|
This documentation is still in the process of being migrated from
|
||||||
|
`OctoPrint's wiki <https://github.com/foosel/OctoPrint/wiki>`_, so also take
|
||||||
|
a look there!
|
||||||
|
|
||||||
Contents
|
Contents
|
||||||
========
|
========
|
||||||
|
|
||||||
|
|||||||
@@ -16,22 +16,23 @@ INSTALL_REQUIRES = [
|
|||||||
"flask>=0.9,<0.11",
|
"flask>=0.9,<0.11",
|
||||||
"werkzeug==0.8.3",
|
"werkzeug==0.8.3",
|
||||||
"tornado==4.0.1",
|
"tornado==4.0.1",
|
||||||
"sockjs-tornado>=1.0.0",
|
"sockjs-tornado==1.0.1",
|
||||||
"PyYAML==3.10",
|
"PyYAML==3.10",
|
||||||
"Flask-Login==0.2.2",
|
"Flask-Login==0.2.2",
|
||||||
"Flask-Principal==0.3.5",
|
"Flask-Principal==0.3.5",
|
||||||
"Flask-Babel==0.9",
|
"Flask-Babel==0.9",
|
||||||
"Flask-Assets==0.10",
|
"Flask-Assets==0.10",
|
||||||
"pyserial",
|
"pyserial==2.7",
|
||||||
"netaddr",
|
"netaddr==0.7.17",
|
||||||
"watchdog",
|
"watchdog==0.8.3",
|
||||||
"sarge>=0.1.4",
|
"sarge==0.1.4",
|
||||||
"netifaces",
|
"netifaces==0.8",
|
||||||
"pylru",
|
"pylru==1.0.9",
|
||||||
"rsa",
|
"rsa==3.2",
|
||||||
"pkginfo",
|
"pkginfo==1.2.1",
|
||||||
"requests",
|
"requests==2.7.0",
|
||||||
"semantic_version"
|
"semantic_version==2.4.2",
|
||||||
|
"psutil==3.1.1"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Additional requirements for optional install options
|
# Additional requirements for optional install options
|
||||||
|
|||||||
@@ -155,7 +155,11 @@ class FileManager(object):
|
|||||||
self._slicing_progress_callbacks.append(callback)
|
self._slicing_progress_callbacks.append(callback)
|
||||||
|
|
||||||
def unregister_slicingprogress_callback(self, callback):
|
def unregister_slicingprogress_callback(self, callback):
|
||||||
self._slicing_progress_callbacks.remove(callback)
|
try:
|
||||||
|
self._slicing_progress_callbacks.remove(callback)
|
||||||
|
except ValueError:
|
||||||
|
# callback was not registered
|
||||||
|
pass
|
||||||
|
|
||||||
def _determine_analysis_backlog(self, storage_type, storage_manager):
|
def _determine_analysis_backlog(self, storage_type, storage_manager):
|
||||||
counter = 0
|
counter = 0
|
||||||
@@ -314,7 +318,12 @@ class FileManager(object):
|
|||||||
printer_profile = self._printer_profile_manager.get_current_or_default()
|
printer_profile = self._printer_profile_manager.get_current_or_default()
|
||||||
|
|
||||||
for hook in self._preprocessor_hooks.values():
|
for hook in self._preprocessor_hooks.values():
|
||||||
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
try:
|
||||||
|
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error when calling preprocessor hook {}, ignoring".format(hook))
|
||||||
|
continue
|
||||||
|
|
||||||
if hook_file_object is not None:
|
if hook_file_object is not None:
|
||||||
file_object = hook_file_object
|
file_object = hook_file_object
|
||||||
file_path = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
file_path = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||||
|
|||||||
@@ -781,7 +781,10 @@ class SettingsPlugin(OctoPrintPlugin):
|
|||||||
|
|
||||||
:return: the current settings of the plugin, as a dictionary
|
:return: the current settings of the plugin, as a dictionary
|
||||||
"""
|
"""
|
||||||
return self._settings.get([], asdict=True, merged=True)
|
data = self._settings.get([], asdict=True, merged=True)
|
||||||
|
if "_config_version" in data:
|
||||||
|
del data["_config_version"]
|
||||||
|
return data
|
||||||
|
|
||||||
def on_settings_save(self, data):
|
def on_settings_save(self, data):
|
||||||
"""
|
"""
|
||||||
@@ -803,9 +806,12 @@ class SettingsPlugin(OctoPrintPlugin):
|
|||||||
"""
|
"""
|
||||||
import octoprint.util
|
import octoprint.util
|
||||||
|
|
||||||
|
if "_config_version" in data:
|
||||||
|
del data["_config_version"]
|
||||||
|
|
||||||
current = self._settings.get([], asdict=True, merged=True)
|
current = self._settings.get([], asdict=True, merged=True)
|
||||||
data = octoprint.util.dict_merge(current, data)
|
merged = octoprint.util.dict_merge(current, data)
|
||||||
self._settings.set([], data)
|
self._settings.set([], merged)
|
||||||
|
|
||||||
def get_settings_defaults(self):
|
def get_settings_defaults(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -35,6 +35,14 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
self._cancelled_jobs = []
|
self._cancelled_jobs = []
|
||||||
self._job_mutex = threading.Lock()
|
self._job_mutex = threading.Lock()
|
||||||
|
|
||||||
|
##~~ TemplatePlugin API
|
||||||
|
|
||||||
|
def get_template_configs(self):
|
||||||
|
from flask.ext.babel import gettext
|
||||||
|
return [
|
||||||
|
dict(type="settings", name=gettext("CuraEngine"))
|
||||||
|
]
|
||||||
|
|
||||||
##~~ StartupPlugin API
|
##~~ StartupPlugin API
|
||||||
|
|
||||||
def on_startup(self, host, port):
|
def on_startup(self, host, port):
|
||||||
@@ -218,7 +226,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
if not on_progress_kwargs:
|
if not on_progress_kwargs:
|
||||||
on_progress_kwargs = dict()
|
on_progress_kwargs = dict()
|
||||||
|
|
||||||
self._cura_logger.info("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
self._cura_logger.info(u"### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||||
|
|
||||||
engine_settings = self._convert_to_engine(profile_path, printer_profile, posX, posY)
|
engine_settings = self._convert_to_engine(profile_path, printer_profile, posX, posY)
|
||||||
|
|
||||||
@@ -227,16 +235,15 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
return False, "Path to CuraEngine is not configured "
|
return False, "Path to CuraEngine is not configured "
|
||||||
|
|
||||||
working_dir, _ = os.path.split(executable)
|
working_dir, _ = os.path.split(executable)
|
||||||
args = ['"%s"' % executable, '-v', '-p']
|
args = [executable, '-v', '-p']
|
||||||
for k, v in engine_settings.items():
|
for k, v in engine_settings.items():
|
||||||
args += ["-s", '"%s=%s"' % (k, str(v))]
|
args += ["-s", "%s=%s" % (k, str(v))]
|
||||||
args += ['-o', '"%s"' % machinecode_path, '"%s"' % model_path]
|
args += ["-o", machinecode_path, model_path]
|
||||||
|
|
||||||
|
self._logger.info(u"Running %r in %s" % (" ".join(args), working_dir))
|
||||||
|
|
||||||
import sarge
|
import sarge
|
||||||
command = " ".join(args)
|
p = sarge.run(args, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
|
||||||
self._logger.info("Running %r in %s" % (command, working_dir))
|
|
||||||
|
|
||||||
p = sarge.run(command, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
|
|
||||||
p.wait_events()
|
p.wait_events()
|
||||||
self._slicing_commands[machinecode_path] = p.commands[0]
|
self._slicing_commands[machinecode_path] = p.commands[0]
|
||||||
|
|
||||||
@@ -254,6 +261,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
p.commands[0].poll()
|
p.commands[0].poll()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
line = octoprint.util.to_unicode(line, errors="replace")
|
||||||
self._cura_logger.debug(line.strip())
|
self._cura_logger.debug(line.strip())
|
||||||
|
|
||||||
if on_progress is not None:
|
if on_progress is not None:
|
||||||
@@ -282,14 +290,14 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
#
|
#
|
||||||
# with <step_factor> being 0 for "inset", 1 for "skin" and 2 for "export".
|
# with <step_factor> being 0 for "inset", 1 for "skin" and 2 for "export".
|
||||||
|
|
||||||
if line.startswith("Layer count:") and layer_count is None:
|
if line.startswith(u"Layer count:") and layer_count is None:
|
||||||
try:
|
try:
|
||||||
layer_count = float(line[len("Layer count:"):].strip())
|
layer_count = float(line[len(u"Layer count:"):].strip())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif line.startswith("Progress:"):
|
elif line.startswith(u"Progress:"):
|
||||||
split_line = line[len("Progress:"):].strip().split(":")
|
split_line = line[len(u"Progress:"):].strip().split(":")
|
||||||
if len(split_line) == 3:
|
if len(split_line) == 3:
|
||||||
step, current_layer, _ = split_line
|
step, current_layer, _ = split_line
|
||||||
try:
|
try:
|
||||||
@@ -302,21 +310,21 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
on_progress_kwargs["_progress"] = (step_factor[step] * layer_count + current_layer) / (layer_count * 3)
|
on_progress_kwargs["_progress"] = (step_factor[step] * layer_count + current_layer) / (layer_count * 3)
|
||||||
on_progress(*on_progress_args, **on_progress_kwargs)
|
on_progress(*on_progress_args, **on_progress_kwargs)
|
||||||
|
|
||||||
elif line.startswith("Print time:"):
|
elif line.startswith(u"Print time:"):
|
||||||
try:
|
try:
|
||||||
print_time = int(line[len("Print time:"):].strip())
|
print_time = int(line[len(u"Print time:"):].strip())
|
||||||
if analysis is None:
|
if analysis is None:
|
||||||
analysis = dict()
|
analysis = dict()
|
||||||
analysis["estimatedPrintTime"] = print_time
|
analysis["estimatedPrintTime"] = print_time
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif line.startswith("Filament:") or line.startswith("Filament2:"):
|
elif line.startswith(u"Filament:") or line.startswith(u"Filament2:"):
|
||||||
if line.startswith("Filament:"):
|
if line.startswith(u"Filament:"):
|
||||||
filament_str = line[len("Filament:"):].strip()
|
filament_str = line[len(u"Filament:"):].strip()
|
||||||
tool_key = "tool0"
|
tool_key = "tool0"
|
||||||
else:
|
else:
|
||||||
filament_str = line[len("Filament2:"):].strip()
|
filament_str = line[len(u"Filament2:"):].strip()
|
||||||
tool_key = "tool1"
|
tool_key = "tool1"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -339,20 +347,20 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
|
|
||||||
with self._job_mutex:
|
with self._job_mutex:
|
||||||
if machinecode_path in self._cancelled_jobs:
|
if machinecode_path in self._cancelled_jobs:
|
||||||
self._cura_logger.info("### Cancelled")
|
self._cura_logger.info(u"### Cancelled")
|
||||||
raise octoprint.slicing.SlicingCancelled()
|
raise octoprint.slicing.SlicingCancelled()
|
||||||
|
|
||||||
self._cura_logger.info("### Finished, returncode %d" % p.returncode)
|
self._cura_logger.info(u"### Finished, returncode %d" % p.returncode)
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
return True, dict(analysis=analysis)
|
return True, dict(analysis=analysis)
|
||||||
else:
|
else:
|
||||||
self._logger.warn("Could not slice via Cura, got return code %r" % p.returncode)
|
self._logger.warn(u"Could not slice via Cura, got return code %r" % p.returncode)
|
||||||
return False, "Got returncode %r" % p.returncode
|
return False, "Got returncode %r" % p.returncode
|
||||||
|
|
||||||
except octoprint.slicing.SlicingCancelled as e:
|
except octoprint.slicing.SlicingCancelled as e:
|
||||||
raise e
|
raise e
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Could not slice via Cura, got an unknown error")
|
self._logger.exception(u"Could not slice via Cura, got an unknown error")
|
||||||
return False, "Unknown error, please consult the log file"
|
return False, "Unknown error, please consult the log file"
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
@@ -371,7 +379,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||||||
command = self._slicing_commands[machinecode_path]
|
command = self._slicing_commands[machinecode_path]
|
||||||
if command is not None:
|
if command is not None:
|
||||||
command.terminate()
|
command.terminate()
|
||||||
self._logger.info("Cancelled slicing of %s" % machinecode_path)
|
self._logger.info(u"Cancelled slicing of %s" % machinecode_path)
|
||||||
|
|
||||||
def _load_profile(self, path):
|
def _load_profile(self, path):
|
||||||
import yaml
|
import yaml
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
self._pending_uninstall = set()
|
self._pending_uninstall = set()
|
||||||
|
|
||||||
self._pip_caller = None
|
self._pip_caller = None
|
||||||
|
self._pip_version_dependency_links = pkg_resources.parse_version("1.5")
|
||||||
|
|
||||||
self._repository_available = False
|
self._repository_available = False
|
||||||
self._repository_plugins = []
|
self._repository_plugins = []
|
||||||
@@ -80,7 +81,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
return dict(
|
return dict(
|
||||||
repository="http://plugins.octoprint.org/plugins.json",
|
repository="http://plugins.octoprint.org/plugins.json",
|
||||||
repository_ttl=24*60,
|
repository_ttl=24*60,
|
||||||
pip=None
|
pip=None,
|
||||||
|
dependency_links=False,
|
||||||
|
hidden=[]
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_settings_save(self, data):
|
def on_settings_save(self, data):
|
||||||
@@ -181,6 +184,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
plugin_name = data["plugin"] if "plugin" in data else None
|
plugin_name = data["plugin"] if "plugin" in data else None
|
||||||
return self.command_install(url=url,
|
return self.command_install(url=url,
|
||||||
force="force" in data and data["force"] in valid_boolean_trues,
|
force="force" in data and data["force"] in valid_boolean_trues,
|
||||||
|
dependency_links="dependency_links" in data and data["dependency_links"] in valid_boolean_trues,
|
||||||
reinstall=plugin_name)
|
reinstall=plugin_name)
|
||||||
|
|
||||||
elif command == "uninstall":
|
elif command == "uninstall":
|
||||||
@@ -199,7 +203,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
plugin = self._plugin_manager.plugins[plugin_name]
|
plugin = self._plugin_manager.plugins[plugin_name]
|
||||||
return self.command_toggle(plugin, command)
|
return self.command_toggle(plugin, command)
|
||||||
|
|
||||||
def command_install(self, url=None, path=None, force=False, reinstall=None):
|
def command_install(self, url=None, path=None, force=False, reinstall=None, dependency_links=False):
|
||||||
if url is not None:
|
if url is not None:
|
||||||
pip_args = ["install", sarge.shell_quote(url)]
|
pip_args = ["install", sarge.shell_quote(url)]
|
||||||
elif path is not None:
|
elif path is not None:
|
||||||
@@ -207,6 +211,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Either url or path must be provided")
|
raise ValueError("Either url or path must be provided")
|
||||||
|
|
||||||
|
if dependency_links or self._settings.get_boolean(["dependency_links"]):
|
||||||
|
pip_args.append("--process-dependency-links")
|
||||||
|
|
||||||
all_plugins_before = self._plugin_manager.find_plugins()
|
all_plugins_before = self._plugin_manager.find_plugins()
|
||||||
|
|
||||||
success_string = "Successfully installed"
|
success_string = "Successfully installed"
|
||||||
@@ -415,16 +422,25 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
def _call_pip(self, args):
|
def _call_pip(self, args):
|
||||||
if self._pip_caller is None or not self._pip_caller.available:
|
if self._pip_caller is None or not self._pip_caller.available:
|
||||||
raise RuntimeError(u"No pip available, can't operate".format(**locals()))
|
raise RuntimeError(u"No pip available, can't operate".format(**locals()))
|
||||||
|
|
||||||
|
if "--process-dependency-links" in args:
|
||||||
|
self._log_message(u"Installation needs to process external dependencies, that might make it take a bit longer than usual depending on the pip version")
|
||||||
|
if self._pip_caller < self._pip_version_dependency_links:
|
||||||
|
args.remove("--process-dependency-links")
|
||||||
|
|
||||||
return self._pip_caller.execute(*args)
|
return self._pip_caller.execute(*args)
|
||||||
|
|
||||||
|
def _log_message(self, *lines):
|
||||||
|
self._log(lines, prefix=u"*", stream="message")
|
||||||
|
|
||||||
def _log_call(self, *lines):
|
def _log_call(self, *lines):
|
||||||
self._log(lines, prefix=" ", stream="call")
|
self._log(lines, prefix=u" ", stream="call")
|
||||||
|
|
||||||
def _log_stdout(self, *lines):
|
def _log_stdout(self, *lines):
|
||||||
self._log(lines, prefix=">", stream="stdout")
|
self._log(lines, prefix=u">", stream="stdout")
|
||||||
|
|
||||||
def _log_stderr(self, *lines):
|
def _log_stderr(self, *lines):
|
||||||
self._log(lines, prefix="!", stream="stderr")
|
self._log(lines, prefix=u"!", stream="stderr")
|
||||||
|
|
||||||
def _log(self, lines, prefix=None, stream=None, strip=True):
|
def _log(self, lines, prefix=None, stream=None, strip=True):
|
||||||
if strip:
|
if strip:
|
||||||
@@ -515,6 +531,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||||||
def map_repository_entry(entry):
|
def map_repository_entry(entry):
|
||||||
result = dict(entry)
|
result = dict(entry)
|
||||||
|
|
||||||
|
if not "follow_dependency_links" in result:
|
||||||
|
result["follow_dependency_links"] = False
|
||||||
|
|
||||||
result["is_compatible"] = dict(
|
result["is_compatible"] = dict(
|
||||||
octoprint=True,
|
octoprint=True,
|
||||||
os=True
|
os=True
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ $(function() {
|
|||||||
self.loglines = ko.observableArray([]);
|
self.loglines = ko.observableArray([]);
|
||||||
self.installedPlugins = ko.observableArray([]);
|
self.installedPlugins = ko.observableArray([]);
|
||||||
|
|
||||||
|
self.followDependencyLinks = ko.observable(false);
|
||||||
|
|
||||||
self.working = ko.observable(false);
|
self.working = ko.observable(false);
|
||||||
self.workingTitle = ko.observable();
|
self.workingTitle = ko.observable();
|
||||||
self.workingDialog = undefined;
|
self.workingDialog = undefined;
|
||||||
@@ -125,6 +127,9 @@ $(function() {
|
|||||||
self.uploadButton.unbind("click");
|
self.uploadButton.unbind("click");
|
||||||
self.uploadButton.bind("click", function() {
|
self.uploadButton.bind("click", function() {
|
||||||
self._markWorking(gettext("Installing plugin..."), gettext("Installing plugin from uploaded archive..."));
|
self._markWorking(gettext("Installing plugin..."), gettext("Installing plugin from uploaded archive..."));
|
||||||
|
data.formData = {
|
||||||
|
dependency_links: self.followDependencyLinks()
|
||||||
|
};
|
||||||
data.submit();
|
data.submit();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -147,19 +152,17 @@ $(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
self.performRepositorySearch = function(e) {
|
self.performRepositorySearch = function() {
|
||||||
if (e !== undefined) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
var query = self.repositorySearchQuery();
|
var query = self.repositorySearchQuery();
|
||||||
if (query !== undefined && query.trim() != "") {
|
if (query !== undefined && query.trim() != "") {
|
||||||
|
query = query.toLocaleLowerCase();
|
||||||
self.repositoryplugins.changeSearchFunction(function(entry) {
|
self.repositoryplugins.changeSearchFunction(function(entry) {
|
||||||
return entry && (entry["title"].toLocaleLowerCase().indexOf(query) > -1 || entry["description"].toLocaleLowerCase().indexOf(query) > -1);
|
return entry && (entry["title"].toLocaleLowerCase().indexOf(query) > -1 || entry["description"].toLocaleLowerCase().indexOf(query) > -1);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.repositoryplugins.resetSearch();
|
self.repositoryplugins.resetSearch();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.fromResponse = function(data) {
|
self.fromResponse = function(data) {
|
||||||
@@ -242,13 +245,13 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self.installed(data)) {
|
if (self.installed(data)) {
|
||||||
self.installPlugin(data.archive, data.title, data.id);
|
self.installPlugin(data.archive, data.title, data.id, data.follow_dependency_links || self.followDependencyLinks());
|
||||||
} else {
|
} else {
|
||||||
self.installPlugin(data.archive, data.title, undefined);
|
self.installPlugin(data.archive, data.title, undefined, data.follow_dependency_links || self.followDependencyLinks());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.installPlugin = function(url, name, reinstall) {
|
self.installPlugin = function(url, name, reinstall, followDependencyLinks) {
|
||||||
if (!self.loginState.isAdmin()) {
|
if (!self.loginState.isAdmin()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -262,6 +265,10 @@ $(function() {
|
|||||||
}
|
}
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
|
if (followDependencyLinks === undefined) {
|
||||||
|
followDependencyLinks = self.followDependencyLinks();
|
||||||
|
}
|
||||||
|
|
||||||
var workTitle, workText;
|
var workTitle, workText;
|
||||||
if (!reinstall) {
|
if (!reinstall) {
|
||||||
workTitle = gettext("Installing plugin...");
|
workTitle = gettext("Installing plugin...");
|
||||||
@@ -277,7 +284,7 @@ $(function() {
|
|||||||
self._markWorking(workTitle, workText);
|
self._markWorking(workTitle, workText);
|
||||||
|
|
||||||
var command = "install";
|
var command = "install";
|
||||||
var payload = {url: url};
|
var payload = {url: url, dependency_links: followDependencyLinks};
|
||||||
if (reinstall) {
|
if (reinstall) {
|
||||||
payload["plugin"] = reinstall;
|
payload["plugin"] = reinstall;
|
||||||
payload["force"] = true;
|
payload["force"] = true;
|
||||||
|
|||||||
@@ -147,6 +147,21 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="help-block" data-bind="visible: invalidArchive">{{ _('This does not look like a valid plugin archive. Valid plugin archives should be either zip files or tarballs and have the extension ".zip", ".tar.gz", ".tgz" or ".tar"') }}</span>
|
<span class="help-block" data-bind="visible: invalidArchive">{{ _('This does not look like a valid plugin archive. Valid plugin archives should be either zip files or tarballs and have the extension ".zip", ".tar.gz", ".tgz" or ".tar"') }}</span>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||||
|
<div class="hide">
|
||||||
|
<form class="form-horizontal">
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: followDependencyLinks"> {{ _('Use <code>--process-dependency-links</code> with <code>pip install</code>') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import flask
|
|||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from . import version_checks, updaters, exceptions, util
|
from . import version_checks, updaters, exceptions, util
|
||||||
|
|
||||||
@@ -82,29 +83,42 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
except:
|
except:
|
||||||
self._logger.exception("Error while loading version cache from disk")
|
self._logger.exception("Error while loading version cache from disk")
|
||||||
else:
|
else:
|
||||||
self._version_cache = data
|
try:
|
||||||
self._version_cache_dirty = False
|
if not isinstance(data, dict):
|
||||||
self._logger.info("Loaded version cache from disk")
|
self._logger.info("Version cache was created in a different format, not using it")
|
||||||
|
return
|
||||||
|
|
||||||
|
if "__version" in data:
|
||||||
|
data_version = data["__version"]
|
||||||
|
else:
|
||||||
|
self._logger.info("Can't determine version of OctoPrint version cache was created for, not using it")
|
||||||
|
return
|
||||||
|
|
||||||
|
from octoprint._version import get_versions
|
||||||
|
octoprint_version = get_versions()["version"]
|
||||||
|
if data_version != octoprint_version:
|
||||||
|
self._logger.info("Version cache was created for another version of OctoPrint, not using it")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._version_cache = data
|
||||||
|
self._version_cache_dirty = False
|
||||||
|
self._logger.info("Loaded version cache from disk")
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error parsing in version cache data")
|
||||||
|
|
||||||
def _save_version_cache(self):
|
def _save_version_cache(self):
|
||||||
import tempfile
|
|
||||||
import yaml
|
import yaml
|
||||||
import shutil
|
from octoprint.util import atomic_write
|
||||||
|
from octoprint._version import get_versions
|
||||||
|
|
||||||
file_obj = tempfile.NamedTemporaryFile(delete=False)
|
octoprint_version = get_versions()["version"]
|
||||||
try:
|
self._version_cache["__version"] = octoprint_version
|
||||||
|
|
||||||
|
with atomic_write(self._version_cache_path) as file_obj:
|
||||||
yaml.safe_dump(self._version_cache, stream=file_obj, default_flow_style=False, indent=" ", allow_unicode=True)
|
yaml.safe_dump(self._version_cache, stream=file_obj, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||||
file_obj.close()
|
|
||||||
shutil.move(file_obj.name, self._version_cache_path)
|
|
||||||
|
|
||||||
self._version_cache_dirty = False
|
self._version_cache_dirty = False
|
||||||
self._logger.info("Saved version cache to disk")
|
self._logger.info("Saved version cache to disk")
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
if os.path.exists(file_obj.name):
|
|
||||||
os.remove(file_obj.name)
|
|
||||||
except Exception as e:
|
|
||||||
self._logger.warn("Could not delete file {}: {}".format(file_obj.name, str(e)))
|
|
||||||
|
|
||||||
#~~ SettingsPlugin API
|
#~~ SettingsPlugin API
|
||||||
|
|
||||||
@@ -119,39 +133,117 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
"restart": "octoprint"
|
"restart": "octoprint"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
"octoprint_restart_command": None,
|
|
||||||
"environment_restart_command": None,
|
|
||||||
"pip_command": None,
|
"pip_command": None,
|
||||||
|
|
||||||
"cache_ttl": 24 * 60,
|
"cache_ttl": 24 * 60,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def on_settings_load(self):
|
||||||
|
data = dict(octoprint.plugin.SettingsPlugin.on_settings_load(self))
|
||||||
|
if "checks" in data:
|
||||||
|
del data["checks"]
|
||||||
|
|
||||||
|
checks = self._get_configured_checks()
|
||||||
|
if "octoprint" in checks:
|
||||||
|
if "checkout_folder" in checks["octoprint"]:
|
||||||
|
data["octoprint_checkout_folder"] = checks["octoprint"]["checkout_folder"]
|
||||||
|
elif "update_folder" in checks["octoprint"]:
|
||||||
|
data["octoprint_checkout_folder"] = checks["octoprint"]["update_folder"]
|
||||||
|
else:
|
||||||
|
data["octoprint_checkout_folder"] = None
|
||||||
|
data["octoprint_type"] = checks["octoprint"].get("type", None)
|
||||||
|
else:
|
||||||
|
data["octoprint_checkout_folder"] = None
|
||||||
|
data["octoprint_type"] = None
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
def on_settings_save(self, data):
|
def on_settings_save(self, data):
|
||||||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
for key in self.get_settings_defaults():
|
||||||
|
if key == "checks" or key == "cache_ttl" or key == "octoprint_checkout_folder" or key == "octoprint_type":
|
||||||
|
continue
|
||||||
|
if key in data:
|
||||||
|
self._settings.set([key], data[key])
|
||||||
|
|
||||||
|
if "cache_ttl" in data:
|
||||||
|
self._settings.set_int(["cache_ttl"], data["cache_ttl"])
|
||||||
self._version_cache_ttl = self._settings.get_int(["cache_ttl"]) * 60
|
self._version_cache_ttl = self._settings.get_int(["cache_ttl"]) * 60
|
||||||
|
|
||||||
|
checks = self._get_configured_checks()
|
||||||
|
if "octoprint" in checks:
|
||||||
|
check = checks["octoprint"]
|
||||||
|
update_type = check.get("type", None)
|
||||||
|
checkout_folder = check.get("checkout_folder", None)
|
||||||
|
update_folder = check.get("update_folder", None)
|
||||||
|
|
||||||
|
defaults = dict(
|
||||||
|
plugins=dict(softwareupdate=dict(
|
||||||
|
checks=dict(
|
||||||
|
octoprint=dict(
|
||||||
|
type=update_type,
|
||||||
|
checkout_folder=checkout_folder,
|
||||||
|
update_folder=update_folder
|
||||||
|
)
|
||||||
|
)
|
||||||
|
))
|
||||||
|
)
|
||||||
|
|
||||||
|
if "octoprint_checkout_folder" in data:
|
||||||
|
self._settings.set(["checks", "octoprint", "checkout_folder"], data["octoprint_checkout_folder"], defaults=defaults, force=True)
|
||||||
|
if update_folder and data["octoprint_checkout_folder"]:
|
||||||
|
self._settings.set(["checks", "octoprint", "update_folder"], None, defaults=defaults, force=True)
|
||||||
|
self._refresh_configured_checks = True
|
||||||
|
|
||||||
|
if "octoprint_type" in data and data["octoprint_type"] in ("github_release", "git_commit"):
|
||||||
|
self._settings.set(["checks", "octoprint", "type"], data["octoprint_type"], defaults=defaults, force=True)
|
||||||
|
self._refresh_configured_checks = True
|
||||||
|
|
||||||
def get_settings_version(self):
|
def get_settings_version(self):
|
||||||
return 2
|
return 4
|
||||||
|
|
||||||
def on_settings_migrate(self, target, current=None):
|
def on_settings_migrate(self, target, current=None):
|
||||||
if current is None:
|
|
||||||
# there might be some left over data from the time we still persisted everything to settings,
|
if current is None or current < 4:
|
||||||
# even the stuff that shouldn't be persisted but always provided by the hook - let's
|
# config version 4 and higher moves octoprint_restart_command and
|
||||||
# clean up
|
# environment_restart_command to the core configuration
|
||||||
|
|
||||||
|
# current plugin commands
|
||||||
|
configured_octoprint_restart_command = self._settings.get(["octoprint_restart_command"])
|
||||||
|
configured_environment_restart_command = self._settings.get(["environment_restart_command"])
|
||||||
|
|
||||||
|
# current global commands
|
||||||
|
configured_system_restart_command = self._settings.global_get(["server", "commands", "systemRestartCommand"])
|
||||||
|
configured_server_restart_command = self._settings.global_get(["server", "commands", "serverRestartCommand"])
|
||||||
|
|
||||||
|
# only set global commands if they are not yet set
|
||||||
|
if configured_system_restart_command is None and configured_environment_restart_command is not None:
|
||||||
|
self._settings.global_set(["server", "commands", "systemRestartCommand"], configured_environment_restart_command)
|
||||||
|
if configured_server_restart_command is None and configured_octoprint_restart_command is not None:
|
||||||
|
self._settings.global_set(["server", "commands", "serverRestartCommand"], configured_octoprint_restart_command)
|
||||||
|
|
||||||
|
# delete current plugin commands from config
|
||||||
|
self._settings.set(["environment_restart_command"], None)
|
||||||
|
self._settings.set(["octoprint_restart_command"], None)
|
||||||
|
|
||||||
|
if current is None or current == 2:
|
||||||
|
# No config version and config version 2 need the same fix, stripping
|
||||||
|
# accidentally persisted data off the checks
|
||||||
|
|
||||||
configured_checks = self._settings.get(["checks"], incl_defaults=False)
|
configured_checks = self._settings.get(["checks"], incl_defaults=False)
|
||||||
if configured_checks is None:
|
if configured_checks is None:
|
||||||
configured_checks = dict()
|
configured_checks = dict()
|
||||||
|
|
||||||
|
check_keys = configured_checks.keys()
|
||||||
|
|
||||||
# take care of the octoprint entry
|
# take care of the octoprint entry
|
||||||
if "octoprint" in configured_checks:
|
if "octoprint" in configured_checks:
|
||||||
octoprint_check = dict(configured_checks["octoprint"])
|
octoprint_check = dict(configured_checks["octoprint"])
|
||||||
if "type" in octoprint_check and not octoprint_check["type"] == "github_commit":
|
if "type" not in octoprint_check or octoprint_check["type"] != "github_commit":
|
||||||
deletables=["current"]
|
deletables=["current", "displayName", "displayVersion"]
|
||||||
else:
|
else:
|
||||||
deletables=[]
|
deletables=[]
|
||||||
octoprint_check = self._clean_settings_check("octoprint", octoprint_check, self.get_settings_defaults()["checks"]["octoprint"], delete=deletables, save=False)
|
octoprint_check = self._clean_settings_check("octoprint", octoprint_check, self.get_settings_defaults()["checks"]["octoprint"], delete=deletables, save=False)
|
||||||
|
check_keys.remove("octoprint")
|
||||||
|
|
||||||
# and the hooks
|
# and the hooks
|
||||||
update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config")
|
update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config")
|
||||||
@@ -165,14 +257,26 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
if key in configured_checks:
|
if key in configured_checks:
|
||||||
settings_check = dict(configured_checks[key])
|
settings_check = dict(configured_checks[key])
|
||||||
merged = dict_merge(data, settings_check)
|
merged = dict_merge(data, settings_check)
|
||||||
if "type" in merged and not merged["type"] == "github_commit":
|
if "type" not in merged or merged["type"] != "github_commit":
|
||||||
deletables = ["current", "displayVersion"]
|
deletables = ["current", "displayVersion"]
|
||||||
else:
|
else:
|
||||||
deletables = []
|
deletables = []
|
||||||
|
|
||||||
self._clean_settings_check(key, settings_check, data, delete=deletables, save=False)
|
self._clean_settings_check(key, settings_check, data, delete=deletables, save=False)
|
||||||
|
check_keys.remove(key)
|
||||||
|
|
||||||
|
# and anything that's left over we'll just remove now
|
||||||
|
for key in check_keys:
|
||||||
|
dummy_defaults = dict(plugins=dict())
|
||||||
|
dummy_defaults["plugins"][self._identifier] = dict(checks=dict())
|
||||||
|
dummy_defaults["plugins"][self._identifier]["checks"][key] = None
|
||||||
|
self._settings.set(["checks", key], None, defaults=dummy_defaults)
|
||||||
|
|
||||||
elif current == 1:
|
elif current == 1:
|
||||||
|
# config version 1 had the error that the octoprint check got accidentally
|
||||||
|
# included in checks["octoprint"], leading to recursion and hence to
|
||||||
|
# yaml parser errors
|
||||||
|
|
||||||
configured_checks = self._settings.get(["checks"], incl_defaults=False)
|
configured_checks = self._settings.get(["checks"], incl_defaults=False)
|
||||||
if configured_checks is None:
|
if configured_checks is None:
|
||||||
return
|
return
|
||||||
@@ -183,7 +287,6 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
dummy_defaults["plugins"][self._identifier] = dict(checks=dict())
|
dummy_defaults["plugins"][self._identifier] = dict(checks=dict())
|
||||||
dummy_defaults["plugins"][self._identifier]["checks"]["octoprint"] = None
|
dummy_defaults["plugins"][self._identifier]["checks"]["octoprint"] = None
|
||||||
self._settings.set(["checks", "octoprint"], None, defaults=dummy_defaults)
|
self._settings.set(["checks", "octoprint"], None, defaults=dummy_defaults)
|
||||||
self._settings.save()
|
|
||||||
|
|
||||||
def _clean_settings_check(self, key, data, defaults, delete=None, save=True):
|
def _clean_settings_check(self, key, data, defaults, delete=None, save=True):
|
||||||
if delete is None:
|
if delete is None:
|
||||||
@@ -270,8 +373,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
##~~ TemplatePlugin API
|
##~~ TemplatePlugin API
|
||||||
|
|
||||||
def get_template_configs(self):
|
def get_template_configs(self):
|
||||||
|
from flask.ext.babel import gettext
|
||||||
return [
|
return [
|
||||||
dict(type="settings", name="Software Update")
|
dict(type="settings", name=gettext("Software Update"))
|
||||||
]
|
]
|
||||||
|
|
||||||
#~~ Updater
|
#~~ Updater
|
||||||
@@ -296,10 +400,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
if not target in check_targets:
|
if not target in check_targets:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
populated_check = self._populated_check(target, check)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
target_information, target_update_available, target_update_possible = self._get_current_version(target, check, force=force)
|
target_information, target_update_available, target_update_possible = self._get_current_version(target, populated_check, force=force)
|
||||||
if target_information is None:
|
if target_information is None:
|
||||||
continue
|
target_information = dict()
|
||||||
except exceptions.UnknownCheckType:
|
except exceptions.UnknownCheckType:
|
||||||
self._logger.warn("Unknown update check type for %s" % target)
|
self._logger.warn("Unknown update check type for %s" % target)
|
||||||
continue
|
continue
|
||||||
@@ -308,32 +414,39 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
|
|
||||||
update_available = update_available or target_update_available
|
update_available = update_available or target_update_available
|
||||||
update_possible = update_possible or (target_update_possible and target_update_available)
|
update_possible = update_possible or (target_update_possible and target_update_available)
|
||||||
information[target] = dict(updateAvailable=target_update_available, updatePossible=target_update_possible, information=target_information)
|
|
||||||
|
|
||||||
if "displayName" in check:
|
from octoprint._version import get_versions
|
||||||
information[target]["displayName"] = check["displayName"]
|
octoprint_version = get_versions()["version"]
|
||||||
|
local_name = target_information["local"]["name"]
|
||||||
|
local_value = target_information["local"]["value"]
|
||||||
|
|
||||||
if "displayVersion" in check:
|
information[target] = dict(updateAvailable=target_update_available,
|
||||||
from octoprint._version import get_versions
|
updatePossible=target_update_possible,
|
||||||
octoprint_version = get_versions()["version"]
|
information=target_information,
|
||||||
local_name = target_information["local"]["name"]
|
displayName=populated_check["displayName"],
|
||||||
local_value = target_information["local"]["value"]
|
displayVersion=populated_check["displayVersion"].format(octoprint_version=octoprint_version, local_name=local_name, local_value=local_value),
|
||||||
information[target]["displayVersion"] = check["displayVersion"].format(octoprint_version=octoprint_version, local_name=local_name, local_value=local_value)
|
check=populated_check)
|
||||||
|
|
||||||
if self._version_cache_dirty:
|
if self._version_cache_dirty:
|
||||||
self._save_version_cache()
|
self._save_version_cache()
|
||||||
return information, update_available, update_possible
|
return information, update_available, update_possible
|
||||||
|
|
||||||
|
def _get_check_hash(self, check):
|
||||||
|
hash = hashlib.md5()
|
||||||
|
hash.update(repr(check))
|
||||||
|
return hash.hexdigest()
|
||||||
|
|
||||||
def _get_current_version(self, target, check, force=False):
|
def _get_current_version(self, target, check, force=False):
|
||||||
"""
|
"""
|
||||||
Determines the current version information for one target based on its check configuration.
|
Determines the current version information for one target based on its check configuration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
current_hash = self._get_check_hash(check)
|
||||||
if target in self._version_cache and not force:
|
if target in self._version_cache and not force:
|
||||||
timestamp, information, update_available, update_possible = self._version_cache[target]
|
data = self._version_cache[target]
|
||||||
if timestamp + self._version_cache_ttl >= time.time() > timestamp:
|
if data["hash"] == current_hash and data["timestamp"] + self._version_cache_ttl >= time.time() > data["timestamp"]:
|
||||||
# we also check that timestamp < now to not get confused too much by clock changes
|
# we also check that timestamp < now to not get confused too much by clock changes
|
||||||
return information, update_available, update_possible
|
return data["information"], data["available"], data["possible"]
|
||||||
|
|
||||||
information = dict()
|
information = dict()
|
||||||
update_available = False
|
update_available = False
|
||||||
@@ -356,7 +469,11 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
except:
|
except:
|
||||||
update_possible = False
|
update_possible = False
|
||||||
|
|
||||||
self._version_cache[target] = (time.time(), information, update_available, update_possible)
|
self._version_cache[target] = dict(timestamp=time.time(),
|
||||||
|
hash=current_hash,
|
||||||
|
information=information,
|
||||||
|
available=update_available,
|
||||||
|
possible=update_possible)
|
||||||
self._version_cache_dirty = True
|
self._version_cache_dirty = True
|
||||||
return information, update_available, update_possible
|
return information, update_available, update_possible
|
||||||
|
|
||||||
@@ -440,7 +557,11 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
if restart_type is not None and restart_type in ("octoprint", "environment"):
|
if restart_type is not None and restart_type in ("octoprint", "environment"):
|
||||||
# one of our updates requires a restart of either type "octoprint" or "environment". Let's see if
|
# one of our updates requires a restart of either type "octoprint" or "environment". Let's see if
|
||||||
# we can actually perform that
|
# we can actually perform that
|
||||||
restart_command = self._settings.get(["%s_restart_command" % restart_type])
|
|
||||||
|
if restart_type == "octoprint":
|
||||||
|
restart_command = self._settings.global_get(["server", "commands", "serverRestartCommand"])
|
||||||
|
elif restart_type == "environment":
|
||||||
|
restart_command = self._settings.global_get(["server", "commands", "systemRestartCommand"])
|
||||||
|
|
||||||
if restart_command is not None:
|
if restart_command is not None:
|
||||||
self._send_client_message("restarting", dict(restart_type=restart_type, results=target_results))
|
self._send_client_message("restarting", dict(restart_type=restart_type, results=target_results))
|
||||||
@@ -533,6 +654,30 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||||||
self._logger.warn("Restart stderr:\n%s" % e.stderr)
|
self._logger.warn("Restart stderr:\n%s" % e.stderr)
|
||||||
raise exceptions.RestartFailed()
|
raise exceptions.RestartFailed()
|
||||||
|
|
||||||
|
def _populated_check(self, target, check):
|
||||||
|
result = dict(check)
|
||||||
|
|
||||||
|
if target == "octoprint":
|
||||||
|
from flask.ext.babel import gettext
|
||||||
|
result["displayName"] = check.get("displayName", gettext("OctoPrint"))
|
||||||
|
result["displayVersion"] = check.get("displayVersion", "{octoprint_version}")
|
||||||
|
|
||||||
|
from octoprint._version import get_versions
|
||||||
|
versions = get_versions()
|
||||||
|
if check["type"] == "github_commit":
|
||||||
|
result["current"] = versions.get("full-revisionid", versions.get("full", "unknown"))
|
||||||
|
else:
|
||||||
|
result["current"] = versions["version"]
|
||||||
|
else:
|
||||||
|
result["displayName"] = check.get("displayName", target)
|
||||||
|
result["displayVersion"] = check.get("displayVersion", check.get("current", "unknown"))
|
||||||
|
if check["type"] in ("github_commit"):
|
||||||
|
result["current"] = check.get("current", None)
|
||||||
|
else:
|
||||||
|
result["current"] = check.get("current", check.get("displayVersion", None))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def _get_version_checker(self, target, check):
|
def _get_version_checker(self, target, check):
|
||||||
"""
|
"""
|
||||||
Retrieves the version checker to use for given target and check configuration. Will raise an UnknownCheckType
|
Retrieves the version checker to use for given target and check configuration. Will raise an UnknownCheckType
|
||||||
|
|||||||
@@ -13,12 +13,20 @@ $(function() {
|
|||||||
|
|
||||||
self.currentlyBeingUpdated = [];
|
self.currentlyBeingUpdated = [];
|
||||||
|
|
||||||
self.config_restartCommand = ko.observable();
|
self.octoprintUnconfigured = ko.observable();
|
||||||
self.config_rebootCommand = ko.observable();
|
self.octoprintUnreleased = ko.observable();
|
||||||
|
|
||||||
self.config_cacheTtl = ko.observable();
|
self.config_cacheTtl = ko.observable();
|
||||||
|
self.config_checkoutFolder = ko.observable();
|
||||||
|
self.config_checkType = ko.observable();
|
||||||
|
|
||||||
self.configurationDialog = $("#settings_plugin_softwareupdate_configurationdialog");
|
self.configurationDialog = $("#settings_plugin_softwareupdate_configurationdialog");
|
||||||
|
|
||||||
|
self.config_availableCheckTypes = [
|
||||||
|
{"key": "github_release", "name": gettext("Release")},
|
||||||
|
{"key": "git_commit", "name": gettext("Commit")}
|
||||||
|
];
|
||||||
|
|
||||||
self.versions = new ItemListHelper(
|
self.versions = new ItemListHelper(
|
||||||
"plugin.softwareupdate.versions",
|
"plugin.softwareupdate.versions",
|
||||||
{
|
{
|
||||||
@@ -78,19 +86,23 @@ $(function() {
|
|||||||
var data = {
|
var data = {
|
||||||
plugins: {
|
plugins: {
|
||||||
softwareupdate: {
|
softwareupdate: {
|
||||||
octoprint_restart_command: self.config_restartCommand(),
|
cache_ttl: parseInt(self.config_cacheTtl()),
|
||||||
environment_restart_command: self.config_rebootCommand(),
|
octoprint_checkout_folder: self.config_checkoutFolder(),
|
||||||
cache_ttl: parseInt(self.config_cacheTtl())
|
octoprint_type: self.config_checkType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.settings.saveData(data, function() { self.configurationDialog.modal("hide"); self._copyConfig(); });
|
self.settings.saveData(data, function() {
|
||||||
|
self.configurationDialog.modal("hide");
|
||||||
|
self._copyConfig();
|
||||||
|
self.performCheck();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self._copyConfig = function() {
|
self._copyConfig = function() {
|
||||||
self.config_restartCommand(self.settings.settings.plugins.softwareupdate.octoprint_restart_command());
|
|
||||||
self.config_rebootCommand(self.settings.settings.plugins.softwareupdate.environment_restart_command());
|
|
||||||
self.config_cacheTtl(self.settings.settings.plugins.softwareupdate.cache_ttl());
|
self.config_cacheTtl(self.settings.settings.plugins.softwareupdate.cache_ttl());
|
||||||
|
self.config_checkoutFolder(self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder());
|
||||||
|
self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type());
|
||||||
};
|
};
|
||||||
|
|
||||||
self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) {
|
self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) {
|
||||||
@@ -109,6 +121,25 @@ $(function() {
|
|||||||
});
|
});
|
||||||
self.versions.updateItems(versions);
|
self.versions.updateItems(versions);
|
||||||
|
|
||||||
|
var octoprint = data.information["octoprint"];
|
||||||
|
if (octoprint && octoprint.hasOwnProperty("check")) {
|
||||||
|
var check = octoprint.check;
|
||||||
|
if (BRANCH != "master" && check["type"] == "github_release") {
|
||||||
|
self.octoprintUnreleased(true);
|
||||||
|
} else {
|
||||||
|
self.octoprintUnreleased(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkoutFolder = (check["checkout_folder"] || "").trim();
|
||||||
|
var updateFolder = (check["update_folder"] || "").trim();
|
||||||
|
var checkType = check["type"] || "";
|
||||||
|
if ((checkType == "github_release" || checkType == "git_commit") && checkoutFolder == "" && updateFolder == "") {
|
||||||
|
self.octoprintUnconfigured(true);
|
||||||
|
} else {
|
||||||
|
self.octoprintUnconfigured(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data.status == "updateAvailable" || data.status == "updatePossible") {
|
if (data.status == "updateAvailable" || data.status == "updatePossible") {
|
||||||
var text = gettext("There are updates available for the following components:");
|
var text = gettext("There are updates available for the following components:");
|
||||||
|
|
||||||
@@ -142,7 +173,7 @@ $(function() {
|
|||||||
click: function() {
|
click: function() {
|
||||||
self._markNotificationAsSeen(data.information);
|
self._markNotificationAsSeen(data.information);
|
||||||
self._showPopup({
|
self._showPopup({
|
||||||
text: gettext("You can make this message display again via \"Settings\" > \"SoftwareUpdate\" > \"Check for update now\"")
|
text: gettext("You can make this message display again via \"Settings\" > \"Software Update\" > \"Check for update now\"")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
<div class="alert" data-bind="visible: octoprintUnconfigured()">{% trans %}
|
||||||
|
Please configure the <strong>checkout folder</strong> of OctoPrint, otherwise
|
||||||
|
this plugin won't be able to update it. Click on the <i class="icon-wrench"></i> button
|
||||||
|
to do this. Also refer to the <a href="https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update" target="_blank">Documentation</a>.
|
||||||
|
{% endtrans %}</div>
|
||||||
|
<div class="alert" data-bind="visible: !octoprintUnconfigured() && octoprintUnreleased()">{% trans %}
|
||||||
|
<p>
|
||||||
|
<strong>You are running a non-release version of OctoPrint but are tracking OctoPrint
|
||||||
|
releases.</strong>
|
||||||
|
</p><p>
|
||||||
|
You probably want OctoPrint to track the matching development version instead.
|
||||||
|
If you have a local OctoPrint checkout folder switched to another branch,
|
||||||
|
<strong>simply switching over to "Commit" tracking</strong> will already
|
||||||
|
take care of that. Otherwise please take a look at the
|
||||||
|
<a href="https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update" target="_blank">Documentation</a>.
|
||||||
|
</p>
|
||||||
|
{% endtrans %}</div>
|
||||||
|
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="icon-wrench"></i></button>
|
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="icon-wrench"></i></button>
|
||||||
</div>
|
</div>
|
||||||
@@ -11,7 +29,7 @@
|
|||||||
<span data-bind="invisible: !updateAvailable"><i class="icon-bell" title="{{ _('Update available') }}"></i></span>
|
<span data-bind="invisible: !updateAvailable"><i class="icon-bell" title="{{ _('Update available') }}"></i></span>
|
||||||
</td>
|
</td>
|
||||||
<td class="settings_plugin_softwareupdate_column_information">
|
<td class="settings_plugin_softwareupdate_column_information">
|
||||||
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span><br>
|
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="icon-exclamation-sign" title="{{ _('Update not possible, configuration ok?') }}"></i></span><br>
|
||||||
<small class="muted">
|
<small class="muted">
|
||||||
{{ _('Installed:') }} <span data-bind="text: information.local.name"></span><br>
|
{{ _('Installed:') }} <span data-bind="text: information.local.name"></span><br>
|
||||||
{{ _('Available:') }} <span data-bind="text: information.remote.name"></span>
|
{{ _('Available:') }} <span data-bind="text: information.remote.name"></span>
|
||||||
@@ -44,7 +62,7 @@
|
|||||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||||
<div class="hide">
|
<div class="hide">
|
||||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }">{{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }">{{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
||||||
<button class="btn btn-block btn-danger" data-bind="click: function() { $root.update(true); }">{{ _('Force update now (even if no new versions are available)') }}</button>
|
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.update(true); }">{{ _('Force update now (even if no new versions are available)') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -56,15 +74,15 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('Restart Command') }}</label>
|
<label class="control-label">{{ _('OctoPrint checkout folder') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-block-level" data-bind="value: config_restartCommand">
|
<input type="text" class="input-block-level" data-bind="value: config_checkoutFolder">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{ _('Reboot Command') }}</label>
|
<label class="control-label">{{ _('OctoPrint version tracking') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-block-level" data-bind="value: config_rebootCommand">
|
<select data-bind="value: config_checkType, options: config_availableCheckTypes, optionsText: 'name', optionsValue: 'key'"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
|||||||
@@ -7,13 +7,16 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
|||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
from octoprint.util.pip import PipCaller, UnknownPip
|
from octoprint.util.pip import PipCaller, UnknownPip
|
||||||
|
from .. import exceptions
|
||||||
|
|
||||||
logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip")
|
logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip")
|
||||||
console_logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip.console")
|
console_logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip.console")
|
||||||
|
|
||||||
_pip_callers = dict()
|
_pip_callers = dict()
|
||||||
|
_pip_version_dependency_links = pkg_resources.parse_version("1.5")
|
||||||
|
|
||||||
def can_perform_update(target, check):
|
def can_perform_update(target, check):
|
||||||
pip_caller = _get_pip_caller(command=check["pip_command"] if "pip_command" in check else None)
|
pip_caller = _get_pip_caller(command=check["pip_command"] if "pip_command" in check else None)
|
||||||
@@ -42,30 +45,37 @@ def perform_update(target, check, target_version):
|
|||||||
|
|
||||||
pip_caller = _get_pip_caller(command=pip_command)
|
pip_caller = _get_pip_caller(command=pip_command)
|
||||||
if pip_caller is None:
|
if pip_caller is None:
|
||||||
raise RuntimeError("Can't run pip")
|
raise exceptions.UpdateError("Can't run pip", None)
|
||||||
|
|
||||||
install_arg = check["pip"].format(target_version=target_version)
|
install_arg = check["pip"].format(target_version=target_version)
|
||||||
|
|
||||||
logger.debug("Target: %s, executing pip install %s" % (target, install_arg))
|
logger.debug(u"Target: %s, executing pip install %s" % (target, install_arg))
|
||||||
pip_args = ["install", check["pip"].format(target_version=target_version, target=target_version)]
|
pip_args = ["install", check["pip"].format(target_version=target_version, target=target_version)]
|
||||||
|
|
||||||
pip_caller.execute(*pip_args)
|
if "dependency_links" in check and check["dependency_links"] and pip_caller >= _pip_version_dependency_links:
|
||||||
|
pip_args += ["--process-dependency-links"]
|
||||||
|
|
||||||
logger.debug("Target: %s, executing pip install %s --ignore-reinstalled --force-reinstall --no-deps" % (target, install_arg))
|
returncode, stdout, stderr = pip_caller.execute(*pip_args)
|
||||||
|
if returncode != 0:
|
||||||
|
raise exceptions.UpdateError("Error while executing pip install", (stdout, stderr))
|
||||||
|
|
||||||
|
logger.debug(u"Target: %s, executing pip install %s --ignore-reinstalled --force-reinstall --no-deps" % (target, install_arg))
|
||||||
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]
|
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]
|
||||||
|
|
||||||
pip_caller.execute(*pip_args)
|
returncode, stdout, stderr = pip_caller.execute(*pip_args)
|
||||||
|
if returncode != 0:
|
||||||
|
raise exceptions.UpdateError("Error while executing pip install --force-reinstall", (stdout, stderr))
|
||||||
|
|
||||||
return "ok"
|
return "ok"
|
||||||
|
|
||||||
def _log_call(*lines):
|
def _log_call(*lines):
|
||||||
_log(lines, prefix=" ")
|
_log(lines, prefix=u" ")
|
||||||
|
|
||||||
def _log_stdout(*lines):
|
def _log_stdout(*lines):
|
||||||
_log(lines, prefix=">")
|
_log(lines, prefix=u">")
|
||||||
|
|
||||||
def _log_stderr(*lines):
|
def _log_stderr(*lines):
|
||||||
_log(lines, prefix="!")
|
_log(lines, prefix=u"!")
|
||||||
|
|
||||||
def _log(lines, prefix=None):
|
def _log(lines, prefix=None):
|
||||||
lines = map(lambda x: x.strip(), lines)
|
lines = map(lambda x: x.strip(), lines)
|
||||||
|
|||||||
@@ -13,7 +13,17 @@ from ..util import execute
|
|||||||
|
|
||||||
|
|
||||||
def can_perform_update(target, check):
|
def can_perform_update(target, check):
|
||||||
return "update_script" in check and ("checkout_folder" in check or "update_folder" in check)
|
import os
|
||||||
|
script_configured = bool("update_script" in check and check["update_script"])
|
||||||
|
|
||||||
|
folder = None
|
||||||
|
if "update_folder" in check:
|
||||||
|
folder = check["update_folder"]
|
||||||
|
elif "checkout_folder" in check:
|
||||||
|
folder = check["checkout_folder"]
|
||||||
|
folder_configured = bool(folder and os.path.isdir(folder))
|
||||||
|
|
||||||
|
return script_configured and folder_configured
|
||||||
|
|
||||||
|
|
||||||
def perform_update(target, check, target_version):
|
def perform_update(target, check, target_version):
|
||||||
|
|||||||
@@ -44,35 +44,71 @@ def _get_latest_release(user, repo, include_prerelease=False):
|
|||||||
return latest["name"], latest["tag_name"]
|
return latest["name"], latest["tag_name"]
|
||||||
|
|
||||||
|
|
||||||
def _is_current(release_information, compare_type, custom=None):
|
def _get_sanitized_version(version_string):
|
||||||
|
if "-" in version_string:
|
||||||
|
version_string = version_string[:version_string.find("-")]
|
||||||
|
return version_string
|
||||||
|
|
||||||
|
|
||||||
|
def _get_comparable_version_pkg_resources(version_string, force_base=True):
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
version = pkg_resources.parse_version(version_string)
|
||||||
|
|
||||||
|
if force_base:
|
||||||
|
if isinstance(version, tuple):
|
||||||
|
# old setuptools
|
||||||
|
base_version = []
|
||||||
|
for part in version:
|
||||||
|
if part.startswith("*"):
|
||||||
|
break
|
||||||
|
base_version.append(part)
|
||||||
|
version = tuple(base_version)
|
||||||
|
else:
|
||||||
|
# new setuptools
|
||||||
|
version = pkg_resources.parse_version(version.base_version)
|
||||||
|
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
|
def _get_comparable_version_semantic(version_string, force_base=True):
|
||||||
|
import semantic_version
|
||||||
|
|
||||||
|
version = semantic_version.Version.coerce(version_string, partial=False)
|
||||||
|
|
||||||
|
if force_base:
|
||||||
|
version_string = "{}.{}.{}".format(version.major, version.minor, version.patch)
|
||||||
|
version = semantic_version.Version.coerce(version_string, partial=False)
|
||||||
|
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
|
def _is_current(release_information, compare_type, custom=None, force_base=True):
|
||||||
if release_information["remote"]["value"] is None:
|
if release_information["remote"]["value"] is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if not compare_type in ("python", "semantic", "unequal", "custom") or compare_type == "custom" and custom is None:
|
if not compare_type in ("python", "semantic", "unequal", "custom") or compare_type == "custom" and custom is None:
|
||||||
compare_type = "python"
|
compare_type = "python"
|
||||||
|
|
||||||
|
sanitized_local = _get_sanitized_version(release_information["local"]["value"])
|
||||||
|
sanitized_remote = _get_sanitized_version(release_information["remote"]["value"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if compare_type == "python":
|
if compare_type == "python":
|
||||||
import pkg_resources
|
local_version = _get_comparable_version_pkg_resources(sanitized_local, force_base=force_base)
|
||||||
|
remote_version = _get_comparable_version_pkg_resources(sanitized_remote, force_base=force_base)
|
||||||
local_version = pkg_resources.parse_version(release_information["local"]["value"])
|
|
||||||
remote_version = pkg_resources.parse_version(release_information["remote"]["value"])
|
|
||||||
|
|
||||||
return local_version >= remote_version
|
return local_version >= remote_version
|
||||||
|
|
||||||
elif compare_type == "semantic":
|
elif compare_type == "semantic":
|
||||||
import semantic_version
|
local_version = _get_comparable_version_semantic(sanitized_local, force_base=force_base)
|
||||||
|
remote_version = _get_comparable_version_semantic(sanitized_remote, force_base=force_base)
|
||||||
local_version = semantic_version.Version(release_information["local"]["value"])
|
|
||||||
remote_version = semantic_version.Version(release_information["remote"]["value"])
|
|
||||||
|
|
||||||
return local_version >= remote_version
|
return local_version >= remote_version
|
||||||
|
|
||||||
elif compare_type == "custom":
|
elif compare_type == "custom":
|
||||||
return custom(release_information["local"], release_information["remote"])
|
return custom(sanitized_local, sanitized_remote)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return release_information["local"]["value"] == release_information["remote"]["value"]
|
return sanitized_local == sanitized_remote
|
||||||
except:
|
except:
|
||||||
logger.exception("Could not check if version is current due to an error, assuming it is")
|
logger.exception("Could not check if version is current due to an error, assuming it is")
|
||||||
return True
|
return True
|
||||||
@@ -82,11 +118,13 @@ def get_latest(target, check, custom_compare=None):
|
|||||||
if not "user" in check or not "repo" in check:
|
if not "user" in check or not "repo" in check:
|
||||||
raise ConfigurationInvalid("github_release update configuration for %s needs user and repo set" % target)
|
raise ConfigurationInvalid("github_release update configuration for %s needs user and repo set" % target)
|
||||||
|
|
||||||
current = None
|
current = check.get("current", None)
|
||||||
if "current" in check:
|
include_prerelease = check.get("prerelease", False)
|
||||||
current = check["current"]
|
force_base = check.get("force_base", True)
|
||||||
|
|
||||||
remote_name, remote_tag = _get_latest_release(check["user"], check["repo"], include_prerelease=check["prerelease"] == True if "prerelease" in check else False)
|
remote_name, remote_tag = _get_latest_release(check["user"],
|
||||||
|
check["repo"],
|
||||||
|
include_prerelease=include_prerelease)
|
||||||
compare_type = check["release_compare"] if "release_compare" in check else "python"
|
compare_type = check["release_compare"] if "release_compare" in check else "python"
|
||||||
|
|
||||||
information =dict(
|
information =dict(
|
||||||
@@ -96,4 +134,7 @@ def get_latest(target, check, custom_compare=None):
|
|||||||
|
|
||||||
logger.debug("Target: %s, local: %s, remote: %s" % (target, current, remote_tag))
|
logger.debug("Target: %s, local: %s, remote: %s" % (target, current, remote_tag))
|
||||||
|
|
||||||
return information, _is_current(information, compare_type, custom=custom_compare)
|
return information, _is_current(information,
|
||||||
|
compare_type,
|
||||||
|
custom=custom_compare,
|
||||||
|
force_base=force_base)
|
||||||
@@ -65,6 +65,7 @@ class VirtualPrinter():
|
|||||||
self._heatupThread = None
|
self._heatupThread = None
|
||||||
|
|
||||||
self._okBeforeCommandOutput = settings().getBoolean(["devel", "virtualPrinter", "okBeforeCommandOutput"])
|
self._okBeforeCommandOutput = settings().getBoolean(["devel", "virtualPrinter", "okBeforeCommandOutput"])
|
||||||
|
self._supportM112 = settings().getBoolean(["devel", "virtualPrinter", "supportM112"])
|
||||||
|
|
||||||
self._sendWait = settings().getBoolean(["devel", "virtualPrinter", "sendWait"])
|
self._sendWait = settings().getBoolean(["devel", "virtualPrinter", "sendWait"])
|
||||||
self._waitInterval = settings().getFloat(["devel", "virtualPrinter", "waitInterval"])
|
self._waitInterval = settings().getFloat(["devel", "virtualPrinter", "waitInterval"])
|
||||||
@@ -83,6 +84,7 @@ class VirtualPrinter():
|
|||||||
|
|
||||||
self._action_hooks = plugin_manager().get_hooks("octoprint.plugin.virtual_printer.custom_action")
|
self._action_hooks = plugin_manager().get_hooks("octoprint.plugin.virtual_printer.custom_action")
|
||||||
|
|
||||||
|
self._killed = False
|
||||||
|
|
||||||
waitThread = threading.Thread(target=self._sendWaitAfterTimeout)
|
waitThread = threading.Thread(target=self._sendWaitAfterTimeout)
|
||||||
waitThread.start()
|
waitThread.start()
|
||||||
@@ -106,7 +108,7 @@ class VirtualPrinter():
|
|||||||
|
|
||||||
def _processIncoming(self):
|
def _processIncoming(self):
|
||||||
next_wait_timeout = time.time() + self._waitInterval
|
next_wait_timeout = time.time() + self._waitInterval
|
||||||
while self.incoming is not None:
|
while self.incoming is not None and not self._killed:
|
||||||
self._simulateTemps()
|
self._simulateTemps()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -266,9 +268,10 @@ class VirtualPrinter():
|
|||||||
elif "G92" in data:
|
elif "G92" in data:
|
||||||
self._setPosition(data)
|
self._setPosition(data)
|
||||||
|
|
||||||
elif data.startswith("G0") or data.startswith("G1") or data.startswith("G2") or data.startswith("G3") \
|
elif data.startswith("G28"):
|
||||||
or data.startswith("G28") or data.startswith("G29") or data.startswith("G30") \
|
self._performMove(data)
|
||||||
or data.startswith("G31") or data.startswith("G32"):
|
|
||||||
|
elif data.startswith("G0") or data.startswith("G1") or data.startswith("G2") or data.startswith("G3"):
|
||||||
# simulate reprap buffered commands via a Queue with maxsize which internally simulates the moves
|
# simulate reprap buffered commands via a Queue with maxsize which internally simulates the moves
|
||||||
self.buffered.put(data)
|
self.buffered.put(data)
|
||||||
|
|
||||||
@@ -291,6 +294,12 @@ class VirtualPrinter():
|
|||||||
if len(data.strip()) > 0 and not self._okBeforeCommandOutput:
|
if len(data.strip()) > 0 and not self._okBeforeCommandOutput:
|
||||||
self._sendOk()
|
self._sendOk()
|
||||||
|
|
||||||
|
def _kill(self):
|
||||||
|
if not self._supportM112:
|
||||||
|
return
|
||||||
|
self._killed = True
|
||||||
|
self.outgoing.put("echo:EMERGENCY SHUTDOWN DETECTED. KILLED.")
|
||||||
|
|
||||||
def _triggerResend(self, expected=None, actual=None):
|
def _triggerResend(self, expected=None, actual=None):
|
||||||
with self._incoming_lock:
|
with self._incoming_lock:
|
||||||
if expected is None:
|
if expected is None:
|
||||||
@@ -303,8 +312,13 @@ class VirtualPrinter():
|
|||||||
else:
|
else:
|
||||||
self.outgoing.put("Error: expected line %d got %d" % (expected, actual))
|
self.outgoing.put("Error: expected line %d got %d" % (expected, actual))
|
||||||
|
|
||||||
self.outgoing.put("Resend:%d" % expected)
|
def request_resend():
|
||||||
self.outgoing.put("ok")
|
self.outgoing.put("Resend:%d" % expected)
|
||||||
|
self.outgoing.put("ok")
|
||||||
|
|
||||||
|
if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleResends"]):
|
||||||
|
request_resend()
|
||||||
|
request_resend()
|
||||||
|
|
||||||
def _debugTrigger(self, data):
|
def _debugTrigger(self, data):
|
||||||
if data == "action_pause":
|
if data == "action_pause":
|
||||||
@@ -516,14 +530,10 @@ class VirtualPrinter():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if duration:
|
if duration:
|
||||||
if settings().getBoolean(["devel", "virtualPrinter", "waitOnLongMoves"]):
|
slept = 0
|
||||||
slept = 0
|
while duration - slept > self._read_timeout and not self._killed:
|
||||||
while duration - slept > self._read_timeout:
|
time.sleep(self._read_timeout)
|
||||||
time.sleep(self._read_timeout)
|
slept += self._read_timeout
|
||||||
self.outgoing.put("wait")
|
|
||||||
slept += self._read_timeout
|
|
||||||
else:
|
|
||||||
time.sleep(duration)
|
|
||||||
|
|
||||||
def _setPosition(self, line):
|
def _setPosition(self, line):
|
||||||
matchX = re.search("X([0-9.]+)", line)
|
matchX = re.search("X([0-9.]+)", line)
|
||||||
@@ -577,6 +587,9 @@ class VirtualPrinter():
|
|||||||
self._selectedSdFilePos = 0
|
self._selectedSdFilePos = 0
|
||||||
with open(self._selectedSdFile, "r") as f:
|
with open(self._selectedSdFile, "r") as f:
|
||||||
for line in iter(f.readline, ""):
|
for line in iter(f.readline, ""):
|
||||||
|
if self._killed:
|
||||||
|
break
|
||||||
|
|
||||||
# reset position if requested by client
|
# reset position if requested by client
|
||||||
if self._newSdFilePos is not None:
|
if self._newSdFilePos is not None:
|
||||||
f.seek(self._newSdFilePos)
|
f.seek(self._newSdFilePos)
|
||||||
@@ -606,12 +619,12 @@ class VirtualPrinter():
|
|||||||
delay = 1
|
delay = 1
|
||||||
if heater.startswith("tool"):
|
if heater.startswith("tool"):
|
||||||
toolNum = int(heater[len("tool"):])
|
toolNum = int(heater[len("tool"):])
|
||||||
while self.temp[toolNum] < self.targetTemp[toolNum] - delta or self.temp[toolNum] > self.targetTemp[toolNum] + delta:
|
while not self._killed and (self.temp[toolNum] < self.targetTemp[toolNum] - delta or self.temp[toolNum] > self.targetTemp[toolNum] + delta):
|
||||||
self._simulateTemps(delta=delta)
|
self._simulateTemps(delta=delta)
|
||||||
self.outgoing.put("T:%0.2f" % self.temp[toolNum])
|
self.outgoing.put("T:%0.2f" % self.temp[toolNum])
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
elif heater == "bed":
|
elif heater == "bed":
|
||||||
while self.bedTemp < self.bedTargetTemp - delta or self.bedTemp > self.bedTargetTemp + delta:
|
while not self._killed and (self.bedTemp < self.bedTargetTemp - delta or self.bedTemp > self.bedTargetTemp + delta):
|
||||||
self._simulateTemps(delta=delta)
|
self._simulateTemps(delta=delta)
|
||||||
self.outgoing.put("B:%0.2f" % self.bedTemp)
|
self.outgoing.put("B:%0.2f" % self.bedTemp)
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
@@ -662,6 +675,11 @@ class VirtualPrinter():
|
|||||||
with self._incoming_lock:
|
with self._incoming_lock:
|
||||||
if self.incoming is None or self.outgoing is None:
|
if self.incoming is None or self.outgoing is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if "M112" in data and self._supportM112:
|
||||||
|
self._kill()
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.incoming.put(data, timeout=self._write_timeout)
|
self.incoming.put(data, timeout=self._write_timeout)
|
||||||
except Queue.Full:
|
except Queue.Full:
|
||||||
@@ -685,6 +703,9 @@ class VirtualPrinter():
|
|||||||
self.buffered = None
|
self.buffered = None
|
||||||
|
|
||||||
def _sendOk(self):
|
def _sendOk(self):
|
||||||
|
if self.outgoing is None:
|
||||||
|
return
|
||||||
|
|
||||||
if settings().getBoolean(["devel", "virtualPrinter", "okWithLinenumber"]):
|
if settings().getBoolean(["devel", "virtualPrinter", "okWithLinenumber"]):
|
||||||
self.outgoing.put("ok %d" % self.lastN)
|
self.outgoing.put("ok %d" % self.lastN)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -329,12 +329,14 @@ class PrinterProfileManager(object):
|
|||||||
if os.path.exists(path) and not allow_overwrite:
|
if os.path.exists(path) and not allow_overwrite:
|
||||||
raise SaveError("Profile %s already exists and not allowed to overwrite" % profile["id"])
|
raise SaveError("Profile %s already exists and not allowed to overwrite" % profile["id"])
|
||||||
|
|
||||||
|
from octoprint.util import atomic_write
|
||||||
import yaml
|
import yaml
|
||||||
with open(path, "wb") as f:
|
try:
|
||||||
try:
|
with atomic_write(path, "wb") as f:
|
||||||
yaml.safe_dump(profile, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
yaml.safe_dump(profile, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise SaveError("Cannot save profile %s: %s" % (profile["id"], str(e)))
|
self._logger.exception("Error while trying to save profile %s" % profile["id"])
|
||||||
|
raise SaveError("Cannot save profile %s: %s" % (profile["id"], str(e)))
|
||||||
|
|
||||||
def _remove_from_path(self, path):
|
def _remove_from_path(self, path):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -389,6 +389,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
|||||||
self._timeEstimationData = TimeEstimationHelper(rolling_window=rolling_window, threshold=threshold, countdown=countdown)
|
self._timeEstimationData = TimeEstimationHelper(rolling_window=rolling_window, threshold=threshold, countdown=countdown)
|
||||||
|
|
||||||
self._lastProgressReport = None
|
self._lastProgressReport = None
|
||||||
|
self._setProgressData(0, None, None, None)
|
||||||
self._setCurrentZ(None)
|
self._setCurrentZ(None)
|
||||||
self._comm.startPrint()
|
self._comm.startPrint()
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from flask.ext.babel import Babel, gettext, ngettext
|
|||||||
from flask.ext.assets import Environment, Bundle
|
from flask.ext.assets import Environment, Bundle
|
||||||
from babel import Locale
|
from babel import Locale
|
||||||
from watchdog.observers import Observer
|
from watchdog.observers import Observer
|
||||||
|
from watchdog.observers.polling import PollingObserver
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -233,7 +234,10 @@ class Server():
|
|||||||
|
|
||||||
settingsPlugins = pluginManager.get_implementations(octoprint.plugin.SettingsPlugin)
|
settingsPlugins = pluginManager.get_implementations(octoprint.plugin.SettingsPlugin)
|
||||||
for implementation in settingsPlugins:
|
for implementation in settingsPlugins:
|
||||||
settings_plugin_config_migration(implementation._identifier, implementation)
|
try:
|
||||||
|
settings_plugin_config_migration(implementation._identifier, implementation)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while trying to migrate settings for plugin {}, ignoring it".format(implementation._identifier))
|
||||||
|
|
||||||
pluginManager.implementation_post_inits=[settings_plugin_config_migration]
|
pluginManager.implementation_post_inits=[settings_plugin_config_migration]
|
||||||
|
|
||||||
@@ -399,7 +403,12 @@ class Server():
|
|||||||
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||||
|
|
||||||
# start up watchdogs
|
# start up watchdogs
|
||||||
observer = Observer()
|
if s.getBoolean(["feature", "pollWatched"]):
|
||||||
|
# use less performant polling observer if explicitely configured
|
||||||
|
observer = PollingObserver()
|
||||||
|
else:
|
||||||
|
# use os default
|
||||||
|
observer = Observer()
|
||||||
observer.schedule(util.watchdog.GcodeWatchdogHandler(fileManager, printer), s.getBaseFolder("watched"))
|
observer.schedule(util.watchdog.GcodeWatchdogHandler(fileManager, printer), s.getBaseFolder("watched"))
|
||||||
observer.start()
|
observer.start()
|
||||||
|
|
||||||
@@ -538,6 +547,9 @@ class Server():
|
|||||||
},
|
},
|
||||||
"tornado.general": {
|
"tornado.general": {
|
||||||
"level": "INFO"
|
"level": "INFO"
|
||||||
|
},
|
||||||
|
"octoprint.server.util.flask": {
|
||||||
|
"level": "WARN"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
@@ -629,7 +641,10 @@ class Server():
|
|||||||
def _register_template_plugins(self):
|
def _register_template_plugins(self):
|
||||||
template_plugins = pluginManager.get_implementations(octoprint.plugin.TemplatePlugin)
|
template_plugins = pluginManager.get_implementations(octoprint.plugin.TemplatePlugin)
|
||||||
for plugin in template_plugins:
|
for plugin in template_plugins:
|
||||||
self._register_additional_template_plugin(plugin)
|
try:
|
||||||
|
self._register_additional_template_plugin(plugin)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while trying to register templates of plugin {}, ignoring it".format(plugin._identifier))
|
||||||
|
|
||||||
def _register_additional_template_plugin(self, plugin):
|
def _register_additional_template_plugin(self, plugin):
|
||||||
folder = plugin.get_template_folder()
|
folder = plugin.get_template_folder()
|
||||||
@@ -664,14 +679,22 @@ class Server():
|
|||||||
def _register_blueprint_plugins(self):
|
def _register_blueprint_plugins(self):
|
||||||
blueprint_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.BlueprintPlugin)
|
blueprint_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.BlueprintPlugin)
|
||||||
for plugin in blueprint_plugins:
|
for plugin in blueprint_plugins:
|
||||||
self._register_blueprint_plugin(plugin)
|
try:
|
||||||
|
self._register_blueprint_plugin(plugin)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while registering blueprint of plugin {}, ignoring it".format(plugin._identifier))
|
||||||
|
continue
|
||||||
|
|
||||||
def _register_asset_plugins(self):
|
def _register_asset_plugins(self):
|
||||||
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
|
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
|
||||||
for plugin in asset_plugins:
|
for plugin in asset_plugins:
|
||||||
if isinstance(plugin, octoprint.plugin.BlueprintPlugin):
|
if isinstance(plugin, octoprint.plugin.BlueprintPlugin):
|
||||||
continue
|
continue
|
||||||
self._register_asset_plugin(plugin)
|
try:
|
||||||
|
self._register_asset_plugin(plugin)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while registering assets of plugin {}, ignoring it".format(plugin._identifier))
|
||||||
|
continue
|
||||||
|
|
||||||
def _register_blueprint_plugin(self, plugin):
|
def _register_blueprint_plugin(self, plugin):
|
||||||
name = plugin._identifier
|
name = plugin._identifier
|
||||||
@@ -706,22 +729,65 @@ class Server():
|
|||||||
global pluginManager
|
global pluginManager
|
||||||
|
|
||||||
util.flask.fix_webassets_cache()
|
util.flask.fix_webassets_cache()
|
||||||
|
util.flask.fix_webassets_filtertool()
|
||||||
|
|
||||||
base_folder = settings().getBaseFolder("generated")
|
base_folder = settings().getBaseFolder("generated")
|
||||||
|
|
||||||
# clean the folder
|
# clean the folder
|
||||||
if settings().getBoolean(["devel", "webassets", "clean_on_startup"]):
|
if settings().getBoolean(["devel", "webassets", "clean_on_startup"]):
|
||||||
import shutil
|
import shutil
|
||||||
|
import errno
|
||||||
|
import sys
|
||||||
|
|
||||||
for entry in ("webassets", ".webassets-cache"):
|
for entry in ("webassets", ".webassets-cache"):
|
||||||
path = os.path.join(base_folder, entry)
|
path = os.path.join(base_folder, entry)
|
||||||
self._logger.debug("Deleting {path}...".format(**locals()))
|
|
||||||
|
# delete path if it exists
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path, ignore_errors=True)
|
|
||||||
elif os.path.isfile(path):
|
|
||||||
try:
|
try:
|
||||||
os.remove(path)
|
self._logger.debug("Deleting {path}...".format(**locals()))
|
||||||
|
shutil.rmtree(path)
|
||||||
except:
|
except:
|
||||||
self._logger.exception("Exception while trying to delete {entry} from {base_folder}".format(**locals()))
|
self._logger.exception("Error while trying to delete {path}, leaving it alone".format(**locals()))
|
||||||
|
continue
|
||||||
|
|
||||||
|
# re-create path
|
||||||
|
self._logger.debug("Creating {path}...".format(**locals()))
|
||||||
|
error_text = "Error while trying to re-create {path}, that might cause errors with the webassets cache".format(**locals())
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno == errno.EACCES:
|
||||||
|
# that might be caused by the user still having the folder open somewhere, let's try again after
|
||||||
|
# waiting a bit
|
||||||
|
import time
|
||||||
|
for n in xrange(3):
|
||||||
|
time.sleep(0.5)
|
||||||
|
self._logger.debug("Creating {path}: Retry #{retry} after {time}s".format(path=path, retry=n+1, time=(n + 1)*0.5))
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
if self._logger.isEnabledFor(logging.DEBUG):
|
||||||
|
self._logger.exception("Ignored error while creating directory {path}".format(**locals()))
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# this will only get executed if we never did
|
||||||
|
# successfully execute makedirs above
|
||||||
|
self._logger.exception(error_text)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
# not an access error, so something we don't understand
|
||||||
|
# went wrong -> log an error and stop
|
||||||
|
self._logger.exception(error_text)
|
||||||
|
continue
|
||||||
|
except:
|
||||||
|
# not an OSError, so something we don't understand
|
||||||
|
# went wrong -> log an error and stop
|
||||||
|
self._logger.exception(error_text)
|
||||||
|
continue
|
||||||
|
|
||||||
|
self._logger.info("Reset webasset folder {path}...".format(**locals()))
|
||||||
|
|
||||||
AdjustedEnvironment = type(Environment)(Environment.__name__, (Environment,), dict(
|
AdjustedEnvironment = type(Environment)(Environment.__name__, (Environment,), dict(
|
||||||
resolver_class=util.flask.PluginAssetResolver
|
resolver_class=util.flask.PluginAssetResolver
|
||||||
@@ -740,12 +806,10 @@ class Server():
|
|||||||
assets.updater = UpdaterType
|
assets.updater = UpdaterType
|
||||||
|
|
||||||
enable_gcodeviewer = settings().getBoolean(["gcodeViewer", "enabled"])
|
enable_gcodeviewer = settings().getBoolean(["gcodeViewer", "enabled"])
|
||||||
enable_timelapse = (settings().get(["webcam", "snapshot"]) and settings().get(["webcam", "ffmpeg"]))
|
|
||||||
preferred_stylesheet = settings().get(["devel", "stylesheet"])
|
preferred_stylesheet = settings().get(["devel", "stylesheet"])
|
||||||
|
|
||||||
dynamic_assets = util.flask.collect_plugin_assets(
|
dynamic_assets = util.flask.collect_plugin_assets(
|
||||||
enable_gcodeviewer=enable_gcodeviewer,
|
enable_gcodeviewer=enable_gcodeviewer,
|
||||||
enable_timelapse=enable_timelapse,
|
|
||||||
preferred_stylesheet=preferred_stylesheet
|
preferred_stylesheet=preferred_stylesheet
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -839,9 +903,9 @@ class Server():
|
|||||||
js_app_bundle = Bundle(*js_app, output="webassets/packed_app.js", filters="js_delimiter_bundler")
|
js_app_bundle = Bundle(*js_app, output="webassets/packed_app.js", filters="js_delimiter_bundler")
|
||||||
|
|
||||||
css_libs_bundle = Bundle(*css_libs, output="webassets/packed_libs.css")
|
css_libs_bundle = Bundle(*css_libs, output="webassets/packed_libs.css")
|
||||||
css_app_bundle = Bundle(*css_app, output="webassets/packed_app.css")
|
css_app_bundle = Bundle(*css_app, output="webassets/packed_app.css", filters="cssrewrite")
|
||||||
|
|
||||||
all_less_bundle = Bundle(*less_app, output="webassets/packed_app.less", filters="less_importrewrite")
|
all_less_bundle = Bundle(*less_app, output="webassets/packed_app.less", filters="cssrewrite, less_importrewrite")
|
||||||
|
|
||||||
assets.register("js_libs", js_libs_bundle)
|
assets.register("js_libs", js_libs_bundle)
|
||||||
assets.register("js_app", js_app_bundle)
|
assets.register("js_app", js_app_bundle)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import octoprint.server
|
|||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
from octoprint.server import admin_permission, NO_CONTENT
|
from octoprint.server import admin_permission, NO_CONTENT
|
||||||
from octoprint.settings import settings as s, valid_boolean_trues
|
from octoprint.settings import settings as s, valid_boolean_trues
|
||||||
from octoprint.server.util import apiKeyRequestHandler, corsResponseHandler
|
from octoprint.server.util import noCachingResponseHandler, apiKeyRequestHandler, corsResponseHandler
|
||||||
from octoprint.server.util.flask import restricted_access, get_json_command_from_request, passive_login
|
from octoprint.server.util.flask import restricted_access, get_json_command_from_request, passive_login
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +42,8 @@ from . import languages as api_languages
|
|||||||
|
|
||||||
VERSION = "0.1"
|
VERSION = "0.1"
|
||||||
|
|
||||||
|
api.after_request(noCachingResponseHandler)
|
||||||
|
|
||||||
api.before_request(apiKeyRequestHandler)
|
api.before_request(apiKeyRequestHandler)
|
||||||
api.after_request(corsResponseHandler)
|
api.after_request(corsResponseHandler)
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
|||||||
|
|
||||||
from flask import request, jsonify, make_response, url_for
|
from flask import request, jsonify, make_response, url_for
|
||||||
|
|
||||||
import octoprint.util as util
|
|
||||||
from octoprint.filemanager.destinations import FileDestinations
|
from octoprint.filemanager.destinations import FileDestinations
|
||||||
from octoprint.settings import settings, valid_boolean_trues
|
from octoprint.settings import settings, valid_boolean_trues
|
||||||
from octoprint.server import printer, fileManager, slicingManager, eventManager, NO_CONTENT
|
from octoprint.server import printer, fileManager, slicingManager, eventManager, NO_CONTENT
|
||||||
@@ -18,6 +17,8 @@ import octoprint.filemanager
|
|||||||
import octoprint.filemanager.util
|
import octoprint.filemanager.util
|
||||||
import octoprint.slicing
|
import octoprint.slicing
|
||||||
|
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
|
||||||
#~~ GCODE file handling
|
#~~ GCODE file handling
|
||||||
|
|
||||||
@@ -29,7 +30,8 @@ def readGcodeFiles():
|
|||||||
filter = request.values["filter"]
|
filter = request.values["filter"]
|
||||||
files = _getFileList(FileDestinations.LOCAL, filter=filter)
|
files = _getFileList(FileDestinations.LOCAL, filter=filter)
|
||||||
files.extend(_getFileList(FileDestinations.SDCARD))
|
files.extend(_getFileList(FileDestinations.SDCARD))
|
||||||
return jsonify(files=files, free=util.get_free_bytes(settings().getBaseFolder("uploads")))
|
usage = psutil.disk_usage(settings().getBaseFolder("uploads"))
|
||||||
|
return jsonify(files=files, free=usage.free, total=usage.total)
|
||||||
|
|
||||||
|
|
||||||
@api.route("/files/<string:origin>", methods=["GET"])
|
@api.route("/files/<string:origin>", methods=["GET"])
|
||||||
@@ -40,7 +42,8 @@ def readGcodeFilesForOrigin(origin):
|
|||||||
files = _getFileList(origin)
|
files = _getFileList(origin)
|
||||||
|
|
||||||
if origin == FileDestinations.LOCAL:
|
if origin == FileDestinations.LOCAL:
|
||||||
return jsonify(files=files, free=util.get_free_bytes(settings().getBaseFolder("uploads")))
|
usage = psutil.disk_usage(settings().getBaseFolder("uploads"))
|
||||||
|
return jsonify(files=files, free=usage.free, total=usage.total)
|
||||||
else:
|
else:
|
||||||
return jsonify(files=files)
|
return jsonify(files=files)
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,18 @@ from octoprint.settings import settings
|
|||||||
from octoprint.server import NO_CONTENT, admin_permission
|
from octoprint.server import NO_CONTENT, admin_permission
|
||||||
from octoprint.server.util.flask import redirect_to_tornado, restricted_access
|
from octoprint.server.util.flask import redirect_to_tornado, restricted_access
|
||||||
from octoprint.server.api import api
|
from octoprint.server.api import api
|
||||||
from octoprint.util import get_free_bytes
|
|
||||||
|
|
||||||
|
|
||||||
@api.route("/logs", methods=["GET"])
|
@api.route("/logs", methods=["GET"])
|
||||||
@restricted_access
|
@restricted_access
|
||||||
@admin_permission.require(403)
|
@admin_permission.require(403)
|
||||||
def getLogFiles():
|
def getLogFiles():
|
||||||
|
import psutil
|
||||||
|
usage = psutil.disk_usage(settings().getBaseFolder("logs"))
|
||||||
|
|
||||||
files = _getLogFiles()
|
files = _getLogFiles()
|
||||||
return jsonify(files=files, free=get_free_bytes(settings().getBaseFolder("logs")))
|
|
||||||
|
return jsonify(files=files, free=usage.free, total=usage.total)
|
||||||
|
|
||||||
|
|
||||||
@api.route("/logs/<path:filename>", methods=["GET"])
|
@api.route("/logs/<path:filename>", methods=["GET"])
|
||||||
|
|||||||
@@ -68,7 +68,9 @@ def getSettings():
|
|||||||
"swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]),
|
"swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"]),
|
||||||
"repetierTargetTemp": s.getBoolean(["feature", "repetierTargetTemp"]),
|
"repetierTargetTemp": s.getBoolean(["feature", "repetierTargetTemp"]),
|
||||||
"externalHeatupDetection": s.getBoolean(["feature", "externalHeatupDetection"]),
|
"externalHeatupDetection": s.getBoolean(["feature", "externalHeatupDetection"]),
|
||||||
"keyboardControl": s.getBoolean(["feature", "keyboardControl"])
|
"keyboardControl": s.getBoolean(["feature", "keyboardControl"]),
|
||||||
|
"pollWatched": s.getBoolean(["feature", "pollWatched"]),
|
||||||
|
"ignoreIdenticalResends": s.getBoolean(["feature", "ignoreIdenticalResends"])
|
||||||
},
|
},
|
||||||
"serial": {
|
"serial": {
|
||||||
"port": connectionOptions["portPreference"],
|
"port": connectionOptions["portPreference"],
|
||||||
@@ -111,6 +113,17 @@ def getSettings():
|
|||||||
"afterPrintResumed": None,
|
"afterPrintResumed": None,
|
||||||
"snippets": dict()
|
"snippets": dict()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"commands": {
|
||||||
|
"systemShutdownCommand": s.get(["server", "commands", "systemShutdownCommand"]),
|
||||||
|
"systemRestartCommand": s.get(["server", "commands", "systemRestartCommand"]),
|
||||||
|
"serverRestartCommand": s.get(["server", "commands", "serverRestartCommand"])
|
||||||
|
},
|
||||||
|
"diskspace": {
|
||||||
|
"warning": s.getInt(["server", "diskspace", "warning"]),
|
||||||
|
"critical": s.getInt(["server", "diskspace", "critical"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,6 +212,8 @@ def setSettings():
|
|||||||
if "repetierTargetTemp" in data["feature"].keys(): s.setBoolean(["feature", "repetierTargetTemp"], data["feature"]["repetierTargetTemp"])
|
if "repetierTargetTemp" in data["feature"].keys(): s.setBoolean(["feature", "repetierTargetTemp"], data["feature"]["repetierTargetTemp"])
|
||||||
if "externalHeatupDetection" in data["feature"].keys(): s.setBoolean(["feature", "externalHeatupDetection"], data["feature"]["externalHeatupDetection"])
|
if "externalHeatupDetection" in data["feature"].keys(): s.setBoolean(["feature", "externalHeatupDetection"], data["feature"]["externalHeatupDetection"])
|
||||||
if "keyboardControl" in data["feature"].keys(): s.setBoolean(["feature", "keyboardControl"], data["feature"]["keyboardControl"])
|
if "keyboardControl" in data["feature"].keys(): s.setBoolean(["feature", "keyboardControl"], data["feature"]["keyboardControl"])
|
||||||
|
if "pollWatched" in data["feature"]: s.setBoolean(["feature", "pollWatched"], data["feature"]["pollWatched"])
|
||||||
|
if "ignoreIdenticalResends" in data["feature"]: s.setBoolean(["feature", "ignoreIdenticalResends"], data["feature"]["ignoreIdenticalResends"])
|
||||||
|
|
||||||
if "serial" in data.keys():
|
if "serial" in data.keys():
|
||||||
if "autoconnect" in data["serial"].keys(): s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"])
|
if "autoconnect" in data["serial"].keys(): s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"])
|
||||||
@@ -248,6 +263,15 @@ def setSettings():
|
|||||||
continue
|
continue
|
||||||
s.saveScript("gcode", name, script.replace("\r\n", "\n").replace("\r", "\n"))
|
s.saveScript("gcode", name, script.replace("\r\n", "\n").replace("\r", "\n"))
|
||||||
|
|
||||||
|
if "server" in data:
|
||||||
|
if "commands" in data["server"]:
|
||||||
|
if "systemShutdownCommand" in data["server"]["commands"].keys(): s.set(["server", "commands", "systemShutdownCommand"], data["server"]["commands"]["systemShutdownCommand"])
|
||||||
|
if "systemRestartCommand" in data["server"]["commands"].keys(): s.set(["server", "commands", "systemRestartCommand"], data["server"]["commands"]["systemRestartCommand"])
|
||||||
|
if "serverRestartCommand" in data["server"]["commands"].keys(): s.set(["server", "commands", "serverRestartCommand"], data["server"]["commands"]["serverRestartCommand"])
|
||||||
|
if "diskspace" in data["server"]:
|
||||||
|
if "warning" in data["server"]["diskspace"]: s.setInt(["server", "diskspace", "warning"], data["server"]["diskspace"]["warning"])
|
||||||
|
if "critical" in data["server"]["diskspace"]: s.setInt(["server", "diskspace", "critical"], data["server"]["diskspace"]["critical"])
|
||||||
|
|
||||||
if "plugins" in data:
|
if "plugins" in data:
|
||||||
for plugin in octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SettingsPlugin):
|
for plugin in octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SettingsPlugin):
|
||||||
plugin_id = plugin._identifier
|
plugin_id = plugin._identifier
|
||||||
|
|||||||
@@ -10,10 +10,15 @@ from flask import Blueprint, request, make_response, jsonify
|
|||||||
|
|
||||||
import octoprint.server
|
import octoprint.server
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
|
from octoprint.server.util import noCachingResponseHandler, corsResponseHandler
|
||||||
from octoprint.settings import settings as s
|
from octoprint.settings import settings as s
|
||||||
|
|
||||||
apps = Blueprint("apps", __name__)
|
apps = Blueprint("apps", __name__)
|
||||||
|
|
||||||
|
apps.after_request(noCachingResponseHandler)
|
||||||
|
apps.after_request(corsResponseHandler)
|
||||||
|
|
||||||
@apps.route("/auth", methods=["GET"])
|
@apps.route("/auth", methods=["GET"])
|
||||||
def getSessionKey():
|
def getSessionKey():
|
||||||
unverified_key, valid_until = octoprint.server.appSessionManager.create()
|
unverified_key, valid_until = octoprint.server.appSessionManager.create()
|
||||||
|
|||||||
@@ -80,6 +80,18 @@ def corsResponseHandler(resp):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
def noCachingResponseHandler(resp):
|
||||||
|
"""
|
||||||
|
``after_request`` handler for blueprints which shall set no caching headers
|
||||||
|
on their responses.
|
||||||
|
|
||||||
|
Sets ``Cache-Control``, ``Pragma`` and ``Expires`` headers accordingly
|
||||||
|
to prevent all client side caching from taking place.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return flask.add_non_caching_response_headers(resp)
|
||||||
|
|
||||||
|
|
||||||
def optionsAllowOrigin(request):
|
def optionsAllowOrigin(request):
|
||||||
"""
|
"""
|
||||||
Shortcut for request handling for CORS OPTIONS requests to set CORS headers.
|
Shortcut for request handling for CORS OPTIONS requests to set CORS headers.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import uuid
|
|||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
import netaddr
|
import netaddr
|
||||||
|
import os
|
||||||
|
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings
|
||||||
import octoprint.server
|
import octoprint.server
|
||||||
@@ -122,12 +123,19 @@ def enable_additional_translations(default_locale="en", additional_folders=None)
|
|||||||
|
|
||||||
def fix_webassets_cache():
|
def fix_webassets_cache():
|
||||||
from webassets import cache
|
from webassets import cache
|
||||||
import os
|
|
||||||
import tempfile
|
error_logger = logging.getLogger(__name__ + ".fix_webassets_cache")
|
||||||
import pickle
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
def fixed_set(self, key, data):
|
def fixed_set(self, key, data):
|
||||||
|
import os
|
||||||
|
import tempfile
|
||||||
|
import pickle
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
if not os.path.exists(self.directory):
|
||||||
|
error_logger.warn("Cache directory {} doesn't exist, not going "
|
||||||
|
"to attempt to write cache file".format(self.directory))
|
||||||
|
|
||||||
md5 = '%s' % cache.make_md5(self.V, key)
|
md5 = '%s' % cache.make_md5(self.V, key)
|
||||||
filename = os.path.join(self.directory, md5)
|
filename = os.path.join(self.directory, md5)
|
||||||
fd, temp_filename = tempfile.mkstemp(prefix='.' + md5,
|
fd, temp_filename = tempfile.mkstemp(prefix='.' + md5,
|
||||||
@@ -147,6 +155,11 @@ def fix_webassets_cache():
|
|||||||
import warnings
|
import warnings
|
||||||
from webassets.cache import make_md5
|
from webassets.cache import make_md5
|
||||||
|
|
||||||
|
if not os.path.exists(self.directory):
|
||||||
|
error_logger.warn("Cache directory {} doesn't exist, not going "
|
||||||
|
"to attempt to read cache file".format(self.directory))
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hash = make_md5(self.V, key)
|
hash = make_md5(self.V, key)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
@@ -174,6 +187,37 @@ def fix_webassets_cache():
|
|||||||
cache.FilesystemCache.set = fixed_set
|
cache.FilesystemCache.set = fixed_set
|
||||||
cache.FilesystemCache.get = fixed_get
|
cache.FilesystemCache.get = fixed_get
|
||||||
|
|
||||||
|
def fix_webassets_filtertool():
|
||||||
|
from webassets.merge import FilterTool, log, MemoryHunk
|
||||||
|
|
||||||
|
error_logger = logging.getLogger(__name__ + ".fix_webassets_filtertool")
|
||||||
|
|
||||||
|
def fixed_wrap_cache(self, key, func):
|
||||||
|
"""Return cache value ``key``, or run ``func``.
|
||||||
|
"""
|
||||||
|
if self.cache:
|
||||||
|
if not self.no_cache_read:
|
||||||
|
log.debug('Checking cache for key %s', key)
|
||||||
|
content = self.cache.get(key)
|
||||||
|
if not content in (False, None):
|
||||||
|
log.debug('Using cached result for %s', key)
|
||||||
|
return MemoryHunk(content)
|
||||||
|
|
||||||
|
try:
|
||||||
|
content = func().getvalue()
|
||||||
|
if self.cache:
|
||||||
|
try:
|
||||||
|
log.debug('Storing result in cache with key %s', key,)
|
||||||
|
self.cache.set(key, content)
|
||||||
|
except:
|
||||||
|
error_logger.exception("Got an exception while trying to save file to cache, not caching")
|
||||||
|
return MemoryHunk(content)
|
||||||
|
except:
|
||||||
|
error_logger.exception("Got an exception while trying to apply filter, ignoring file")
|
||||||
|
return MemoryHunk(u"")
|
||||||
|
|
||||||
|
FilterTool._wrap_cache = fixed_wrap_cache
|
||||||
|
|
||||||
#~~ passive login helper
|
#~~ passive login helper
|
||||||
|
|
||||||
def passive_login():
|
def passive_login():
|
||||||
@@ -215,7 +259,7 @@ def passive_login():
|
|||||||
|
|
||||||
_cache = SimpleCache()
|
_cache = SimpleCache()
|
||||||
|
|
||||||
def cached(timeout=5 * 60, key=lambda: "view/%s" % flask.request.path, unless=None, refreshif=None):
|
def cached(timeout=5 * 60, key=lambda: "view/%s" % flask.request.path, unless=None, refreshif=None, unless_response=None):
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
@functools.wraps(f)
|
@functools.wraps(f)
|
||||||
def decorated_function(*args, **kwargs):
|
def decorated_function(*args, **kwargs):
|
||||||
@@ -244,6 +288,11 @@ def cached(timeout=5 * 60, key=lambda: "view/%s" % flask.request.path, unless=No
|
|||||||
logger.debug("No cache entry or refreshing cache for {path}, calling wrapped function".format(path=flask.request.path))
|
logger.debug("No cache entry or refreshing cache for {path}, calling wrapped function".format(path=flask.request.path))
|
||||||
rv = f(*args, **kwargs)
|
rv = f(*args, **kwargs)
|
||||||
|
|
||||||
|
# do not store if the "unless_response" condition is true
|
||||||
|
if callable(unless_response) and unless_response(rv):
|
||||||
|
logger.debug("Not caching result for {path}, bypassed".format(path=flask.request.path))
|
||||||
|
return rv
|
||||||
|
|
||||||
# store it in the cache
|
# store it in the cache
|
||||||
_cache.set(cache_key, rv, timeout=timeout)
|
_cache.set(cache_key, rv, timeout=timeout)
|
||||||
|
|
||||||
@@ -256,6 +305,31 @@ def cached(timeout=5 * 60, key=lambda: "view/%s" % flask.request.path, unless=No
|
|||||||
def cache_check_headers():
|
def cache_check_headers():
|
||||||
return "no-cache" in flask.request.cache_control or "no-cache" in flask.request.pragma
|
return "no-cache" in flask.request.cache_control or "no-cache" in flask.request.pragma
|
||||||
|
|
||||||
|
def cache_check_response_headers(response):
|
||||||
|
if not isinstance(response, flask.Response):
|
||||||
|
return False
|
||||||
|
|
||||||
|
headers = response.headers
|
||||||
|
|
||||||
|
if "Cache-Control" in headers and "no-cache" in headers["Cache-Control"]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if "Pragma" in headers and "no-cache" in headers["Pragma"]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if "Expires" in headers and headers["Expires"] in ("0", "-1"):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def add_non_caching_response_headers(response):
|
||||||
|
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0"
|
||||||
|
response.headers["Pragma"] = "no-cache"
|
||||||
|
response.headers["Expires"] = "-1"
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
#~~ access validators for use with tornado
|
#~~ access validators for use with tornado
|
||||||
|
|
||||||
|
|
||||||
@@ -534,7 +608,9 @@ class SettingsCheckUpdater(webassets.updater.BaseUpdater):
|
|||||||
|
|
||||||
##~~ plugin assets collector
|
##~~ plugin assets collector
|
||||||
|
|
||||||
def collect_plugin_assets(enable_gcodeviewer=True, enable_timelapse=True, preferred_stylesheet="css"):
|
def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
|
||||||
|
logger = logging.getLogger(__name__ + ".collect_plugin_assets")
|
||||||
|
|
||||||
supported_stylesheets = ("css", "less")
|
supported_stylesheets = ("css", "less")
|
||||||
assets = dict(
|
assets = dict(
|
||||||
js=[],
|
js=[],
|
||||||
@@ -555,6 +631,7 @@ def collect_plugin_assets(enable_gcodeviewer=True, enable_timelapse=True, prefer
|
|||||||
'js/app/viewmodels/slicing.js',
|
'js/app/viewmodels/slicing.js',
|
||||||
'js/app/viewmodels/temperature.js',
|
'js/app/viewmodels/temperature.js',
|
||||||
'js/app/viewmodels/terminal.js',
|
'js/app/viewmodels/terminal.js',
|
||||||
|
'js/app/viewmodels/timelapse.js',
|
||||||
'js/app/viewmodels/users.js',
|
'js/app/viewmodels/users.js',
|
||||||
'js/app/viewmodels/log.js',
|
'js/app/viewmodels/log.js',
|
||||||
'js/app/viewmodels/usersettings.js'
|
'js/app/viewmodels/usersettings.js'
|
||||||
@@ -566,8 +643,6 @@ def collect_plugin_assets(enable_gcodeviewer=True, enable_timelapse=True, prefer
|
|||||||
'gcodeviewer/js/gCodeReader.js',
|
'gcodeviewer/js/gCodeReader.js',
|
||||||
'gcodeviewer/js/renderer.js'
|
'gcodeviewer/js/renderer.js'
|
||||||
]
|
]
|
||||||
if enable_timelapse:
|
|
||||||
assets["js"].append('js/app/viewmodels/timelapse.js')
|
|
||||||
|
|
||||||
if preferred_stylesheet == "less":
|
if preferred_stylesheet == "less":
|
||||||
assets["less"].append('less/octoprint.less')
|
assets["less"].append('less/octoprint.less')
|
||||||
@@ -577,14 +652,29 @@ def collect_plugin_assets(enable_gcodeviewer=True, enable_timelapse=True, prefer
|
|||||||
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
|
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
|
||||||
for implementation in asset_plugins:
|
for implementation in asset_plugins:
|
||||||
name = implementation._identifier
|
name = implementation._identifier
|
||||||
all_assets = implementation.get_assets()
|
try:
|
||||||
|
all_assets = implementation.get_assets()
|
||||||
|
basefolder = implementation.get_asset_folder()
|
||||||
|
except:
|
||||||
|
logger.exception("Got an error while trying to collect assets from {}, ignoring assets from the plugin".format(name))
|
||||||
|
continue
|
||||||
|
|
||||||
|
def asset_exists(category, asset):
|
||||||
|
exists = os.path.exists(os.path.join(basefolder, asset))
|
||||||
|
if not exists:
|
||||||
|
logger.warn("Plugin {} is referring to non existing {} asset {}".format(name, category, asset))
|
||||||
|
return exists
|
||||||
|
|
||||||
if "js" in all_assets:
|
if "js" in all_assets:
|
||||||
for asset in all_assets["js"]:
|
for asset in all_assets["js"]:
|
||||||
|
if not asset_exists("js", asset):
|
||||||
|
continue
|
||||||
assets["js"].append('plugin/{name}/{asset}'.format(**locals()))
|
assets["js"].append('plugin/{name}/{asset}'.format(**locals()))
|
||||||
|
|
||||||
if preferred_stylesheet in all_assets:
|
if preferred_stylesheet in all_assets:
|
||||||
for asset in all_assets[preferred_stylesheet]:
|
for asset in all_assets[preferred_stylesheet]:
|
||||||
|
if not asset_exists(preferred_stylesheet, asset):
|
||||||
|
continue
|
||||||
assets[preferred_stylesheet].append('plugin/{name}/{asset}'.format(**locals()))
|
assets[preferred_stylesheet].append('plugin/{name}/{asset}'.format(**locals()))
|
||||||
else:
|
else:
|
||||||
for stylesheet in supported_stylesheets:
|
for stylesheet in supported_stylesheets:
|
||||||
@@ -592,6 +682,8 @@ def collect_plugin_assets(enable_gcodeviewer=True, enable_timelapse=True, prefer
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for asset in all_assets[stylesheet]:
|
for asset in all_assets[stylesheet]:
|
||||||
|
if not asset_exists(stylesheet, asset):
|
||||||
|
continue
|
||||||
assets[stylesheet].append('plugin/{name}/{asset}'.format(**locals()))
|
assets[stylesheet].append('plugin/{name}/{asset}'.format(**locals()))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,13 @@ class PrinterStateConnection(sockjs.tornado.SockJSConnection, octoprint.printer.
|
|||||||
plugin_hash.update(",".join(ui_plugins))
|
plugin_hash.update(",".join(ui_plugins))
|
||||||
|
|
||||||
# connected => update the API key, might be necessary if the client was left open while the server restarted
|
# connected => update the API key, might be necessary if the client was left open while the server restarted
|
||||||
self._emit("connected", {"apikey": octoprint.server.UI_API_KEY, "version": octoprint.server.VERSION, "display_version": octoprint.server.DISPLAY_VERSION, "plugin_hash": plugin_hash.hexdigest()})
|
self._emit("connected", {
|
||||||
|
"apikey": octoprint.server.UI_API_KEY,
|
||||||
|
"version": octoprint.server.VERSION,
|
||||||
|
"display_version": octoprint.server.DISPLAY_VERSION,
|
||||||
|
"branch": octoprint.server.BRANCH,
|
||||||
|
"plugin_hash": plugin_hash.hexdigest()
|
||||||
|
})
|
||||||
|
|
||||||
self._printer.register_callback(self)
|
self._printer.register_callback(self)
|
||||||
self._fileManager.register_slicingprogress_callback(self)
|
self._fileManager.register_slicingprogress_callback(self)
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ class UploadStorageFallbackHandler(tornado.web.RequestHandler):
|
|||||||
self._on_part_header(self._buffer[delimiter_len+2:end_of_header])
|
self._on_part_header(self._buffer[delimiter_len+2:end_of_header])
|
||||||
self._buffer = self._buffer[end_of_header + 4:]
|
self._buffer = self._buffer[end_of_header + 4:]
|
||||||
|
|
||||||
if delimiter_loc != -1 and self._buffer[delimiter_len:delimiter_len+2] == "--":
|
if delimiter_loc != -1 and self._buffer.strip() == delimiter + "--":
|
||||||
# we saw the last boundary and are at the end of our request
|
# we saw the last boundary and are at the end of our request
|
||||||
if self._current_part:
|
if self._current_part:
|
||||||
self._on_part_finish(self._current_part)
|
self._on_part_finish(self._current_part)
|
||||||
@@ -360,13 +360,24 @@ class UploadStorageFallbackHandler(tornado.web.RequestHandler):
|
|||||||
for name, part in self._parts.iteritems():
|
for name, part in self._parts.iteritems():
|
||||||
if "filename" in part:
|
if "filename" in part:
|
||||||
# add form fields for filename, path, size and content_type for all files contained in the request
|
# add form fields for filename, path, size and content_type for all files contained in the request
|
||||||
fields = dict((self._suffixes[key], value) for (key, value) in dict(name=part["filename"], path=part["path"], size=str(os.stat(part["path"]).st_size), content_type=part["content_type"]).iteritems())
|
if not "path" in part:
|
||||||
|
continue
|
||||||
|
|
||||||
|
parameters = dict(
|
||||||
|
name=part["filename"],
|
||||||
|
path=part["path"],
|
||||||
|
size=str(os.stat(part["path"]).st_size)
|
||||||
|
)
|
||||||
|
if "content_type" in part:
|
||||||
|
parameters["content_type"] = part["content_type"]
|
||||||
|
|
||||||
|
fields = dict((self._suffixes[key], value) for (key, value) in parameters.iteritems())
|
||||||
for n, p in fields.iteritems():
|
for n, p in fields.iteritems():
|
||||||
key = name + "." + n
|
key = name + "." + n
|
||||||
self._new_body += b"--%s\r\n" % self._multipart_boundary
|
self._new_body += b"--%s\r\n" % self._multipart_boundary
|
||||||
self._new_body += b"Content-Disposition: form-data; name=\"%s\"\r\n" % key
|
self._new_body += b"Content-Disposition: form-data; name=\"%s\"\r\n" % key
|
||||||
self._new_body += b"\r\n"
|
self._new_body += b"\r\n"
|
||||||
self._new_body += p + b"\r\n"
|
self._new_body += b"%s\r\n" % p
|
||||||
elif "data" in part:
|
elif "data" in part:
|
||||||
self._new_body += b"--%s\r\n" % self._multipart_boundary
|
self._new_body += b"--%s\r\n" % self._multipart_boundary
|
||||||
value = part["data"]
|
value = part["data"]
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ class GcodeWatchdogHandler(watchdog.events.PatternMatchingEventHandler):
|
|||||||
file_wrapper.filename,
|
file_wrapper.filename,
|
||||||
file_wrapper,
|
file_wrapper,
|
||||||
allow_overwrite=True)
|
allow_overwrite=True)
|
||||||
|
if os.path.exists(path):
|
||||||
|
try:
|
||||||
|
os.remove(path)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while trying to clear a file from the watched folder")
|
||||||
|
|
||||||
def on_created(self, event):
|
def on_created(self, event):
|
||||||
self._upload(event.src_path)
|
self._upload(event.src_path)
|
||||||
@@ -12,7 +12,8 @@ from flask import request, g, url_for, make_response, render_template, send_from
|
|||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
from octoprint.server import app, userManager, pluginManager, gettext, debug, LOCALES, VERSION, DISPLAY_VERSION, UI_API_KEY
|
from octoprint.server import app, userManager, pluginManager, gettext, \
|
||||||
|
debug, LOCALES, VERSION, DISPLAY_VERSION, UI_API_KEY, BRANCH
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings
|
||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
@@ -21,7 +22,9 @@ import logging
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@util.flask.cached(refreshif=lambda: util.flask.cache_check_headers() or "_refresh" in request.values, key=lambda: "view/%s/%s" % (request.path, g.locale))
|
@util.flask.cached(refreshif=lambda: util.flask.cache_check_headers() or "_refresh" in request.values,
|
||||||
|
key=lambda: "view/%s/%s" % (request.path, g.locale),
|
||||||
|
unless_response=util.flask.cache_check_response_headers)
|
||||||
def index():
|
def index():
|
||||||
|
|
||||||
#~~ a bunch of settings
|
#~~ a bunch of settings
|
||||||
@@ -148,6 +151,7 @@ def index():
|
|||||||
folders=(gettext("Folders"), dict(template="dialogs/settings/folders.jinja2", _div="settings_folders", custom_bindings=False)),
|
folders=(gettext("Folders"), dict(template="dialogs/settings/folders.jinja2", _div="settings_folders", custom_bindings=False)),
|
||||||
appearance=(gettext("Appearance"), dict(template="dialogs/settings/appearance.jinja2", _div="settings_appearance", custom_bindings=False)),
|
appearance=(gettext("Appearance"), dict(template="dialogs/settings/appearance.jinja2", _div="settings_appearance", custom_bindings=False)),
|
||||||
logs=(gettext("Logs"), dict(template="dialogs/settings/logs.jinja2", _div="settings_logs")),
|
logs=(gettext("Logs"), dict(template="dialogs/settings/logs.jinja2", _div="settings_logs")),
|
||||||
|
server=(gettext("Server"), dict(template="dialogs/settings/server.jinja2", _div="settings_server", custom_bindings=False)),
|
||||||
)
|
)
|
||||||
if enable_accesscontrol:
|
if enable_accesscontrol:
|
||||||
templates["settings"]["entries"]["accesscontrol"] = (gettext("Access Control"), dict(template="dialogs/settings/accesscontrol.jinja2", _div="settings_users", custom_bindings=False))
|
templates["settings"]["entries"]["accesscontrol"] = (gettext("Access Control"), dict(template="dialogs/settings/accesscontrol.jinja2", _div="settings_users", custom_bindings=False))
|
||||||
@@ -170,17 +174,21 @@ def index():
|
|||||||
name = implementation._identifier
|
name = implementation._identifier
|
||||||
plugin_names.add(name)
|
plugin_names.add(name)
|
||||||
|
|
||||||
vars = implementation.get_template_vars()
|
try:
|
||||||
|
vars = implementation.get_template_vars()
|
||||||
|
configs = implementation.get_template_configs()
|
||||||
|
except:
|
||||||
|
_logger.exception("Error while retrieving template data for plugin {}, ignoring it".format(name))
|
||||||
|
continue
|
||||||
|
|
||||||
if not isinstance(vars, dict):
|
if not isinstance(vars, dict):
|
||||||
vars = dict()
|
vars = dict()
|
||||||
|
if not isinstance(configs, (list, tuple)):
|
||||||
|
configs = []
|
||||||
|
|
||||||
for var_name, var_value in vars.items():
|
for var_name, var_value in vars.items():
|
||||||
plugin_vars["plugin_" + name + "_" + var_name] = var_value
|
plugin_vars["plugin_" + name + "_" + var_name] = var_value
|
||||||
|
|
||||||
configs = implementation.get_template_configs()
|
|
||||||
if not isinstance(configs, (list, tuple)):
|
|
||||||
configs = []
|
|
||||||
|
|
||||||
includes = _process_template_configs(name, implementation, configs, template_rules)
|
includes = _process_template_configs(name, implementation, configs, template_rules)
|
||||||
|
|
||||||
for t in template_types:
|
for t in template_types:
|
||||||
@@ -223,9 +231,30 @@ def index():
|
|||||||
# finally add anything that's not included in our order yet
|
# finally add anything that's not included in our order yet
|
||||||
sorted_missing = list(missing_in_order)
|
sorted_missing = list(missing_in_order)
|
||||||
if template_sorting[t]["key"] is not None:
|
if template_sorting[t]["key"] is not None:
|
||||||
# anything but navbar and generic components get sorted by their name
|
# default extractor: works with entries that are dicts and entries that are 2-tuples with the
|
||||||
if template_sorting[t]["key"] == "name":
|
# entry data at index 1
|
||||||
sorted_missing = sorted(missing_in_order, key=lambda x: templates[t]["entries"][x][0])
|
def extractor(item, key):
|
||||||
|
if isinstance(item, dict) and key in item:
|
||||||
|
return item[key]
|
||||||
|
elif isinstance(item, tuple) and len(item) > 1 and isinstance(item[1], dict) and key in item[1]:
|
||||||
|
return item[1][key]
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
# if template type provides custom extractor, make sure its exceptions are handled
|
||||||
|
if "key_extractor" in template_sorting[t] and callable(template_sorting[t]["key_extractor"]):
|
||||||
|
def create_safe_extractor(extractor):
|
||||||
|
def f(x, k):
|
||||||
|
try:
|
||||||
|
return extractor(x, k)
|
||||||
|
except:
|
||||||
|
_logger.exception("Error while extracting sorting keys for template {}".format(t))
|
||||||
|
return None
|
||||||
|
return f
|
||||||
|
extractor = create_safe_extractor(template_sorting[t]["key_extractor"])
|
||||||
|
|
||||||
|
sort_key = template_sorting[t]["key"]
|
||||||
|
sorted_missing = sorted(missing_in_order, key=lambda x: extractor(templates[t]["entries"][x], sort_key))
|
||||||
|
|
||||||
if template_sorting[t]["add"] == "prepend":
|
if template_sorting[t]["add"] == "prepend":
|
||||||
templates[t]["order"] = sorted_missing + templates[t]["order"]
|
templates[t]["order"] = sorted_missing + templates[t]["order"]
|
||||||
@@ -240,15 +269,17 @@ def index():
|
|||||||
|
|
||||||
#~~ prepare full set of template vars for rendering
|
#~~ prepare full set of template vars for rendering
|
||||||
|
|
||||||
|
first_run = settings().getBoolean(["server", "firstRun"]) and (userManager is None or not userManager.hasBeenCustomized())
|
||||||
render_kwargs = dict(
|
render_kwargs = dict(
|
||||||
webcamStream=settings().get(["webcam", "stream"]),
|
webcamStream=settings().get(["webcam", "stream"]),
|
||||||
enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]),
|
enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]),
|
||||||
enableAccessControl=userManager is not None,
|
enableAccessControl=userManager is not None,
|
||||||
enableSdSupport=settings().get(["feature", "sdSupport"]),
|
enableSdSupport=settings().get(["feature", "sdSupport"]),
|
||||||
firstRun=settings().getBoolean(["server", "firstRun"]) and (userManager is None or not userManager.hasBeenCustomized()),
|
firstRun=first_run,
|
||||||
debug=debug,
|
debug=debug,
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
display_version=DISPLAY_VERSION,
|
display_version=DISPLAY_VERSION,
|
||||||
|
branch=BRANCH,
|
||||||
gcodeMobileThreshold=settings().get(["gcodeViewer", "mobileSizeThreshold"]),
|
gcodeMobileThreshold=settings().get(["gcodeViewer", "mobileSizeThreshold"]),
|
||||||
gcodeThreshold=settings().get(["gcodeViewer", "sizeThreshold"]),
|
gcodeThreshold=settings().get(["gcodeViewer", "sizeThreshold"]),
|
||||||
uiApiKey=UI_API_KEY,
|
uiApiKey=UI_API_KEY,
|
||||||
@@ -260,10 +291,18 @@ def index():
|
|||||||
|
|
||||||
#~~ render!
|
#~~ render!
|
||||||
|
|
||||||
return render_template(
|
import datetime
|
||||||
|
|
||||||
|
response = make_response(render_template(
|
||||||
"index.jinja2",
|
"index.jinja2",
|
||||||
**render_kwargs
|
**render_kwargs
|
||||||
)
|
))
|
||||||
|
response.headers["Last-Modified"] = datetime.datetime.now()
|
||||||
|
|
||||||
|
if first_run:
|
||||||
|
response = util.flask.add_non_caching_response_headers(response)
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def _process_template_configs(name, implementation, configs, rules):
|
def _process_template_configs(name, implementation, configs, rules):
|
||||||
@@ -302,6 +341,8 @@ def _process_template_configs(name, implementation, configs, rules):
|
|||||||
app.jinja_env.get_or_select_template(data["template"])
|
app.jinja_env.get_or_select_template(data["template"])
|
||||||
except TemplateNotFound:
|
except TemplateNotFound:
|
||||||
pass
|
pass
|
||||||
|
except:
|
||||||
|
_logger.exception("Error in template {}, not going to include it".format(data["template"]))
|
||||||
else:
|
else:
|
||||||
includes[template_type].append(rule["to_entry"](data))
|
includes[template_type].append(rule["to_entry"](data))
|
||||||
|
|
||||||
|
|||||||
+31
-11
@@ -104,6 +104,15 @@ default_settings = {
|
|||||||
"pathSuffix": "path"
|
"pathSuffix": "path"
|
||||||
},
|
},
|
||||||
"maxSize": 100 * 1024, # 100 KB
|
"maxSize": 100 * 1024, # 100 KB
|
||||||
|
"commands": {
|
||||||
|
"systemShutdownCommand": None,
|
||||||
|
"systemRestartCommand": None,
|
||||||
|
"serverRestartCommand": None
|
||||||
|
},
|
||||||
|
"diskspace": {
|
||||||
|
"warning": 500 * 1024 * 1024, # 500 MB
|
||||||
|
"critical": 200 * 1024 * 1024, # 200 MB
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"webcam": {
|
"webcam": {
|
||||||
"stream": None,
|
"stream": None,
|
||||||
@@ -142,7 +151,10 @@ default_settings = {
|
|||||||
"repetierTargetTemp": False,
|
"repetierTargetTemp": False,
|
||||||
"externalHeatupDetection": True,
|
"externalHeatupDetection": True,
|
||||||
"supportWait": True,
|
"supportWait": True,
|
||||||
"keyboardControl": True
|
"keyboardControl": True,
|
||||||
|
"pollWatched": False,
|
||||||
|
"ignoreIdenticalResends": False,
|
||||||
|
"identicalResendsCountdown": 7
|
||||||
},
|
},
|
||||||
"folder": {
|
"folder": {
|
||||||
"uploads": None,
|
"uploads": None,
|
||||||
@@ -187,7 +199,7 @@ default_settings = {
|
|||||||
"settings": [
|
"settings": [
|
||||||
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
|
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
|
||||||
"section_features", "features", "webcam", "accesscontrol", "api",
|
"section_features", "features", "webcam", "accesscontrol", "api",
|
||||||
"section_octoprint", "folders", "appearance", "logs", "plugin_pluginmanager", "plugin_softwareupdate"
|
"section_octoprint", "server", "folders", "appearance", "logs", "plugin_pluginmanager", "plugin_softwareupdate"
|
||||||
],
|
],
|
||||||
"usersettings": ["access", "interface"],
|
"usersettings": ["access", "interface"],
|
||||||
"generic": []
|
"generic": []
|
||||||
@@ -270,6 +282,7 @@ default_settings = {
|
|||||||
},
|
},
|
||||||
"hasBed": True,
|
"hasBed": True,
|
||||||
"repetierStyleTargetTemperature": False,
|
"repetierStyleTargetTemperature": False,
|
||||||
|
"repetierStyleResends": False,
|
||||||
"okBeforeCommandOutput": False,
|
"okBeforeCommandOutput": False,
|
||||||
"smoothieTemperatureReporting": False,
|
"smoothieTemperatureReporting": False,
|
||||||
"extendedSdFileList": False,
|
"extendedSdFileList": False,
|
||||||
@@ -279,7 +292,8 @@ default_settings = {
|
|||||||
"txBuffer": 40,
|
"txBuffer": 40,
|
||||||
"commandBuffer": 4,
|
"commandBuffer": 4,
|
||||||
"sendWait": True,
|
"sendWait": True,
|
||||||
"waitInterval": 1.0
|
"waitInterval": 1.0,
|
||||||
|
"supportM112": True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,14 +334,14 @@ class Settings(object):
|
|||||||
|
|
||||||
"/dev/ttyACM0"
|
"/dev/ttyACM0"
|
||||||
|
|
||||||
``["serial", "timeouts"]`` ::
|
``["serial", "timeout"]`` ::
|
||||||
|
|
||||||
communication: 20.0
|
communication: 20.0
|
||||||
temperature: 5.0
|
temperature: 5.0
|
||||||
sdStatus: 1.0
|
sdStatus: 1.0
|
||||||
connection: 10.0
|
connection: 10.0
|
||||||
|
|
||||||
``["serial", "timeouts", "temperature"]`` ::
|
``["serial", "timeout", "temperature"]`` ::
|
||||||
|
|
||||||
5.0
|
5.0
|
||||||
|
|
||||||
@@ -773,11 +787,17 @@ class Settings(object):
|
|||||||
if not self._dirty and not force:
|
if not self._dirty and not force:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
with open(self._configfile, "wb") as configFile:
|
from octoprint.util import atomic_write
|
||||||
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=" ", allow_unicode=True)
|
try:
|
||||||
self._dirty = False
|
with atomic_write(self._configfile, "wb", prefix="octoprint-config-", suffix=".yaml") as configFile:
|
||||||
self.load()
|
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||||
return True
|
self._dirty = False
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while saving config.yaml!")
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
self.load()
|
||||||
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def last_modified(self):
|
def last_modified(self):
|
||||||
@@ -969,7 +989,7 @@ class Settings(object):
|
|||||||
if not force and key in defaults and key in config and defaults[key] == value:
|
if not force and key in defaults and key in config and defaults[key] == value:
|
||||||
del config[key]
|
del config[key]
|
||||||
self._dirty = True
|
self._dirty = True
|
||||||
elif force or (not key in config and defaults[key] != value) or (key in config and config[key] != value):
|
elif force or (not key in config and key in defaults and defaults[key] != value) or (key in config and config[key] != value):
|
||||||
if value is None and key in config:
|
if value is None and key in config:
|
||||||
del config[key]
|
del config[key]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import octoprint.plugin
|
|||||||
import octoprint.events
|
import octoprint.events
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
|
|
||||||
|
|
||||||
@@ -102,6 +104,8 @@ class SlicingManager(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, profile_path, printer_profile_manager):
|
def __init__(self, profile_path, printer_profile_manager):
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
self._profile_path = profile_path
|
self._profile_path = profile_path
|
||||||
self._printer_profile_manager = printer_profile_manager
|
self._printer_profile_manager = printer_profile_manager
|
||||||
|
|
||||||
@@ -123,7 +127,11 @@ class SlicingManager(object):
|
|||||||
plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SlicerPlugin)
|
plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SlicerPlugin)
|
||||||
slicers = dict()
|
slicers = dict()
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
slicers[plugin.get_slicer_properties()["type"]] = plugin
|
try:
|
||||||
|
slicers[plugin.get_slicer_properties()["type"]] = plugin
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while getting properties from slicer {}, ignoring it".format(plugin._identifier))
|
||||||
|
continue
|
||||||
self._slicers = slicers
|
self._slicers = slicers
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -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,0.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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*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:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.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:hover,.btn:focus{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:thin dotted #333;outline:5px auto -webkit-focus-ring-color;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.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.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,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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-warning:hover,.btn-warning:focus,.btn-warning:aLine 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,0.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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*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:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.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:hover,.btn:focus{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:thin dotted #333;outline:5px auto -webkit-focus-ring-color;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.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.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,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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-warning:hover,.btn-warning:focus,.btn-warning:aLine truncated
|
||||||
@@ -122,6 +122,7 @@ function DataUpdater(allViewModels) {
|
|||||||
var oldVersion = VERSION;
|
var oldVersion = VERSION;
|
||||||
VERSION = data["version"];
|
VERSION = data["version"];
|
||||||
DISPLAY_VERSION = data["display_version"];
|
DISPLAY_VERSION = data["display_version"];
|
||||||
|
BRANCH = data["branch"];
|
||||||
$("span.version").text(DISPLAY_VERSION);
|
$("span.version").text(DISPLAY_VERSION);
|
||||||
|
|
||||||
var oldPluginHash = self._pluginHash;
|
var oldPluginHash = self._pluginHash;
|
||||||
|
|||||||
@@ -333,6 +333,34 @@ function formatSize(bytes) {
|
|||||||
return _.sprintf("%.1f%s", bytes, "TB");
|
return _.sprintf("%.1f%s", bytes, "TB");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bytesFromSize(size) {
|
||||||
|
if (size == undefined || size.trim() == "") return undefined;
|
||||||
|
|
||||||
|
var parsed = size.match(/^([+]?[0-9]*\.?[0-9]+)(?:\s*)?(.*)$/);
|
||||||
|
var number = parsed[1];
|
||||||
|
var unit = parsed[2].trim();
|
||||||
|
|
||||||
|
if (unit == "") return parseFloat(number);
|
||||||
|
|
||||||
|
var units = {
|
||||||
|
b: 1,
|
||||||
|
byte: 1,
|
||||||
|
bytes: 1,
|
||||||
|
kb: 1024,
|
||||||
|
mb: Math.pow(1024, 2),
|
||||||
|
gb: Math.pow(1024, 3),
|
||||||
|
tb: Math.pow(1024, 4)
|
||||||
|
};
|
||||||
|
unit = unit.toLowerCase();
|
||||||
|
|
||||||
|
if (!units.hasOwnProperty(unit)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
var factor = units[unit];
|
||||||
|
return number * factor;
|
||||||
|
}
|
||||||
|
|
||||||
function formatDuration(seconds) {
|
function formatDuration(seconds) {
|
||||||
if (!seconds) return "-";
|
if (!seconds) return "-";
|
||||||
if (seconds < 0) return "00:00:00";
|
if (seconds < 0) return "00:00:00";
|
||||||
@@ -461,3 +489,17 @@ function splitTextToArray(text, sep, stripEmpty, filter) {
|
|||||||
function(item) { return (stripEmpty ? item : true) && (filter ? filter(item) : true); }
|
function(item) { return (stripEmpty ? item : true) && (filter ? filter(item) : true); }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sizeObservable = function(observable) {
|
||||||
|
return ko.computed({
|
||||||
|
read: function() {
|
||||||
|
return formatSize(observable());
|
||||||
|
},
|
||||||
|
write: function(value) {
|
||||||
|
var result = bytesFromSize(value);
|
||||||
|
if (result != undefined) {
|
||||||
|
observable(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
@@ -51,6 +51,7 @@ $(function() {
|
|||||||
//~~ Initialize PNotify
|
//~~ Initialize PNotify
|
||||||
|
|
||||||
PNotify.prototype.options.styling = "bootstrap2";
|
PNotify.prototype.options.styling = "bootstrap2";
|
||||||
|
PNotify.prototype.options.mouse_reset = false;
|
||||||
|
|
||||||
//~~ Initialize view models
|
//~~ Initialize view models
|
||||||
|
|
||||||
@@ -320,7 +321,7 @@ $(function() {
|
|||||||
.data("contextParent", $(this))
|
.data("contextParent", $(this))
|
||||||
.show()
|
.show()
|
||||||
.css({
|
.css({
|
||||||
position: "absolute",
|
position: "fixed",
|
||||||
left: getMenuPosition(e.clientX, 'width', 'scrollLeft'),
|
left: getMenuPosition(e.clientX, 'width', 'scrollLeft'),
|
||||||
top: getMenuPosition(e.clientY, 'height', 'scrollTop'),
|
top: getMenuPosition(e.clientY, 'height', 'scrollTop'),
|
||||||
"z-index": 9999
|
"z-index": 9999
|
||||||
|
|||||||
@@ -86,6 +86,15 @@ $(function() {
|
|||||||
self._processStateData(data.state);
|
self._processStateData(data.state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.openOrCloseOnStateChange = function() {
|
||||||
|
var connectionTab = $("#connection");
|
||||||
|
if (self.isOperational() && connectionTab.hasClass("in")) {
|
||||||
|
connectionTab.collapse("hide");
|
||||||
|
} else if (!self.isOperational() && !connectionTab.hasClass("in")) {
|
||||||
|
connectionTab.collapse("show");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self._processStateData = function(data) {
|
self._processStateData = function(data) {
|
||||||
self.previousIsOperational = self.isOperational();
|
self.previousIsOperational = self.isOperational();
|
||||||
|
|
||||||
@@ -97,15 +106,10 @@ $(function() {
|
|||||||
self.isReady(data.flags.ready);
|
self.isReady(data.flags.ready);
|
||||||
self.isLoading(data.flags.loading);
|
self.isLoading(data.flags.loading);
|
||||||
|
|
||||||
var connectionTab = $("#connection");
|
if (self.loginState.isAdmin() && self.previousIsOperational != self.isOperational()) {
|
||||||
if (self.previousIsOperational != self.isOperational()) {
|
// only open or close if the panel is visible (for admins) and
|
||||||
if (self.isOperational() && connectionTab.hasClass("in")) {
|
// the state just changed to avoid thwarting manual open/close
|
||||||
// connection just got established, close connection tab for now
|
self.openOrCloseOnStateChange();
|
||||||
connectionTab.collapse("hide");
|
|
||||||
} else if (!connectionTab.hasClass("in")) {
|
|
||||||
// connection just dropped, make sure connection tab is open
|
|
||||||
connectionTab.collapse("show");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -147,6 +151,16 @@ $(function() {
|
|||||||
|
|
||||||
self.onStartup = function() {
|
self.onStartup = function() {
|
||||||
self.requestData();
|
self.requestData();
|
||||||
|
|
||||||
|
// when isAdmin becomes true the first time, set the panel open or
|
||||||
|
// closed based on the connection state
|
||||||
|
var subscription = self.loginState.isAdmin.subscribe(function(newValue) {
|
||||||
|
if (newValue) {
|
||||||
|
// wait until after the isAdmin state has run through all subscriptions
|
||||||
|
setTimeout(self.openOrCloseOnStateChange, 0);
|
||||||
|
subscription.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ $(function() {
|
|||||||
function GcodeFilesViewModel(parameters) {
|
function GcodeFilesViewModel(parameters) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.printerState = parameters[0];
|
self.settingsViewModel = parameters[0];
|
||||||
self.loginState = parameters[1];
|
self.loginState = parameters[1];
|
||||||
self.slicing = parameters[2];
|
self.printerState = parameters[2];
|
||||||
|
self.slicing = parameters[3];
|
||||||
|
|
||||||
self.isErrorOrClosed = ko.observable(undefined);
|
self.isErrorOrClosed = ko.observable(undefined);
|
||||||
self.isOperational = ko.observable(undefined);
|
self.isOperational = ko.observable(undefined);
|
||||||
@@ -21,11 +22,35 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.freeSpace = ko.observable(undefined);
|
self.freeSpace = ko.observable(undefined);
|
||||||
|
self.totalSpace = ko.observable(undefined);
|
||||||
self.freeSpaceString = ko.computed(function() {
|
self.freeSpaceString = ko.computed(function() {
|
||||||
if (!self.freeSpace())
|
if (!self.freeSpace())
|
||||||
return "-";
|
return "-";
|
||||||
return formatSize(self.freeSpace());
|
return formatSize(self.freeSpace());
|
||||||
});
|
});
|
||||||
|
self.totalSpaceString = ko.computed(function() {
|
||||||
|
if (!self.totalSpace())
|
||||||
|
return "-";
|
||||||
|
return formatSize(self.totalSpace());
|
||||||
|
});
|
||||||
|
|
||||||
|
self.diskusageWarning = ko.computed(function() {
|
||||||
|
return self.freeSpace() != undefined
|
||||||
|
&& self.freeSpace() < self.settingsViewModel.server_diskspace_warning();
|
||||||
|
});
|
||||||
|
self.diskusageCritical = ko.computed(function() {
|
||||||
|
return self.freeSpace() != undefined
|
||||||
|
&& self.freeSpace() < self.settingsViewModel.server_diskspace_critical();
|
||||||
|
});
|
||||||
|
self.diskusageString = ko.computed(function() {
|
||||||
|
if (self.diskusageCritical()) {
|
||||||
|
return gettext("Your available free disk space is critically low.");
|
||||||
|
} else if (self.diskusageWarning()) {
|
||||||
|
return gettext("Your available free disk space is starting to run low.");
|
||||||
|
} else {
|
||||||
|
return gettext("Your current disk usage.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
self.uploadButton = undefined;
|
self.uploadButton = undefined;
|
||||||
|
|
||||||
@@ -47,8 +72,8 @@ $(function() {
|
|||||||
},
|
},
|
||||||
"size": function(a, b) {
|
"size": function(a, b) {
|
||||||
// sorts descending
|
// sorts descending
|
||||||
if (b["bytes"] === undefined || a["bytes"] > b["bytes"]) return -1;
|
if (b["size"] === undefined || a["size"] > b["size"]) return -1;
|
||||||
if (a["bytes"] < b["bytes"]) return 1;
|
if (a["size"] < b["size"]) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -155,10 +180,14 @@ $(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.free) {
|
if (response.free != undefined) {
|
||||||
self.freeSpace(response.free);
|
self.freeSpace(response.free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.total != undefined) {
|
||||||
|
self.totalSpace(response.total);
|
||||||
|
}
|
||||||
|
|
||||||
self.highlightFilename(self.printerState.filename());
|
self.highlightFilename(self.printerState.filename());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -309,18 +338,17 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.performSearch = function(e) {
|
self.performSearch = function(e) {
|
||||||
if (e !== undefined) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
var query = self.searchQuery();
|
var query = self.searchQuery();
|
||||||
if (query !== undefined && query.trim() != "") {
|
if (query !== undefined && query.trim() != "") {
|
||||||
|
query = query.toLocaleLowerCase();
|
||||||
self.listHelper.changeSearchFunction(function(entry) {
|
self.listHelper.changeSearchFunction(function(entry) {
|
||||||
return entry && entry["name"].toLocaleLowerCase().indexOf(query) > -1;
|
return entry && entry["name"].toLocaleLowerCase().indexOf(query) > -1;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
self.listHelper.resetSearch();
|
self.listHelper.resetSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.onDataUpdaterReconnect = function() {
|
self.onDataUpdaterReconnect = function() {
|
||||||
@@ -576,7 +604,7 @@ $(function() {
|
|||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push([
|
OCTOPRINT_VIEWMODELS.push([
|
||||||
GcodeFilesViewModel,
|
GcodeFilesViewModel,
|
||||||
["printerStateViewModel", "loginStateViewModel", "slicingViewModel"],
|
["settingsViewModel", "loginStateViewModel", "printerStateViewModel", "slicingViewModel"],
|
||||||
"#files_wrapper"
|
"#files_wrapper"
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -6,6 +6,10 @@ $(function() {
|
|||||||
self.users = parameters[1];
|
self.users = parameters[1];
|
||||||
self.printerProfiles = parameters[2];
|
self.printerProfiles = parameters[2];
|
||||||
|
|
||||||
|
self.receiving = ko.observable(false);
|
||||||
|
self.sending = ko.observable(false);
|
||||||
|
self.callbacks = [];
|
||||||
|
|
||||||
self.api_enabled = ko.observable(undefined);
|
self.api_enabled = ko.observable(undefined);
|
||||||
self.api_key = ko.observable(undefined);
|
self.api_key = ko.observable(undefined);
|
||||||
self.api_allowCrossOrigin = ko.observable(undefined);
|
self.api_allowCrossOrigin = ko.observable(undefined);
|
||||||
@@ -113,6 +117,8 @@ $(function() {
|
|||||||
self.feature_repetierTargetTemp = ko.observable(undefined);
|
self.feature_repetierTargetTemp = ko.observable(undefined);
|
||||||
self.feature_disableExternalHeatupDetection = ko.observable(undefined);
|
self.feature_disableExternalHeatupDetection = ko.observable(undefined);
|
||||||
self.feature_keyboardControl = ko.observable(undefined);
|
self.feature_keyboardControl = ko.observable(undefined);
|
||||||
|
self.feature_pollWatched = ko.observable(undefined);
|
||||||
|
self.feature_ignoreIdenticalResends = ko.observable(undefined);
|
||||||
|
|
||||||
self.serial_port = ko.observable();
|
self.serial_port = ko.observable();
|
||||||
self.serial_baudrate = ko.observable();
|
self.serial_baudrate = ko.observable();
|
||||||
@@ -148,6 +154,15 @@ $(function() {
|
|||||||
|
|
||||||
self.terminalFilters = ko.observableArray([]);
|
self.terminalFilters = ko.observableArray([]);
|
||||||
|
|
||||||
|
self.server_commands_systemShutdownCommand = ko.observable(undefined);
|
||||||
|
self.server_commands_systemRestartCommand = ko.observable(undefined);
|
||||||
|
self.server_commands_serverRestartCommand = ko.observable(undefined);
|
||||||
|
|
||||||
|
self.server_diskspace_warning = ko.observable();
|
||||||
|
self.server_diskspace_critical = ko.observable();
|
||||||
|
self.server_diskspace_warning_str = sizeObservable(self.server_diskspace_warning);
|
||||||
|
self.server_diskspace_critical_str = sizeObservable(self.server_diskspace_critical);
|
||||||
|
|
||||||
self.settings = undefined;
|
self.settings = undefined;
|
||||||
|
|
||||||
self.addTemperatureProfile = function() {
|
self.addTemperatureProfile = function() {
|
||||||
@@ -256,13 +271,42 @@ $(function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self.requestData = function(callback) {
|
self.requestData = function(callback) {
|
||||||
|
if (self.receiving()) {
|
||||||
|
if (callback) {
|
||||||
|
self.callbacks.push(callback);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.receiving(true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: API_BASEURL + "settings",
|
url: API_BASEURL + "settings",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
self.fromResponse(response);
|
if (callback) {
|
||||||
if (callback) callback();
|
self.callbacks.push(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
self.fromResponse(response);
|
||||||
|
|
||||||
|
var cb;
|
||||||
|
while (self.callbacks.length) {
|
||||||
|
cb = self.callbacks.shift();
|
||||||
|
try {
|
||||||
|
cb();
|
||||||
|
} catch(exc) {
|
||||||
|
log.error("Error calling settings callback", cb, ":", (exc.stack || exc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
self.receiving(false);
|
||||||
|
self.callbacks = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
self.receiving(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -377,6 +421,7 @@ $(function() {
|
|||||||
self.feature_repetierTargetTemp(response.feature.repetierTargetTemp);
|
self.feature_repetierTargetTemp(response.feature.repetierTargetTemp);
|
||||||
self.feature_disableExternalHeatupDetection(!response.feature.externalHeatupDetection);
|
self.feature_disableExternalHeatupDetection(!response.feature.externalHeatupDetection);
|
||||||
self.feature_keyboardControl(response.feature.keyboardControl);
|
self.feature_keyboardControl(response.feature.keyboardControl);
|
||||||
|
self.feature_pollWatched(response.feature.pollWatched);
|
||||||
|
|
||||||
self.serial_port(response.serial.port);
|
self.serial_port(response.serial.port);
|
||||||
self.serial_baudrate(response.serial.baudrate);
|
self.serial_baudrate(response.serial.baudrate);
|
||||||
@@ -413,12 +458,18 @@ $(function() {
|
|||||||
self.system_actions(response.system.actions);
|
self.system_actions(response.system.actions);
|
||||||
|
|
||||||
self.terminalFilters(response.terminalFilters);
|
self.terminalFilters(response.terminalFilters);
|
||||||
|
|
||||||
|
self.server_commands_systemShutdownCommand(response.server.commands.systemShutdownCommand);
|
||||||
|
self.server_commands_systemRestartCommand(response.server.commands.systemRestartCommand);
|
||||||
|
self.server_commands_serverRestartCommand(response.server.commands.serverRestartCommand);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.saveData = function (data, successCallback) {
|
self.saveData = function (data, successCallback) {
|
||||||
self.settingsDialog.trigger("beforeSave");
|
self.settingsDialog.trigger("beforeSave");
|
||||||
|
|
||||||
if (data == undefined) {
|
if (data == undefined) {
|
||||||
|
// we only set sending to true when we didn't include data
|
||||||
|
self.sending(true);
|
||||||
data = ko.mapping.toJS(self.settings);
|
data = ko.mapping.toJS(self.settings);
|
||||||
|
|
||||||
data = _.extend(data, {
|
data = _.extend(data, {
|
||||||
@@ -457,7 +508,8 @@ $(function() {
|
|||||||
"swallowOkAfterResend": self.feature_swallowOkAfterResend(),
|
"swallowOkAfterResend": self.feature_swallowOkAfterResend(),
|
||||||
"repetierTargetTemp": self.feature_repetierTargetTemp(),
|
"repetierTargetTemp": self.feature_repetierTargetTemp(),
|
||||||
"externalHeatupDetection": !self.feature_disableExternalHeatupDetection(),
|
"externalHeatupDetection": !self.feature_disableExternalHeatupDetection(),
|
||||||
"keyboardControl": self.feature_keyboardControl()
|
"keyboardControl": self.feature_keyboardControl(),
|
||||||
|
"pollWatched": self.feature_pollWatched()
|
||||||
},
|
},
|
||||||
"serial": {
|
"serial": {
|
||||||
"port": self.serial_port(),
|
"port": self.serial_port(),
|
||||||
@@ -496,6 +548,13 @@ $(function() {
|
|||||||
"beforePrintResumed": self.scripts_gcode_beforePrintResumed(),
|
"beforePrintResumed": self.scripts_gcode_beforePrintResumed(),
|
||||||
"afterPrinterConnected": self.scripts_gcode_afterPrinterConnected()
|
"afterPrinterConnected": self.scripts_gcode_afterPrinterConnected()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"commands": {
|
||||||
|
"systemShutdownCommand": self.server_commands_systemShutdownCommand(),
|
||||||
|
"systemRestartCommand": self.server_commands_systemRestartCommand(),
|
||||||
|
"serverRestartCommand": self.server_commands_serverRestartCommand()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -507,11 +566,24 @@ $(function() {
|
|||||||
contentType: "application/json; charset=UTF-8",
|
contentType: "application/json; charset=UTF-8",
|
||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
self.fromResponse(response);
|
self.receiving(true);
|
||||||
if (successCallback) successCallback(response);
|
self.sending(false);
|
||||||
|
try {
|
||||||
|
self.fromResponse(response);
|
||||||
|
if (successCallback) successCallback(response);
|
||||||
|
} finally {
|
||||||
|
self.receiving(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
self.sending(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.onEventSettingsUpdated = function() {
|
||||||
|
self.requestData();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
OCTOPRINT_VIEWMODELS.push([
|
OCTOPRINT_VIEWMODELS.push([
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ $(function() {
|
|||||||
self._processCurrentLogData = function(data) {
|
self._processCurrentLogData = function(data) {
|
||||||
self.log(self.log().concat(_.map(data, function(line) { return self._toInternalFormat(line) })));
|
self.log(self.log().concat(_.map(data, function(line) { return self._toInternalFormat(line) })));
|
||||||
if (self.autoscrollEnabled()) {
|
if (self.autoscrollEnabled()) {
|
||||||
self.log(self.log.slice(-300));
|
self.log(self.log.slice(-self.buffer()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -726,8 +726,9 @@
|
|||||||
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $(selector)
|
$parent = selector && (selector != "#") && $(selector)
|
||||||
$parent.length || ($parent = $this.parent())
|
|
||||||
|
if (!$parent || !$parent.length) $parent = $this.parent()
|
||||||
|
|
||||||
return $parent
|
return $parent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Bootstrap.js by @fat & @mdo
|
|
||||||
* Copyright 2012 Twitter, Inc.
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
|
||||||
*/
|
|
||||||
!function($){"use strict";$(function(){$.support.transition=function(){var transitionEnd=function(){var name,el=document.createElement("bootstrap"),transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(name in transEndEventNames)if(void 0!==el.style[name])return transEndEventNames[name]}();return transitionEnd&&{end:transitionEnd}}()})}(window.jQuery),!function($){"use strict";var dismiss='[data-dismiss="alert"]',Alert=function(el){$(el).on("click",dismiss,this.close)};Alert.prototype.close=function(e){function removeElement(){$parent.trigger("closed").remove()}var $parent,$this=$(this),selector=$this.attr("data-target");selector||(selector=$this.attr("href"),selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")),$parent=$(selector),e&&e.preventDefault(),$parent.length||($parent=$this.hasClass("alert")?$this:$this.parent()),$parent.trigger(e=$.Event("close")),e.isDefaultPrevented()||($parent.removeClass("in"),$.support.transition&&$parent.hasClass("fade")?$parent.on($.support.transition.end,removeElement):removeElement())};var old=$.fn.alert;$.fn.alert=function(option){return this.each(function(){var $this=$(this),data=$this.data("alert");data||$this.data("alert",data=new Alert(this)),"string"==typeof option&&data[option].call($this)})},$.fn.alert.Constructor=Alert,$.fn.alert.noConflict=function(){return $.fn.alert=old,this},$(document).on("click.alert.data-api",dismiss,Alert.prototype.close)}(window.jQuery),!function($){"use strict";var Button=function(element,options){this.$element=$(element),this.options=$.extend({},$.fn.button.defaults,options)};Button.prototype.setState=function(state){var d="disabled",$el=this.$element,data=$el.data(),val=$el.is("input")?"val":"html";state+="Text",data.resetText||$el.data("resetText",$el[val]()),$el[val](data[state]||this.options[state]),setTimeout(function(){"loadingText"==state?$el.addClass(d).attr(d,d):$el.removeClass(d).removeAttr(d)},0)},Button.prototype.toggle=function(){var $parent=this.$element.closest('[data-toggle="buttons-radio"]');$parent&&$parent.find(".active").removeClass("active"),this.$element.toggleClass("active")};var old=$.fn.button;$.fn.button=function(option){return this.each(function(){var $this=$(this),data=$this.data("button"),options="object"==typeof option&&option;data||$this.data("button",data=new Button(this,options)),"toggle"==option?data.toggle():option&&data.setState(option)})},$.fn.button.defaults={loadingText:"loading..."},$.fn.button.Constructor=Button,$.fn.button.noConflict=function(){return $.fn.button=old,this},$(document).on("click.button.data-api","[data-toggle^=button]",function(e){var $btn=$(e.target);$btn.hasClass("btn")||($btn=$btn.closest(".btn")),$btn.button("toggle")})}(window.jQuery),!function($){"use strict";var Carousel=function(element,options){this.$element=$(element),this.options=options,"hover"==this.options.pause&&this.$element.on("mouseenter",$.proxy(this.pause,this)).on("mouseleave",$.proxy(this.cycle,this))};Carousel.prototype={cycle:function(e){return e||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval($.proxy(this.next,this),this.options.interval)),this},to:function(pos){var $active=this.$element.find(".item.active"),children=$active.parent().children(),activePos=children.index($active),that=this;if(!(pos>children.length-1||0>pos))return this.sliding?this.$element.one("slid",function(){that.to(pos)}):activePos==pos?this.pause().cycle():this.slide(pos>activePos?"next":"prev",$(children[pos]))},pause:function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&$.support.transition.end&&(this.$element.trigger($.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){return this.sliding?void 0:this.slide("next")},prev:function(){return this.sliding?void 0:this.slide("prev")},slide:function(type,next){var e,$active=this.$element.find(".item.active"),$next=next||$active[type](),isCycling=this.interval,direction="next"==type?"left":"right",fallback="next"==type?"first":"last",that=this;if(this.sliding=!0,isCycling&&this.pause(),$next=$next.length?$next:this.$element.find(".item")[fallback](),e=$.Event("slide",{relatedTarget:$next[0]}),!$next.hasClass("active")){if($.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(e),e.isDefaultPrevented())return;$next.addClass(type),$next[0].offsetWidth,$active.addClass(direction),$next.addClass(direction),this.$element.one($.support.transition.end,function(){$next.removeClass([type,direction].join(" ")).addClass("active"),$active.removeClass(["active",direction].join(" ")),that.sliding=!1,setTimeout(function(){that.$element.trigger("slid")},0)})}else{if(this.$element.trigger(e),e.isDefaultPrevented())return;$active.removeClass("active"),$next.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return isCycling&&this.cycle()Line truncated
|
|
||||||
@@ -611,11 +611,11 @@ ul.dropdown-menu li a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom_section_horizontal .custom_control {
|
.custom_section_horizontal > .custom_control {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom_section_vertical .custom_control {
|
.custom_section_vertical > .custom_control {
|
||||||
display:block;
|
display:block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -975,6 +975,20 @@ textarea.block {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special delivery for Safari browsers... because Safari >= 8 sometimes just
|
||||||
|
// shows us white panes on the settings dialog when the full-sized-box has
|
||||||
|
// an absolute position (which it needs for both scrollbars to work), at least
|
||||||
|
// until the page is resized or otherwise a rerender is triggered, we'll have
|
||||||
|
// our styling resolve to static positioning on that browser for now.
|
||||||
|
//
|
||||||
|
// This btw also means that the dialog will change in size. Yay.
|
||||||
|
//
|
||||||
|
// Better use something else if you have the option, that thing is really
|
||||||
|
// weird.
|
||||||
|
_::-webkit-full-page-media, _:future, :root .full-sized-box {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
|
||||||
.scrollable {
|
.scrollable {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div id="settings_dialog" class="modal hide fade large" tabindex="-1" role="dialog" aria-labelledby="settings_dialog_label" aria-hidden="true">
|
<div id="settings_dialog" class="modal hide fade large" tabindex="-1" role="dialog" aria-labelledby="settings_dialog_label" aria-hidden="true">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h3 id="settings_dialog_label">{{ _('OctoPrint Settings') }}</h3>
|
<h3 id="settings_dialog_label">{{ _('OctoPrint Settings') }} <i class="icon-spinner icon-spin" data-bind="visible: receiving"></i></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="full-sized-box">
|
<div class="full-sized-box">
|
||||||
@@ -49,6 +49,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</button>
|
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</button>
|
||||||
<button class="btn btn-primary" data-bind="click: function() { saveData(undefined, $root.hide) }">{{ _('Save') }}</button>
|
<button class="btn btn-primary" data-bind="click: function() { saveData(undefined, $root.hide) }, enable: !sending(), css: {disabled: sending()}"><i class="icon-spinner icon-spin" data-bind="visible: sending"></i> {{ _('Save') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -48,6 +48,13 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: feature_ignoreIdenticalResends" id="settings-ignoreIdenticalResends"> {{ _('Ignore consecutive resend requests for the same line') }} <span class="label">{{ _('Repetier') }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
@@ -62,11 +69,4 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
|
||||||
<div class="controls">
|
|
||||||
<label class="checkbox">
|
|
||||||
<input type="checkbox" data-bind="checked: feature_swallowOkAfterResend" id="settings-swallowOkAfterResend"> {{ _('Swallow the first "ok" after a resend response') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
|
<h3>{{ _('Folders') }}</h3>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="settings-folderUploads">{{ _('Upload Folder') }}</label>
|
<label class="control-label" for="settings-folderUploads">{{ _('Upload Folder') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
@@ -29,4 +31,28 @@
|
|||||||
<input type="text" class="input-block-level" data-bind="value: folder_watched" id="settings-folderWatched">
|
<input type="text" class="input-block-level" data-bind="value: folder_watched" id="settings-folderWatched">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" data-bind="checked: feature_pollWatched" id="settings-featurePollWatched"> {{ _('Actively poll the watched folder. Check this if files in your watched folder aren\'t automatically added otherwise.') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>{{ _('Disk space thresholds') }}</h3>
|
||||||
|
|
||||||
|
<p>{{ _('If the free disk space falls below these thresholds, OctoPrint will warn the user.') }}</p>
|
||||||
|
|
||||||
|
<div class="control-group" title="{{ ('Threshold after which to warn about the remaining free space on disk.') }}">
|
||||||
|
<label class="control-label" for="settings.serverDiskusageWarning">{{ _('Warning') }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="input-mini text-right" data-bind="value: server_diskspace_warning_str">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group" title="{{ ('Threshold after which to consider remaining free space on disk as critical.') }}">
|
||||||
|
<label class="control-label" for="settings.serverDiskusageCritical">{{ _('Critical') }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="input-mini text-right" data-bind="value: server_diskspace_critical_str">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<label class="control-label" for="settings-serialTimeoutTemperature">{{ _('Temperature interval') }}</label>
|
<label class="control-label" for="settings-serialTimeoutTemperature">{{ _('Temperature interval') }}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="input-append">
|
<div class="input-append">
|
||||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutTemperature" id="settings-serialTimeoutTemperature">
|
<input type="number" step="any" min="1" class="input-mini text-right" data-bind="value: serial_timeoutTemperature" id="settings-serialTimeoutTemperature">
|
||||||
<span class="add-on">s</span>
|
<span class="add-on">s</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<form class="form-horizontal">
|
||||||
|
<h3>{{ _('Commands') }}</h3>
|
||||||
|
|
||||||
|
<div class="control-group" title="{{ _('Command to restart the OctoPrint server') }}">
|
||||||
|
<label class="control-label" for="settings-serverRestartCommand">{{ _('Restart OctoPrint') }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="input-block-level" data-bind="value: server_commands_serverRestartCommand" id="settings-serverRestartCommand">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group" title="{{ _('Command to restart the system OctoPrint is running on') }}">
|
||||||
|
<label class="control-label" for="settings-systemRestartCommand">{{ _('Restart system') }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="input-block-level" data-bind="value: server_commands_systemRestartCommand" id="settings-systemRestartCommand">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group" title="{{ _('Command to shut down the system OctoPrint is running on') }}">
|
||||||
|
<label class="control-label" for="settings-systemShutdownCommand">{{ _('Shutdown system') }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="input-block-level" data-bind="value: server_commands_systemShutdownCommand" id="settings-systemShutdownCommand">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
@@ -21,11 +21,12 @@
|
|||||||
var SOCKJS_URI = "{{ url_for('index') }}" + "sockjs";
|
var SOCKJS_URI = "{{ url_for('index') }}" + "sockjs";
|
||||||
var SOCKJS_DEBUG = CONFIG_DEBUG;
|
var SOCKJS_DEBUG = CONFIG_DEBUG;
|
||||||
// sockjs should define CLOSE_NORMAL for us, but they don't (from ws spec)
|
// sockjs should define CLOSE_NORMAL for us, but they don't (from ws spec)
|
||||||
var SOCKJS_CLOSE_NORMAL = 1000
|
var SOCKJS_CLOSE_NORMAL = 1000;
|
||||||
|
|
||||||
var UI_API_KEY = "{{ uiApiKey }}";
|
var UI_API_KEY = "{{ uiApiKey }}";
|
||||||
var VERSION = "{{ version }}";
|
var VERSION = "{{ version }}";
|
||||||
var DISPLAY_VERSION = "{{ display_version }}";
|
var DISPLAY_VERSION = "{{ display_version }}";
|
||||||
|
var BRANCH = "{{ branch }}";
|
||||||
var LOCALE = "{{ g.locale }}";
|
var LOCALE = "{{ g.locale }}";
|
||||||
var AVAILABLE_LOCALES = {{ locales|tojson }};
|
var AVAILABLE_LOCALES = {{ locales|tojson }};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" id="login_remember" data-bind="checked: loginState.loginRemember"> {{ _('Remember me') }}
|
<input type="checkbox" id="login_remember" data-bind="checked: loginState.loginRemember"> {{ _('Remember me') }}
|
||||||
</label>
|
</label>
|
||||||
<button class="btn btn-block btn-primary" id="login_button" data-bind="click: loginState.login">{{ _('Login') }}</button>
|
<button class="btn btn-block btn-primary" id="login_button" data-bind="click: function() { loginState.login(); }">{{ _('Login') }}</button>
|
||||||
</div>
|
</div>
|
||||||
<ul id="login_dropdown_loggedin" class="hide" data-bind="css: {hide: !loginState.loggedIn(), 'dropdown-menu': loginState.loggedIn()}">
|
<ul id="login_dropdown_loggedin" class="hide" data-bind="css: {hide: !loginState.loggedIn(), 'dropdown-menu': loginState.loggedIn()}">
|
||||||
<li><a href="#" id="usersettings_button" data-bind="click: function() { usersettings.show(); }">{{ _('User Settings') }}</a></li>
|
<li><a href="#" id="usersettings_button" data-bind="click: function() { usersettings.show(); }">{{ _('User Settings') }}</a></li>
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></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="additionalInfo hide" data-bind="html: $root.getAdditionalData($data)"></div>
|
||||||
<div class="btn-group action-buttons">
|
<div class="btn-group action-buttons">
|
||||||
<div class="btn btn-mini toggleAdditionalData" data-bind="click: function() { if ($root.enableAdditionalData($data)) { $root.toggleAdditionalData($data); } else { return; } }, css: { disabled: !$root.enableAdditionalData($data) }"><i class="icon-chevron-down"></i></div>
|
<div class="btn btn-mini toggleAdditionalData" data-bind="click: function() { if ($root.enableAdditionalData($data)) { $root.toggleAdditionalData($data); } else { return; } }, css: { disabled: !$root.enableAdditionalData($data) }" title="{{ _('Additional data') }}"><i class="icon-chevron-down"></i></div>
|
||||||
<a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}"><i class="icon-download-alt" title="{{ _('Download') }}"></i></a>
|
<a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}" title="{{ _('Download') }}"><i class="icon-download-alt"></i></a>
|
||||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>
|
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove') }}"><i class="icon-trash"></i></div>
|
||||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-folder-open" title="{{ _('Load') }}"></i></div>
|
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}" title="{{ _('Load') }}"><i class="icon-folder-open"></i></div>
|
||||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-print" title="{{ _('Load and Print') }}"></i></div>
|
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelect($data)}" title="{{ _('Load and Print') }}"><i class="icon-print"></i></div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -23,9 +23,9 @@
|
|||||||
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date)"></span></div>
|
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date)"></span></div>
|
||||||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
||||||
<div class="btn-group action-buttons">
|
<div class="btn-group action-buttons">
|
||||||
<a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}"><i class="icon-download-alt" title="{{ _('Download') }}"></i></a>
|
<a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}" title="{{ _('Download') }}"><i class="icon-download-alt"></i></a>
|
||||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>
|
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove') }}"><i class="icon-trash"></i></div>
|
||||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSlicing($data)) { $root.sliceFile($data); } else { return; } }, css: {disabled: !$root.enableSlicing($data)}"><i class="icon-magic" title="{{ _('Slice') }}"></i></div>
|
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSlicing($data)) { $root.sliceFile($data); } else { return; } }, css: {disabled: !$root.enableSlicing($data)}" title="{{ _('Slice') }}"><i class="icon-magic"></i></div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
<div class="title" data-bind="text: name"></div>
|
<div class="title" data-bind="text: name"></div>
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
<div class="muted text-right">
|
<div class="text-right muted" data-bind="attr: {title: diskusageString}, css: {'text-error': diskusageCritical}, style: {'font-weight': diskusageCritical() || diskusageWarning() ? 'bold' : 'normal'}">
|
||||||
<small>{{ _('Free') }}: <span data-bind="text: freeSpaceString"></span></small>
|
<small>{{ _('Free') }}: <span data-bind="text: freeSpaceString"></span> / {{ _('Total') }}: <span data-bind="text: totalSpaceString"></span> <i class="icon-exclamation-sign" data-bind="visible: diskusageWarning" style="display: none"></i></small>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: none;" data-bind="visible: loginState.isUser">
|
<div style="display: none;" data-bind="visible: loginState.isUser">
|
||||||
<div class="row-fluid upload-buttons">
|
<div class="row-fluid upload-buttons">
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<div style="display: none;" data-bind="visible: loginState.isUser">
|
<div style="display: none;" data-bind="visible: loginState.isUser">
|
||||||
|
<div class="alert" data-bind="visible: isPrinting()">
|
||||||
|
{{ _('Take note that timelapse configuration is disabled while your printer is printing.') }}
|
||||||
|
</div>
|
||||||
<h1>{{ _('Timelapse Configuration') }}</h1>
|
<h1>{{ _('Timelapse Configuration') }}</h1>
|
||||||
|
|
||||||
<label for="webcam_timelapse_mode">{{ _('Timelapse Mode') }}</label>
|
<label for="webcam_timelapse_mode">{{ _('Timelapse Mode') }}</label>
|
||||||
@@ -7,6 +10,7 @@
|
|||||||
<option value="zchange">{{ _('On Z Change') }}</option>
|
<option value="zchange">{{ _('On Z Change') }}</option>
|
||||||
<option value="timed">{{ _('Timed') }}</option>
|
<option value="timed">{{ _('Timed') }}</option>
|
||||||
</select>
|
</select>
|
||||||
|
<span class="help-block" data-bind="visible: timelapseType() == 'zchange'"><span class="label label-warning">{{ _('Warning') }}</span> {{ _('Do not use with spiralized ("Joris") vases or similar continuous Z models.') }}</span>
|
||||||
|
|
||||||
<label for="webcam_timelapse_fps">{{ _('Timelapse frame rate (in frames per second)') }}</label>
|
<label for="webcam_timelapse_fps">{{ _('Timelapse frame rate (in frames per second)') }}</label>
|
||||||
<div class="input-append">
|
<div class="input-append">
|
||||||
|
|||||||
@@ -281,12 +281,12 @@ class Timelapse(object):
|
|||||||
filters = []
|
filters = []
|
||||||
|
|
||||||
# flip video if configured
|
# flip video if configured
|
||||||
if settings().getBoolean(["webcam", "rotate90"]):
|
|
||||||
filters.append('transpose=1')
|
|
||||||
if settings().getBoolean(["webcam", "flipH"]):
|
if settings().getBoolean(["webcam", "flipH"]):
|
||||||
filters.append('hflip')
|
filters.append('hflip')
|
||||||
if settings().getBoolean(["webcam", "flipV"]):
|
if settings().getBoolean(["webcam", "flipV"]):
|
||||||
filters.append('vflip')
|
filters.append('vflip')
|
||||||
|
if settings().getBoolean(["webcam", "rotate90"]):
|
||||||
|
filters.append('transpose=2')
|
||||||
|
|
||||||
# add watermark if configured
|
# add watermark if configured
|
||||||
watermarkFilter = None
|
watermarkFilter = None
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -474,7 +474,7 @@ class User(UserMixin):
|
|||||||
|
|
||||||
class SessionUser(User):
|
class SessionUser(User):
|
||||||
def __init__(self, user):
|
def __init__(self, user):
|
||||||
User.__init__(self, user._username, user._passwordHash, user._active, user._roles, user._apikey)
|
User.__init__(self, user._username, user._passwordHash, user._active, user._roles, user._apikey, user._settings)
|
||||||
|
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import shutil
|
|||||||
import threading
|
import threading
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
import warnings
|
import warnings
|
||||||
|
import contextlib
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -197,29 +197,12 @@ def get_exception_string():
|
|||||||
return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])
|
return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("get_free_bytes has been deprecated and will be removed in the future",
|
||||||
|
includedoc="Replaced by `psutil.disk_usage <http://pythonhosted.org/psutil/#psutil.disk_usage>`_.",
|
||||||
|
since="1.2.5")
|
||||||
def get_free_bytes(path):
|
def get_free_bytes(path):
|
||||||
"""
|
import psutil
|
||||||
Retrieves the number of free bytes on the partition ``path`` is located at and returns it. Works on both Windows and
|
return psutil.disk_usage(path).free
|
||||||
Unix/Linux.
|
|
||||||
|
|
||||||
Taken from http://stackoverflow.com/a/2372171/2028598
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
path (string): The path for which to check the remaining partition space.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
int: The amount of bytes still left on the partition.
|
|
||||||
"""
|
|
||||||
|
|
||||||
path = os.path.abspath(path)
|
|
||||||
if sys.platform == "win32":
|
|
||||||
import ctypes
|
|
||||||
freeBytes = ctypes.c_ulonglong(0)
|
|
||||||
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(path), None, None, ctypes.pointer(freeBytes))
|
|
||||||
return freeBytes.value
|
|
||||||
else:
|
|
||||||
st = os.statvfs(path)
|
|
||||||
return st.f_bavail * st.f_frsize
|
|
||||||
|
|
||||||
|
|
||||||
def get_dos_filename(origin, existing_filenames=None, extension=None, **kwargs):
|
def get_dos_filename(origin, existing_filenames=None, extension=None, **kwargs):
|
||||||
@@ -352,9 +335,7 @@ def silent_remove(file):
|
|||||||
def sanitize_ascii(line):
|
def sanitize_ascii(line):
|
||||||
if not isinstance(line, basestring):
|
if not isinstance(line, basestring):
|
||||||
raise ValueError("Expected either str or unicode but got {} instead".format(line.__class__.__name__ if line is not None else None))
|
raise ValueError("Expected either str or unicode but got {} instead".format(line.__class__.__name__ if line is not None else None))
|
||||||
if isinstance(line, str):
|
return to_unicode(line, encoding="ascii", errors="replace").rstrip()
|
||||||
line = unicode(line, 'ascii', 'replace')
|
|
||||||
return line.encode('ascii', 'replace').rstrip()
|
|
||||||
|
|
||||||
|
|
||||||
def filter_non_ascii(line):
|
def filter_non_ascii(line):
|
||||||
@@ -369,12 +350,28 @@ def filter_non_ascii(line):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
unicode(line, 'ascii').encode('ascii')
|
to_str(to_unicode(line, encoding="ascii"), encoding="ascii")
|
||||||
return False
|
return False
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def to_str(s_or_u, encoding="utf-8", errors="strict"):
|
||||||
|
"""Make sure ``s_or_u`` is a str."""
|
||||||
|
if isinstance(s_or_u, unicode):
|
||||||
|
return s_or_u.encode(encoding, errors=errors)
|
||||||
|
else:
|
||||||
|
return s_or_u
|
||||||
|
|
||||||
|
|
||||||
|
def to_unicode(s_or_u, encoding="utf-8", errors="strict"):
|
||||||
|
"""Make sure ``s_or_u`` is a unicode string."""
|
||||||
|
if isinstance(s_or_u, str):
|
||||||
|
return s_or_u.decode(encoding, errors=errors)
|
||||||
|
else:
|
||||||
|
return s_or_u
|
||||||
|
|
||||||
|
|
||||||
def dict_merge(a, b):
|
def dict_merge(a, b):
|
||||||
"""
|
"""
|
||||||
Recursively deep-merges two dictionaries.
|
Recursively deep-merges two dictionaries.
|
||||||
@@ -499,6 +496,15 @@ def address_for_client(host, port):
|
|||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def atomic_write(filename, mode="w+b", prefix="tmp", suffix=""):
|
||||||
|
temp_config = tempfile.NamedTemporaryFile(mode=mode, prefix=prefix, suffix=suffix, delete=False)
|
||||||
|
yield temp_config
|
||||||
|
temp_config.close()
|
||||||
|
shutil.move(temp_config.name, filename)
|
||||||
|
|
||||||
|
|
||||||
class RepeatedTimer(threading.Thread):
|
class RepeatedTimer(threading.Thread):
|
||||||
"""
|
"""
|
||||||
This class represents an action that should be run repeatedly in an interval. It is similar to python's
|
This class represents an action that should be run repeatedly in an interval. It is similar to python's
|
||||||
@@ -556,9 +562,10 @@ class RepeatedTimer(threading.Thread):
|
|||||||
run_first (boolean): If set to True, the function will be run for the first time *before* the first wait period.
|
run_first (boolean): If set to True, the function will be run for the first time *before* the first wait period.
|
||||||
If set to False (the default), the function will be run for the first time *after* the first wait period.
|
If set to False (the default), the function will be run for the first time *after* the first wait period.
|
||||||
condition (callable): Condition that needs to be True for loop to continue. Defaults to ``lambda: True``.
|
condition (callable): Condition that needs to be True for loop to continue. Defaults to ``lambda: True``.
|
||||||
|
daemon (bool): daemon flag to set on underlying thread.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, interval, function, args=None, kwargs=None, run_first=False, condition=None):
|
def __init__(self, interval, function, args=None, kwargs=None, run_first=False, condition=None, daemon=True):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
if args is None:
|
if args is None:
|
||||||
@@ -579,6 +586,7 @@ class RepeatedTimer(threading.Thread):
|
|||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.run_first = run_first
|
self.run_first = run_first
|
||||||
self.condition = condition
|
self.condition = condition
|
||||||
|
self.daemon = daemon
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
self.finished.set()
|
self.finished.set()
|
||||||
|
|||||||
+364
-151
@@ -31,6 +31,79 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# a bunch of regexes we'll need for the communication parsing...
|
||||||
|
|
||||||
|
regex_float_pattern = "[-+]?[0-9]*\.?[0-9]+"
|
||||||
|
regex_positive_float_pattern = "[+]?[0-9]*\.?[0-9]+"
|
||||||
|
regex_int_pattern = "\d+"
|
||||||
|
|
||||||
|
regex_command = re.compile("^\s*((?P<commandGM>[GM]\d+)|(?P<commandT>T)\d+)")
|
||||||
|
"""Regex for a GCODE command."""
|
||||||
|
|
||||||
|
regex_float = re.compile(regex_float_pattern)
|
||||||
|
"""Regex for a float value."""
|
||||||
|
|
||||||
|
regexes_parameters = dict(
|
||||||
|
floatP=re.compile("(^|[^A-Za-z])[Pp](?P<value>%s)" % regex_float_pattern),
|
||||||
|
floatS=re.compile("(^|[^A-Za-z])[Ss](?P<value>%s)" % regex_float_pattern),
|
||||||
|
floatZ=re.compile("(^|[^A-Za-z])[Zz](?P<value>%s)" % regex_float_pattern),
|
||||||
|
intN=re.compile("(^|[^A-Za-z])[Nn](?P<value>%s)" % regex_int_pattern),
|
||||||
|
intT=re.compile("(^|[^A-Za-z])[Tt](?P<value>%s)" % regex_int_pattern)
|
||||||
|
)
|
||||||
|
"""Regexes for parsing various GCODE command parameters."""
|
||||||
|
|
||||||
|
regex_minMaxError = re.compile("Error:[0-9]\n")
|
||||||
|
"""Regex matching first line of min/max errors from the firmware."""
|
||||||
|
|
||||||
|
regex_sdPrintingByte = re.compile("(?P<current>[0-9]*)/(?P<total>[0-9]*)")
|
||||||
|
"""Regex matching SD printing status reports.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``current``: current byte position in file being printed
|
||||||
|
* ``total``: total size of file being printed
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_sdFileOpened = re.compile("File opened:\s*(?P<name>.*?)\s+Size:\s*(?P<size>%s)" % regex_int_pattern)
|
||||||
|
"""Regex matching "File opened" messages from the firmware.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``name``: name of the file reported as having been opened (str)
|
||||||
|
* ``size``: size of the file in bytes (int)
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_temp = re.compile("(?P<tool>B|T(?P<toolnum>\d*)):\s*(?P<actual>%s)(\s*\/?\s*(?P<target>%s))?" % (regex_positive_float_pattern, regex_positive_float_pattern))
|
||||||
|
"""Regex matching temperature entries in line.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``tool``: whole tool designator, incl. optional ``toolnum`` (str)
|
||||||
|
* ``toolnum``: tool number, if provided (int)
|
||||||
|
* ``actual``: actual temperature (float)
|
||||||
|
* ``target``: target temperature, if provided (float)
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_repetierTempExtr = re.compile("TargetExtr(?P<toolnum>\d+):(?P<target>%s)" % regex_positive_float_pattern)
|
||||||
|
"""Regex for matching target temp reporting from Repetier.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``toolnum``: number of the extruder to which the target temperature
|
||||||
|
report belongs (int)
|
||||||
|
* ``target``: new target temperature (float)
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_repetierTempBed = re.compile("TargetBed:(?P<target>%s)" % regex_positive_float_pattern)
|
||||||
|
"""Regex for matching target temp reporting from Repetier for beds.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``target``: new target temperature (float)
|
||||||
|
"""
|
||||||
|
|
||||||
def serialList():
|
def serialList():
|
||||||
baselist=[]
|
baselist=[]
|
||||||
if os.name=="nt":
|
if os.name=="nt":
|
||||||
@@ -151,6 +224,7 @@ class MachineCom(object):
|
|||||||
|
|
||||||
self._long_running_command = False
|
self._long_running_command = False
|
||||||
self._heating = False
|
self._heating = False
|
||||||
|
self._connection_closing = False
|
||||||
|
|
||||||
self._timeout = None
|
self._timeout = None
|
||||||
|
|
||||||
@@ -158,12 +232,15 @@ class MachineCom(object):
|
|||||||
self._sendChecksumWithUnknownCommands = settings().getBoolean(["feature", "sendChecksumWithUnknownCommands"])
|
self._sendChecksumWithUnknownCommands = settings().getBoolean(["feature", "sendChecksumWithUnknownCommands"])
|
||||||
self._unknownCommandsNeedAck = settings().getBoolean(["feature", "unknownCommandsNeedAck"])
|
self._unknownCommandsNeedAck = settings().getBoolean(["feature", "unknownCommandsNeedAck"])
|
||||||
self._currentLine = 1
|
self._currentLine = 1
|
||||||
|
self._line_mutex = threading.RLock()
|
||||||
self._resendDelta = None
|
self._resendDelta = None
|
||||||
self._lastLines = deque([], 50)
|
self._lastLines = deque([], 50)
|
||||||
self._lastCommError = None
|
self._lastCommError = None
|
||||||
self._lastResendNumber = None
|
self._lastResendNumber = None
|
||||||
self._currentResendCount = 0
|
self._currentResendCount = 0
|
||||||
self._resendSwallowNextOk = False
|
self._resendSwallowNextOk = False
|
||||||
|
self._resendSwallowRepetitions = settings().getBoolean(["feature", "ignoreIdenticalResends"])
|
||||||
|
self._resendSwallowRepetitionsCounter = 0
|
||||||
|
|
||||||
self._clear_to_send = CountedEvent(max=10, name="comm.clear_to_send")
|
self._clear_to_send = CountedEvent(max=10, name="comm.clear_to_send")
|
||||||
self._send_queue = TypedQueue()
|
self._send_queue = TypedQueue()
|
||||||
@@ -195,28 +272,6 @@ class MachineCom(object):
|
|||||||
self._currentFile = None
|
self._currentFile = None
|
||||||
|
|
||||||
# regexes
|
# regexes
|
||||||
floatPattern = "[-+]?[0-9]*\.?[0-9]+"
|
|
||||||
positiveFloatPattern = "[+]?[0-9]*\.?[0-9]+"
|
|
||||||
intPattern = "\d+"
|
|
||||||
self._regex_command = re.compile("^\s*([GM]\d+|T)")
|
|
||||||
self._regex_float = re.compile(floatPattern)
|
|
||||||
self._regex_paramZFloat = re.compile("Z(%s)" % floatPattern)
|
|
||||||
self._regex_paramSInt = re.compile("S(%s)" % intPattern)
|
|
||||||
self._regex_paramNInt = re.compile("N(%s)" % intPattern)
|
|
||||||
self._regex_paramTInt = re.compile("T(%s)" % intPattern)
|
|
||||||
self._regex_minMaxError = re.compile("Error:[0-9]\n")
|
|
||||||
self._regex_sdPrintingByte = re.compile("([0-9]*)/([0-9]*)")
|
|
||||||
self._regex_sdFileOpened = re.compile("File opened:\s*(.*?)\s+Size:\s*(%s)" % intPattern)
|
|
||||||
|
|
||||||
# Regex matching temperature entries in line. Groups will be as follows:
|
|
||||||
# - 1: whole tool designator incl. optional toolNumber ("T", "Tn", "B")
|
|
||||||
# - 2: toolNumber, if given ("", "n", "")
|
|
||||||
# - 3: actual temperature
|
|
||||||
# - 4: whole target substring, if given (e.g. " / 22.0")
|
|
||||||
# - 5: target temperature
|
|
||||||
self._regex_temp = re.compile("(B|T(\d*)):\s*(%s)(\s*\/?\s*(%s))?" % (positiveFloatPattern, positiveFloatPattern))
|
|
||||||
self._regex_repetierTempExtr = re.compile("TargetExtr([0-9]+):(%s)" % positiveFloatPattern)
|
|
||||||
self._regex_repetierTempBed = re.compile("TargetBed:(%s)" % positiveFloatPattern)
|
|
||||||
|
|
||||||
self._long_running_commands = settings().get(["serial", "longRunningCommands"])
|
self._long_running_commands = settings().get(["serial", "longRunningCommands"])
|
||||||
|
|
||||||
@@ -383,6 +438,10 @@ class MachineCom(object):
|
|||||||
##~~ external interface
|
##~~ external interface
|
||||||
|
|
||||||
def close(self, isError = False):
|
def close(self, isError = False):
|
||||||
|
if self._connection_closing:
|
||||||
|
return
|
||||||
|
self._connection_closing = True
|
||||||
|
|
||||||
if self._temperature_timer is not None:
|
if self._temperature_timer is not None:
|
||||||
try:
|
try:
|
||||||
self._temperature_timer.cancel()
|
self._temperature_timer.cancel()
|
||||||
@@ -400,11 +459,15 @@ class MachineCom(object):
|
|||||||
|
|
||||||
printing = self.isPrinting() or self.isPaused()
|
printing = self.isPrinting() or self.isPaused()
|
||||||
if self._serial is not None:
|
if self._serial is not None:
|
||||||
|
try:
|
||||||
|
self._serial.close()
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while trying to close serial port")
|
||||||
|
isError = True
|
||||||
if isError:
|
if isError:
|
||||||
self._changeState(self.STATE_CLOSED_WITH_ERROR)
|
self._changeState(self.STATE_CLOSED_WITH_ERROR)
|
||||||
else:
|
else:
|
||||||
self._changeState(self.STATE_CLOSED)
|
self._changeState(self.STATE_CLOSED)
|
||||||
self._serial.close()
|
|
||||||
self._serial = None
|
self._serial = None
|
||||||
|
|
||||||
if settings().get(["feature", "sdSupport"]):
|
if settings().get(["feature", "sdSupport"]):
|
||||||
@@ -529,7 +592,7 @@ class MachineCom(object):
|
|||||||
|
|
||||||
self.sendCommand("M24")
|
self.sendCommand("M24")
|
||||||
|
|
||||||
self._sd_status_timer = RepeatedTimer(lambda: get_interval("sdStatus"), self._poll_sd_status, run_first=True)
|
self._sd_status_timer = RepeatedTimer(lambda: get_interval("sdStatus", default_value=1.0), self._poll_sd_status, run_first=True)
|
||||||
self._sd_status_timer.start()
|
self._sd_status_timer.start()
|
||||||
else:
|
else:
|
||||||
line = self._getNext()
|
line = self._getNext()
|
||||||
@@ -708,51 +771,9 @@ class MachineCom(object):
|
|||||||
|
|
||||||
##~~ communication monitoring and handling
|
##~~ communication monitoring and handling
|
||||||
|
|
||||||
def _parseTemperatures(self, line):
|
|
||||||
result = {}
|
|
||||||
maxToolNum = 0
|
|
||||||
for match in re.finditer(self._regex_temp, line):
|
|
||||||
tool = match.group(1)
|
|
||||||
toolNumber = int(match.group(2)) if match.group(2) and len(match.group(2)) > 0 else None
|
|
||||||
if toolNumber > maxToolNum:
|
|
||||||
maxToolNum = toolNumber
|
|
||||||
|
|
||||||
try:
|
|
||||||
actual = float(match.group(3))
|
|
||||||
target = None
|
|
||||||
if match.group(4) and match.group(5):
|
|
||||||
target = float(match.group(5))
|
|
||||||
|
|
||||||
result[tool] = (toolNumber, actual, target)
|
|
||||||
except ValueError:
|
|
||||||
# catch conversion issues, we'll rather just not get the temperature update instead of killing the connection
|
|
||||||
pass
|
|
||||||
|
|
||||||
if "T0" in result.keys() and "T" in result.keys():
|
|
||||||
del result["T"]
|
|
||||||
|
|
||||||
return maxToolNum, result
|
|
||||||
|
|
||||||
def _processTemperatures(self, line):
|
def _processTemperatures(self, line):
|
||||||
maxToolNum, parsedTemps = self._parseTemperatures(line)
|
current_tool = self._currentTool if self._currentTool is not None else 0
|
||||||
|
maxToolNum, parsedTemps = parse_temperature_line(line, current_tool)
|
||||||
# extruder temperatures
|
|
||||||
if not "T0" in parsedTemps.keys() and not "T1" in parsedTemps.keys() and "T" in parsedTemps.keys():
|
|
||||||
# no T1 so only single reporting, "T" is our one and only extruder temperature
|
|
||||||
toolNum, actual, target = parsedTemps["T"]
|
|
||||||
|
|
||||||
if target is not None:
|
|
||||||
self._temp[0] = (actual, target)
|
|
||||||
elif 0 in self._temp.keys() and self._temp[0] is not None and isinstance(self._temp[0], tuple):
|
|
||||||
(oldActual, oldTarget) = self._temp[0]
|
|
||||||
self._temp[0] = (actual, oldTarget)
|
|
||||||
else:
|
|
||||||
self._temp[0] = (actual, None)
|
|
||||||
elif not "T0" in parsedTemps.keys() and "T" in parsedTemps.keys():
|
|
||||||
# Smoothieware sends multi extruder temperature data this way: "T:<first extruder> T1:<second extruder> ..." and therefore needs some special treatment...
|
|
||||||
_, actual, target = parsedTemps["T"]
|
|
||||||
del parsedTemps["T"]
|
|
||||||
parsedTemps["T0"] = (0, actual, target)
|
|
||||||
|
|
||||||
if "T0" in parsedTemps.keys():
|
if "T0" in parsedTemps.keys():
|
||||||
for n in range(maxToolNum + 1):
|
for n in range(maxToolNum + 1):
|
||||||
@@ -760,18 +781,18 @@ class MachineCom(object):
|
|||||||
if not tool in parsedTemps.keys():
|
if not tool in parsedTemps.keys():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
toolNum, actual, target = parsedTemps[tool]
|
actual, target = parsedTemps[tool]
|
||||||
if target is not None:
|
if target is not None:
|
||||||
self._temp[toolNum] = (actual, target)
|
self._temp[n] = (actual, target)
|
||||||
elif toolNum in self._temp.keys() and self._temp[toolNum] is not None and isinstance(self._temp[toolNum], tuple):
|
elif n in self._temp and self._temp[n] is not None and isinstance(self._temp[n], tuple):
|
||||||
(oldActual, oldTarget) = self._temp[toolNum]
|
(oldActual, oldTarget) = self._temp[n]
|
||||||
self._temp[toolNum] = (actual, oldTarget)
|
self._temp[n] = (actual, oldTarget)
|
||||||
else:
|
else:
|
||||||
self._temp[toolNum] = (actual, None)
|
self._temp[n] = (actual, None)
|
||||||
|
|
||||||
# bed temperature
|
# bed temperature
|
||||||
if "B" in parsedTemps.keys():
|
if "B" in parsedTemps.keys():
|
||||||
toolNum, actual, target = parsedTemps["B"]
|
actual, target = parsedTemps["B"]
|
||||||
if target is not None:
|
if target is not None:
|
||||||
self._bedTemp = (actual, target)
|
self._bedTemp = (actual, target)
|
||||||
elif self._bedTemp is not None and isinstance(self._bedTemp, tuple):
|
elif self._bedTemp is not None and isinstance(self._bedTemp, tuple):
|
||||||
@@ -844,7 +865,11 @@ class MachineCom(object):
|
|||||||
self._callback.on_comm_force_disconnect()
|
self._callback.on_comm_force_disconnect()
|
||||||
else:
|
else:
|
||||||
for hook in self._printer_action_hooks:
|
for hook in self._printer_action_hooks:
|
||||||
self._printer_action_hooks[hook](self, line, action_command)
|
try:
|
||||||
|
self._printer_action_hooks[hook](self, line, action_command)
|
||||||
|
except:
|
||||||
|
self._logger.exception("Error while calling hook {} with action command {}".format(self._printer_action_hooks[hook], action_command))
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -895,8 +920,8 @@ class MachineCom(object):
|
|||||||
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
|
self._callback.on_comm_temperature_update(self._temp, self._bedTemp)
|
||||||
|
|
||||||
elif supportRepetierTargetTemp and ('TargetExtr' in line or 'TargetBed' in line):
|
elif supportRepetierTargetTemp and ('TargetExtr' in line or 'TargetBed' in line):
|
||||||
matchExtr = self._regex_repetierTempExtr.match(line)
|
matchExtr = regex_repetierTempExtr.match(line)
|
||||||
matchBed = self._regex_repetierTempBed.match(line)
|
matchBed = regex_repetierTempBed.match(line)
|
||||||
|
|
||||||
if matchExtr is not None:
|
if matchExtr is not None:
|
||||||
toolNum = int(matchExtr.group(1))
|
toolNum = int(matchExtr.group(1))
|
||||||
@@ -950,18 +975,18 @@ class MachineCom(object):
|
|||||||
self._callback.on_comm_sd_files(self._sdFiles)
|
self._callback.on_comm_sd_files(self._sdFiles)
|
||||||
elif 'SD printing byte' in line and self.isSdPrinting():
|
elif 'SD printing byte' in line and self.isSdPrinting():
|
||||||
# answer to M27, at least on Marlin, Repetier and Sprinter: "SD printing byte %d/%d"
|
# answer to M27, at least on Marlin, Repetier and Sprinter: "SD printing byte %d/%d"
|
||||||
match = self._regex_sdPrintingByte.search(line)
|
match = regex_sdPrintingByte.search(line)
|
||||||
self._currentFile.setFilepos(int(match.group(1)))
|
self._currentFile.setFilepos(int(match.group("current")))
|
||||||
self._callback.on_comm_progress()
|
self._callback.on_comm_progress()
|
||||||
elif 'File opened' in line and not self._ignore_select:
|
elif 'File opened' in line and not self._ignore_select:
|
||||||
# answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d"
|
# answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d"
|
||||||
match = self._regex_sdFileOpened.search(line)
|
match = regex_sdFileOpened.search(line)
|
||||||
if self._sdFileToSelect:
|
if self._sdFileToSelect:
|
||||||
name = self._sdFileToSelect
|
name = self._sdFileToSelect
|
||||||
self._sdFileToSelect = None
|
self._sdFileToSelect = None
|
||||||
else:
|
else:
|
||||||
name = match.group(1)
|
name = match.group("name")
|
||||||
self._currentFile = PrintingSdFileInformation(name, int(match.group(2)))
|
self._currentFile = PrintingSdFileInformation(name, int(match.group("size")))
|
||||||
elif 'File selected' in line:
|
elif 'File selected' in line:
|
||||||
if self._ignore_select:
|
if self._ignore_select:
|
||||||
self._ignore_select = False
|
self._ignore_select = False
|
||||||
@@ -1181,7 +1206,7 @@ class MachineCom(object):
|
|||||||
|
|
||||||
def _onConnected(self):
|
def _onConnected(self):
|
||||||
self._serial.timeout = settings().getFloat(["serial", "timeout", "communication"])
|
self._serial.timeout = settings().getFloat(["serial", "timeout", "communication"])
|
||||||
self._temperature_timer = RepeatedTimer(lambda: get_interval("temperature"), self._poll_temperature, run_first=True)
|
self._temperature_timer = RepeatedTimer(lambda: get_interval("temperature", default_value=4.0), self._poll_temperature, run_first=True)
|
||||||
self._temperature_timer.start()
|
self._temperature_timer.start()
|
||||||
|
|
||||||
self._changeState(self.STATE_OPERATIONAL)
|
self._changeState(self.STATE_OPERATIONAL)
|
||||||
@@ -1295,10 +1320,10 @@ class MachineCom(object):
|
|||||||
# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
|
# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
|
||||||
# But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
|
# But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
|
||||||
# So we can have an extra newline in the most common case. Awesome work people.
|
# So we can have an extra newline in the most common case. Awesome work people.
|
||||||
if self._regex_minMaxError.match(line):
|
if regex_minMaxError.match(line):
|
||||||
line = line.rstrip() + self._readline()
|
line = line.rstrip() + self._readline()
|
||||||
|
|
||||||
if 'line number' in line.lower() or 'checksum' in line.lower() or 'expected line' in line.lower():
|
if 'line number' in line.lower() or 'checksum' in line.lower() or 'format error' in line.lower() or 'expected line' in line.lower():
|
||||||
#Skip the communication errors, as those get corrected.
|
#Skip the communication errors, as those get corrected.
|
||||||
self._lastCommError = line[6:] if line.startswith("Error:") else line[2:]
|
self._lastCommError = line[6:] if line.startswith("Error:") else line[2:]
|
||||||
pass
|
pass
|
||||||
@@ -1313,14 +1338,17 @@ class MachineCom(object):
|
|||||||
return line
|
return line
|
||||||
|
|
||||||
def _readline(self):
|
def _readline(self):
|
||||||
if self._serial == None:
|
if self._serial is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret = self._serial.readline()
|
ret = self._serial.readline()
|
||||||
except:
|
except:
|
||||||
self._log("Unexpected error while reading serial port: %s" % (get_exception_string()))
|
if not self._connection_closing:
|
||||||
self._errorValue = get_exception_string()
|
self._logger.exception("Unexpected error while reading from serial port")
|
||||||
self.close(True)
|
self._log("Unexpected error while reading serial port, please consult octoprint.log for details: %s" % (get_exception_string()))
|
||||||
|
self._errorValue = get_exception_string()
|
||||||
|
self.close(True)
|
||||||
return None
|
return None
|
||||||
if ret == '':
|
if ret == '':
|
||||||
#self._log("Recv: TIMEOUT")
|
#self._log("Recv: TIMEOUT")
|
||||||
@@ -1397,9 +1425,18 @@ class MachineCom(object):
|
|||||||
self._currentResendCount += 1
|
self._currentResendCount += 1
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 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.debug("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
|
||||||
|
|
||||||
self._resendDelta = resendDelta
|
self._resendDelta = resendDelta
|
||||||
self._lastResendNumber = lineToResend
|
self._lastResendNumber = lineToResend
|
||||||
self._currentResendCount = 0
|
self._currentResendCount = 0
|
||||||
|
self._resendSwallowRepetitionsCounter = settings().getInt(["feature", "identicalResendsCountdown"])
|
||||||
|
|
||||||
if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0:
|
if self._resendDelta > len(self._lastLines) or len(self._lastLines) == 0 or self._resendDelta < 0:
|
||||||
self._errorValue = "Printer requested line %d but no sufficient history is available, can't resend" % lineToResend
|
self._errorValue = "Printer requested line %d but no sufficient history is available, can't resend" % lineToResend
|
||||||
@@ -1456,25 +1493,6 @@ class MachineCom(object):
|
|||||||
# trigger the "queued" phase only if we are not streaming to sd right now
|
# trigger the "queued" phase only if we are not streaming to sd right now
|
||||||
self._process_command_phase("queued", cmd, cmd_type, gcode=gcode)
|
self._process_command_phase("queued", cmd, cmd_type, gcode=gcode)
|
||||||
|
|
||||||
def gcode_command_for_cmd(self, cmd):
|
|
||||||
"""
|
|
||||||
Tries to parse the provided ``cmd`` and extract the GCODE command identifier from it (e.g. "G0" for "G0 X10.0").
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
cmd (str): The command to try to parse.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str or None: The GCODE command identifier if it could be parsed, or None if not.
|
|
||||||
"""
|
|
||||||
if not cmd:
|
|
||||||
return None
|
|
||||||
|
|
||||||
gcode = self._regex_command.search(cmd)
|
|
||||||
if not gcode:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return gcode.group(1)
|
|
||||||
|
|
||||||
##~~ send loop handling
|
##~~ send loop handling
|
||||||
|
|
||||||
def _enqueue_for_sending(self, command, linenumber=None, command_type=None):
|
def _enqueue_for_sending(self, command, linenumber=None, command_type=None):
|
||||||
@@ -1515,7 +1533,7 @@ class MachineCom(object):
|
|||||||
# some firmwares (e.g. Smoothie) might support additional in-band communication that will not
|
# some firmwares (e.g. Smoothie) might support additional in-band communication that will not
|
||||||
# stick to the acknowledgement behaviour of GCODE, so we check here if we have a GCODE command
|
# stick to the acknowledgement behaviour of GCODE, so we check here if we have a GCODE command
|
||||||
# at hand here and only clear our clear_to_send flag later if that's the case
|
# at hand here and only clear our clear_to_send flag later if that's the case
|
||||||
gcode = self.gcode_command_for_cmd(command)
|
gcode = gcode_command_for_cmd(command)
|
||||||
|
|
||||||
if linenumber is not None:
|
if linenumber is not None:
|
||||||
# line number predetermined - this only happens for resends, so we'll use the number and
|
# line number predetermined - this only happens for resends, so we'll use the number and
|
||||||
@@ -1532,10 +1550,7 @@ class MachineCom(object):
|
|||||||
|
|
||||||
# now comes the part where we increase line numbers and send stuff - no turning back now
|
# now comes the part where we increase line numbers and send stuff - no turning back now
|
||||||
if (gcode is not None or self._sendChecksumWithUnknownCommands) and (self.isPrinting() or self._alwaysSendChecksum):
|
if (gcode is not None or self._sendChecksumWithUnknownCommands) and (self.isPrinting() or self._alwaysSendChecksum):
|
||||||
linenumber = self._currentLine
|
self._doIncrementAndSendWithChecksum(command)
|
||||||
self._addToLastLines(command)
|
|
||||||
self._currentLine += 1
|
|
||||||
self._doSendWithChecksum(command, linenumber)
|
|
||||||
else:
|
else:
|
||||||
self._doSendWithoutChecksum(command)
|
self._doSendWithoutChecksum(command)
|
||||||
|
|
||||||
@@ -1563,7 +1578,7 @@ class MachineCom(object):
|
|||||||
return command, command_type, gcode
|
return command, command_type, gcode
|
||||||
|
|
||||||
if gcode is None:
|
if gcode is None:
|
||||||
gcode = self.gcode_command_for_cmd(command)
|
gcode = gcode_command_for_cmd(command)
|
||||||
|
|
||||||
# send it through the phase specific handlers provided by plugins
|
# send it through the phase specific handlers provided by plugins
|
||||||
for name, hook in self._gcode_hooks[phase].items():
|
for name, hook in self._gcode_hooks[phase].items():
|
||||||
@@ -1618,11 +1633,18 @@ class MachineCom(object):
|
|||||||
# handler returned a tuple of an unexpected length
|
# handler returned a tuple of an unexpected length
|
||||||
return original_tuple
|
return original_tuple
|
||||||
|
|
||||||
gcode = self.gcode_command_for_cmd(command)
|
gcode = gcode_command_for_cmd(command)
|
||||||
return command, command_type, gcode
|
return command, command_type, gcode
|
||||||
|
|
||||||
##~~ actual sending via serial
|
##~~ actual sending via serial
|
||||||
|
|
||||||
|
def _doIncrementAndSendWithChecksum(self, cmd):
|
||||||
|
with self._line_mutex:
|
||||||
|
linenumber = self._currentLine
|
||||||
|
self._addToLastLines(cmd)
|
||||||
|
self._currentLine += 1
|
||||||
|
self._doSendWithChecksum(cmd, linenumber)
|
||||||
|
|
||||||
def _doSendWithChecksum(self, cmd, lineNumber):
|
def _doSendWithChecksum(self, cmd, lineNumber):
|
||||||
commandToSend = "N%d %s" % (lineNumber, cmd)
|
commandToSend = "N%d %s" % (lineNumber, cmd)
|
||||||
checksum = reduce(lambda x,y:x^y, map(ord, commandToSend))
|
checksum = reduce(lambda x,y:x^y, map(ord, commandToSend))
|
||||||
@@ -1630,6 +1652,9 @@ class MachineCom(object):
|
|||||||
self._doSendWithoutChecksum(commandToSend)
|
self._doSendWithoutChecksum(commandToSend)
|
||||||
|
|
||||||
def _doSendWithoutChecksum(self, cmd):
|
def _doSendWithoutChecksum(self, cmd):
|
||||||
|
if self._serial is None:
|
||||||
|
return
|
||||||
|
|
||||||
self._log("Send: %s" % cmd)
|
self._log("Send: %s" % cmd)
|
||||||
try:
|
try:
|
||||||
self._serial.write(cmd + '\n')
|
self._serial.write(cmd + '\n')
|
||||||
@@ -1638,27 +1663,31 @@ class MachineCom(object):
|
|||||||
try:
|
try:
|
||||||
self._serial.write(cmd + '\n')
|
self._serial.write(cmd + '\n')
|
||||||
except:
|
except:
|
||||||
self._log("Unexpected error while writing serial port: %s" % (get_exception_string()))
|
if not self._connection_closing:
|
||||||
|
self._logger.exception("Unexpected error while writing to serial port")
|
||||||
|
self._log("Unexpected error while writing to serial port: %s" % (get_exception_string()))
|
||||||
|
self._errorValue = get_exception_string()
|
||||||
|
self.close(True)
|
||||||
|
except:
|
||||||
|
if not self._connection_closing:
|
||||||
|
self._logger.exception("Unexpected error while writing to serial port")
|
||||||
|
self._log("Unexpected error while writing to serial port: %s" % (get_exception_string()))
|
||||||
self._errorValue = get_exception_string()
|
self._errorValue = get_exception_string()
|
||||||
self.close(True)
|
self.close(True)
|
||||||
except:
|
|
||||||
self._log("Unexpected error while writing serial port: %s" % (get_exception_string()))
|
|
||||||
self._errorValue = get_exception_string()
|
|
||||||
self.close(True)
|
|
||||||
|
|
||||||
##~~ command handlers
|
##~~ command handlers
|
||||||
|
|
||||||
def _gcode_T_sent(self, cmd, cmd_type=None):
|
def _gcode_T_sent(self, cmd, cmd_type=None):
|
||||||
toolMatch = self._regex_paramTInt.search(cmd)
|
toolMatch = regexes_parameters["intT"].search(cmd)
|
||||||
if toolMatch:
|
if toolMatch:
|
||||||
self._currentTool = int(toolMatch.group(1))
|
self._currentTool = int(toolMatch.group("value"))
|
||||||
|
|
||||||
def _gcode_G0_sent(self, cmd, cmd_type=None):
|
def _gcode_G0_sent(self, cmd, cmd_type=None):
|
||||||
if 'Z' in cmd:
|
if 'Z' in cmd:
|
||||||
match = self._regex_paramZFloat.search(cmd)
|
match = regexes_parameters["floatZ"].search(cmd)
|
||||||
if match:
|
if match:
|
||||||
try:
|
try:
|
||||||
z = float(match.group(1))
|
z = float(match.group("value"))
|
||||||
if self._currentZ != z:
|
if self._currentZ != z:
|
||||||
self._currentZ = z
|
self._currentZ = z
|
||||||
self._callback.on_comm_z_change(z)
|
self._callback.on_comm_z_change(z)
|
||||||
@@ -1673,13 +1702,13 @@ class MachineCom(object):
|
|||||||
|
|
||||||
def _gcode_M104_sent(self, cmd, cmd_type=None):
|
def _gcode_M104_sent(self, cmd, cmd_type=None):
|
||||||
toolNum = self._currentTool
|
toolNum = self._currentTool
|
||||||
toolMatch = self._regex_paramTInt.search(cmd)
|
toolMatch = regexes_parameters["intT"].search(cmd)
|
||||||
if toolMatch:
|
if toolMatch:
|
||||||
toolNum = int(toolMatch.group(1))
|
toolNum = int(toolMatch.group("value"))
|
||||||
match = self._regex_paramSInt.search(cmd)
|
match = regexes_parameters["floatS"].search(cmd)
|
||||||
if match:
|
if match:
|
||||||
try:
|
try:
|
||||||
target = float(match.group(1))
|
target = float(match.group("value"))
|
||||||
if toolNum in self._temp.keys() and self._temp[toolNum] is not None and isinstance(self._temp[toolNum], tuple):
|
if toolNum in self._temp.keys() and self._temp[toolNum] is not None and isinstance(self._temp[toolNum], tuple):
|
||||||
(actual, oldTarget) = self._temp[toolNum]
|
(actual, oldTarget) = self._temp[toolNum]
|
||||||
self._temp[toolNum] = (actual, target)
|
self._temp[toolNum] = (actual, target)
|
||||||
@@ -1689,10 +1718,10 @@ class MachineCom(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _gcode_M140_sent(self, cmd, cmd_type=None):
|
def _gcode_M140_sent(self, cmd, cmd_type=None):
|
||||||
match = self._regex_paramSInt.search(cmd)
|
match = regexes_parameters["floatS"].search(cmd)
|
||||||
if match:
|
if match:
|
||||||
try:
|
try:
|
||||||
target = float(match.group(1))
|
target = float(match.group("value"))
|
||||||
if self._bedTemp is not None and isinstance(self._bedTemp, tuple):
|
if self._bedTemp is not None and isinstance(self._bedTemp, tuple):
|
||||||
(actual, oldTarget) = self._bedTemp
|
(actual, oldTarget) = self._bedTemp
|
||||||
self._bedTemp = (actual, target)
|
self._bedTemp = (actual, target)
|
||||||
@@ -1715,37 +1744,61 @@ class MachineCom(object):
|
|||||||
|
|
||||||
def _gcode_M110_sending(self, cmd, cmd_type=None):
|
def _gcode_M110_sending(self, cmd, cmd_type=None):
|
||||||
newLineNumber = None
|
newLineNumber = None
|
||||||
match = self._regex_paramNInt.search(cmd)
|
match = regexes_parameters["intN"].search(cmd)
|
||||||
if match:
|
if match:
|
||||||
try:
|
try:
|
||||||
newLineNumber = int(match.group(1))
|
newLineNumber = int(match.group("value"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
newLineNumber = 0
|
newLineNumber = 0
|
||||||
|
|
||||||
# send M110 command with new line number
|
with self._line_mutex:
|
||||||
self._currentLine = newLineNumber
|
# send M110 command with new line number
|
||||||
|
self._currentLine = newLineNumber
|
||||||
|
|
||||||
# after a reset of the line number we have no way to determine what line exactly the printer now wants
|
# after a reset of the line number we have no way to determine what line exactly the printer now wants
|
||||||
self._lastLines.clear()
|
self._lastLines.clear()
|
||||||
self._resendDelta = None
|
self._resendDelta = None
|
||||||
|
|
||||||
def _gcode_M112_queuing(self, cmd, cmd_type=None): # It's an emergency what todo? Canceling the print should be the minimum
|
def _gcode_M112_queuing(self, cmd, cmd_type=None):
|
||||||
self.cancelPrint()
|
# emergency stop, jump the queue with the M112
|
||||||
|
self._doSendWithoutChecksum("M112")
|
||||||
|
self._doIncrementAndSendWithChecksum("M112")
|
||||||
|
|
||||||
|
# No idea if the printer is still listening or if M112 won. Just in case
|
||||||
|
# we'll now try to also manually make sure all heaters are shut off - better
|
||||||
|
# safe than sorry. We do this ignoring the queue since at this point it
|
||||||
|
# is irrelevant whether the printer has sent enough ack's or not, we
|
||||||
|
# are going to shutdown the connection in a second anyhow.
|
||||||
|
for tool in range(self._printerProfileManager.get_current_or_default()["extruder"]["count"]):
|
||||||
|
self._doIncrementAndSendWithChecksum("M104 T{tool} S0".format(tool=tool))
|
||||||
|
self._doIncrementAndSendWithChecksum("M140 S0")
|
||||||
|
|
||||||
|
# close to reset host state
|
||||||
|
self._errorValue = "Closing serial port due to emergency stop M112."
|
||||||
|
self._log(self._errorValue)
|
||||||
|
self.close(isError=True)
|
||||||
|
|
||||||
|
# fire the M112 event since we sent it and we're going to prevent the caller from seeing it
|
||||||
|
gcode = "M112"
|
||||||
|
if gcode in gcodeToEvent:
|
||||||
|
eventManager().fire(gcodeToEvent[gcode])
|
||||||
|
|
||||||
|
# return None 1-tuple to eat the one that is queuing because we don't want to send it twice
|
||||||
|
# I hope it got it the first time because as far as I can tell, there is no way to know
|
||||||
|
return None,
|
||||||
|
|
||||||
def _gcode_G4_sent(self, cmd, cmd_type=None):
|
def _gcode_G4_sent(self, cmd, cmd_type=None):
|
||||||
# we are intending to dwell for a period of time, increase the timeout to match
|
# we are intending to dwell for a period of time, increase the timeout to match
|
||||||
cmd = cmd.upper()
|
p_match = regexes_parameters["floatP"].search(cmd)
|
||||||
p_idx = cmd.find('P')
|
s_match = regexes_parameters["floatS"].search(cmd)
|
||||||
s_idx = cmd.find('S')
|
|
||||||
_timeout = 0
|
_timeout = 0
|
||||||
if p_idx != -1:
|
if p_match:
|
||||||
# dwell time is specified in milliseconds
|
_timeout = float(p_match.group("value")) / 1000.0
|
||||||
_timeout = float(cmd[p_idx+1:]) / 1000.0
|
elif s_match:
|
||||||
elif s_idx != -1:
|
_timeout = float(s_match.group("value"))
|
||||||
# dwell time is specified in seconds
|
|
||||||
_timeout = float(cmd[s_idx+1:])
|
|
||||||
self._timeout = get_new_timeout("communication") + _timeout
|
self._timeout = get_new_timeout("communication") + _timeout
|
||||||
|
|
||||||
##~~ command phase handlers
|
##~~ command phase handlers
|
||||||
@@ -1997,11 +2050,15 @@ def get_new_timeout(type):
|
|||||||
return now + get_interval(type)
|
return now + get_interval(type)
|
||||||
|
|
||||||
|
|
||||||
def get_interval(type):
|
def get_interval(type, default_value=0.0):
|
||||||
if type not in default_settings["serial"]["timeout"]:
|
if type not in default_settings["serial"]["timeout"]:
|
||||||
return 0
|
return default_value
|
||||||
else:
|
else:
|
||||||
return settings().getFloat(["serial", "timeout", type])
|
value = settings().getFloat(["serial", "timeout", type])
|
||||||
|
if not value:
|
||||||
|
return default_value
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|
||||||
_temp_command_regex = re.compile("^M(?P<command>104|109|140|190)(\s+T(?P<tool>\d+)|\s+S(?P<temperature>[-+]?\d*\.?\d*))+")
|
_temp_command_regex = re.compile("^M(?P<command>104|109|140|190)(\s+T(?P<tool>\d+)|\s+S(?P<temperature>[-+]?\d*\.?\d*))+")
|
||||||
|
|
||||||
@@ -2131,3 +2188,159 @@ def convert_feedback_controls(configured_controls):
|
|||||||
|
|
||||||
return feedback_controls, feedback_matcher
|
return feedback_controls, feedback_matcher
|
||||||
|
|
||||||
|
def canonicalize_temperatures(parsed, current):
|
||||||
|
"""
|
||||||
|
Canonicalizes the temperatures provided in parsed.
|
||||||
|
|
||||||
|
Will make sure that returned result only contains extruder keys
|
||||||
|
like Tn, so always qualified with a tool number.
|
||||||
|
|
||||||
|
The algorithm for cleaning up the parsed keys is the following:
|
||||||
|
|
||||||
|
* If ``T`` is not included with the reported extruders, return
|
||||||
|
* If more than just ``T`` is reported:
|
||||||
|
* If both ``T`` and ``T0`` are reported set ``Tc`` to ``T``, remove
|
||||||
|
``T`` from the result.
|
||||||
|
* Else set ``T0`` to ``T`` and delete ``T`` (Smoothie extra).
|
||||||
|
* If only ``T`` is reported, set ``Tc`` to ``T`` and delete ``T``
|
||||||
|
* return
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
parsed (dict): the parsed temperatures (mapping tool => (actual, target))
|
||||||
|
to canonicalize
|
||||||
|
current (int): the current active extruder
|
||||||
|
Returns:
|
||||||
|
dict: the canonicalized version of ``parsed``
|
||||||
|
"""
|
||||||
|
|
||||||
|
reported_extruders = filter(lambda x: x.startswith("T"), parsed.keys())
|
||||||
|
if not "T" in reported_extruders:
|
||||||
|
# Our reported_extruders are either empty or consist purely
|
||||||
|
# of Tn keys, no need for any action
|
||||||
|
return parsed
|
||||||
|
|
||||||
|
current_tool_key = "T%d" % current
|
||||||
|
result = dict(parsed)
|
||||||
|
|
||||||
|
if len(reported_extruders) > 1:
|
||||||
|
if "T0" in reported_extruders:
|
||||||
|
# Both T and T0 are present, so T contains the current
|
||||||
|
# extruder's temperature, e.g. for current_tool == 1:
|
||||||
|
#
|
||||||
|
# T:<T1> T0:<T0> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T0:<T1> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# Same goes if Tc is already present, it will be overwritten:
|
||||||
|
#
|
||||||
|
# T:<T1> T0:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T0:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
result[current_tool_key] = result["T"]
|
||||||
|
del result["T"]
|
||||||
|
else:
|
||||||
|
# So T is there, but T0 isn't. That looks like Smoothieware which
|
||||||
|
# always reports the first extruder T0 as T:
|
||||||
|
#
|
||||||
|
# T:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T0:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
result["T0"] = result["T"]
|
||||||
|
del result["T"]
|
||||||
|
|
||||||
|
else:
|
||||||
|
# We only have T. That can mean two things:
|
||||||
|
#
|
||||||
|
# * we only have one extruder at all, or
|
||||||
|
# * we are currently parsing a response to M109/M190, which on
|
||||||
|
# some firmwares doesn't report the full M105 output while
|
||||||
|
# waiting for the target temperature to be reached but only
|
||||||
|
# reports the current tool and bed
|
||||||
|
#
|
||||||
|
# In both cases it is however safe to just move our T over
|
||||||
|
# to T<current> in the parsed data, current should always stay
|
||||||
|
# 0 for single extruder printers. E.g. for current_tool == 1:
|
||||||
|
#
|
||||||
|
# T:<T1>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T1:<T1>
|
||||||
|
|
||||||
|
result[current_tool_key] = result["T"]
|
||||||
|
del result["T"]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def parse_temperature_line(line, current):
|
||||||
|
"""
|
||||||
|
Parses the provided temperature line.
|
||||||
|
|
||||||
|
The result will be a dictionary mapping from the extruder or bed key to
|
||||||
|
a tuple with current and target temperature. The result will be canonicalized
|
||||||
|
with :func:`canonicalize_temperatures` before returning.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
line (str): the temperature line to parse
|
||||||
|
current (int): the current active extruder
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: a 2-tuple with the maximum tool number and a dict mapping from
|
||||||
|
key to (actual, target) tuples, with key either matching ``Tn`` for ``n >= 0`` or ``B``
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
maxToolNum = 0
|
||||||
|
for match in re.finditer(regex_temp, line):
|
||||||
|
values = match.groupdict()
|
||||||
|
tool = values["tool"]
|
||||||
|
toolnum = values.get("toolnum", None)
|
||||||
|
toolNumber = int(toolnum) if toolnum is not None and len(toolnum) else None
|
||||||
|
if toolNumber > maxToolNum:
|
||||||
|
maxToolNum = toolNumber
|
||||||
|
|
||||||
|
try:
|
||||||
|
actual = float(match.group(3))
|
||||||
|
target = None
|
||||||
|
if match.group(4) and match.group(5):
|
||||||
|
target = float(match.group(5))
|
||||||
|
|
||||||
|
result[tool] = (actual, target)
|
||||||
|
except ValueError:
|
||||||
|
# catch conversion issues, we'll rather just not get the temperature update instead of killing the connection
|
||||||
|
pass
|
||||||
|
|
||||||
|
return max(maxToolNum, current), canonicalize_temperatures(result, current)
|
||||||
|
|
||||||
|
def gcode_command_for_cmd(cmd):
|
||||||
|
"""
|
||||||
|
Tries to parse the provided ``cmd`` and extract the GCODE command identifier from it (e.g. "G0" for "G0 X10.0").
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
cmd (str): The command to try to parse.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str or None: The GCODE command identifier if it could be parsed, or None if not.
|
||||||
|
"""
|
||||||
|
if not cmd:
|
||||||
|
return None
|
||||||
|
|
||||||
|
gcode = regex_command.search(cmd)
|
||||||
|
if not gcode:
|
||||||
|
return None
|
||||||
|
|
||||||
|
values = gcode.groupdict()
|
||||||
|
if "commandGM" in values and values["commandGM"]:
|
||||||
|
return values["commandGM"]
|
||||||
|
elif "commandT" in values and values["commandT"]:
|
||||||
|
return values["commandT"]
|
||||||
|
else:
|
||||||
|
# this should never happen
|
||||||
|
return None
|
||||||
|
|
||||||
@@ -11,6 +11,9 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
from octoprint.util import to_unicode
|
||||||
|
|
||||||
|
|
||||||
class UnknownPip(Exception):
|
class UnknownPip(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -77,11 +80,13 @@ class PipCaller(object):
|
|||||||
while p.returncode is None:
|
while p.returncode is None:
|
||||||
line = p.stderr.readline(timeout=0.5)
|
line = p.stderr.readline(timeout=0.5)
|
||||||
if line:
|
if line:
|
||||||
|
line = to_unicode(line, errors="replace")
|
||||||
self._log_stderr(line)
|
self._log_stderr(line)
|
||||||
all_stderr.append(line)
|
all_stderr.append(line)
|
||||||
|
|
||||||
line = p.stdout.readline(timeout=0.5)
|
line = p.stdout.readline(timeout=0.5)
|
||||||
if line:
|
if line:
|
||||||
|
line = to_unicode(line, errors="replace")
|
||||||
self._log_stdout(line)
|
self._log_stdout(line)
|
||||||
all_stdout.append(line)
|
all_stdout.append(line)
|
||||||
|
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ def get_babel_commandclasses(pot_file=None,
|
|||||||
def create_plugin_setup_parameters(identifier="todo", name="TODO", version="0.1", description="TODO", author="TODO",
|
def create_plugin_setup_parameters(identifier="todo", name="TODO", version="0.1", description="TODO", author="TODO",
|
||||||
mail="todo@example.com", url="TODO", license="AGPLv3", source_folder=".", additional_data=None,
|
mail="todo@example.com", url="TODO", license="AGPLv3", source_folder=".", additional_data=None,
|
||||||
additional_packages=None, ignored_packages=None, requires=None, extra_requires=None,
|
additional_packages=None, ignored_packages=None, requires=None, extra_requires=None,
|
||||||
cmdclass=None, eggs=None, package=None):
|
cmdclass=None, eggs=None, package=None, dependency_links=None):
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
if package is None:
|
if package is None:
|
||||||
@@ -454,6 +454,9 @@ def create_plugin_setup_parameters(identifier="todo", name="TODO", version="0.1"
|
|||||||
if ignored_packages is None:
|
if ignored_packages is None:
|
||||||
ignored_packages = list()
|
ignored_packages = list()
|
||||||
|
|
||||||
|
if dependency_links is None:
|
||||||
|
dependency_links = list()
|
||||||
|
|
||||||
if requires is None:
|
if requires is None:
|
||||||
requires = ["OctoPrint"]
|
requires = ["OctoPrint"]
|
||||||
if not isinstance(requires, list):
|
if not isinstance(requires, list):
|
||||||
@@ -519,6 +522,7 @@ def create_plugin_setup_parameters(identifier="todo", name="TODO", version="0.1"
|
|||||||
|
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
extras_require=extra_requires,
|
extras_require=extra_requires,
|
||||||
|
dependency_links=dependency_links,
|
||||||
|
|
||||||
# Hook the plugin into the "octoprint.plugin" entry point, mapping the plugin_identifier to the plugin_package.
|
# Hook the plugin into the "octoprint.plugin" entry point, mapping the plugin_identifier to the plugin_package.
|
||||||
# That way OctoPrint will be able to find the plugin and load it.
|
# That way OctoPrint will be able to find the plugin and load it.
|
||||||
|
|||||||
@@ -156,3 +156,76 @@ class TestCommHelpers(unittest.TestCase):
|
|||||||
self.assertEquals(x_template, x["templates"][x_template_key])
|
self.assertEquals(x_template, x["templates"][x_template_key])
|
||||||
|
|
||||||
self.assertEquals("(?P<group{temp_key}>{temp_regex})|(?P<group{x_key}>{x_regex})".format(**locals()), matcher.pattern)
|
self.assertEquals("(?P<group{temp_key}>{temp_regex})|(?P<group{x_key}>{x_regex})".format(**locals()), matcher.pattern)
|
||||||
|
|
||||||
|
@data(
|
||||||
|
("G4 P2.0", "floatP", True, "2.0"),
|
||||||
|
("M109 S220.0", "floatS", True, "220.0"),
|
||||||
|
("G1 X10.0 Y10.0 Z0.2", "floatZ", True, "0.2"),
|
||||||
|
("G1X10.0Y10.0Z0.2", "floatZ", True, "0.2"),
|
||||||
|
("g1x10.0y10.0z0.2", "floatZ", True, "0.2"),
|
||||||
|
("M110 N0", "intN", True, "0"),
|
||||||
|
("M104 S220.0 T1", "intT", True, "1"),
|
||||||
|
("M104 T1 S220.0", "intT", True, "1"),
|
||||||
|
("N100 M110", "intN", True, "100"),
|
||||||
|
("NP100", "floatP", False, None),
|
||||||
|
)
|
||||||
|
@unpack
|
||||||
|
def test_parameter_regexes(self, line, parameter, should_match, expected_value):
|
||||||
|
from octoprint.util.comm import regexes_parameters
|
||||||
|
|
||||||
|
regex = regexes_parameters[parameter]
|
||||||
|
match = regex.search(line)
|
||||||
|
|
||||||
|
if should_match:
|
||||||
|
self.assertIsNotNone(match)
|
||||||
|
self.assertEquals(expected_value, match.group("value"))
|
||||||
|
else:
|
||||||
|
self.assertIsNone(match)
|
||||||
|
|
||||||
|
@data(
|
||||||
|
("G0 X0", "G0"),
|
||||||
|
("G28 X0 Y0", "G28"),
|
||||||
|
("M109 S220.0 T1", "M109"),
|
||||||
|
("M117 Hello World", "M117"),
|
||||||
|
("T0", "T"),
|
||||||
|
("T3", "T"),
|
||||||
|
(None, None),
|
||||||
|
("No match", None)
|
||||||
|
)
|
||||||
|
@unpack
|
||||||
|
def test_gcode_command_for_cmd(self, cmd, expected):
|
||||||
|
from octoprint.util.comm import gcode_command_for_cmd
|
||||||
|
result = gcode_command_for_cmd(cmd)
|
||||||
|
self.assertEquals(expected, result)
|
||||||
|
|
||||||
|
@data(
|
||||||
|
("T:23.0 B:60.0", 0, dict(T0=(23.0, None), B=(60.0, None)), 0),
|
||||||
|
("T:23.0 B:60.0", 1, dict(T1=(23.0, None), B=(60.0, None)), 1),
|
||||||
|
("T:23.0/220.0 B:60.0/70.0", 0, dict(T0=(23.0, 220.0), B=(60.0, 70.0)), 0),
|
||||||
|
("ok T:23.0/220.0 T0:23.0/220.0 T1:50.2/210.0 T2:39.4/220.0 B:60.0", 0, dict(T0=(23.0, 220.0), T1=(50.2, 210.0), T2=(39.4, 220.0), B=(60.0, None)), 2),
|
||||||
|
("ok T:50.2/210.0 T0:23.0/220.0 T1:50.2/210.0 T2:39.4/220.0 B:60.0", 1, dict(T0=(23.0, 220.0), T1=(50.2, 210.0), T2=(39.4, 220.0), B=(60.0, None)), 2)
|
||||||
|
)
|
||||||
|
@unpack
|
||||||
|
def test_process_temperature_line(self, line, current, expected_result, expected_max):
|
||||||
|
from octoprint.util.comm import parse_temperature_line
|
||||||
|
maxtool, result = parse_temperature_line(line, current)
|
||||||
|
self.assertDictEqual(expected_result, result)
|
||||||
|
self.assertEquals(expected_max, maxtool)
|
||||||
|
|
||||||
|
@data(
|
||||||
|
(dict(T=(23.0,None)), 0, dict(T0=(23.0, None))),
|
||||||
|
(dict(T=(23.0,None)), 1, dict(T1=(23.0, None))),
|
||||||
|
(dict(T=(23.0, None), T0=(23.0, None), T1=(42.0, None)), 0, dict(T0=(23.0, None), T1=(42.0, None))),
|
||||||
|
(dict(T=(42.0, None), T0=(23.0, None), T1=(42.0, None)), 1, dict(T0=(23.0, None), T1=(42.0, None))),
|
||||||
|
(dict(T=(21.0, None), T0=(23.0, None), T1=(42.0, None)), 0, dict(T0=(21.0, None), T1=(42.0, None))),
|
||||||
|
(dict(T=(41.0, None), T0=(23.0, None), T1=(42.0, None)), 1, dict(T0=(23.0, None), T1=(41.0, None))),
|
||||||
|
(dict(T=(23.0, None), T1=(42.0, None)), 1, dict(T0=(23.0, None), T1=(42.0, None))),
|
||||||
|
(dict(T0=(23.0, None), T1=(42.0, None)), 1, dict(T0=(23.0, None), T1=(42.0, None)))
|
||||||
|
|
||||||
|
)
|
||||||
|
@unpack
|
||||||
|
def test_canonicalize_temperatures(self, parsed, current, expected):
|
||||||
|
from octoprint.util.comm import canonicalize_temperatures
|
||||||
|
result = canonicalize_temperatures(parsed, current)
|
||||||
|
self.assertDictEqual(expected, result)
|
||||||
|
|
||||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
+373
-232
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user