Compare commits
251
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e603b98d0d | ||
|
|
e235fc299f | ||
|
|
4f25ed546e | ||
|
|
f72b9db6a9 | ||
|
|
80e8e33283 | ||
|
|
00d0396417 | ||
|
|
59e39662f1 | ||
|
|
038e1b9a57 | ||
|
|
bbefeeeb02 | ||
|
|
2801da5c51 | ||
|
|
471dab9406 | ||
|
|
1deb247ce5 | ||
|
|
4469a2d84a | ||
|
|
2da7aa358d | ||
|
|
cbb083d7f6 | ||
|
|
d68de2c3c7 | ||
|
|
454c5e494a | ||
|
|
3b1874ea25 | ||
|
|
e0233dee13 | ||
|
|
84a99e1b53 | ||
|
|
b7e0e89bb4 | ||
|
|
d8c3063813 | ||
|
|
1485050234 | ||
|
|
6d7721f8f5 | ||
|
|
e3ae71eabd | ||
|
|
e88041c59e | ||
|
|
e17db4e1cf | ||
|
|
766a64c8f6 | ||
|
|
8485d2c9a7 | ||
|
|
397e691a6a | ||
|
|
6481f7cf6b | ||
|
|
46c527d24a | ||
|
|
5392f39cc4 | ||
|
|
4a324b4f5e | ||
|
|
2855b0e7a7 | ||
|
|
39e4cd3136 | ||
|
|
8fefa63c8c | ||
|
|
10532b9118 | ||
|
|
7f2eb470e4 | ||
|
|
8955b8e0b6 | ||
|
|
ee9d5048e2 | ||
|
|
09bb74b6c6 | ||
|
|
493dddf66e | ||
|
|
8173f8d0c4 | ||
|
|
01feec47d7 | ||
|
|
2b60dbc7e1 | ||
|
|
32f5f36e5a | ||
|
|
96294df710 | ||
|
|
ef54cbb148 | ||
|
|
9cd597a467 | ||
|
|
2263ebde72 | ||
|
|
1fd8d597ab | ||
|
|
2aec0b3a75 | ||
|
|
47d10a6d3e | ||
|
|
ee216ddc93 | ||
|
|
7756d312e2 | ||
|
|
19e03eeeb2 | ||
|
|
e73aeba03b | ||
|
|
87f3c5acce | ||
|
|
a38a3e67c9 | ||
|
|
547ae9e13e | ||
|
|
b031092f07 | ||
|
|
6e6dd2c34e | ||
|
|
759f4f8ea2 | ||
|
|
bee82bcde9 | ||
|
|
888fb97e66 | ||
|
|
9c775bd899 | ||
|
|
4bf3445eef | ||
|
|
47b3f51a3f | ||
|
|
2e6b85990d | ||
|
|
30a4b9e9ab | ||
|
|
81a259e51b | ||
|
|
e85e9661e0 | ||
|
|
1d60250942 | ||
|
|
e11463f6ce | ||
|
|
1146a1bb6f | ||
|
|
311fdd5aca | ||
|
|
6ddc55bf80 | ||
|
|
2c930ef069 | ||
|
|
3739bbc652 | ||
|
|
8d544e63f4 | ||
|
|
7e4cf6c5dc | ||
|
|
c8d162c999 | ||
|
|
017515dcc1 | ||
|
|
d8bd684f96 | ||
|
|
aad5c70eb0 | ||
|
|
ea2f0a9b17 | ||
|
|
c4131d5e4b | ||
|
|
21127bcf2a | ||
|
|
04da8afb07 | ||
|
|
c38f06cce2 | ||
|
|
968f952f69 | ||
|
|
8409fdaa48 | ||
|
|
f29e736427 | ||
|
|
ac3b6f6df8 | ||
|
|
a4444ccb68 | ||
|
|
270a0dcb1f | ||
|
|
a889bec4d8 | ||
|
|
7ee9bc32eb | ||
|
|
fd62c1fa3d | ||
|
|
a445cfe65e | ||
|
|
e20a9925dd | ||
|
|
09a4fb2515 | ||
|
|
cce7389a42 | ||
|
|
b138ea7a47 | ||
|
|
3b708ce079 | ||
|
|
4441618be5 | ||
|
|
0525c9ab40 | ||
|
|
0035e7c3ff | ||
|
|
073060d253 | ||
|
|
55980a1c2c | ||
|
|
852a2cf157 | ||
|
|
2e6ee57162 | ||
|
|
5c54f16ece | ||
|
|
04a13268ad | ||
|
|
49fdac7528 | ||
|
|
75f6ef4bae | ||
|
|
9fd608691b | ||
|
|
a70a45f062 | ||
|
|
61b0845f19 | ||
|
|
30d618267f | ||
|
|
b9665a8af4 | ||
|
|
204d212323 | ||
|
|
04528a635b | ||
|
|
15522a98b0 | ||
|
|
db1c18075f | ||
|
|
3b556e9d79 | ||
|
|
8761273636 | ||
|
|
08efe80304 | ||
|
|
c4258c5bb0 | ||
|
|
58799888b7 | ||
|
|
fb6d57963b | ||
|
|
03f228c0ef | ||
|
|
93ae368f58 | ||
|
|
378752e155 | ||
|
|
bec307900d | ||
|
|
cc1d88c4c8 | ||
|
|
72eef3e224 | ||
|
|
84f6833597 | ||
|
|
2a94abdc49 | ||
|
|
fab5f34aaa | ||
|
|
76f79e5380 | ||
|
|
1b25029207 | ||
|
|
8df2a5436b | ||
|
|
72f005b7fe | ||
|
|
0eac10d5a6 | ||
|
|
2a42f02aec | ||
|
|
7c48cfd0f7 | ||
|
|
bba796d551 | ||
|
|
a855f3e62c | ||
|
|
5079e7e891 | ||
|
|
ddc948fa94 | ||
|
|
f88f2b25ea | ||
|
|
ea59dab7ab | ||
|
|
f0914c2214 | ||
|
|
b3e76c3ecc | ||
|
|
a4d5acb0b8 | ||
|
|
79b66f17b6 | ||
|
|
bcb6c7a1d4 | ||
|
|
36198c684f | ||
|
|
a3a60c5967 | ||
|
|
6df3cb5c12 | ||
|
|
0611329a6d | ||
|
|
2f90fca5ce | ||
|
|
e4e97190da | ||
|
|
9c748a85b4 | ||
|
|
78c2199d89 | ||
|
|
0e67906d1e | ||
|
|
4c602cba2e | ||
|
|
89255e2ec9 | ||
|
|
372b3662e9 | ||
|
|
e007dbaf4c | ||
|
|
dbe07af426 | ||
|
|
f67f9b9399 | ||
|
|
c6c5328418 | ||
|
|
accbfc2b45 | ||
|
|
9976f2b7a3 | ||
|
|
f249563b2c | ||
|
|
09e023917c | ||
|
|
799b86b287 | ||
|
|
ea1bcf8e5d | ||
|
|
ee93e25ffd | ||
|
|
d25f664be3 | ||
|
|
3bffe4f7cb | ||
|
|
f140dd9d44 | ||
|
|
d44747b39a | ||
|
|
f2da9d8d7d | ||
|
|
5483ef7cd4 | ||
|
|
85d212ba97 | ||
|
|
44af09580a | ||
|
|
530fca95e4 | ||
|
|
59ae7e39f2 | ||
|
|
72167d14d2 | ||
|
|
2c6568acd1 | ||
|
|
e27c216a05 | ||
|
|
7b4c148dd7 | ||
|
|
a924520dd6 | ||
|
|
1c3e463ac6 | ||
|
|
e88eb6dd85 | ||
|
|
59dfa994bd | ||
|
|
6959ce4d38 | ||
|
|
08bc0082cf | ||
|
|
6069d74a54 | ||
|
|
68ee7030f1 | ||
|
|
81342acccc | ||
|
|
e029f33901 | ||
|
|
7bd8cff137 | ||
|
|
055dcfa0e1 | ||
|
|
8acf417383 | ||
|
|
b50e1aee8a | ||
|
|
c714bce17e | ||
|
|
a9a8e48489 | ||
|
|
9dec840818 | ||
|
|
9af125ca6d | ||
|
|
1f4fabe6ef | ||
|
|
121f36704d | ||
|
|
85ff545c07 | ||
|
|
3662c84de5 | ||
|
|
79558fdfbf | ||
|
|
11040f272a | ||
|
|
fa2716c65c | ||
|
|
768b06e35a | ||
|
|
0820c23aea | ||
|
|
361fbaa366 | ||
|
|
a91359f2af | ||
|
|
4bfabf82ae | ||
|
|
c90f556fe9 | ||
|
|
352b190a72 | ||
|
|
e9b0bd9e65 | ||
|
|
c8ea808d93 | ||
|
|
d40c3e6241 | ||
|
|
e94f789b72 | ||
|
|
9ff44c49a6 | ||
|
|
c7b933ba00 | ||
|
|
6765b25803 | ||
|
|
59b60f5dad | ||
|
|
2822992843 | ||
|
|
1b82aa859f | ||
|
|
12be637f85 | ||
|
|
3bd9d11fc3 | ||
|
|
e864d6b03e | ||
|
|
547db7c1f5 | ||
|
|
d6516e4a4c | ||
|
|
2387b4a771 | ||
|
|
b03d43156d | ||
|
|
07423712a6 | ||
|
|
81735d07c9 | ||
|
|
03e328fd13 | ||
|
|
7efcf00baf | ||
|
|
a3254466f7 | ||
|
|
f8dc504773 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [foosel]
|
||||
patreon: foosel
|
||||
custom: https://octoprint.org/support-octoprint/
|
||||
@@ -16,8 +16,9 @@ checklist:
|
||||
made sure your changes don't interfere with current development by
|
||||
talking it through with the maintainers, e.g. through a
|
||||
Brainstorming ticket
|
||||
* [ ] Your PR targets OctoPrint's devel branch, or maintenance if it's
|
||||
a bug fix for an issue present in the current stable version (no PRs
|
||||
* [ ] Your PR targets OctoPrint's devel branch if it's a completely
|
||||
new feature, or maintenance if it's a bug fix or improvement of
|
||||
existing functionality for the current stable version (no PRs
|
||||
against master or anything else please)
|
||||
* [ ] Your PR was opened from a custom branch on your repository
|
||||
(no PRs from your version of master, maintenance or devel please),
|
||||
|
||||
+12
-9
@@ -18,16 +18,19 @@ prerelease
|
||||
HEAD
|
||||
\(detached.*
|
||||
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.3.12
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.3.13
|
||||
# so are any fix/... and improve/... branches
|
||||
maintenance 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
|
||||
fix/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
|
||||
improve/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
|
||||
maintenance 1.3.13 2a42f02aecaedf2c55579984e0bc94e44402cc15 pep440-dev
|
||||
fix/.* 1.3.13 2a42f02aecaedf2c55579984e0bc94e44402cc15 pep440-dev
|
||||
improve/.* 1.3.13 2a42f02aecaedf2c55579984e0bc94e44402cc15 pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.3.11rc4
|
||||
# staging/maintenance is currently the branch for preparation of 1.3.12rc4
|
||||
# so is regressionfix/...
|
||||
staging/maintenance 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev
|
||||
regressionfix/.* 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev
|
||||
staging/maintenance 1.3.12rc4 a70a45f062687beb510fb3192e4227754e1dff39 pep440-dev
|
||||
regressionfix/.* 1.3.12rc4 a70a45f062687beb510fb3192e4227754e1dff39 pep440-dev
|
||||
|
||||
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
|
||||
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
|
||||
# staging/devel is currently the branch for preparation of 1.4.0rc2
|
||||
staging/devel 1.4.0rc2 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
|
||||
|
||||
# every other branch is a development branch and thus gets resolved to 1.5.0-dev for now
|
||||
.* 1.5.0 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
|
||||
+10
@@ -105,6 +105,16 @@ date of first contribution):
|
||||
* [Jack Wilsdon](https://github.com/jackwilsdon)
|
||||
* [Ryan Finnie](https://github.com/rfinnie)
|
||||
* [Timur Duehr](https://github.com/tduehr)
|
||||
* [Nicolai Nielsen](https://github.com/dovecode)
|
||||
* [Janne Mäntyharju](https://github.com/JanneMantyharju)
|
||||
* [Steven Spungin](https://github.com/flamenco)
|
||||
* [Piotr Usewicz](https://github.com/pusewicz)
|
||||
* [Aliaksei Pilko](https://github.com/aliaksei135)
|
||||
* [Ben Yarmis](https://github.com/byarmis)
|
||||
* [Florian Heilmann](https://github.com/FHeilmann)
|
||||
* [Ludovico de Nittis](https://github.com/RyuzakiKK)
|
||||
* [Dominik Paľo](https://github.com/DominikPalo)
|
||||
* [Kelly Anderson](https://github.com/cbxbiker61)
|
||||
|
||||
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
|
||||
|
||||
+3
-1172
File diff suppressed because it is too large.
Load diff
@@ -31,7 +31,7 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!**
|
||||
You are currently looking at the source code repository of OctoPrint. If you already installed it
|
||||
(e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only
|
||||
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
|
||||
might be of more interest for you. You might also want to subscribe to join
|
||||
might be of more interest for you. You might also want to subscribe to join
|
||||
[the community forum at community.octoprint.org](https://community.octoprint.org) where there are other active users who might be
|
||||
able to help you with any questions you might have.
|
||||
|
||||
@@ -39,7 +39,7 @@ able to help you with any questions you might have.
|
||||
|
||||
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
|
||||
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), debugging help
|
||||
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
|
||||
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
|
||||
[the community forum at community.octoprint.org](https://community.octoprint.org)
|
||||
and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
|
||||
|
||||
@@ -65,14 +65,15 @@ you already have Python 2.7, 3.6 or 3.7, pip and virtualenv set up on your syste
|
||||
|
||||
1. Checkout OctoPrint: `git clone https://github.com/foosel/OctoPrint.git`
|
||||
2. Change into the OctoPrint folder: `cd OctoPrint`
|
||||
3. Create a user-owned virtual environment therein: `virtualenv venv`
|
||||
3. Create a user-owned virtual environment therein: `virtualenv venv` if your system default python version is
|
||||
python 2.7, otherwise you need to specify the version explicitly, e.g. `virtualenv --python=python2.7 venv`.
|
||||
4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .`
|
||||
|
||||
You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage)
|
||||
for details.
|
||||
|
||||
After installation, please make sure you follow the first-run wizard and set up
|
||||
access control as necessary.
|
||||
access control as necessary.
|
||||
|
||||
## Dependencies
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Always update to the latest version of OctoPrint to keep up with security patches.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Email to security@octoprint.org.
|
||||
|
||||
For the sake of the userbase of OctoPrint please always disclose responsibly and with a 90+ day window.
|
||||
+10
-5
@@ -8,8 +8,8 @@ thanks to everyone who contributed!
|
||||
|
||||
* Andre Bubel
|
||||
* Andrew Moorby
|
||||
* ANTONIO AUGUSTO DE LIMA PONTES
|
||||
* Arnljot Arntsen
|
||||
* Bjorn Breckenridge
|
||||
* Boris Hussein
|
||||
* Brad Jackson
|
||||
* Christian Petropolis
|
||||
@@ -22,36 +22,41 @@ thanks to everyone who contributed!
|
||||
* Eric Betts
|
||||
* Ernesto Martinez
|
||||
* Franziska Kunsmann
|
||||
* GadgetAngel
|
||||
* George Robles
|
||||
* jean-claude migneault
|
||||
* Jeff Renfer
|
||||
* Jefferson Hunt
|
||||
* Jeremiah Avery
|
||||
* Joseph Payne
|
||||
* John Robinson (JRo)
|
||||
* Joshua Wills
|
||||
* Justin Kaufman
|
||||
* Kaile Riser
|
||||
* Kale Stedman
|
||||
* Kazuhiro Ogura
|
||||
* Kyle Menigoz
|
||||
* LA 3D Printer Repair
|
||||
* Lee Dohm
|
||||
* LulzBot®
|
||||
* Makespace Madrid
|
||||
* Mark Walker
|
||||
* Martin Majewski
|
||||
* Michael Aumock
|
||||
* Miles Flavel
|
||||
* Mosaic Manufacturing
|
||||
* OMER MEHMET SUTAS
|
||||
* Patrick Glyré
|
||||
* Patrick McGinnis
|
||||
* Prof Yuh Wen Chen
|
||||
* Randy C. Will
|
||||
* Ranjib Dey
|
||||
* Robert Gusek
|
||||
* Samer Najia
|
||||
* Shawn Lewis
|
||||
* Simon Hallam
|
||||
* Stefan Krister
|
||||
* Sven Mueller
|
||||
* TEVO 3D Printers
|
||||
* Trent Shumay
|
||||
* Ulrich Kempken
|
||||
* Vladislav Kuzemchik
|
||||
|
||||
and 1544 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
and 1653 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
|
||||
@@ -218,6 +218,17 @@ Progress information
|
||||
- 1
|
||||
- Integer
|
||||
- Estimate of time left to print, in seconds
|
||||
* - ``printTimeLeftOrigin``
|
||||
- 1
|
||||
- String
|
||||
- Origin of the current time left estimate. Can currently be either of:
|
||||
|
||||
* ``linear``: based on an linear approximation of the progress in file in bytes vs time
|
||||
* ``analysis``: based on an analysis of the file
|
||||
* ``estimate``: calculated estimate after stabilization of linear estimation
|
||||
* ``average``: based on the average total from past prints of the same model against the same printer profile
|
||||
* ``mixed-analysis``: mixture of ``estimate`` and ``analysis``
|
||||
* ``mixed-average``: mixture of ``estimate`` and ``average``
|
||||
|
||||
.. _sec-api-datamodel-files:
|
||||
|
||||
|
||||
@@ -148,8 +148,14 @@ Login
|
||||
via the ``passive`` flag.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`login response <sec-api-general-datamodel-login>` on successful
|
||||
login, whether active or passive. The active (username/password) login may also return a :http:statuscode:`401` in
|
||||
case of a username/password mismatch or unknown user and a :http:statuscode:`403` in case of a deactivated account.
|
||||
login, whether active or passive. The active (username/password) login may also return a :http:statuscode:`403` in
|
||||
case of a username/password mismatch, unknown user or a deactivated account.
|
||||
|
||||
.. warning::
|
||||
|
||||
Previous versions of this API endpoint did return a :http:statuscode:`401` in case of a username/password
|
||||
mismatch or an unknown user. That was incompatible with basic authentication since it was a wrong use of
|
||||
the :http:statuscode:`401` code and got therefore changed as part of a bug fix.
|
||||
|
||||
:json passive: If present, performs a passive login only, returning information about the current user that's
|
||||
active either through an existing session or the used API key
|
||||
@@ -157,8 +163,7 @@ Login
|
||||
:json pass: (active login only) Password
|
||||
:json remember: (active login only) Whether to set a "remember me" cookie on the session
|
||||
:status 200: Successful login
|
||||
:status 401: Username/password mismatch or unknown user
|
||||
:status 403: Deactivated account
|
||||
:status 403: Username/password mismatch, unknown user or deactivated account
|
||||
|
||||
.. _sec-api-general-logout:
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ REST API
|
||||
|
||||
general.rst
|
||||
version.rst
|
||||
apps.rst
|
||||
connection.rst
|
||||
files.rst
|
||||
job.rst
|
||||
|
||||
@@ -350,7 +350,7 @@ Issue a tool command
|
||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
||||
|
||||
* ``targets``: Target temperature(s) to set, properties must match the format ``tool{n}`` with ``n`` being the
|
||||
tool's index starting with 0.
|
||||
tool's index starting with 0. A value of `0` will turn the heater off.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
||||
@@ -630,7 +630,7 @@ Issue a bed command
|
||||
target
|
||||
Sets the given target temperature on the printer's bed. Additional parameters:
|
||||
|
||||
* ``target``: Target temperature to set.
|
||||
* ``target``: Target temperature to set. A value of `0` will turn the heater off.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's bed. Additional parameters:
|
||||
@@ -770,7 +770,7 @@ Retrieve the current bed state
|
||||
Issue a chamber command
|
||||
=======================
|
||||
|
||||
.. http:post:: /api/printer/bed
|
||||
.. http:post:: /api/printer/chamber
|
||||
|
||||
Chamber commands allow setting the temperature and temperature offsets for the printer's heated chamber. Available commands
|
||||
are:
|
||||
@@ -778,7 +778,7 @@ Issue a chamber command
|
||||
target
|
||||
Sets the given target temperature on the printer's chamber. Additional parameters:
|
||||
|
||||
* ``target``: Target temperature to set.
|
||||
* ``target``: Target temperature to set. A value of `0` will turn the heater off.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's chamber. Additional parameters:
|
||||
@@ -790,7 +790,7 @@ Issue a chamber command
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
If no heated chambed is configured for the currently selected printer profile, the resource will return
|
||||
If no heated chamber is configured for the currently selected printer profile, the resource will return
|
||||
an :http:statuscode:`409`.
|
||||
|
||||
Requires user rights.
|
||||
|
||||
@@ -27,7 +27,7 @@ Command line usage
|
||||
------------------
|
||||
|
||||
The Backup Plugin implements a command line interface that allows creation and restoration of backups.
|
||||
It adds two new commands, ``backup:backup`` and ``backup_restore``.
|
||||
It adds two new commands, ``backup:backup`` and ``backup:restore``.
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ network running Microsoft Windows. You will be able to just double click on the
|
||||
OctoPrint instance icon in "Networks > Other Devices" in your Windows Explorer,
|
||||
which will take you directly to the web frontend.
|
||||
|
||||
The ZeroConf support allows OctoPrint to announce itself to Safari on MacOS X
|
||||
The ZeroConf support allows OctoPrint to announce itself to Safari on macOS
|
||||
on the same network.
|
||||
|
||||
Linux users should install `Avahi <http://avahi.org>`_ and can then use one
|
||||
|
||||
@@ -196,6 +196,10 @@ Version checks
|
||||
* ``checkout_folder``: (mandatory) The full path to the folder with a valid git
|
||||
repository to check.
|
||||
|
||||
* ``pypi_release``: Checks `pypi.org <https://pypi.org>`_ for new releases of a specified package.
|
||||
|
||||
* ``package``: (mandatory) Name of the package which to check.
|
||||
|
||||
* ``command_line``: Uses a provided script to determine whether an update
|
||||
is available. Additional config parameters:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ config.yaml
|
||||
|
||||
If not specified via the command line, the main configuration file ``config.yaml`` for OctoPrint is expected in its
|
||||
settings folder, which unless defined differently via the command line is located at ``~/.octoprint`` on Linux, at
|
||||
``%APPDATA%/OctoPrint`` on Windows and at ``~/Library/Application Support/OctoPrint`` on MacOS. If the file is not there,
|
||||
``%APPDATA%/OctoPrint`` on Windows and at ``~/Library/Application Support/OctoPrint`` on macOS. If the file is not there,
|
||||
you can just create it - it will only get created by OctoPrint once you save settings that deviate from the default
|
||||
settings.
|
||||
|
||||
@@ -290,6 +290,9 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# Whether to delete generated web assets on server startup (forcing a regeneration)
|
||||
clean_on_startup: true
|
||||
|
||||
# enable or disable the loading animation
|
||||
showLoadingAnimation: true
|
||||
|
||||
# Settings for the virtual printer
|
||||
virtualPrinter:
|
||||
|
||||
@@ -425,8 +428,7 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
||||
# Lines to send on simulated reset
|
||||
resetLines:
|
||||
- start
|
||||
- Marlin: Virtual Marlin!
|
||||
- "\x80"
|
||||
- "Marlin: Virtual Marlin!"
|
||||
- "SD card ok"
|
||||
|
||||
# Initial set of prepared oks to use instead of regular ok (e.g. to simulate
|
||||
|
||||
@@ -5,7 +5,7 @@ logging.yaml
|
||||
|
||||
The logging configuration file ``logging.yaml`` for OctoPrint is expected in its settings folder, which unless defined
|
||||
differently on the command line is located at ``~/.octoprint`` on Linux, at ``%APPDATA%/OctoPrint`` on Windows and at
|
||||
``~/Library/Application Support/OctoPrint`` on MacOS.
|
||||
``~/Library/Application Support/OctoPrint`` on macOS.
|
||||
|
||||
You can use it to change the log levels of the individual components within OctoPrint, which might be necessary to help
|
||||
in debugging issues you are experiencing, or to change the configuration of the logging handlers themselves, e.g. in
|
||||
|
||||
@@ -17,21 +17,30 @@ below.
|
||||
* `Python 3.7 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv``
|
||||
* `Git <https://git-scm.com>`_
|
||||
|
||||
* Checkout the OctoPrint sources from their Git repository:
|
||||
* Checkout the OctoPrint sources from their Git repository:
|
||||
|
||||
* ``git clone -b devel https://github.com/foosel/OctoPrint.git``
|
||||
|
||||
* Enter the checked out source folder: ``cd OctoPrint``
|
||||
* Create virtual environments in the checked out source folder for both Python 2.7 and Python 3.7 to use for
|
||||
installing and running OctoPrint and its dependencies (this avoids potential versioning issues for the dependencies
|
||||
with system wide installed instances):
|
||||
* PY2: ``virtualenv --python=python2 venv2``
|
||||
* PY3: ``virtualenv --python=python3 venv3``
|
||||
|
||||
* PY2: ``virtualenv --python=python2 venv2``
|
||||
* PY3: ``virtualenv --python=python3 venv3``
|
||||
|
||||
* Activate one of the virtual environments:
|
||||
* PY2: ``source venv2/bin/activate`` (Linux, MacOS) or ``source venv2/Scripts/activate`` (Git Bash under Windows, see below)
|
||||
* PY3: ``source venv3/bin/activate`` (Linux, MacOS) or ``source venv3/Scripts/activate`` (Git Bash under Windows, see below)
|
||||
|
||||
* PY2: ``source venv2/bin/activate`` (Linux, macOS) or ``source venv2/Scripts/activate`` (Git Bash under Windows, see below)
|
||||
* PY3: ``source venv3/bin/activate`` (Linux, macOS) or ``source venv3/Scripts/activate`` (Git Bash under Windows, see below)
|
||||
|
||||
* Update ``pip`` in the virtual environment:
|
||||
|
||||
* ``pip install --upgrade pip``
|
||||
|
||||
* Install OctoPrint in `"editable" mode <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_,
|
||||
including its regular *and* development and plugin development dependencies:
|
||||
including its regular *and* development and plugin development dependencies:
|
||||
|
||||
* ``pip install -e .[develop,plugins]``
|
||||
|
||||
When the virtual environment is activated you can then:
|
||||
@@ -197,8 +206,10 @@ PyCharm
|
||||
.......
|
||||
|
||||
- "File" > "Open ...", select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``)
|
||||
- "File" > "Settings ..." > "Project: OctoPrint" > "Project Interpreter" > "Add local ...", select OctoPrint venv
|
||||
- **(Linux, Windows)** "File" > "Settings ..." > "Project: OctoPrint" > "Project Interpreter" > "Add local ...", select OctoPrint venv
|
||||
folder (e.g. ``~/devel/OctoPrint/venv`` or ``C:\Devel\OctoPrint\venv``)
|
||||
- **(macOS)** "PyCharm" > "Preferences ..." > "Project: OctoPrint" > "Project Interpreter" > "Add ..." >
|
||||
"Virtualenv Environment > "Existing Environment", select OctoPrint venv folder (e.g. ``~/devel/OctoPrint/venv``)
|
||||
- Right click "src" in project tree, mark as source folder
|
||||
- Add Run/Debug Configuration, select "Python":
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ be found in the full :ref:`config.yaml documentation <sec-configuration-config_y
|
||||
|
||||
The steps to take are as follows:
|
||||
|
||||
* Find config.yaml in the OctoPrint settings folder. Usually in ``~/.octoprint`` on Linux, in ``%APPDATA%/OctoPrint`` on Windows and in ``~/Library/Application Support/OctoPrint`` on MacOS.
|
||||
* Find config.yaml in the OctoPrint settings folder. Usually in ``~/.octoprint`` on Linux, in ``%APPDATA%/OctoPrint`` on Windows and in ``~/Library/Application Support/OctoPrint`` on macOS.
|
||||
* Add or extend the ``devel`` section with:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
+35
-2
@@ -104,7 +104,8 @@ ClientOpened
|
||||
|
||||
Payload:
|
||||
|
||||
* ``remoteAddress``: the remote address (IP) of the client that connected
|
||||
* ``remoteAddress``: the remote address (IP) of the client that connected. On the push socket only available with
|
||||
a valid login session.
|
||||
|
||||
**Note:** Name changed in version 1.1.0
|
||||
|
||||
@@ -115,6 +116,19 @@ ClientClosed
|
||||
|
||||
* ``remoteAddress``: the remote address (IP) of the client that disconnected
|
||||
|
||||
UserLoggedIn
|
||||
A user logged in. On the push socket only available with a valid login session with admin rights.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``username``: the name of the user who logged in
|
||||
|
||||
UserLoggedOut
|
||||
A user logged out. On the push socket only available with a valid login session with admin rights.
|
||||
|
||||
Payload:
|
||||
* ``username``: the name of the user who logged out
|
||||
|
||||
ConnectivityChanged
|
||||
The server's internet connectivity changed
|
||||
|
||||
@@ -151,6 +165,9 @@ Error
|
||||
An unrecoverable error has been encountered, either as reported by the firmware (e.g. a thermal runaway) or
|
||||
on the connection.
|
||||
|
||||
Note that this event will not fire for error messages from the firmware that are handled (and as such recovered from)
|
||||
either by OctoPrint or a plugin.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``error``: the error string
|
||||
@@ -588,6 +605,7 @@ SlicingStarted
|
||||
|
||||
Payload:
|
||||
|
||||
* ``slicer``: the used slicer
|
||||
* ``stl``: the STL's filename
|
||||
* ``stl_location``: the STL's location
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
@@ -599,6 +617,7 @@ SlicingDone
|
||||
|
||||
Payload:
|
||||
|
||||
* ``slicer``: the used slicer
|
||||
* ``stl``: the STL's filename
|
||||
* ``stl_location``: the STL's location
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
@@ -611,6 +630,7 @@ SlicingCancelled
|
||||
|
||||
Payload:
|
||||
|
||||
* ``slicer``: the used slicer
|
||||
* ``stl``: the STL's filename
|
||||
* ``stl_location``: the STL's location
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
@@ -621,6 +641,7 @@ SlicingFailed
|
||||
|
||||
Payload:
|
||||
|
||||
* ``slicer``: the used slicer
|
||||
* ``stl``: the STL's filename
|
||||
* ``stl_location``: the STL's location
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
@@ -636,7 +657,7 @@ SlicingProfileAdded
|
||||
* ``profile``: the profile that was added
|
||||
|
||||
SlicingProfileModified
|
||||
A new slicing profile was modified.
|
||||
A slicing profile was modified.
|
||||
|
||||
Payload:
|
||||
|
||||
@@ -661,3 +682,15 @@ SettingsUpdated
|
||||
|
||||
This event may also be triggered if calling code of :py:class:`octoprint.settings.Settings.save` or
|
||||
:py:class:`octoprint.plugin.PluginSettings.save` sets the ``trigger_event`` parameter to ``True``.
|
||||
|
||||
.. _sec-events-available_events-printer_profile:
|
||||
|
||||
Printer Profile
|
||||
---------------
|
||||
|
||||
PrinterProfileModified
|
||||
A printer profile was modified.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``identifier``: the identifier of the modified printer profile
|
||||
@@ -11,7 +11,7 @@ is clicked.
|
||||
|
||||
Unless :ref:`configured otherwise <sec-configuration-config_yaml-folder>`, OctoPrint expects scripts to be located in
|
||||
the ``scripts/gcode`` folder in OctoPrint configuration directory (per default ``~/.octoprint`` on Linux, ``%APPDATA%\OctoPrint``
|
||||
on Windows and ``~/Library/Application Support/OctoPrint`` on MacOS).
|
||||
on Windows and ``~/Library/Application Support/OctoPrint`` on macOS).
|
||||
|
||||
These GCODE scripts are backed by the templating engine Jinja2, allowing more than just
|
||||
simple "send-as-is" scripts but making use of a full blown templating language in order to create your scripts. To
|
||||
|
||||
+17
-10
@@ -5,19 +5,20 @@ Safe mode
|
||||
*********
|
||||
|
||||
With the advent of support for plugins in OctoPrint, it quickly became apparent that some of the bugs
|
||||
reported on OctoPrint's bug tracker were actually bugs with installed third party plugins instead of
|
||||
OctoPrint itself.
|
||||
reported on OctoPrint's bug tracker were actually bugs with installed third party plugins or language
|
||||
packs instead of OctoPrint itself.
|
||||
|
||||
To allow an easier identification of these cases, OctoPrint 1.3.0 introduced safe mode. Starting
|
||||
OctoPrint in safe mode disables all plugins that are not bundled with OctoPrint, allowing to easier
|
||||
identify most cases where a third party plugin is the culprit of an observed issue.
|
||||
OctoPrint in safe mode disables all plugins (and starting with 1.3.13 also all language packs) that are
|
||||
not bundled with OctoPrint, allowing to easier identify most cases where a third party plugin or language
|
||||
pack is the culprit of an observed issue.
|
||||
|
||||
Additionally, OctoPrint allows uninstalling plugins in this mode, allowing recovery from cases where
|
||||
a third party plugin causes the server to not start up or the web interface to not render or function
|
||||
correctly anymore.
|
||||
Additionally, OctoPrint allows uninstalling plugins and language packs in this mode, allowing recovery
|
||||
from cases where a third party addition causes the server to not start up or the web interface to not
|
||||
render or function correctly anymore.
|
||||
|
||||
Whenever reporting an issue with OctoPrint, please always attempt to reproduce it in safe mode as well to
|
||||
ensure it really is an issue in OctoPrint itself and now caused by one of your installed third party plugins.
|
||||
ensure it really is an issue in OctoPrint itself and now caused by one of your installed third party additions.
|
||||
|
||||
.. _sec-features-safemode-how:
|
||||
|
||||
@@ -73,11 +74,17 @@ When OctoPrint is running in safe mode the following changes to its normal opera
|
||||
|
||||
* OctoPrint will not enable any of the installed third party plugins. OctoPrint considers all plugins third
|
||||
party plugins that do not ship with OctoPrint's sources, so any plugins installed either via `pip` or
|
||||
into OctoPrint's plugin folder at ``~/.octoprint/plugins`` (Linux), ``%APPDATA%/OctoPrint`` (Windows) and
|
||||
``~/Library/Application Support/OctoPrint`` (MacOS).
|
||||
into OctoPrint's plugin folder at ``~/.octoprint/plugins`` (Linux), ``%APPDATA%/OctoPrint/plugins`` (Windows) and
|
||||
``~/Library/Application Support/OctoPrint/plugins`` (macOS).
|
||||
* OctoPrint will not enable any of the installed third party language packs. OctoPrint considers all language packs
|
||||
third party language packs that do not ship with OctoPrint's sources, so any language plugins installed
|
||||
through the language pack manager within settings and/or stored in the language pack folder at
|
||||
``~/.octoprint/translations`` (Linux), ``%APPDATA%/OctoPrint/translations`` (Windows) or
|
||||
``~/Library/Application Support/OctoPrint/translations`` (macOS).
|
||||
* OctoPrint will still allow to uninstall third party plugins through the built-in Plugin Manager.
|
||||
* OctoPrint will still allow to disable (bundled) plugins that are still enabled.
|
||||
* OctoPrint will not allow to enable third party plugins.
|
||||
* OctoPrint will still allow to manage language packs.
|
||||
* OctoPrint's web interface will display a notification to remind you that it is running in
|
||||
safe mode.
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 58 KiB |
@@ -42,7 +42,7 @@
|
||||
To register for all message types, provide ``*`` as the type to register for.
|
||||
|
||||
``handler`` is expected to be a function accepting one object parameter ``eventObj``, consisting
|
||||
of the received message as property ``key`` and the received payload (if any) as property ``data``.
|
||||
of the received message as property ``event`` and the received payload (if any) as property ``data``.
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ Now, the execution order of the ``on_after_startup`` method will be determined b
|
||||
|
||||
This will result in the following messages to be generated:
|
||||
|
||||
.. code-block:: plain
|
||||
.. code-block:: none
|
||||
|
||||
Plugin B starting up
|
||||
Plugin C starting up
|
||||
|
||||
@@ -11,7 +11,7 @@ import requests
|
||||
from contextlib import closing
|
||||
|
||||
from sphinx.directives.code import LiteralIncludeReader, LiteralInclude, dedent_lines, \
|
||||
nodes, set_source_info, parselinenos, logger, container_wrapper
|
||||
nodes, parselinenos, logger, container_wrapper
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
@@ -39,11 +39,10 @@ class OnlineIncludeReader(LiteralIncludeReader):
|
||||
|
||||
return lines
|
||||
except (IOError, OSError):
|
||||
raise IOError(_('Include file %r not found or reading it failed') % filename)
|
||||
raise IOError('Include file %r not found or reading it failed' % filename)
|
||||
except UnicodeError:
|
||||
raise UnicodeError(_('Encoding %r used for reading included file %r seems to '
|
||||
'be wrong, try giving an :encoding: option') %
|
||||
(self.encoding, filename))
|
||||
raise UnicodeError('Encoding %r used for reading included file %r seems to '
|
||||
'be wrong, try giving an :encoding: option' % (self.encoding, filename))
|
||||
|
||||
|
||||
class OnlineIncludeDirective(LiteralInclude):
|
||||
@@ -69,7 +68,7 @@ class OnlineIncludeDirective(LiteralInclude):
|
||||
text, lines = reader.read(location=location)
|
||||
|
||||
retnode = nodes.literal_block(text, text, source=url)
|
||||
set_source_info(self, retnode)
|
||||
self.set_source_info(retnode)
|
||||
if self.options.get('diff'): # if diff is set, set udiff
|
||||
retnode['language'] = 'udiff'
|
||||
elif 'language' in self.options:
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ octoprint.init => /etc/init.d/octoprint
|
||||
## systemd
|
||||
|
||||
```
|
||||
octoprint.service => /etc/systemd/service/octoprint.service
|
||||
octoprint.service => /etc/systemd/system/octoprint.service
|
||||
```
|
||||
@@ -17,6 +17,11 @@ import setuptools
|
||||
# we test against 2.7, 3.6 and 3.7, so that's what we'll mark as supported
|
||||
PYTHON_REQUIRES = ">=2.7.9, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
|
||||
|
||||
# Requirements for setup.py
|
||||
SETUP_REQUIRES = [
|
||||
"markdown>=3.1,<3.2",
|
||||
]
|
||||
|
||||
# Requirements for our application
|
||||
INSTALL_REQUIRES = [
|
||||
# the following dependencies are non trivial to update since later versions introduce backwards incompatible
|
||||
@@ -27,7 +32,7 @@ INSTALL_REQUIRES = [
|
||||
# guarantee backwards compatibility for plugins and such with that
|
||||
# version, hence we need to pin to a lower version for now. See #1697
|
||||
"tornado==4.5.3", # a memory leak was observed in tornado >= 5, see #2585
|
||||
"regex!=2018.11.6", # avoid broken 2018.11.6. See #2874
|
||||
"regex!=2018.11.6", # avoid broken 2018.11.6. See #2874
|
||||
|
||||
# anything below this should be checked on releases for new versions
|
||||
|
||||
@@ -35,10 +40,10 @@ INSTALL_REQUIRES = [
|
||||
"Flask-Principal>=0.4,<0.5",
|
||||
"Flask-Babel>=0.12,<0.13",
|
||||
"Flask-Assets>=0.12,<0.13",
|
||||
"werkzeug>=0.15.1,<0.16",
|
||||
"werkzeug>=0.16,<0.17",
|
||||
"cachelib>=0.1,<0.2",
|
||||
"PyYAML>=5.1,<6",
|
||||
"markdown>=3.0,<3.1",
|
||||
"markdown>=3.1,<3.2",
|
||||
"pyserial>=3.4,<3.5",
|
||||
"netaddr>=0.7.19,<0.8",
|
||||
"watchdog>=0.9.0,<0.10",
|
||||
@@ -47,41 +52,42 @@ INSTALL_REQUIRES = [
|
||||
"pylru>=1.2,<1.3",
|
||||
"rsa>=4.0,<5",
|
||||
"pkginfo>=1.5.0.1,<1.6",
|
||||
"requests>=2.21.0,<3",
|
||||
"semantic_version>=2.6,<2.7",
|
||||
"psutil>=5.6.1,<5.7",
|
||||
"requests>=2.22.0,<3",
|
||||
"semantic_version>=2.8,<2.9",
|
||||
"psutil>=5.6.5,<5.7",
|
||||
"Click>=7,<8",
|
||||
"awesome-slugify>=1.6.5,<1.7",
|
||||
"feedparser>=5.2.1,<5.3",
|
||||
"future>=0.17,<0.18",
|
||||
"future>=0.18.2,<0.19",
|
||||
"websocket-client>=0.56,<0.57",
|
||||
"wrapt>=1.11.1,<1.12",
|
||||
"emoji>=0.5.1,<0.6",
|
||||
"wrapt>=1.11.2,<1.12",
|
||||
"emoji>=0.5.4,<0.6",
|
||||
"frozendict>=1.2,<1.3",
|
||||
"sentry-sdk==0.7.7"
|
||||
"sentry-sdk==0.13.2",
|
||||
"filetype>=1.0.5,<2"
|
||||
]
|
||||
|
||||
# Python 2 specific requirements
|
||||
INSTALL_REQUIRES_PYTHON2 = [
|
||||
"futures>=3.2,<3.3",
|
||||
"futures>=3.3,<3.4",
|
||||
"monotonic>=1.5,<1.6",
|
||||
"scandir>=1.10,<1.11",
|
||||
"chainmap>=1.0.3,<1.1",
|
||||
"typing>=3.6.6,<4"
|
||||
"typing>=3.7.4.1,<4"
|
||||
]
|
||||
|
||||
# OSX specific requirements
|
||||
INSTALL_REQUIRES_OSX = [
|
||||
"appdirs>=1.4.0",
|
||||
"appdirs>=1.4.3",
|
||||
]
|
||||
|
||||
# Additional requirements for optional install options
|
||||
EXTRA_REQUIRES = dict(
|
||||
# Dependencies for developing OctoPrint
|
||||
develop=[
|
||||
# Testing dependencies
|
||||
"mock>=2.0.0,<3",
|
||||
"pytest>=4.2.1,<5.0",
|
||||
# Testing dependencies - SEE ALSO tox.ini
|
||||
"mock>=3.0.5,<4",
|
||||
"pytest==4.6.6",
|
||||
"pytest-doctest-custom>=1.0.0,<1.1",
|
||||
"ddt",
|
||||
|
||||
@@ -89,10 +95,11 @@ EXTRA_REQUIRES = dict(
|
||||
"flake8",
|
||||
|
||||
# Documentation dependencies
|
||||
"sphinx>=1.6,<1.7",
|
||||
"sphinx>=1.8.5,<2",
|
||||
"sphinxcontrib-httpdomain",
|
||||
"sphinxcontrib-mermaid>=0.3",
|
||||
"sphinxcontrib-mermaid>=0.3.1",
|
||||
"sphinx_rtd_theme",
|
||||
"readthedocs-sphinx-ext==0.5.17" # Later versions require Jinja >= 2.9
|
||||
],
|
||||
|
||||
# Dependencies for developing OctoPrint plugins
|
||||
@@ -131,14 +138,14 @@ def read_file_contents(path):
|
||||
with codecs.open(path, encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
def data_copy_build_py_factory(files, baseclass):
|
||||
class data_copy_build_py(baseclass):
|
||||
def md_to_html_build_py_factory(files, baseclass):
|
||||
class md_to_html_build_py(baseclass):
|
||||
files = dict()
|
||||
|
||||
def run(self):
|
||||
import shutil
|
||||
print("RUNNING md_to_html_build_py")
|
||||
if not self.dry_run:
|
||||
for directory, files in self.__class__.files.items():
|
||||
for directory, files in self.files.items():
|
||||
target_dir = os.path.join(self.build_lib, directory)
|
||||
self.mkpath(target_dir)
|
||||
|
||||
@@ -146,16 +153,22 @@ def data_copy_build_py_factory(files, baseclass):
|
||||
if isinstance(entry, tuple):
|
||||
if len(entry) != 2:
|
||||
continue
|
||||
source, dest = entry
|
||||
source, dest = entry[0], os.path.join(target_dir, entry[1])
|
||||
else:
|
||||
source = dest = entry
|
||||
shutil.copy(source, os.path.join(target_dir, dest))
|
||||
source = entry
|
||||
dest = os.path.join(target_dir, source + ".html")
|
||||
|
||||
print("Rendering markdown from {} to {}".format(source, dest))
|
||||
|
||||
from markdown import markdownFromFile
|
||||
markdownFromFile(input=source,
|
||||
output=dest,
|
||||
encoding="utf-8")
|
||||
baseclass.run(self)
|
||||
|
||||
return type(data_copy_build_py)(data_copy_build_py.__name__,
|
||||
(data_copy_build_py,),
|
||||
dict(files=files))
|
||||
return type(md_to_html_build_py)(md_to_html_build_py.__name__,
|
||||
(md_to_html_build_py,),
|
||||
dict(files=files))
|
||||
|
||||
def get_cmdclass():
|
||||
cmdclass = versioneer.get_cmdclass()
|
||||
@@ -169,10 +182,9 @@ def get_cmdclass():
|
||||
bundled_dir = os.path.join("src", "octoprint", "translations")
|
||||
cmdclass.update(octoprint_setuptools.get_babel_commandclasses(pot_file=pot_file, output_dir=translation_dir, pack_name_prefix="OctoPrint-i18n-", pack_path_prefix="", bundled_dir=bundled_dir))
|
||||
|
||||
cmdclass["build_py"] = data_copy_build_py_factory({
|
||||
cmdclass["build_py"] = md_to_html_build_py_factory({
|
||||
"octoprint/templates/_data": [
|
||||
"AUTHORS.md",
|
||||
"CHANGELOG.md",
|
||||
"SUPPORTERS.md",
|
||||
"THIRDPARTYLICENSES.md",
|
||||
]
|
||||
@@ -191,6 +203,7 @@ def params():
|
||||
long_description_content_type = "text/markdown"
|
||||
|
||||
python_requires = PYTHON_REQUIRES
|
||||
setup_requires = SETUP_REQUIRES
|
||||
install_requires = INSTALL_REQUIRES
|
||||
extras_require = EXTRA_REQUIRES
|
||||
dependency_links = DEPENDENCY_LINKS
|
||||
@@ -215,6 +228,7 @@ def params():
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: JavaScript",
|
||||
"Topic :: Printing",
|
||||
|
||||
@@ -410,7 +410,9 @@ def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connecti
|
||||
if not startup:
|
||||
return
|
||||
|
||||
sorted_disabled_from_overlays = sorted([(key, value[0], value[1]) for key, value in disabled_from_overlays.items()], key=lambda x: (x[2] is None, x[2], x[0]))
|
||||
from octoprint.util import sv
|
||||
|
||||
sorted_disabled_from_overlays = sorted([(key, value[0], value[1]) for key, value in disabled_from_overlays.items()], key=lambda x: (x[2] is None, sv(x[2]), sv(x[0])))
|
||||
|
||||
disabled_list = pm.plugin_disabled_list
|
||||
already_processed = []
|
||||
|
||||
@@ -19,15 +19,18 @@ import logging
|
||||
# noinspection PyCompatibility
|
||||
from builtins import range, bytes
|
||||
|
||||
from octoprint.settings import settings
|
||||
from octoprint.settings import settings as s
|
||||
|
||||
from octoprint.util import atomic_write, to_bytes, deprecated, monotonic_time
|
||||
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
|
||||
from octoprint.access.permissions import Permissions, OctoPrintPermission
|
||||
from octoprint.access.groups import GroupChangeListener, Group
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
class UserManager(GroupChangeListener, object):
|
||||
def __init__(self, group_manager):
|
||||
def __init__(self, group_manager, settings=None):
|
||||
self._group_manager = group_manager
|
||||
self._group_manager.register_listener(self)
|
||||
|
||||
@@ -36,6 +39,10 @@ class UserManager(GroupChangeListener, object):
|
||||
self._sessionids_by_userid = dict()
|
||||
self._enabled = True
|
||||
|
||||
if settings is None:
|
||||
settings = s()
|
||||
self._settings = settings
|
||||
|
||||
self._login_status_listeners = []
|
||||
|
||||
def register_login_status_listener(self, listener):
|
||||
@@ -92,14 +99,15 @@ class UserManager(GroupChangeListener, object):
|
||||
try:
|
||||
listener.on_user_logged_in(user)
|
||||
except Exception:
|
||||
self._logger.exception("Error in on_user_logged_in on {!r}".format(listener))
|
||||
self._logger.exception("Error in on_user_logged_in on {!r}".format(listener),
|
||||
extra=dict(callback=fqcn(listener)))
|
||||
|
||||
self._logger.debug("Logged in user: %r" % user)
|
||||
|
||||
return user
|
||||
|
||||
def logout_user(self, user):
|
||||
if user is None or user.is_anonymous:
|
||||
if user is None or user.is_anonymous or isinstance(user, AdminUser):
|
||||
return
|
||||
|
||||
if isinstance(user, LocalProxy):
|
||||
@@ -124,28 +132,31 @@ class UserManager(GroupChangeListener, object):
|
||||
try:
|
||||
listener.on_user_logged_out(user)
|
||||
except Exception:
|
||||
self._logger.exception("Error in on_user_logged_out on {!r}".format(listener))
|
||||
self._logger.exception("Error in on_user_logged_out on {!r}".format(listener),
|
||||
extra=dict(callback=fqcn(listener)))
|
||||
|
||||
self._logger.debug("Logged out user: %r" % user)
|
||||
|
||||
def _cleanup_sessions(self):
|
||||
for session, user in self._session_users_by_session.items():
|
||||
for session, user in list(self._session_users_by_session.items()):
|
||||
if not isinstance(user, SessionUser):
|
||||
continue
|
||||
if user.created + (24 * 60 * 60) < monotonic_time():
|
||||
self.logout_user(user)
|
||||
|
||||
@staticmethod
|
||||
def create_password_hash(password, salt=None):
|
||||
def create_password_hash(password, salt=None, settings=None):
|
||||
if not salt:
|
||||
salt = settings().get(["accessControl", "salt"])
|
||||
if settings is None:
|
||||
settings = s()
|
||||
salt = settings.get(["accessControl", "salt"])
|
||||
if salt is None:
|
||||
import string
|
||||
from random import choice
|
||||
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
|
||||
salt = "".join(choice(chars) for _ in range(32))
|
||||
settings().set(["accessControl", "salt"], salt)
|
||||
settings().save()
|
||||
settings.set(["accessControl", "salt"], salt)
|
||||
settings.save()
|
||||
|
||||
return hashlib.sha512(to_bytes(password, encoding="utf-8", errors="replace") + to_bytes(salt)).hexdigest()
|
||||
|
||||
@@ -154,13 +165,16 @@ class UserManager(GroupChangeListener, object):
|
||||
if not user:
|
||||
return False
|
||||
|
||||
hash = UserManager.create_password_hash(password)
|
||||
hash = UserManager.create_password_hash(password,
|
||||
settings=self._settings)
|
||||
if user.check_password(hash):
|
||||
# new hash matches, correct password
|
||||
return True
|
||||
else:
|
||||
# new hash doesn't match, but maybe the old one does, so check that!
|
||||
oldHash = UserManager.create_password_hash(password, salt="mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW")
|
||||
oldHash = UserManager.create_password_hash(password,
|
||||
salt="mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW",
|
||||
settings=self._settings)
|
||||
if user.check_password(oldHash):
|
||||
# old hash matches, we migrate the stored password hash to the new one and return True since it's the correct password
|
||||
self.change_user_password(username, password)
|
||||
@@ -261,7 +275,8 @@ class UserManager(GroupChangeListener, object):
|
||||
for user in users:
|
||||
listener.on_user_modified(user)
|
||||
except Exception:
|
||||
self._logger.exception("Error in on_user_modified on {!r}".format(listener))
|
||||
self._logger.exception("Error in on_user_modified on {!r}".format(listener),
|
||||
extra=dict(callback=fqcn(listener)))
|
||||
|
||||
def on_group_subgroups_changed(self, group, added=None, removed=None):
|
||||
users = self.find_sessions_for(lambda u: group in u.groups)
|
||||
@@ -271,7 +286,8 @@ class UserManager(GroupChangeListener, object):
|
||||
for user in users:
|
||||
listener.on_user_modified(user)
|
||||
except Exception:
|
||||
self._logger.exception("Error in on_user_modified on {!r}".format(listener))
|
||||
self._logger.exception("Error in on_user_modified on {!r}".format(listener),
|
||||
extra=dict(callback=fqcn(listener)))
|
||||
|
||||
def _trigger_on_user_modified(self, user):
|
||||
if isinstance(user, basestring):
|
||||
@@ -300,14 +316,16 @@ class UserManager(GroupChangeListener, object):
|
||||
for user in users:
|
||||
listener.on_user_modified(user)
|
||||
except Exception:
|
||||
self._logger.exception("Error in on_user_modified on {!r}".format(listener))
|
||||
self._logger.exception("Error in on_user_modified on {!r}".format(listener),
|
||||
extra=dict(callback=fqcn(listener)))
|
||||
|
||||
def _trigger_on_user_removed(self, username):
|
||||
for listener in self._login_status_listeners:
|
||||
try:
|
||||
listener.on_user_removed(username)
|
||||
except Exception:
|
||||
self._logger.exception("Error in on_user_removed on {!r}".format(listener))
|
||||
self._logger.exception("Error in on_user_removed on {!r}".format(listener),
|
||||
extra=dict(callback=fqcn(listener)))
|
||||
|
||||
#~~ Deprecated methods follow
|
||||
|
||||
@@ -428,13 +446,13 @@ class LoginStatusListener(object):
|
||||
##~~ FilebasedUserManager, takes available users from users.yaml file
|
||||
|
||||
class FilebasedUserManager(UserManager):
|
||||
def __init__(self, group_manager, path=None):
|
||||
UserManager.__init__(self, group_manager)
|
||||
def __init__(self, group_manager, path=None, settings=None):
|
||||
UserManager.__init__(self, group_manager, settings=settings)
|
||||
|
||||
if path is None:
|
||||
path = settings().get(["accessControl", "userfile"])
|
||||
path = self._settings.get(["accessControl", "userfile"])
|
||||
if path is None:
|
||||
path = os.path.join(settings().getBaseFolder("base"), "users.yaml")
|
||||
path = os.path.join(s().getBaseFolder("base"), "users.yaml")
|
||||
|
||||
self._userfile = path
|
||||
|
||||
@@ -537,7 +555,13 @@ class FilebasedUserManager(UserManager):
|
||||
if username in self._users and not overwrite:
|
||||
raise UserAlreadyExists(username)
|
||||
|
||||
self._users[username] = User(username, UserManager.create_password_hash(password), active, permissions, groups, apikey=apikey)
|
||||
self._users[username] = User(username,
|
||||
UserManager.create_password_hash(password,
|
||||
settings=self._settings),
|
||||
active,
|
||||
permissions,
|
||||
groups,
|
||||
apikey=apikey)
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
@@ -670,7 +694,8 @@ class FilebasedUserManager(UserManager):
|
||||
if not username in self._users:
|
||||
raise UnknownUser(username)
|
||||
|
||||
passwordHash = UserManager.create_password_hash(password)
|
||||
passwordHash = UserManager.create_password_hash(password,
|
||||
settings=self._settings)
|
||||
user = self._users[username]
|
||||
if user._passwordHash != passwordHash:
|
||||
user._passwordHash = passwordHash
|
||||
|
||||
@@ -138,9 +138,10 @@ from .dev import dev_commands
|
||||
from .client import client_commands
|
||||
from .config import config_commands
|
||||
from .analysis import analysis_commands
|
||||
from .user import user_commands
|
||||
|
||||
@click.group(name="octoprint", invoke_without_command=True, cls=click.CommandCollection,
|
||||
sources=[server_commands, plugin_commands, dev_commands, client_commands, config_commands, analysis_commands])
|
||||
sources=[server_commands, plugin_commands, dev_commands, client_commands, config_commands, analysis_commands, user_commands])
|
||||
@standard_options()
|
||||
@legacy_options
|
||||
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import click
|
||||
import logging
|
||||
|
||||
from octoprint import init_settings
|
||||
from octoprint.cli import get_ctx_obj_option
|
||||
from octoprint.access.groups import FilebasedGroupManager
|
||||
from octoprint.access.users import FilebasedUserManager, UnknownUser, UserAlreadyExists
|
||||
from octoprint.util import get_class, sv
|
||||
|
||||
click.disable_unicode_literals_warning = True
|
||||
|
||||
#~~ "octoprint user" commands
|
||||
|
||||
|
||||
@click.group()
|
||||
def user_commands():
|
||||
pass
|
||||
|
||||
|
||||
@user_commands.group(name="user")
|
||||
@click.pass_context
|
||||
def user(ctx):
|
||||
"""
|
||||
User management.
|
||||
|
||||
Note that this currently only supports managing user accounts stored in the configured user manager, not any
|
||||
user managers added through plugins and the "octoprint.users.factory" hook.
|
||||
"""
|
||||
try:
|
||||
logging.basicConfig(level=logging.DEBUG if get_ctx_obj_option(ctx, "verbosity", 0) > 0 else logging.WARN)
|
||||
settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None))
|
||||
|
||||
group_manager_name = settings.get(["accessControl", "groupManager"])
|
||||
try:
|
||||
clazz = get_class(group_manager_name)
|
||||
group_manager = clazz()
|
||||
except AttributeError:
|
||||
click.echo("Could not instantiate group manager {}, "
|
||||
"falling back to FilebasedGroupManager!".format(group_manager_name), err=True)
|
||||
group_manager = FilebasedGroupManager()
|
||||
|
||||
ctx.obj.group_manager = group_manager
|
||||
|
||||
name = settings.get(["accessControl", "userManager"])
|
||||
try:
|
||||
clazz = get_class(name)
|
||||
user_manager = clazz(group_manager=group_manager, settings=settings)
|
||||
except Exception:
|
||||
click.echo("Could not instantiate user manager {}, falling back to FilebasedUserManager!".format(name), err=True)
|
||||
user_manager = FilebasedUserManager(group_manager, settings=settings)
|
||||
finally:
|
||||
user_manager.enabled = settings.getBoolean(["accessControl", "enabled"])
|
||||
|
||||
ctx.obj.user_manager = user_manager
|
||||
|
||||
except Exception:
|
||||
click.echo("Could not instantiate user manager", err=True)
|
||||
return
|
||||
|
||||
|
||||
@user.command(name="list")
|
||||
@click.pass_context
|
||||
def list_users_command(ctx):
|
||||
"""Lists user information"""
|
||||
users = ctx.obj.user_manager.get_all_users()
|
||||
_print_list(users)
|
||||
|
||||
|
||||
@user.command(name="add")
|
||||
@click.argument("username", type=click.STRING, required=True)
|
||||
@click.password_option("--password", "password", help="Password for the user")
|
||||
@click.option("-g", "--group", "groups", multiple=True,
|
||||
help="Groups to set on the user")
|
||||
@click.option("-p", "--permission", "permissions", multiple=True,
|
||||
help="Individual permissions to set on the user")
|
||||
@click.option("--admin", "is_admin", type=click.BOOL, is_flag=True, default=False,
|
||||
help="Adds user to admin group")
|
||||
@click.pass_context
|
||||
def add_user_command(ctx, username, password, groups, permissions, is_admin):
|
||||
"""Add a new user."""
|
||||
if not groups:
|
||||
groups = []
|
||||
|
||||
if is_admin:
|
||||
groups.append(ctx.obj.group_manager.admin_group)
|
||||
|
||||
try:
|
||||
ctx.obj.user_manager.add_user(username,
|
||||
password,
|
||||
groups=groups,
|
||||
permissions=permissions,
|
||||
active=True)
|
||||
|
||||
user = ctx.obj.user_manager.find_user(username)
|
||||
if user:
|
||||
click.echo("User created:")
|
||||
click.echo("\t{}".format(_user_to_line(user.as_dict())))
|
||||
except UserAlreadyExists:
|
||||
click.echo("A user with the name {} does already exist!".format(username), err=True)
|
||||
|
||||
|
||||
@user.command(name="remove")
|
||||
@click.argument("username", type=click.STRING)
|
||||
@click.pass_context
|
||||
def remove_user_command(ctx, username):
|
||||
"""Remove an existing user."""
|
||||
confirm = click.prompt("This is will irreversibly destroy the user account! Enter 'yes' to confirm",
|
||||
type=click.STRING)
|
||||
|
||||
if confirm.lower() == "yes":
|
||||
ctx.obj.user_manager.remove_user(username)
|
||||
click.echo("User {} removed.".format(username))
|
||||
else:
|
||||
click.echo("User {} not removed.".format(username))
|
||||
|
||||
|
||||
@user.command(name="password")
|
||||
@click.argument("username", type=click.STRING)
|
||||
@click.password_option("--password", "password", help="New password for user")
|
||||
@click.pass_context
|
||||
def change_password_command(ctx, username, password):
|
||||
"""Change an existing user's password."""
|
||||
try:
|
||||
ctx.obj.user_manager.change_user_password(username, password)
|
||||
click.echo("Password changed for user {}.".format(username))
|
||||
except UnknownUser:
|
||||
click.echo("User {} does not exist!".format(username), err=True)
|
||||
|
||||
|
||||
@user.command(name="activate")
|
||||
@click.argument("username", type=click.STRING)
|
||||
@click.pass_context
|
||||
def activate_command(ctx, username):
|
||||
"""Activate a user account."""
|
||||
try:
|
||||
ctx.obj.user_manager.change_user_activation(username, True)
|
||||
click.echo("User {} activated.".format(username))
|
||||
|
||||
user = ctx.obj.user_manager.find_user(username)
|
||||
if user:
|
||||
click.echo("User created:")
|
||||
click.echo("\t{}".format(_user_to_line(user.asDict())))
|
||||
except UnknownUser:
|
||||
click.echo("User {} does not exist!".format(username), err=True)
|
||||
|
||||
|
||||
@user.command(name="deactivate")
|
||||
@click.argument("username", type=click.STRING)
|
||||
@click.pass_context
|
||||
def deactivate_command(ctx, username):
|
||||
"""Activate a user account."""
|
||||
try:
|
||||
ctx.obj.user_manager.change_user_activation(username, False)
|
||||
click.echo("User {} activated.".format(username))
|
||||
|
||||
user = ctx.obj.user_manager.find_user(username)
|
||||
if user:
|
||||
click.echo("User created:")
|
||||
click.echo("\t{}".format(_user_to_line(user.asDict())))
|
||||
except UnknownUser:
|
||||
click.echo("User {} does not exist!".format(username), err=True)
|
||||
|
||||
|
||||
def _print_list(users):
|
||||
click.echo("{} users registered in the system:".format(len(users)))
|
||||
for user in sorted(map(lambda x: x.as_dict(), users), key=lambda x: sv(x.get("name"))):
|
||||
click.echo("\t{}".format(_user_to_line(user)))
|
||||
|
||||
|
||||
def _user_to_line(user):
|
||||
return "{name}" \
|
||||
"\n\t\tactive: {active}" \
|
||||
"\n\t\tgroups: {groups}" \
|
||||
"\n\t\tpermissions: {permissions}".format(name=user.get("name"),
|
||||
active=user.get("active", "False"),
|
||||
groups=", ".join(user.get("groups", [])),
|
||||
permissions=", ".join(user.get("permissions", [])))
|
||||
@@ -47,6 +47,10 @@ class Events(object):
|
||||
CLIENT_OPENED = "ClientOpened"
|
||||
CLIENT_CLOSED = "ClientClosed"
|
||||
|
||||
# user login/logout
|
||||
USER_LOGGED_IN = "UserLoggedIn"
|
||||
USER_LOGGED_OUT = "UserLoggedOut"
|
||||
|
||||
# File management
|
||||
UPLOAD = "Upload"
|
||||
FILE_SELECTED = "FileSelected"
|
||||
@@ -227,14 +231,6 @@ class EventManager(object):
|
||||
|
||||
q.put((event, payload))
|
||||
|
||||
if event == Events.UPDATED_FILES and "type" in payload and payload["type"] == "printables":
|
||||
# when sending UpdatedFiles with type "printables", also send another event with deprecated type "gcode"
|
||||
# TODO v1.4.0 Remove again
|
||||
import copy
|
||||
legacy_payload = copy.deepcopy(payload)
|
||||
legacy_payload["type"] = "gcode"
|
||||
q.put((event, legacy_payload))
|
||||
|
||||
def subscribe(self, event, callback):
|
||||
"""
|
||||
Subscribe a listener to an event -- pass in the event name (as a string) and the callback object
|
||||
|
||||
@@ -18,6 +18,7 @@ from .destinations import FileDestinations
|
||||
from .analysis import QueueEntry, AnalysisQueue
|
||||
from .storage import LocalFileStorage
|
||||
from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
|
||||
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -224,6 +225,7 @@ class FileManager(object):
|
||||
|
||||
import octoprint.settings
|
||||
self._recovery_file = os.path.join(octoprint.settings.settings().getBaseFolder("data"), "print_recovery_data.yaml")
|
||||
self._analyzeGcode = octoprint.settings.settings().get(["gcodeAnalysis", "runAt"])
|
||||
|
||||
def initialize(self, process_backlog=False):
|
||||
self.reload_plugins()
|
||||
@@ -231,6 +233,10 @@ class FileManager(object):
|
||||
self.process_backlog()
|
||||
|
||||
def process_backlog(self):
|
||||
# only check for a backlog if gcodeAnalysis is 'idle' or 'always'
|
||||
if self._analyzeGcode == "never":
|
||||
return
|
||||
|
||||
def worker():
|
||||
self._logger.info("Adding backlog items from all storage types to analysis queue...".format(**locals()))
|
||||
for storage_type, storage_manager in self._storage_managers.items():
|
||||
@@ -330,16 +336,18 @@ class FileManager(object):
|
||||
printer_profile_id, callback, callback_args, _error=None, _cancelled=False, _analysis=None):
|
||||
try:
|
||||
if _error:
|
||||
eventManager().fire(Events.SLICING_FAILED, dict(stl=source_path,
|
||||
stl_location=source_location,
|
||||
gcode=dest_path,
|
||||
gcode_location=dest_location,
|
||||
reason=_error))
|
||||
eventManager().fire(Events.SLICING_FAILED, dict(slicer=slicer_name,
|
||||
stl=source_path,
|
||||
stl_location=source_location,
|
||||
gcode=dest_path,
|
||||
gcode_location=dest_location,
|
||||
reason=_error))
|
||||
elif _cancelled:
|
||||
eventManager().fire(Events.SLICING_CANCELLED, dict(stl=source_path,
|
||||
stl_location=source_location,
|
||||
gcode=dest_path,
|
||||
gcode_location=dest_location))
|
||||
eventManager().fire(Events.SLICING_CANCELLED, dict(slicer=slicer_name,
|
||||
stl=source_path,
|
||||
stl_location=source_location,
|
||||
gcode=dest_path,
|
||||
gcode_location=dest_location))
|
||||
else:
|
||||
source_meta = self.get_metadata(source_location, source_path)
|
||||
hash = source_meta.get("hash", "n/a")
|
||||
@@ -357,11 +365,12 @@ class FileManager(object):
|
||||
printer_profile=printer_profile, analysis=_analysis)
|
||||
|
||||
end_time = octoprint.util.monotonic_time()
|
||||
eventManager().fire(Events.SLICING_DONE, dict(stl=source_path,
|
||||
stl_location=source_location,
|
||||
gcode=dest_path,
|
||||
gcode_location=dest_location,
|
||||
time=end_time - start_time))
|
||||
eventManager().fire(Events.SLICING_DONE, dict(slicer=slicer_name,
|
||||
stl=source_path,
|
||||
stl_location=source_location,
|
||||
gcode=dest_path,
|
||||
gcode_location=dest_location,
|
||||
time=end_time - start_time))
|
||||
|
||||
if callback is not None:
|
||||
if callback_args is None:
|
||||
@@ -382,7 +391,8 @@ class FileManager(object):
|
||||
slicer = self._slicing_manager.get_slicer(slicer_name)
|
||||
|
||||
start_time = octoprint.util.monotonic_time()
|
||||
eventManager().fire(Events.SLICING_STARTED, {"stl": source_path,
|
||||
eventManager().fire(Events.SLICING_STARTED, {"slicer": slicer_name,
|
||||
"stl": source_path,
|
||||
"stl_location": source_location,
|
||||
"gcode": dest_path,
|
||||
"gcode_location": dest_location,
|
||||
@@ -428,7 +438,8 @@ class FileManager(object):
|
||||
try:
|
||||
callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
||||
except Exception:
|
||||
self._logger.exception("Exception while pushing slicing progress")
|
||||
self._logger.exception("Exception while pushing slicing progress",
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
|
||||
if progress_int:
|
||||
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
|
||||
@@ -657,6 +668,8 @@ class FileManager(object):
|
||||
try:
|
||||
with io.open(self._recovery_file, 'rt', encoding='utf-8') as f:
|
||||
data = yaml.safe_load(f)
|
||||
if not isinstance(data, dict) or not all(map(lambda x: x in data, ("origin", "path", "pos", "date"))):
|
||||
raise ValueError("Invalid recovery data structure")
|
||||
return data
|
||||
except Exception:
|
||||
self._logger.exception("Could not read recovery data from file {}".format(self._recovery_file))
|
||||
|
||||
@@ -19,6 +19,7 @@ import time
|
||||
from octoprint.events import Events, eventManager
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import monotonic_time
|
||||
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
|
||||
|
||||
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
|
||||
@@ -109,14 +110,15 @@ class AnalysisQueue(object):
|
||||
|
||||
def _analysis_finished(self, entry, result):
|
||||
for callback in self._callbacks:
|
||||
callback(entry, result)
|
||||
try:
|
||||
callback(entry, result)
|
||||
except:
|
||||
self._logger.exception(u"Error while pushing analysis data to callback {}".format(callback),
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
eventManager().fire(Events.METADATA_ANALYSIS_FINISHED, {"name": entry.name,
|
||||
"path": entry.path,
|
||||
"origin": entry.location,
|
||||
"result": result,
|
||||
|
||||
# TODO: deprecated, remove in a future release
|
||||
"file": entry.path})
|
||||
"result": result})
|
||||
|
||||
class AbstractAnalysisQueue(object):
|
||||
"""
|
||||
@@ -174,7 +176,10 @@ class AbstractAnalysisQueue(object):
|
||||
(False, default)
|
||||
"""
|
||||
|
||||
if high_priority:
|
||||
if settings().get(["gcodeAnalysis", "runAt"]) == "never":
|
||||
self._logger.debug("Ignoring entry {entry} for analysis queue".format(entry=entry))
|
||||
return
|
||||
elif high_priority:
|
||||
self._logger.debug("Adding entry {entry} to analysis queue with high priority".format(entry=entry))
|
||||
prio = self.__class__.HIGH_PRIO
|
||||
else:
|
||||
@@ -255,10 +260,7 @@ class AbstractAnalysisQueue(object):
|
||||
eventManager().fire(Events.METADATA_ANALYSIS_STARTED, {"name": entry.name,
|
||||
"path": entry.path,
|
||||
"origin": entry.location,
|
||||
"type": entry.type,
|
||||
|
||||
# TODO deprecated, remove in 1.4.0
|
||||
"file": entry.path})
|
||||
"type": entry.type})
|
||||
try:
|
||||
result = self._do_analysis(high_priority=high_priority)
|
||||
except TypeError:
|
||||
|
||||
@@ -528,38 +528,3 @@ class PluginSettings(object):
|
||||
return _func
|
||||
|
||||
return getattr(self.settings, item)
|
||||
|
||||
##~~ deprecated methods follow
|
||||
|
||||
# TODO: Remove with release of 1.3.0
|
||||
|
||||
globalGet = deprecated("globalGet has been renamed to global_get",
|
||||
includedoc="Replaced by :func:`global_get`",
|
||||
since="1.2.0-dev-546")(global_get)
|
||||
globalGetInt = deprecated("globalGetInt has been renamed to global_get_int",
|
||||
includedoc="Replaced by :func:`global_get_int`",
|
||||
since="1.2.0-dev-546")(global_get_int)
|
||||
globalGetFloat = deprecated("globalGetFloat has been renamed to global_get_float",
|
||||
includedoc="Replaced by :func:`global_get_float`",
|
||||
since="1.2.0-dev-546")(global_get_float)
|
||||
globalGetBoolean = deprecated("globalGetBoolean has been renamed to global_get_boolean",
|
||||
includedoc="Replaced by :func:`global_get_boolean`",
|
||||
since="1.2.0-dev-546")(global_get_boolean)
|
||||
globalSet = deprecated("globalSet has been renamed to global_set",
|
||||
includedoc="Replaced by :func:`global_set`",
|
||||
since="1.2.0-dev-546")(global_set)
|
||||
globalSetInt = deprecated("globalSetInt has been renamed to global_set_int",
|
||||
includedoc="Replaced by :func:`global_set_int`",
|
||||
since="1.2.0-dev-546")(global_set_int)
|
||||
globalSetFloat = deprecated("globalSetFloat has been renamed to global_set_float",
|
||||
includedoc="Replaced by :func:`global_set_float`",
|
||||
since="1.2.0-dev-546")(global_set_float)
|
||||
globalSetBoolean = deprecated("globalSetBoolean has been renamed to global_set_boolean",
|
||||
includedoc="Replaced by :func:`global_set_boolean`",
|
||||
since="1.2.0-dev-546")(global_set_boolean)
|
||||
globalGetBaseFolder = deprecated("globalGetBaseFolder has been renamed to global_get_basefolder",
|
||||
includedoc="Replaced by :func:`global_get_basefolder`",
|
||||
since="1.2.0-dev-546")(global_get_basefolder)
|
||||
getPluginLogfilePath = deprecated("getPluginLogfilePath has been renamed to get_plugin_logfile_path",
|
||||
includedoc="Replaced by :func:`get_plugin_logfile_path`",
|
||||
since="1.2.0-dev-546")(get_plugin_logfile_path)
|
||||
@@ -39,7 +39,7 @@ import pkginfo
|
||||
|
||||
from past.builtins import unicode
|
||||
|
||||
from octoprint.util import to_unicode
|
||||
from octoprint.util import to_unicode, sv
|
||||
from octoprint.util.version import is_python_compatible, get_python_version_string
|
||||
|
||||
try:
|
||||
@@ -447,7 +447,7 @@ class PluginInfo(object):
|
||||
@property
|
||||
def hooks(self):
|
||||
"""
|
||||
Hooks provided by the plugin. Will be taken from the hooks attribute of the plugin module as defiend in
|
||||
Hooks provided by the plugin. Will be taken from the hooks attribute of the plugin module as defined in
|
||||
:attr:`attr_hooks` if available, otherwise an empty dictionary is returned.
|
||||
|
||||
Returns:
|
||||
@@ -1585,7 +1585,7 @@ class PluginManager(object):
|
||||
sorting_value = None
|
||||
|
||||
plugin_info = self.get_plugin_info(impl[0], require_enabled=False)
|
||||
return sorting_value is None, sorting_value, not plugin_info.bundled if plugin_info else True, impl[0]
|
||||
return sorting_value is None, sv(sorting_value), not plugin_info.bundled if plugin_info else True, sv(impl[0])
|
||||
|
||||
return [impl[1] for impl in sorted(result, key=sort_func)]
|
||||
|
||||
@@ -1672,7 +1672,7 @@ class PluginManager(object):
|
||||
|
||||
def _sort_hooks(self, hook):
|
||||
self._plugin_hooks[hook] = sorted(self._plugin_hooks[hook],
|
||||
key=lambda x: (x[0] is None, x[0], x[1], x[2]))
|
||||
key=lambda x: (x[0] is None, sv(x[0]), sv(x[1]), sv(x[2])))
|
||||
|
||||
def _get_callback_and_order(self, hook):
|
||||
if callable(hook):
|
||||
|
||||
@@ -82,6 +82,8 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
|
||||
def on_event(self, event, payload):
|
||||
if event == Events.CONNECTED and self._enable == "always" and self._enable_signal_support:
|
||||
self._printer.commands(["{command} P1".format(command=self._command)])
|
||||
elif event == Events.DISCONNECTED:
|
||||
self._close_prompt()
|
||||
|
||||
#~ SettingsPlugin
|
||||
|
||||
@@ -218,15 +220,18 @@ class ActionCommandPromptPlugin(octoprint.plugin.AssetPlugin,
|
||||
return
|
||||
|
||||
self._close_prompt()
|
||||
self._printer.commands(["{command} S{choice}".format(command=self._command,
|
||||
choice=choice)])
|
||||
if "{choice}" in self._command:
|
||||
self._printer.commands([self._command.format(choice=choice)])
|
||||
else:
|
||||
self._printer.commands(["{command} S{choice}".format(command=self._command,
|
||||
choice=choice)])
|
||||
|
||||
|
||||
__plugin_name__ = "Action Command Prompt Support"
|
||||
__plugin_description__ = "Allows your printer to trigger prompts via action commands on the connection"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin your printer will no longer be able to trigger"
|
||||
"confirmation or selection prompts in OctoPrint")
|
||||
" confirmation or selection prompts in OctoPrint")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = ActionCommandPromptPlugin()
|
||||
__plugin_hooks__ = {
|
||||
|
||||
@@ -5,7 +5,17 @@ $(function() {
|
||||
self.loginState = parameters[0];
|
||||
self.access = parameters[1];
|
||||
|
||||
self._modal = undefined;
|
||||
self.modal = ko.observable(undefined);
|
||||
|
||||
self.text = ko.observable();
|
||||
self.buttons = ko.observableArray([]);
|
||||
|
||||
self.active = ko.pureComputed(function() {
|
||||
return self.text() !== undefined;
|
||||
});
|
||||
self.visible = ko.pureComputed(function() {
|
||||
return self.modal() !== undefined;
|
||||
});
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_ACTION_COMMAND_PROMPT_INTERACT)) return;
|
||||
@@ -16,26 +26,35 @@ $(function() {
|
||||
|
||||
self.fromResponse = function(data) {
|
||||
if (data.hasOwnProperty("text") && data.hasOwnProperty("choices")) {
|
||||
self._showPrompt(data.text, data.choices);
|
||||
self.text(data.text);
|
||||
self.buttons(data.choices);
|
||||
self.showPrompt();
|
||||
} else {
|
||||
self.text(undefined);
|
||||
self.buttons([]);
|
||||
}
|
||||
};
|
||||
|
||||
self._showPrompt = function(text, buttons) {
|
||||
self.showPrompt = function() {
|
||||
var text = self.text();
|
||||
var buttons = self.buttons();
|
||||
|
||||
var opts = {
|
||||
title: gettext("Message from your printer"),
|
||||
message: text,
|
||||
selections: buttons,
|
||||
maycancel: true, // see #3171
|
||||
onselect: function(index) {
|
||||
if (index > -1) {
|
||||
self._select(index);
|
||||
}
|
||||
},
|
||||
onclose: function() {
|
||||
self._modal = undefined;
|
||||
self.modal(undefined);
|
||||
}
|
||||
};
|
||||
|
||||
self._modal = showSelectionDialog(opts)
|
||||
self.modal(showSelectionDialog(opts));
|
||||
};
|
||||
|
||||
self._select = function(index) {
|
||||
@@ -43,8 +62,9 @@ $(function() {
|
||||
};
|
||||
|
||||
self._closePrompt = function() {
|
||||
if (self._modal) {
|
||||
self._modal.modal("hide");
|
||||
var modal = self.modal();
|
||||
if (modal) {
|
||||
modal.modal("hide");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,10 +80,14 @@ $(function() {
|
||||
|
||||
switch (data.action) {
|
||||
case "show": {
|
||||
self._showPrompt(data.text, data.choices);
|
||||
self.text(data.text);
|
||||
self.buttons(data.choices);
|
||||
self.showPrompt();
|
||||
break;
|
||||
}
|
||||
case "close": {
|
||||
self.text(undefined);
|
||||
self.buttons([]);
|
||||
self._closePrompt();
|
||||
break;
|
||||
}
|
||||
@@ -74,6 +98,7 @@ $(function() {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: ActionCommandPromptViewModel,
|
||||
dependencies: ["loginStateViewModel", "accessViewModel"]
|
||||
dependencies: ["loginStateViewModel", "accessViewModel"],
|
||||
elements: ["#navbar_plugin_action_command_prompt"]
|
||||
});
|
||||
});
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<a id="navbar_show_prompt" class="pull-right" style="display: none" href="javascript:void(0)" data-bind="click: function() { showPrompt(); }, visible: active() && !visible()" title="{{ _('Message from your printer')|edq }}">
|
||||
<i class="fa fa-commenting-o"></i>
|
||||
</a>
|
||||
@@ -1,3 +1,3 @@
|
||||
<a id="navbar_show_announcements" class="pull-right" href="javascript:void(0)" data-bind="click: function() { showAnnouncementDialog(); }" title="{{ _('Announcements') }}">
|
||||
<a id="navbar_show_announcements" class="pull-right" href="javascript:void(0)" data-bind="click: function() { showAnnouncementDialog(); }" title="{{ _('Announcements')|edq }}">
|
||||
<i class="fa" data-bind="css: {'fa-bell-o': !unread(), 'fa-bell': unread()}"></i>
|
||||
</a>
|
||||
@@ -7,7 +7,7 @@ import os
|
||||
import yaml
|
||||
import io
|
||||
import time
|
||||
from binascii import hexlify
|
||||
import uuid
|
||||
from collections import defaultdict
|
||||
from flask_babel import gettext
|
||||
|
||||
@@ -45,6 +45,12 @@ class PendingDecision(object):
|
||||
user_id=self.user_id,
|
||||
user_token=self.user_token)
|
||||
|
||||
def __repr__(self):
|
||||
return u"PendingDecision({!r}, {!r}, {!r}, {!r}, timeout_callback=...)".format(self.app_id,
|
||||
self.app_token,
|
||||
self.user_id,
|
||||
self.user_token)
|
||||
|
||||
|
||||
class ReadyDecision(object):
|
||||
def __init__(self, app_id, app_token, user_id):
|
||||
@@ -56,6 +62,11 @@ class ReadyDecision(object):
|
||||
def for_pending(cls, pending, user_id):
|
||||
return cls(pending.app_id, pending.app_token, user_id)
|
||||
|
||||
def __repr__(self):
|
||||
return u"ReadyDecision({!r}, {!r}, {!r})".format(self.app_id,
|
||||
self.app_token,
|
||||
self.user_id)
|
||||
|
||||
|
||||
class ActiveKey(object):
|
||||
def __init__(self, app_id, api_key, user_id):
|
||||
@@ -76,6 +87,11 @@ class ActiveKey(object):
|
||||
def for_internal(cls, internal, user_id):
|
||||
return cls(internal["app_id"], internal["api_key"], user_id)
|
||||
|
||||
def __repr__(self):
|
||||
return u"ActiveKey({!r}, {!r}, {!r})".format(self.app_id,
|
||||
self.api_key,
|
||||
self.user_id)
|
||||
|
||||
|
||||
class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
@@ -135,12 +151,15 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
||||
@no_firstrun_access
|
||||
def handle_request(self):
|
||||
data = flask.request.json
|
||||
if data is None:
|
||||
return flask.make_response("Missing key request", 400)
|
||||
|
||||
if not "app" in data:
|
||||
return flask.make_response("No app name provided", 400)
|
||||
|
||||
app_name = data["app"]
|
||||
user_id = None
|
||||
if "user" in data:
|
||||
if "user" in data and data["user"]:
|
||||
user_id = data["user"]
|
||||
|
||||
app_token, user_token = self._add_pending_decision(app_name, user_id=user_id)
|
||||
@@ -362,7 +381,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
||||
for user_id, data in self._keys.items():
|
||||
if any(filter(lambda x: x.api_key == api_key, data)):
|
||||
if self._user_manager.enabled:
|
||||
return self._user_manager.findUser(userid=user_id)
|
||||
return self._user_manager.find_user(userid=user_id)
|
||||
elif user_id == "_admin" or user_id == "dummy":
|
||||
# dummy = backwards compatible
|
||||
return self._user_manager.anonymous_user_factory()
|
||||
@@ -380,7 +399,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
||||
return result
|
||||
|
||||
def _generate_key(self):
|
||||
return hexlify(os.urandom(16))
|
||||
return ''.join('%02X' % z for z in bytes(uuid.uuid4().bytes))
|
||||
|
||||
def _load_keys(self):
|
||||
with self._keys_lock:
|
||||
|
||||
@@ -52,7 +52,7 @@ $(function() {
|
||||
.done(self.requestData);
|
||||
};
|
||||
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: key}),
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: _.escape(key)}),
|
||||
perform);
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ $(function() {
|
||||
|
||||
self.promptForAccess = function(app, token) {
|
||||
var message = gettext("\"<strong>%(app)s</strong>\" has requested access to control OctoPrint through the API.");
|
||||
message = _.sprintf(message, {app: app});
|
||||
message = _.sprintf(message, {app: _.escape(app)});
|
||||
message = "<p>" + message + "</p><p>" + gettext("Do you want to allow access to this application with your user account?") + "</p>";
|
||||
return new PNotify({
|
||||
title: gettext("Access Request"),
|
||||
@@ -210,7 +210,7 @@ $(function() {
|
||||
.done(self.requestData);
|
||||
};
|
||||
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: key}),
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to revoke the application key \"%(key)s\"."), {key: _.escape(key)}),
|
||||
perform);
|
||||
};
|
||||
|
||||
@@ -258,11 +258,11 @@ $(function() {
|
||||
handler = function(key) {
|
||||
return OctoPrint.plugins.appkeys.revokeKey(key)
|
||||
.done(function() {
|
||||
deferred.notify(_.sprintf(gettext("Revoked %(key)s..."), {key: key}), true);
|
||||
deferred.notify(_.sprintf(gettext("Revoked %(key)s..."), {key: _.escape(key)}), true);
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
var short = _.sprintf(gettext("Revocation of %(key)s failed, continuing..."), {key: key});
|
||||
var long = _.sprintf(gettext("Deletion of %(key)s failed: %(error)s"), {key: key, error: jqXHR.responseText});
|
||||
var short = _.sprintf(gettext("Revocation of %(key)s failed, continuing..."), {key: _.escape(key)});
|
||||
var long = _.sprintf(gettext("Deletion of %(key)s failed: %(error)s"), {key: _.escape(key), error: _.escape(jqXHR.responseText)});
|
||||
deferred.notify(short, long, false);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
<tr>
|
||||
<td class="settings_plugin_appkeys_checkbox"><input type="checkbox" data-bind="value: api_key, checked: $root.markedForDeletion"></td>
|
||||
<td class="settings_plugin_appkeys_user"><span data-bind="text: user_id"></span></td>
|
||||
<td class="settings_plugin_appkeys_app"><span data-bind="text: app_id"></span><br /><small class="muted">{{ _('API Key') }}: <span data-bind="text: api_key"></span> <a href="javascript:void(0)" title="{{ _('Copy API Key to clipboard') }}" data-bind="click: function() { copyToClipboard(api_key) }"><i class="fa fa-copy"></i></a></small></td>
|
||||
<td class="settings_plugin_appkeys_actions"><a href="javascript:void(0)" title="{{ _('Revoke') }}" class="fa fa-trash-o" data-bind="click: function() { $parent.revokeKey($data.api_key, $data.user_id) }"></a></td>
|
||||
<td class="settings_plugin_appkeys_app"><span data-bind="text: app_id"></span><br /><small class="muted">{{ _('API Key') }}: <span data-bind="text: api_key"></span> <a href="javascript:void(0)" title="{{ _('Copy API Key to clipboard')|edq }}" data-bind="click: function() { copyToClipboard(api_key) }"><i class="fa fa-copy"></i></a></small></td>
|
||||
<td class="settings_plugin_appkeys_actions"><a href="javascript:void(0)" title="{{ _('Revoke')|edq }}" class="fa fa-trash-o" data-bind="click: function() { $parent.revokeKey($data.api_key, $data.user_id) }"></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
</thead>
|
||||
<tbody data-bind="foreach: keys.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_plugin_appkeys_app"><span data-bind="text: app_id"></span><br /><small class="muted">{{ _('API Key') }}: <span data-bind="text: api_key"></span> <a href="javascript:void(0)" title="{{ _('Copy API Key to clipboard') }}" data-bind="click: function() { copyToClipboard(api_key) }"><i class="fa fa-copy"></i></a></small></td>
|
||||
<td class="settings_plugin_appkeys_actions"><a href="javascript:void(0)" title="{{ _('Revoke') }}" class="fa fa-trash-o" data-bind="click: function() { $parent.revokeKey($data.api_key) }"></a></td>
|
||||
<td class="settings_plugin_appkeys_app"><span data-bind="text: app_id"></span><br /><small class="muted">{{ _('API Key') }}: <span data-bind="text: api_key"></span> <a href="javascript:void(0)" title="{{ _('Copy API Key to clipboard')|edq }}" data-bind="click: function() { copyToClipboard(api_key) }"><i class="fa fa-copy"></i></a></small></td>
|
||||
<td class="settings_plugin_appkeys_actions"><a href="javascript:void(0)" title="{{ _('Revoke')|edq }}" class="fa fa-trash-o" data-bind="click: function() { $parent.revokeKey($data.api_key) }"></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -633,6 +633,8 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
|
||||
try:
|
||||
if exclude is None:
|
||||
exclude = []
|
||||
if not isinstance(exclude, list):
|
||||
exclude = list(exclude)
|
||||
|
||||
if "timelapse" in exclude:
|
||||
exclude.append("timelapse_tmp")
|
||||
|
||||
@@ -85,7 +85,7 @@ $(function() {
|
||||
self.requestData();
|
||||
});
|
||||
};
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to delete backup file \"%(name)s\"."), {name: backup}),
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to delete backup file \"%(name)s\"."), {name: _.escape(backup)}),
|
||||
perform);
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ $(function() {
|
||||
|
||||
OctoPrint.plugins.backup.restoreBackup(backup);
|
||||
};
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to restore the backup file \"%(name)s\". This cannot be undone."), {name: backup}),
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to restore the backup file \"%(name)s\". This cannot be undone."), {name: _.escape(backup)}),
|
||||
perform);
|
||||
};
|
||||
|
||||
@@ -117,7 +117,7 @@ $(function() {
|
||||
|
||||
self.backupUploadData.submit();
|
||||
};
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to upload and restore the backup file \"%(name)s\". This cannot be undone."), {name: self.backupUploadName()}),
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to upload and restore the backup file \"%(name)s\". This cannot be undone."), {name: _.escape(self.backupUploadName())}),
|
||||
perform);
|
||||
};
|
||||
|
||||
@@ -182,7 +182,7 @@ $(function() {
|
||||
self.backupInProgress(false);
|
||||
new PNotify({
|
||||
title: gettext("Creating the backup failed"),
|
||||
text: _.sprintf(gettext("OctoPrint could not create your backup. Please consult <code>octoprint.log</code> for details. Error: %(error)s"), {error:data.error}),
|
||||
text: _.sprintf(gettext("OctoPrint could not create your backup. Please consult <code>octoprint.log</code> for details. Error: %(error)s"), {error: _.escape(data.error)}),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
@@ -197,16 +197,16 @@ $(function() {
|
||||
self.loglines.push({line: " ", stream: "message"});
|
||||
self.loglines.push({line: gettext("Restore successful! The server will now be restarted!"), stream: "message"});
|
||||
self.restoreInProgress(false);
|
||||
} else if (data.type === "install_plugin") {
|
||||
} else if (data.type === "installing_plugin") {
|
||||
self.loglines.push({line: " ", stream: "message"});
|
||||
self.loglines.push({
|
||||
line: _.sprintf(gettext("Installing plugin \"%(plugin)s}\"..."), {plugin: data.plugin.name}),
|
||||
line: _.sprintf(gettext("Installing plugin \"%(plugin)s\"..."), {plugin: _.escape(data.plugin)}),
|
||||
stream: "message"
|
||||
});
|
||||
} else if (data.type === "plugin_incompatible") {
|
||||
self.loglines.push({line: " ", stream: "message"});
|
||||
self.loglines.push({
|
||||
line: _.sprintf(gettext("Cannot install plugin \"%(plugin)s\" due to it being incompatible to this OctoPrint version and/or underlying operating system"), {plugin: data.plugin.key}),
|
||||
line: _.sprintf(gettext("Cannot install plugin \"%(plugin)s\" due to it being incompatible to this OctoPrint version and/or underlying operating system"), {plugin: _.escape(data.plugin.key)}),
|
||||
stream: "stderr"
|
||||
});
|
||||
} else if (data.type === "unknown_plugins") {
|
||||
@@ -245,11 +245,11 @@ $(function() {
|
||||
handler = function(filename) {
|
||||
return OctoPrint.plugins.backup.deleteBackup(filename)
|
||||
.done(function() {
|
||||
deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: filename}), true);
|
||||
deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: _.escape(filename)}), true);
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: filename});
|
||||
var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: filename, error: jqXHR.responseText});
|
||||
var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: _.escape(filename)});
|
||||
var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: _.escape(filename), error: _.escape(jqXHR.responseText)});
|
||||
deferred.notify(short, long, false);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<td class="settings_plugin_backup_name" data-bind="text: name"></td>
|
||||
<td class="settings_plugin_backup_date" data-bind="text: formatDate(date)"></td>
|
||||
<td class="settings_plugin_backup_size" data-bind="text: formatSize(size)"></td>
|
||||
<td class="settings_plugin_backup_actions"><a href="javascript:void(0)" title="{{ _('Delete') }}" class="fa fa-trash-o" data-bind="click: function() { $parent.removeBackup($data.name) }, css: {disabled: $root.backupInProgress() || $root.restoreInProgress()"></a> | <a href="javascript:void(0)" title="{{ _('Download') }}" class="fa fa-download" data-bind="attr: {href: url}"></a><span data-bind="visible: $parent.restoreSupported()"> | <a href="javascript:void(0)" title="{{ _('Restore') }}" data-bind="click: function() { $parent.restoreBackup($data.name) }, css: {disabled: $root.backupInProgress() || $root.restoreInProgress()"><i class="fa fa-refresh"></i></a></span></td>
|
||||
<td class="settings_plugin_backup_actions"><a href="javascript:void(0)" title="{{ _('Delete')|edq }}" class="fa fa-trash-o" data-bind="click: function() { $parent.removeBackup($data.name) }, css: {disabled: $root.backupInProgress() || $root.restoreInProgress()"></a> | <a href="javascript:void(0)" title="{{ _('Download')|edq }}" class="fa fa-download" data-bind="attr: {href: url}"></a><span data-bind="visible: $parent.restoreSupported()"> | <a href="javascript:void(0)" title="{{ _('Restore')|edq }}" data-bind="click: function() { $parent.restoreBackup($data.name) }, css: {disabled: $root.backupInProgress() || $root.restoreInProgress()"><i class="fa fa-refresh"></i></a></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<p>{% trans %}
|
||||
Finally, please decide on whether to enable or disable the connectivity check. You may change the configuration at
|
||||
any time to a later date through Settings > Server right from within OctoPrint.
|
||||
any time through Settings > Server right from within OctoPrint.
|
||||
{% endtrans %}</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
|
||||
@@ -212,7 +212,7 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
|
||||
|
||||
def zeroconf_unregister(self, reg_type, port=None):
|
||||
"""
|
||||
Unregisteres a previously registered Zeroconf/Bonjour/Avahi service identified by service and port.
|
||||
Unregisters a previously registered Zeroconf/Bonjour/Avahi service identified by service and port.
|
||||
|
||||
:param reg_type: the type of the service to be unregistered
|
||||
:param port: the port of the service to be unregistered, defaults to OctoPrint's (public) port if not given
|
||||
|
||||
@@ -7,13 +7,14 @@ __copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms
|
||||
import octoprint.plugin
|
||||
import logging
|
||||
|
||||
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
from octoprint.util.version import get_octoprint_version_string, is_released_octoprint_version
|
||||
|
||||
from flask import jsonify
|
||||
from flask_babel import gettext
|
||||
|
||||
SENTRY_URL_SERVER = "https://4069187705ab4e76921eb19db2e9ccbb@sentry.io/1373987"
|
||||
SENTRY_URL_COREUI = "https://a4ab48f27daf4c129392b78be15412b8@sentry.io/1374096"
|
||||
SENTRY_URL_SERVER = "https://bcd62166a2b145aa9818947bfb76706f@sentry.io/1373987"
|
||||
SENTRY_URL_COREUI = "https://217a5d75940b443eaaec347bb30c128d@sentry.io/1374096"
|
||||
|
||||
SETTINGS_DEFAULTS = dict(enabled=False,
|
||||
enabled_unreleased=False,
|
||||
@@ -29,19 +30,24 @@ import tornado.websocket
|
||||
|
||||
IGNORED_EXCEPTIONS = [
|
||||
# serial exceptions in octoprint.util.comm
|
||||
(serial.SerialException, lambda exc, logger, plugin: logger == "octoprint.util.comm"),
|
||||
(serial.SerialException, lambda exc, logger, plugin, cb: logger == "octoprint.util.comm"),
|
||||
|
||||
# isp errors during port auto detection in octoprint.util.comm
|
||||
(octoprint.util.avr_isp.ispBase.IspError, lambda exc, logger, plugin: logger == "octoprint.util.comm"),
|
||||
(octoprint.util.avr_isp.ispBase.IspError, lambda exc, logger, plugin, cb: logger == "octoprint.util.comm"),
|
||||
|
||||
# IOErrors of any kind due to a full file system
|
||||
(IOError, lambda exc, logger, plugin: getattr(exc, "errno") and exc.errno in (getattr(errno, "ENOSPC"),)),
|
||||
(IOError, lambda exc, logger, plugin, cb: getattr(exc, "errno") and exc.errno in (getattr(errno, "ENOSPC"),)),
|
||||
|
||||
# RequestExceptions of any kind
|
||||
requests.exceptions.RequestException,
|
||||
|
||||
# Tornado WebSocketErrors of any kind
|
||||
tornado.websocket.WebSocketError
|
||||
tornado.websocket.WebSocketError,
|
||||
|
||||
# Anything triggered by or in third party plugin Astroprint
|
||||
(Exception, lambda exc, logger, plugin, cb: logger.startswith("octoprint.plugins.astroprint")
|
||||
or plugin == "astroprint"
|
||||
or cb.startswith("octoprint_astroprint."))
|
||||
]
|
||||
|
||||
try:
|
||||
@@ -138,6 +144,7 @@ def _enable_errortracking():
|
||||
handled = True
|
||||
logger = event.get("logger", "")
|
||||
plugin = event.get("extra", dict()).get("plugin", None)
|
||||
callback = event.get("extra", dict()).get("callback", None)
|
||||
|
||||
for ignore in IGNORED_EXCEPTIONS:
|
||||
if isinstance(ignore, tuple):
|
||||
@@ -147,8 +154,8 @@ def _enable_errortracking():
|
||||
matcher = lambda *args: True
|
||||
|
||||
exc = hint["exc_info"][1]
|
||||
if isinstance(exc, ignored_exc) and matcher(exc, logger, plugin):
|
||||
# exception ignored for logger
|
||||
if isinstance(exc, ignored_exc) and matcher(exc, logger, plugin, callback):
|
||||
# exception ignored for logger, plugin and/or callback
|
||||
return None
|
||||
|
||||
elif isinstance(ignore, type):
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" title="{{ _('Random unique instance ID') }}">{{ _('Instance ID') }}</label>
|
||||
<label class="control-label" title="{{ _('Random unique instance ID')|edq }}">{{ _('Instance ID') }}</label>
|
||||
<div class="controls">
|
||||
<span style="padding-top: 5px; margin-bottom: 5px; display: inline-block" data-bind="text: settings.plugins.errortracking.unique_id() || 'N/A'"></span>
|
||||
</div>
|
||||
|
||||
@@ -121,7 +121,7 @@ $(function() {
|
||||
.done(self.requestData);
|
||||
};
|
||||
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to delete log file \"%(name)s\"."), {name: filename}),
|
||||
showConfirmationDialog(_.sprintf(gettext("You are about to delete log file \"%(name)s\"."), {name: _.escape(filename)}),
|
||||
perform);
|
||||
};
|
||||
|
||||
@@ -172,11 +172,11 @@ $(function() {
|
||||
var handler = function(filename) {
|
||||
return OctoPrint.plugins.logging.deleteLog(filename)
|
||||
.done(function() {
|
||||
deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: filename}), true);
|
||||
deferred.notify(_.sprintf(gettext("Deleted %(filename)s..."), {filename: _.escape(filename)}), true);
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: filename});
|
||||
var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: filename, error: jqXHR.responseText});
|
||||
var short = _.sprintf(gettext("Deletion of %(filename)s failed, continuing..."), {filename: _.escape(filename)});
|
||||
var long = _.sprintf(gettext("Deletion of %(filename)s failed: %(error)s"), {filename: _.escape(filename), error: _.escape(jqXHR.responseText)});
|
||||
deferred.notify(short, long, false);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<a title="{{ _('Remove') }}" class="btn btn-danger" data-bind="click: $parent.removeLogger"><i class="icon-trash"></i></a>
|
||||
<a title="{{ _('Remove')|edq }}" class="btn btn-danger" data-bind="click: $parent.removeLogger"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,7 +103,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<a title="{{ _('Add') }}" class="btn btn-primary" data-bind="click: $root.addLogger"><i class="icon-plus"></i></a>
|
||||
<a title="{{ _('Add')|edq }}" class="btn btn-primary" data-bind="click: $root.addLogger"><i class="icon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -19,14 +19,23 @@ _PROC_DT_MODEL_PATH = "/proc/device-tree/model"
|
||||
_OCTOPI_VERSION_PATH = "/etc/octopi_version"
|
||||
_VCGENCMD_THROTTLE = "/usr/bin/vcgencmd get_throttled"
|
||||
|
||||
### uncomment for local debugging
|
||||
#import sys
|
||||
#base = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "tests", "plugins", "pi_support", "fakes"))
|
||||
#_PROC_DT_MODEL_PATH = os.path.join(base, "fake_model.txt")
|
||||
#_OCTOPI_VERSION_PATH = os.path.join(base, "fake_octopi.txt")
|
||||
#_VCGENCMD_THROTTLE = "{} {}".format(sys.executable, os.path.join(base, "fake_vcgencmd.py"))
|
||||
#import itertools
|
||||
#_VCGENCMD_OUTPUT = itertools.chain(iter(("0x0", "0x0", "0x50005", "0x50000", "0x70007")), itertools.repeat("0x70000"))
|
||||
_CHECK_INTERVAL_OK = 300
|
||||
_CHECK_INTERVAL_THROTTLED = 30
|
||||
|
||||
__LOCAL_DEBUG = False
|
||||
|
||||
if __LOCAL_DEBUG:
|
||||
### mocks & settings for local debugging
|
||||
import sys
|
||||
base = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "tests", "plugins", "pi_support", "fakes"))
|
||||
_PROC_DT_MODEL_PATH = os.path.join(base, "fake_model.txt")
|
||||
_OCTOPI_VERSION_PATH = os.path.join(base, "fake_octopi.txt")
|
||||
_VCGENCMD_THROTTLE = "{} {}".format(sys.executable, os.path.join(base, "fake_vcgencmd.py"))
|
||||
import itertools
|
||||
_VCGENCMD_OUTPUT = itertools.chain(iter(("0x0", "0x0", "0x50005", "0x50000", "0x70007")), itertools.repeat("0x70005"))
|
||||
|
||||
_CHECK_INTERVAL_OK = 10
|
||||
_CHECK_INTERVAL_THROTTLED = 5
|
||||
|
||||
|
||||
# see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=147781&start=50#p972790
|
||||
@@ -135,8 +144,11 @@ def get_proc_dt_model():
|
||||
|
||||
|
||||
def get_vcgencmd_throttled_state(command):
|
||||
output = sarge.get_stdout(command)
|
||||
#output = "throttled={}".format(next(_VCGENCMD_OUTPUT)) # for local debugging
|
||||
if __LOCAL_DEBUG:
|
||||
output = "throttled={}".format(next(_VCGENCMD_OUTPUT)) # mock for local debugging
|
||||
else:
|
||||
output = sarge.get_stdout(command)
|
||||
|
||||
if not "throttled=0x" in output:
|
||||
raise ValueError("cannot parse \"{}\" output: {}".format(command, output))
|
||||
|
||||
@@ -237,11 +249,9 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin,
|
||||
|
||||
def _check_throttled_state_interval(self):
|
||||
if self._throttle_state.current_issue:
|
||||
# check state every 30s if something's currently amiss
|
||||
return 30
|
||||
return _CHECK_INTERVAL_THROTTLED
|
||||
else:
|
||||
# check state every 5min if nothing's currently amiss
|
||||
return 300
|
||||
return _CHECK_INTERVAL_OK
|
||||
|
||||
def _check_throttled_state_condition(self):
|
||||
return self._throttle_functional
|
||||
@@ -305,7 +315,7 @@ __plugin_name__ = "Pi Support Plugin"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_description__ = "Provides additional information about your Pi in the UI."
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
||||
"provide additional information about your Pi,"
|
||||
"provide additional information about your Pi, "
|
||||
"which will make it more tricky to help you if you need support.")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<a href="https://faq.octoprint.org/pi-issues" target="_blank" rel="noopener noreferrer" data-bind="visible: currentIssue() || pastIssue(), popover: { placement: 'bottom', title: '{{ _('What do the symbols mean?') }}', html: true, content: popoverContent, trigger: 'hover' }" style="display: none">
|
||||
<span data-bind="visible: currentUndervoltage() || pastUndervoltage(), css: {'pi_support_state_pulsate': currentUndervoltage}" title="{{ _('Undervoltage') }}"><i class="fa fa-bolt"></i><i class="fa fa-exclamation"></i></span>
|
||||
<span data-bind="visible: currentOverheat() || pastOverheat(), css: {'pi_support_state_pulsate': currentOverheat}" title="{{ _('Overheat') }}"><i class="fa fa-thermometer-full"></i><i class="fa fa-exclamation"></i></span>
|
||||
<a href="https://faq.octoprint.org/pi-issues" target="_blank" rel="noopener noreferrer" data-bind="visible: currentIssue() || pastIssue(), popover: { placement: 'bottom', title: '{{ _('What do the symbols mean?')|esq }}', html: true, content: popoverContent, trigger: 'hover' }" style="display: none">
|
||||
<span data-bind="visible: currentUndervoltage() || pastUndervoltage(), css: {'pi_support_state_pulsate': currentUndervoltage}" title="{{ _('Undervoltage')|edq }}"><i class="fa fa-bolt"></i><i class="fa fa-exclamation"></i></span>
|
||||
<span data-bind="visible: currentOverheat() || pastOverheat(), css: {'pi_support_state_pulsate': currentOverheat}" title="{{ _('Overheat')|edq }}"><i class="fa fa-thermometer-full"></i><i class="fa fa-exclamation"></i></span>
|
||||
</a>
|
||||
@@ -36,10 +36,18 @@ import threading
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
_DATA_FORMAT_VERSION = "v2"
|
||||
try:
|
||||
from os import scandir
|
||||
except:
|
||||
from scandir import scandir
|
||||
|
||||
_DATA_FORMAT_VERSION = "v3"
|
||||
|
||||
|
||||
def map_repository_entry(entry):
|
||||
if not isinstance(entry, dict):
|
||||
return None
|
||||
|
||||
result = copy.deepcopy(entry)
|
||||
|
||||
if not "follow_dependency_links" in result:
|
||||
@@ -113,20 +121,27 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._repository_plugins = []
|
||||
self._repository_cache_path = None
|
||||
self._repository_cache_ttl = 0
|
||||
self._repository_mtime = None
|
||||
|
||||
self._notices = dict()
|
||||
self._notices_available = False
|
||||
self._notices_cache_path = None
|
||||
self._notices_cache_ttl = 0
|
||||
self._notices_mtime = None
|
||||
|
||||
self._orphans = None
|
||||
|
||||
self._console_logger = None
|
||||
|
||||
self._get_throttled = lambda: False
|
||||
|
||||
def initialize(self):
|
||||
self._console_logger = logging.getLogger("octoprint.plugins.pluginmanager.console")
|
||||
self._repository_cache_path = os.path.join(self.get_plugin_data_folder(), "plugins.json")
|
||||
self._repository_cache_ttl = self._settings.get_int(["repository_ttl"]) * 60
|
||||
self._notices_cache_path = os.path.join(self.get_plugin_data_folder(), "notices.json")
|
||||
self._notices_cache_ttl = self._settings.get_int(["notices_ttl"]) * 60
|
||||
self._confirm_disable = self._settings.global_get_boolean(["confirm_disable"])
|
||||
|
||||
self._pip_caller = LocalPipCaller(force_user=self._settings.get_boolean(["pip_force_user"]))
|
||||
self._pip_caller.on_log_call = self._log_call
|
||||
@@ -169,6 +184,12 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._console_logger.setLevel(logging.DEBUG)
|
||||
self._console_logger.propagate = False
|
||||
|
||||
helpers = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
||||
if helpers and "get_throttled" in helpers:
|
||||
self._get_throttled = helpers["get_throttled"]
|
||||
if self._settings.get_boolean(["ignore_throttled"]):
|
||||
self._logger.warn("!!! THROTTLE STATE IGNORED !!! You have configured the Plugin Manager plugin to ignore an active throttle state of the underlying system. You might run into stability issues or outright corrupt your install. Consider fixing the throttling issue instead of suppressing it.")
|
||||
|
||||
# decouple repository fetching from server startup
|
||||
self._fetch_all_data(do_async=True)
|
||||
|
||||
@@ -182,8 +203,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
notices_ttl=6*60,
|
||||
pip_args=None,
|
||||
pip_force_user=False,
|
||||
confirm_disable=False,
|
||||
dependency_links=False,
|
||||
hidden=[]
|
||||
hidden=[],
|
||||
ignore_throttled=False
|
||||
)
|
||||
|
||||
def on_settings_save(self, data):
|
||||
@@ -192,6 +215,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._repository_cache_ttl = self._settings.get_int(["repository_ttl"]) * 60
|
||||
self._notices_cache_ttl = self._settings.get_int(["notices_ttl"]) * 60
|
||||
self._pip_caller.force_user = self._settings.get_boolean(["pip_force_user"])
|
||||
self._confirm_disable = self._settings.global_get_boolean(["confirm_disable"])
|
||||
|
||||
##~~ AssetPlugin
|
||||
|
||||
@@ -278,6 +302,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
"uninstall": ["plugin"],
|
||||
"enable": ["plugin"],
|
||||
"disable": ["plugin"],
|
||||
"cleanup": ["plugin"],
|
||||
"cleanup_all": [],
|
||||
"refresh_repository": []
|
||||
}
|
||||
|
||||
@@ -288,19 +314,22 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
from octoprint.server import safe_mode
|
||||
|
||||
refresh_repository = request.values.get("refresh_repository", "false") in valid_boolean_trues
|
||||
if refresh_repository:
|
||||
if refresh_repository or not self._is_repository_cache_valid():
|
||||
self._repository_available = self._refresh_repository()
|
||||
|
||||
refresh_notices = request.values.get("refresh_notices", "false") in valid_boolean_trues
|
||||
if refresh_notices:
|
||||
if refresh_notices or not self._is_notices_cache_valid():
|
||||
self._notices_available = self._refresh_notices()
|
||||
|
||||
refresh_orphan = request.values.get("refresh_orphans", "false") in valid_boolean_trues
|
||||
|
||||
def view():
|
||||
return jsonify(plugins=self._get_plugins(),
|
||||
repository=dict(
|
||||
available=self._repository_available,
|
||||
plugins=self._repository_plugins
|
||||
),
|
||||
orphan_data=self._get_orphans(refresh=refresh_orphan),
|
||||
os=get_os(),
|
||||
octoprint=get_octoprint_version_string(),
|
||||
pip=dict(
|
||||
@@ -327,6 +356,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
hash_update(repr(self._repository_plugins))
|
||||
hash_update(str(self._notices_available))
|
||||
hash_update(repr(self._notices))
|
||||
hash_update(repr(self._get_orphans()))
|
||||
hash_update(repr(safe_mode))
|
||||
hash_update(repr(self._connectivity_checker.online))
|
||||
hash_update(repr(_DATA_FORMAT_VERSION))
|
||||
@@ -337,7 +367,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
return with_revalidation_checking(etag_factory=lambda *args, **kwargs: etag(),
|
||||
condition=lambda *args, **kwargs: condition(),
|
||||
unless=lambda: refresh_repository or refresh_notices)(view)()
|
||||
unless=lambda: refresh_repository or refresh_notices or refresh_orphan)(view)()
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
if not Permissions.PLUGIN_PLUGINMANAGER_MANAGE.can():
|
||||
@@ -364,7 +394,20 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return make_response("Unknown plugin: %s" % plugin_name, 404)
|
||||
|
||||
plugin = self._plugin_manager.plugins[plugin_name]
|
||||
return self.command_uninstall(plugin)
|
||||
return self.command_uninstall(plugin, cleanup=data.get("cleanup", False))
|
||||
|
||||
elif command == "cleanup":
|
||||
plugin = data["plugin"]
|
||||
try:
|
||||
plugin = self._plugin_manager.plugins[plugin]
|
||||
except KeyError:
|
||||
# not installed, we are cleaning up left overs, that's ok
|
||||
pass
|
||||
|
||||
return self.command_cleanup(plugin, include_disabled=True)
|
||||
|
||||
elif command == "cleanup_all":
|
||||
return self.command_cleanup_all()
|
||||
|
||||
elif command == "enable" or command == "disable":
|
||||
plugin_name = data["plugin"]
|
||||
@@ -375,6 +418,12 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return self.command_toggle(plugin, command)
|
||||
|
||||
def command_install(self, url=None, path=None, force=False, reinstall=None, dependency_links=False):
|
||||
throttled = self._get_throttled()
|
||||
if throttled and isinstance(throttled, dict) and throttled.get("current_issue", False) and not self._settings.get_boolean(["ignore_throttled"]):
|
||||
# currently throttled, we refuse to run
|
||||
return make_response("System is currently throttled, refusing to install "
|
||||
"anything due to possible stability issues", 409)
|
||||
|
||||
if url is not None:
|
||||
if not any(map(lambda scheme: url.startswith(scheme + "://"), self.URL_SCHEMES)):
|
||||
raise ValueError("Invalid URL to pip install from")
|
||||
@@ -539,7 +588,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
def command_uninstall(self, plugin):
|
||||
def command_uninstall(self, plugin, cleanup=False):
|
||||
if plugin.key == "pluginmanager":
|
||||
return make_response("Can't uninstall Plugin Manager", 403)
|
||||
|
||||
@@ -588,7 +637,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._logger.warning("Trying to uninstall plugin {plugin} but origin is unknown ({plugin.origin.type})".format(**locals()))
|
||||
return make_response("Could not uninstall plugin, its origin is unknown")
|
||||
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin)
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin) or cleanup
|
||||
needs_refresh = plugin.implementation and isinstance(plugin.implementation, octoprint.plugin.ReloadNeedingPlugin)
|
||||
needs_reconnect = self._plugin_manager.has_any_of_hooks(plugin, self._reconnect_hooks) and self._printer.is_operational()
|
||||
|
||||
@@ -628,8 +677,108 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
needs_reconnect=needs_reconnect,
|
||||
plugin=self._to_external_plugin(plugin))
|
||||
self._send_result_notification("uninstall", result)
|
||||
self._logger.info("Plugin {} uninstalled".format(plugin.key))
|
||||
|
||||
self._cleanup_disabled(plugin.key)
|
||||
if cleanup:
|
||||
self.command_cleanup(plugin.key, result_notifications=False)
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
def command_cleanup(self, plugin, include_disabled=False, result_notifications=True, settings_save=True):
|
||||
if isinstance(plugin, basestring):
|
||||
key = result_value = plugin
|
||||
else:
|
||||
key = plugin.key
|
||||
result_value = self._to_external_plugin(plugin)
|
||||
|
||||
message = "Cleaning up plugin {}...".format(key)
|
||||
self._logger.info(message)
|
||||
self._log_stdout(message)
|
||||
|
||||
# delete plugin settings
|
||||
self._cleanup_settings(key)
|
||||
|
||||
# delete plugin disabled entry
|
||||
if include_disabled:
|
||||
self._cleanup_disabled(key)
|
||||
|
||||
# delete plugin data folder
|
||||
result_data = True
|
||||
if not self._cleanup_data(key):
|
||||
message = "Could not delete data folder of plugin {}".format(key)
|
||||
self._logger.exception(message)
|
||||
self._log_stderr(message)
|
||||
result_data = False
|
||||
|
||||
if settings_save:
|
||||
self._settings.save()
|
||||
|
||||
result = dict(result=result_data,
|
||||
needs_restart=True,
|
||||
plugin=result_value)
|
||||
if result_notifications:
|
||||
self._send_result_notification("cleanup", result)
|
||||
|
||||
# cleaning orphan cache
|
||||
self._orphans = None
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
def command_cleanup_all(self):
|
||||
orphans = self._get_orphans()
|
||||
cleaned_up = set()
|
||||
|
||||
for orphan in sorted(orphans.keys()):
|
||||
self.command_cleanup(orphan,
|
||||
include_disabled=True,
|
||||
result_notifications=False,
|
||||
settings_save=False)
|
||||
cleaned_up.add(orphan)
|
||||
|
||||
self._settings.save()
|
||||
|
||||
result = dict(result=True,
|
||||
needs_restart=len(cleaned_up) > 0,
|
||||
cleaned_up=sorted(list(cleaned_up)))
|
||||
self._send_result_notification("cleanup_all", result)
|
||||
self._logger.info("Cleaned up all data, {} left overs removed".format(len(cleaned_up)))
|
||||
|
||||
# cleaning orphan cache
|
||||
self._orphans = None
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
def _cleanup_disabled(self, plugin):
|
||||
# delete from disabled list
|
||||
disabled = self._settings.global_get(["plugins", "_disabled"])
|
||||
try:
|
||||
disabled.remove(plugin)
|
||||
except ValueError:
|
||||
# not in list, ok
|
||||
pass
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled)
|
||||
|
||||
def _cleanup_settings(self, plugin):
|
||||
# delete plugin settings
|
||||
self._settings.global_set(["plugins", plugin], None)
|
||||
return True
|
||||
|
||||
def _cleanup_data(self, plugin):
|
||||
import os
|
||||
import shutil
|
||||
|
||||
data_folder = os.path.join(self._settings.getBaseFolder("data"), plugin)
|
||||
if os.path.exists(data_folder):
|
||||
try:
|
||||
shutil.rmtree(data_folder)
|
||||
return True
|
||||
except Exception:
|
||||
self._logger.exception("Could not delete plugin data folder at {}".format(data_folder))
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def command_toggle(self, plugin, command):
|
||||
if plugin.key == "pluginmanager":
|
||||
return make_response("Can't enable/disable Plugin Manager", 400)
|
||||
@@ -717,7 +866,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
inapplicable_arguments = self.__class__.PIP_INAPPLICABLE_ARGUMENTS.get(args[0], list())
|
||||
for inapplicable_argument in inapplicable_arguments:
|
||||
additional_args = re.sub("(^|\s)" + re.escape(inapplicable_argument) + "\\b", "", additional_args)
|
||||
additional_args = re.sub(r"(^|\s)" + re.escape(inapplicable_argument) + r"\\b", "", additional_args)
|
||||
|
||||
if additional_args:
|
||||
args.append(additional_args)
|
||||
@@ -801,16 +950,25 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
else:
|
||||
run()
|
||||
|
||||
def _is_repository_cache_valid(self, mtime=None):
|
||||
import time
|
||||
if mtime is None:
|
||||
mtime = self._repository_mtime
|
||||
if mtime is None:
|
||||
return False
|
||||
return mtime + self._repository_cache_ttl >= time.time() > mtime
|
||||
|
||||
def _fetch_repository_from_disk(self):
|
||||
repo_data = None
|
||||
if os.path.isfile(self._repository_cache_path):
|
||||
import time
|
||||
mtime = os.path.getmtime(self._repository_cache_path)
|
||||
if mtime + self._repository_cache_ttl >= time.time() > mtime:
|
||||
if self._is_repository_cache_valid(mtime=mtime):
|
||||
try:
|
||||
import json
|
||||
with io.open(self._repository_cache_path, 'rt', encoding='utf-8') as f:
|
||||
repo_data = json.load(f)
|
||||
self._repository_mtime = mtime
|
||||
self._logger.info("Loaded plugin repository data from disk, was still valid")
|
||||
except Exception:
|
||||
self._logger.exception("Error while loading repository data from {}".format(self._repository_cache_path))
|
||||
@@ -828,17 +986,27 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
r.raise_for_status()
|
||||
self._logger.info("Loaded plugin repository data from {}".format(repository_url))
|
||||
except Exception as e:
|
||||
self._logger.exception("Could not fetch plugins from repository at {repository_url}: {message}".format(repository_url=repository_url, message=str(e)))
|
||||
self._logger.exception("Could not fetch plugins from repository at {repository_url}: {message}".format(repository_url=repository_url, message=e))
|
||||
return None
|
||||
|
||||
repo_data = r.json()
|
||||
try:
|
||||
repo_data = r.json()
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while reading repository data: {}".format(e))
|
||||
return None
|
||||
|
||||
# validation
|
||||
if not isinstance(repo_data, (list, tuple)):
|
||||
self._logger.warn("Invalid repository data: expected a list, got {!r}".format(repo_data))
|
||||
return None
|
||||
|
||||
try:
|
||||
import json
|
||||
with octoprint.util.atomic_write(self._repository_cache_path, mode='wb') as f:
|
||||
f.write(to_bytes(json.dumps(repo_data)))
|
||||
self._repository_mtime = os.path.getmtime(self._repository_cache_path)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while saving repository data to {}: {}".format(self._repository_cache_path, str(e)))
|
||||
self._logger.exception("Error while saving repository data to {}: {}".format(self._repository_cache_path, e))
|
||||
|
||||
return repo_data
|
||||
|
||||
@@ -848,19 +1016,29 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
if repo_data is None:
|
||||
return False
|
||||
|
||||
self._repository_plugins = list(map(map_repository_entry, repo_data))
|
||||
self._repository_plugins = list(filter(lambda x: x is not None,
|
||||
map(map_repository_entry, repo_data)))
|
||||
return True
|
||||
|
||||
def _is_notices_cache_valid(self, mtime=None):
|
||||
import time
|
||||
if mtime is None:
|
||||
mtime = self._notices_mtime
|
||||
if mtime is None:
|
||||
return False
|
||||
return mtime + self._notices_cache_ttl >= time.time() > mtime
|
||||
|
||||
def _fetch_notices_from_disk(self):
|
||||
notice_data = None
|
||||
if os.path.isfile(self._notices_cache_path):
|
||||
import time
|
||||
mtime = os.path.getmtime(self._notices_cache_path)
|
||||
if mtime + self._notices_cache_ttl >= time.time() > mtime:
|
||||
if self._is_notices_cache_valid(mtime=mtime):
|
||||
try:
|
||||
import json
|
||||
with io.open(self._notices_cache_path, 'rt', encoding='utf-8') as f:
|
||||
notice_data = json.load(f)
|
||||
self._notices_mtime = mtime
|
||||
self._logger.info("Loaded notice data from disk, was still valid")
|
||||
except Exception:
|
||||
self._logger.exception("Error while loading notices from {}".format(self._notices_cache_path))
|
||||
@@ -887,6 +1065,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
import json
|
||||
with octoprint.util.atomic_write(self._notices_cache_path, mode="wb") as f:
|
||||
f.write(to_bytes(json.dumps(notice_data)))
|
||||
self._notices_mtime = os.path.getmtime(self._notices_cache_path)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while saving notices to {}: {}".format(self._notices_cache_path, str(e)))
|
||||
return notice_data
|
||||
@@ -924,6 +1103,41 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._notices = notices
|
||||
return True
|
||||
|
||||
def _get_orphans(self, refresh=False):
|
||||
from collections import defaultdict
|
||||
|
||||
if self._orphans is not None and not refresh:
|
||||
return self._orphans
|
||||
|
||||
installed_keys = self._plugin_manager.plugins.keys()
|
||||
orphans = defaultdict(lambda: dict(settings=False, data=False, disabled=False))
|
||||
|
||||
# settings
|
||||
for key in list(self._settings.global_get(["plugins"]).keys()):
|
||||
if key.startswith("_"):
|
||||
# internal key, like _disabled
|
||||
continue
|
||||
|
||||
if key not in installed_keys:
|
||||
orphans[key]["settings"] = True
|
||||
|
||||
# data
|
||||
for entry in scandir(self._settings.getBaseFolder("data")):
|
||||
if not entry.is_dir():
|
||||
continue
|
||||
|
||||
if entry.name not in installed_keys:
|
||||
orphans[entry.name]["data"] = True
|
||||
|
||||
# disabled
|
||||
disabled = self._settings.global_get(["plugins", "_disabled"])
|
||||
for key in disabled:
|
||||
if key not in installed_keys:
|
||||
orphans[key]["disabled"] = True
|
||||
|
||||
self._orphans = dict(**orphans)
|
||||
return self._orphans
|
||||
|
||||
@property
|
||||
def _reconnect_hooks(self):
|
||||
reconnect_hooks = self.__class__.RECONNECT_HOOKS
|
||||
|
||||
@@ -10,18 +10,21 @@
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.get = function(refresh, opts) {
|
||||
var refresh_repo, refresh_notices;
|
||||
var refresh_repo, refresh_notices, refresh_orphans;
|
||||
if (_.isPlainObject(refresh)) {
|
||||
refresh_repo = refresh.repo || false;
|
||||
refresh_notices = refresh.notices || false;
|
||||
refresh_orphans = refresh.orphans || false;
|
||||
} else {
|
||||
refresh_repo = refresh;
|
||||
refresh_notices = false;
|
||||
refresh_orphans = false;
|
||||
}
|
||||
|
||||
var query = [];
|
||||
if (refresh_repo) query.push("refresh_repository=true");
|
||||
if (refresh_notices) query.push("refresh_notices=true");
|
||||
if (refresh_orphans) query.push("refresh_orphans=true");
|
||||
|
||||
return this.base.get(this.base.getSimpleApiUrl("pluginmanager") + ((query.length) ? "?" + query.join("&") : ""), opts);
|
||||
};
|
||||
@@ -52,11 +55,30 @@
|
||||
return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, cleanup, opts) {
|
||||
// backwards compatibility to former argument list (plugin, opts)
|
||||
if (arguments.length === 2 && typeof cleanup === "object") {
|
||||
opts = cleanup;
|
||||
cleanup = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
plugin: plugin,
|
||||
cleanup: !!cleanup
|
||||
};
|
||||
return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.cleanup = function(plugin, opts) {
|
||||
var data = {
|
||||
plugin: plugin
|
||||
};
|
||||
return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "cleanup", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.cleanupAll = function(plugin, opts) {
|
||||
var data = {};
|
||||
return this.base.simpleApiCommand("pluginmanager", "cleanup_all", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;height:500px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
|
||||
#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
|
||||
@@ -8,12 +8,17 @@ $(function() {
|
||||
self.systemViewModel = parameters[3];
|
||||
self.access = parameters[4];
|
||||
|
||||
// optional
|
||||
self.piSupport = parameters[5];
|
||||
|
||||
self.config_repositoryUrl = ko.observable();
|
||||
self.config_repositoryTtl = ko.observable();
|
||||
self.config_noticesUrl = ko.observable();
|
||||
self.config_noticesTtl = ko.observable();
|
||||
self.config_pipAdditionalArgs = ko.observable();
|
||||
self.config_pipForceUser = ko.observable();
|
||||
self.config_confirmUninstall = ko.observable();
|
||||
self.config_confirmDisable = ko.observable();
|
||||
|
||||
self.configurationDialog = $("#settings_plugin_pluginmanager_configurationdialog");
|
||||
|
||||
@@ -28,10 +33,22 @@ $(function() {
|
||||
}
|
||||
},
|
||||
{
|
||||
"bundled": function(item) {
|
||||
return item.bundled;
|
||||
},
|
||||
"3rdparty": function(item) {
|
||||
return !item.bundled;
|
||||
},
|
||||
"enabled": function(item) {
|
||||
return item.enabled;
|
||||
},
|
||||
"disabled": function(item) {
|
||||
return !item.enabled;
|
||||
}
|
||||
},
|
||||
"name",
|
||||
[],
|
||||
[],
|
||||
[["bundled", "3rdparty"], ["enabled", "disabled"]],
|
||||
0
|
||||
);
|
||||
|
||||
@@ -65,6 +82,23 @@ $(function() {
|
||||
0
|
||||
);
|
||||
|
||||
self.orphans = new ItemListHelper(
|
||||
"plugin.pluginmanager.orphans",
|
||||
{
|
||||
"identifier": function (a, b) {
|
||||
// sorts ascending
|
||||
if (a["identifier"].toLocaleLowerCase() < b["identifier"].toLocaleLowerCase()) return -1;
|
||||
if (a["identifier"].toLocaleLowerCase() > b["identifier"].toLocaleLowerCase()) return 1;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
{},
|
||||
"identifier",
|
||||
[],
|
||||
[],
|
||||
0
|
||||
);
|
||||
|
||||
self.uploadElement = $("#settings_plugin_pluginmanager_repositorydialog_upload");
|
||||
self.uploadButton = $("#settings_plugin_pluginmanager_repositorydialog_upload_start");
|
||||
|
||||
@@ -75,6 +109,11 @@ $(function() {
|
||||
self.performRepositorySearch();
|
||||
});
|
||||
|
||||
self.listingSearchQuery = ko.observable();
|
||||
self.listingSearchQuery.subscribe(function() {
|
||||
self.performListingSearch();
|
||||
});
|
||||
|
||||
self.installUrl = ko.observable();
|
||||
self.uploadFilename = ko.observable();
|
||||
|
||||
@@ -145,7 +184,7 @@ $(function() {
|
||||
});
|
||||
|
||||
self.enableManagement = ko.pureComputed(function() {
|
||||
return !self.printerState.isPrinting();
|
||||
return !self.printerState.isBusy();
|
||||
});
|
||||
|
||||
self.enableToggle = function(data) {
|
||||
@@ -164,10 +203,20 @@ $(function() {
|
||||
&& !data.pending_uninstall;
|
||||
};
|
||||
|
||||
self.enableRepoInstall = function(data) {
|
||||
return self.enableManagement() && self.pipAvailable() && !self.safeMode() && self.online() && self.isCompatible(data);
|
||||
self.enableCleanup = function(data) {
|
||||
return self.enableManagement()
|
||||
&& data.key !== 'pluginmanager'
|
||||
&& !data.pending_uninstall;
|
||||
};
|
||||
|
||||
self.enableRepoInstall = function(data) {
|
||||
return self.enableManagement() && self.pipAvailable() && !self.safeMode() && !self.throttled() && self.online() && self.isCompatible(data);
|
||||
};
|
||||
|
||||
self.throttled = ko.pureComputed(function() {
|
||||
return self.piSupport && self.piSupport.currentIssue() && !self.settingsViewModel.settings.plugins.pluginmanager.ignore_throttled();
|
||||
});
|
||||
|
||||
self.invalidUrl = ko.pureComputed(function() {
|
||||
// supported pip install URL schemes, according to https://pip.pypa.io/en/stable/reference/pip_install/
|
||||
var allowedUrlSchemes = ["http", "https",
|
||||
@@ -192,6 +241,7 @@ $(function() {
|
||||
return self.enableManagement()
|
||||
&& self.pipAvailable()
|
||||
&& !self.safeMode()
|
||||
&& !self.throttled()
|
||||
&& self.online()
|
||||
&& url !== undefined
|
||||
&& url.trim() !== ""
|
||||
@@ -217,6 +267,7 @@ $(function() {
|
||||
return self.enableManagement()
|
||||
&& self.pipAvailable()
|
||||
&& !self.safeMode()
|
||||
&& !self.throttled()
|
||||
&& name !== undefined
|
||||
&& name.trim() !== ""
|
||||
&& !self.invalidArchive();
|
||||
@@ -267,9 +318,21 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
self.performListingSearch = function() {
|
||||
var query = self.listingSearchQuery();
|
||||
if (query !== undefined && query.trim() !== "") {
|
||||
query = query.toLocaleLowerCase();
|
||||
self.plugins.changeSearchFunction(function (entry) {
|
||||
return entry && (entry["name"].toLocaleLowerCase().indexOf(query) > -1 || (entry.description && entry.description.toLocaleLowerCase().indexOf(query) > -1));
|
||||
});
|
||||
} else {
|
||||
self.plugins.resetSearch();
|
||||
}
|
||||
};
|
||||
|
||||
self.performRepositorySearch = function() {
|
||||
var query = self.repositorySearchQuery();
|
||||
if (query !== undefined && query.trim() != "") {
|
||||
if (query !== undefined && query.trim() !== "") {
|
||||
query = query.toLocaleLowerCase();
|
||||
self.repositoryplugins.changeSearchFunction(function(entry) {
|
||||
return entry && (entry["title"].toLocaleLowerCase().indexOf(query) > -1 || entry["description"].toLocaleLowerCase().indexOf(query) > -1);
|
||||
@@ -282,6 +345,7 @@ $(function() {
|
||||
|
||||
self.fromResponse = function(data, options) {
|
||||
self._fromPluginsResponse(data.plugins, options);
|
||||
self._fromOrphanResponse(data.orphan_data, options);
|
||||
self._fromRepositoryResponse(data.repository, options);
|
||||
self._fromPipResponse(data.pip, options);
|
||||
|
||||
@@ -315,6 +379,14 @@ $(function() {
|
||||
self.plugins.updateItems(data);
|
||||
};
|
||||
|
||||
self._fromOrphanResponse = function(data) {
|
||||
var orphans = [];
|
||||
_.each(data, function(value, key) {
|
||||
orphans.push({identifier: key, settings: value.settings, data: value.data});
|
||||
});
|
||||
self.orphans.updateItems(orphans);
|
||||
};
|
||||
|
||||
self._fromRepositoryResponse = function(data) {
|
||||
self.repositoryAvailable(data.available);
|
||||
if (data.available) {
|
||||
@@ -350,17 +422,18 @@ $(function() {
|
||||
if (!_.isPlainObject(options)) {
|
||||
options = {
|
||||
refresh_repo: options,
|
||||
refresh_orphans: false,
|
||||
refresh_notices: false,
|
||||
eval_notices: false
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
options.refresh_repo = options.refresh_repo || false;
|
||||
options.refresh_orphans = options.refresh_orphans || false;
|
||||
options.refresh_notices = options.refresh_notices || false;
|
||||
options.eval_notices = options.eval_notices || false;
|
||||
|
||||
OctoPrint.plugins.pluginmanager.get({repo: options.refresh_repo, notices: options.refresh_notices})
|
||||
OctoPrint.plugins.pluginmanager.get({repo: options.refresh_repo, notices: options.refresh_notices, orphans: options.refresh_orphans})
|
||||
.done(function(data) {
|
||||
self.fromResponse(data, options);
|
||||
});
|
||||
@@ -395,14 +468,15 @@ $(function() {
|
||||
.done(onSuccess)
|
||||
.fail(onError);
|
||||
} else {
|
||||
var perform = function() {
|
||||
var performDisabling = function() {
|
||||
OctoPrint.plugins.pluginmanager.disable(data.key)
|
||||
.done(onSuccess)
|
||||
.fail(onError);
|
||||
};
|
||||
|
||||
// always warn if plugin is marked "disabling discouraged"
|
||||
if (data.disabling_discouraged) {
|
||||
var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: data.name})
|
||||
var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: _.escape(data.name)})
|
||||
+ "</p><p>" + data.disabling_discouraged;
|
||||
showConfirmationDialog({
|
||||
title: gettext("This is not recommended"),
|
||||
@@ -410,10 +484,21 @@ $(function() {
|
||||
question: gettext("Do you still want to disable it?"),
|
||||
cancel: gettext("Keep enabled"),
|
||||
proceed: gettext("Disable anyway"),
|
||||
onproceed: perform
|
||||
})
|
||||
onproceed: performDisabling
|
||||
});
|
||||
}
|
||||
// warn if global "warn disabling" setting is set"
|
||||
else if (self.settingsViewModel.settings.plugins.pluginmanager.confirm_disable()) {
|
||||
showConfirmationDialog({
|
||||
message: _.sprintf(gettext("You are about to disable \"%(name)s\""), {name: _.escape(data.name)}),
|
||||
cancel: gettext("Keep enabled"),
|
||||
proceed: gettext("Disable plugin"),
|
||||
onproceed: performDisabling,
|
||||
nofade: true
|
||||
});
|
||||
} else {
|
||||
perform();
|
||||
// otherwise just go ahead and disable...
|
||||
performDisabling();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -447,6 +532,10 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.throttled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (url === undefined) {
|
||||
url = self.installUrl();
|
||||
}
|
||||
@@ -460,13 +549,13 @@ $(function() {
|
||||
if (!reinstall) {
|
||||
workTitle = gettext("Installing plugin...");
|
||||
if (name) {
|
||||
workText = _.sprintf(gettext("Installing plugin \"%(name)s\" from %(url)s..."), {url: url, name: name});
|
||||
workText = _.sprintf(gettext("Installing plugin \"%(name)s\" from %(url)s..."), {url: _.escape(url), name: _.escape(name)});
|
||||
} else {
|
||||
workText = _.sprintf(gettext("Installing plugin from %(url)s..."), {url: url});
|
||||
workText = _.sprintf(gettext("Installing plugin from %(url)s..."), {url: _.escape(url)});
|
||||
}
|
||||
} else {
|
||||
workTitle = gettext("Reinstalling plugin...");
|
||||
workText = _.sprintf(gettext("Reinstalling plugin \"%(name)s\" from %(url)s..."), {url: url, name: name});
|
||||
workText = _.sprintf(gettext("Reinstalling plugin \"%(name)s\" from %(url)s..."), {url: _.escape(url), name: _.escape(name)});
|
||||
}
|
||||
self._markWorking(workTitle, workText);
|
||||
|
||||
@@ -510,25 +599,119 @@ $(function() {
|
||||
}
|
||||
|
||||
if (data.bundled) return;
|
||||
if (data.key == "pluginmanager") return;
|
||||
if (data.key === "pluginmanager") return;
|
||||
|
||||
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name}));
|
||||
// defining actual uninstall logic as functor in order to handle
|
||||
// the confirm/no-confirm logic without duplication of logic
|
||||
var performUninstall = function(cleanup) {
|
||||
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: _.escape(data.name)}));
|
||||
|
||||
OctoPrint.plugins.pluginmanager.uninstall(data.key)
|
||||
.done(function() {
|
||||
self.requestData();
|
||||
})
|
||||
.fail(function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
OctoPrint.plugins.pluginmanager.uninstall(data.key, cleanup)
|
||||
.done(function() {
|
||||
self.requestData();
|
||||
})
|
||||
.fail(function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
})
|
||||
.always(function() {
|
||||
self._markDone();
|
||||
});
|
||||
})
|
||||
.always(function() {
|
||||
self._markDone();
|
||||
});
|
||||
};
|
||||
|
||||
showConfirmationDialog({
|
||||
message: _.sprintf(gettext("You are about to uninstall the plugin \"%(name)s\""), {name: _.escape(data.name)}),
|
||||
cancel: gettext("Keep installed"),
|
||||
proceed: [
|
||||
gettext("Uninstall"),
|
||||
gettext("Uninstall & clean up data")
|
||||
],
|
||||
onproceed: function(button) {
|
||||
// buttons: 0=uninstall, 1=uninstall&cleanup
|
||||
performUninstall(button === 1)
|
||||
},
|
||||
nofade: true
|
||||
});
|
||||
};
|
||||
|
||||
self.cleanupPlugin = function(data) {
|
||||
var key, name;
|
||||
if (_.isObject(data)) {
|
||||
key = data.key;
|
||||
name = data.name;
|
||||
} else {
|
||||
key = name = data;
|
||||
}
|
||||
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === "pluginmanager") return;
|
||||
|
||||
var performCleanup = function() {
|
||||
self._markWorking(gettext("Cleaning up plugin data..."), _.sprintf(gettext("Cleaning up data of plugin \"%(name)s\""), {name: _.escape(name)}));
|
||||
|
||||
OctoPrint.plugins.pluginmanager.cleanup(key)
|
||||
.done(function() {
|
||||
self.requestData();
|
||||
})
|
||||
.fail(function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
})
|
||||
.always(function() {
|
||||
self._markDone();
|
||||
})
|
||||
};
|
||||
|
||||
showConfirmationDialog({
|
||||
message: _.sprintf(gettext("You are about to cleanup the plugin data of \"%(name)s\". This operation cannot be reversed."), {name: _.escape(name)}),
|
||||
cancel: gettext("Keep data"),
|
||||
proceed: gettext("Cleanup data"),
|
||||
onproceed: performCleanup,
|
||||
nofade: true
|
||||
});
|
||||
};
|
||||
|
||||
self.cleanupAll = function() {
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var performCleanup = function() {
|
||||
var title = gettext("Cleaning up all left over plugin data...");
|
||||
self._markWorking(title, title);
|
||||
|
||||
OctoPrint.plugins.pluginmanager.cleanupAll()
|
||||
.fail(function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
})
|
||||
.always(function() {
|
||||
self._markDone();
|
||||
})
|
||||
};
|
||||
|
||||
showConfirmationDialog({
|
||||
message: gettext("You are about to cleanup left over plugin settings and data of plugins no longer installed. This operation cannot be reversed."),
|
||||
cancel: gettext("Keep data"),
|
||||
proceed: gettext("Cleanup all data"),
|
||||
onproceed: performCleanup,
|
||||
nofade: true
|
||||
});
|
||||
};
|
||||
|
||||
self.refreshRepository = function() {
|
||||
@@ -597,7 +780,8 @@ $(function() {
|
||||
notices: notices,
|
||||
notices_ttl: noticesTtl,
|
||||
pip_args: pipArgs,
|
||||
pip_force_user: self.config_pipForceUser()
|
||||
pip_force_user: self.config_pipForceUser(),
|
||||
confirm_disable: self.config_confirmDisable(),
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -615,6 +799,7 @@ $(function() {
|
||||
self.config_noticesTtl(self.settingsViewModel.settings.plugins.pluginmanager.notices_ttl());
|
||||
self.config_pipAdditionalArgs(self.settingsViewModel.settings.plugins.pluginmanager.pip_args());
|
||||
self.config_pipForceUser(self.settingsViewModel.settings.plugins.pluginmanager.pip_force_user());
|
||||
self.config_confirmDisable(self.settingsViewModel.settings.plugins.pluginmanager.confirm_disable());
|
||||
};
|
||||
|
||||
self.installed = function(data) {
|
||||
@@ -671,13 +856,21 @@ $(function() {
|
||||
line = gettext("Disable <em>%(plugin)s</em>: %(result)s");
|
||||
break;
|
||||
}
|
||||
case "cleanup": {
|
||||
line = gettext("Cleanup <em>%(plugin)s</em>: %(result)s");
|
||||
break;
|
||||
}
|
||||
case "cleanup_all": {
|
||||
line = gettext("Cleanup all: %(result)s");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
text += "<li>"
|
||||
+ _.sprintf(line, {plugin: step.plugin, result: step.result ? "<i class=\"fa fa-check\"></i>" : "<i class=\"fa fa-remove\"></i>"})
|
||||
+ _.sprintf(line, {plugin: _.escape(step.plugin), result: step.result ? "<i class=\"fa fa-check\"></i>" : "<i class=\"fa fa-remove\"></i>"})
|
||||
+ "</li>";
|
||||
});
|
||||
text += "</ul></p>";
|
||||
@@ -855,16 +1048,16 @@ $(function() {
|
||||
|
||||
var title;
|
||||
if (important) {
|
||||
title = _.sprintf(gettext("Important notice regarding plugin \"%(name)s\""), {name: name});
|
||||
title = _.sprintf(gettext("Important notice regarding plugin \"%(name)s\""), {name: _.escape(name)});
|
||||
} else {
|
||||
title = _.sprintf(gettext("Notice regarding plugin \"%(name)s\""), {name: name});
|
||||
title = _.sprintf(gettext("Notice regarding plugin \"%(name)s\""), {name: _.escape(name)});
|
||||
}
|
||||
|
||||
var text = "";
|
||||
|
||||
if (notification.versions && notification.versions.length > 0) {
|
||||
var versions = _.map(notification.versions, function(v) { return (v == version) ? "<strong>" + v + "</strong>" : v; }).join(", ");
|
||||
text += "<small>" + _.sprintf(gettext("Affected versions: %(versions)s"), {versions: versions}) + "</small>";
|
||||
text += "<small>" + _.sprintf(gettext("Affected versions: %(versions)s"), {versions: _.escape(versions)}) + "</small>";
|
||||
} else {
|
||||
text += "<small>" + gettext("Affected versions: all") + "</small>";
|
||||
}
|
||||
@@ -1060,7 +1253,11 @@ $(function() {
|
||||
var name = "Unknown";
|
||||
if (data.hasOwnProperty("plugin")) {
|
||||
if (data.plugin !== "unknown") {
|
||||
name = data.plugin.name;
|
||||
if (_.isPlainObject(data.plugin)) {
|
||||
name = data.plugin.name;
|
||||
} else {
|
||||
name = data.plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,7 +1277,8 @@ $(function() {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: PluginManagerViewModel,
|
||||
dependencies: ["loginStateViewModel", "settingsViewModel", "printerStateViewModel", "systemViewModel", "accessViewModel"],
|
||||
dependencies: ["loginStateViewModel", "settingsViewModel", "printerStateViewModel", "systemViewModel", "accessViewModel", "piSupportViewModel"],
|
||||
optional: ["piSupportViewModel"],
|
||||
elements: ["#settings_plugin_pluginmanager"]
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,10 @@
|
||||
#settings_plugin_pluginmanager {
|
||||
}
|
||||
|
||||
#settings_plugin_pluginmanager_pluginlist {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: 500px;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 2px;
|
||||
@@ -33,6 +36,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
#settings_plugin_pluginmanager_orphanlist {
|
||||
display: block;
|
||||
width: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 2px;
|
||||
margin-bottom: 1em;
|
||||
|
||||
table {
|
||||
|
||||
th, td {
|
||||
&.settings_plugin_plugin_manager_orphans_id {
|
||||
text-overflow: ellipsis;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
&.settings_plugin_plugin_manager_orphans_actions {
|
||||
text-align: center;
|
||||
width: 80px;
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000;
|
||||
|
||||
&.disabled {
|
||||
color: #ccc;
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#settings_plugin_pluginmanager_repositorydialog {
|
||||
h4 {
|
||||
position: relative;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% macro pluginmanager_printing() %}
|
||||
<div class="alert" data-bind="visible: !enableManagement()">
|
||||
{{ _('Take note that all plugin management functionality is disabled while your printer is printing.') }}
|
||||
{{ _('Take note that all plugin management functionality is disabled while your printer is printing or paused.') }}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
{% endtrans %}</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro pluginmanager_throttled() %}
|
||||
<div class="alert" data-bind="visible: throttled">{% trans %}
|
||||
The system OctoPrint is running on is currently throttled. Due to that it's not possible to install new
|
||||
plugins in order to avoid possible issues caused by system instability.
|
||||
{% endtrans %}</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro pluginmanager_offline() %}
|
||||
<div class="alert" data-bind="visible: !online()">{% trans %}
|
||||
It looks like OctoPrint has currently no connection to the internet. Due to that it's not possible
|
||||
@@ -27,77 +34,144 @@
|
||||
{% endtrans %}</div>
|
||||
{% endmacro %}
|
||||
|
||||
{{ pluginmanager_printing() }}
|
||||
{{ pluginmanager_nopip() }}
|
||||
{{ pluginmanager_safemode() }}
|
||||
<ul class="nav nav-pills">
|
||||
<li class="active">
|
||||
<a href="#settings_plugin_pluginmanager_plugins" data-toggle="tab">{{ _('Plugins') }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#settings_plugin_pluginmanager_cleanup" data-toggle="tab">{{ _('Cleanup') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="settings_plugin_pluginmanager_plugins">
|
||||
{{ pluginmanager_printing() }}
|
||||
{{ pluginmanager_nopip() }}
|
||||
{{ pluginmanager_safemode() }}
|
||||
{{ pluginmanager_throttled() }}
|
||||
|
||||
<h3>{{ _('Installed Plugins') }}</h3>
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fa fa-wrench"></i></button>
|
||||
</div>
|
||||
|
||||
<div id="settings_plugin_pluginmanager_pluginlist">
|
||||
<table class="table table-striped table-hover table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_plugin_plugin_manager_plugins_name">{{ _('Name') }}</th>
|
||||
<th class="settings_plugin_plugin_manager_plugins_actions">{{ _('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: plugins.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_plugin_plugin_manager_plugins_name">
|
||||
<div data-bind="css: {muted: !enabled}"><span data-bind="text: name"></span> <span data-bind="visible: version">(<span data-bind="text: version"></span>)</span> <i title="{{ _('Bundled with OctoPrint') }}" class="fa fa-th-large" data-bind="visible: bundled"></i> <i class="fa fa-lock" title="{{ _('Cannot be uninstalled through OctoPrint') }}" data-bind="visible: !managable"></i> <i title="{{ _('Restart of OctoPrint needed for changes to take effect') }}" class="fa fa-refresh" data-bind="visible: pending_enable || pending_disable || pending_install || pending_uninstall"></i> <i title="{{ _('Pending install') }}" class="fa fa-plus" data-bind="visible: pending_install"></i> <i title="{{ _('Pending uninstall') }}" class="fa fa-minus" data-bind="visible: pending_uninstall"></i> <i title="{{ _('Disabled due to safe mode') }}" class="fa fa-medkit" data-bind="visible: safe_mode_victim"></i> <i class="fa fa-exclamation-triangle" title="{{ _('There are notices available regarding this plugin') }}" data-bind="visible: notifications && notifications.length"></i> <i class="fa fa-ban" title="{{ _('This plugin is blacklisted') }}" data-bind="visible: blacklisted"></i></div>
|
||||
<div data-bind="visible: notifications && notifications.length"><a href="javascript:void(0)" class="text-error" style="text-decoration: underline" data-bind="click: function() { $root.showPluginNotifications($data) }, text: $root.showPluginNotificationsLinkText($data)"></a></div>
|
||||
<div><small class="muted" data-bind="text: description"> </small></div>
|
||||
<div data-bind="css: {muted: !enabled}">
|
||||
<small data-bind="visible: url"><i class="fa fa-home"></i> <a data-bind="attr: {href: url}" target="_blank" rel="noreferrer noopener">{{ _('Homepage') }}</a></small>
|
||||
<small data-bind="visible: license"><i class="fa fa-gavel"></i> <span data-bind="text: license"></span></small>
|
||||
<small data-bind="visible: author"><i class="fa fa-user"></i> <span data-bind="text: author"></span></small>
|
||||
<small> </small>
|
||||
<h3>{{ _('Installed Plugins') }}</h3>
|
||||
|
||||
<div style="margin-bottom: 1em" class="clearfix">
|
||||
<input type="text" class="input-block search-query pull-left" data-bind="value: listingSearchQuery, valueUpdate: 'input'" placeholder="{{ _('Search...')|edq }}">
|
||||
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('bundled'); plugins.removeFilter('3rdparty'); }, css: {active: !_.contains(plugins.currentFilters(), 'bundled') && !_.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show both bundled and third-party plugins')|edq }}">All</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('bundled') }, css: {active: _.contains(plugins.currentFilters(), 'bundled')}" title="{{ _('Show only bundled plugins')|edq }}">{{ _('Bundled') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('3rdparty') }, css: {active: _.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show only third-party plugins')|edq }}">{{ _('3rd party') }}</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="settings_plugin_plugin_manager_plugins_actions">
|
||||
<a href="#" data-bind="css: $root.toggleButtonCss($data), attr: {title: $root.toggleButtonTitle($data)}, enable: $root.enableToggle($data), click: function() { $root.togglePlugin($data) }"></a> | <a href="#" class="fa fa-trash-o" title="{{ _('Uninstall Plugin') }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('enabled'); plugins.removeFilter('disabled'); }, css: {active: !_.contains(plugins.currentFilters(), 'enabled') && !_.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show both enabled and disabled plugins')|edq }}">All</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('enabled') }, css: {active: _.contains(plugins.currentFilters(), 'enabled')}" title="{{ _('Show only enabled plugins')|edq }}">{{ _('Enabled') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('disabled') }, css: {active: _.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show only disabled plugins')|edq }}">{{ _('Disabled') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-block" data-bind="click: $root.showRepository">{{ _('Get More...') }}</button>
|
||||
<div id="settings_plugin_pluginmanager_pluginlist">
|
||||
<table class="table table-striped table-hover table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_plugin_plugin_manager_plugins_name">{{ _('Name') }}</th>
|
||||
<th class="settings_plugin_plugin_manager_plugins_actions">{{ _('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: plugins.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_plugin_plugin_manager_plugins_name">
|
||||
<div data-bind="css: {muted: !enabled}"><span data-bind="text: name"></span> <span data-bind="visible: version">(<span data-bind="text: version"></span>)</span> <i title="{{ _('Bundled with OctoPrint')|edq }}" class="fa fa-th-large" data-bind="visible: bundled"></i> <i class="fa fa-lock" title="{{ _('Cannot be uninstalled through OctoPrint')|edq }}" data-bind="visible: !managable"></i> <i title="{{ _('Restart of OctoPrint needed for changes to take effect')|edq }}" class="fa fa-refresh" data-bind="visible: pending_enable || pending_disable || pending_install || pending_uninstall"></i> <i title="{{ _('Pending install')|edq }}" class="fa fa-plus" data-bind="visible: pending_install"></i> <i title="{{ _('Pending uninstall')|edq }}" class="fa fa-minus" data-bind="visible: pending_uninstall"></i> <i title="{{ _('Disabled due to safe mode')|edq }}" class="fa fa-medkit" data-bind="visible: safe_mode_victim"></i> <i class="fa fa-exclamation-triangle" title="{{ _('There are notices available regarding this plugin')|edq }}" data-bind="visible: notifications && notifications.length"></i> <i class="fa fa-ban" title="{{ _('This plugin is blacklisted')|edq }}" data-bind="visible: blacklisted"></i></div>
|
||||
<div data-bind="visible: notifications && notifications.length"><a href="javascript:void(0)" class="text-error" style="text-decoration: underline" data-bind="click: function() { $root.showPluginNotifications($data) }, text: $root.showPluginNotificationsLinkText($data)"></a></div>
|
||||
<div><small class="muted" data-bind="text: description"> </small></div>
|
||||
<div data-bind="css: {muted: !enabled}">
|
||||
<small data-bind="visible: url"><i class="fa fa-home"></i> <a data-bind="attr: {href: url}" target="_blank" rel="noreferrer noopener">{{ _('Homepage') }}</a></small>
|
||||
<small data-bind="visible: license"><i class="fa fa-gavel"></i> <span data-bind="text: license"></span></small>
|
||||
<small data-bind="visible: author"><i class="fa fa-user"></i> <span data-bind="text: author"></span></small>
|
||||
<small> </small>
|
||||
</div>
|
||||
</td>
|
||||
<td class="settings_plugin_plugin_manager_plugins_actions">
|
||||
<a href="#" data-bind="css: $root.toggleButtonCss($data), attr: {title: $root.toggleButtonTitle($data)}, enable: $root.enableToggle($data), click: function() { $root.togglePlugin($data) }"></a> | <a href="#" class="fa fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" data-bind="css: {disabled: !$root.enableCleanup($data)}, enable: $root.enableCleanup($data), click: function() { $root.cleanupPlugin($data) }"></a> | <a href="#" class="fa fa-trash-o" title="{{ _('Uninstall Plugin')|edq }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="muted" data-bind="visible: pipAvailable()">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="fa toggle-arrow fa-caret-right"></i> Using pip of "<span data-bind="text: pipPython"></span>", Version <span data-bind="text: pipVersion"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
Installation directory: <span data-bind="text: pipInstallDir"></span> ("--user" flag: <span data-bind="text: pipUseUserString"></span>)<br />
|
||||
Virtual environment: <span data-bind="text: pipVirtualEnvString"></span><br />
|
||||
<span data-bind="visible: pipAdditionalArgs">Additional Arguments: <span data-bind="text: pipAdditionalArgs"></span></span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-block" data-bind="click: $root.showRepository">{{ _('Get More...') }}</button>
|
||||
|
||||
<div class="muted">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="toggle-arrow fa fa-caret-right"></i> <span data-bind="text: noticeCountText"></span>
|
||||
</a>
|
||||
</small>
|
||||
<div class="muted" data-bind="visible: pipAvailable()">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="fa toggle-arrow fa-caret-right"></i> Using pip of "<span data-bind="text: pipPython"></span>", Version <span data-bind="text: pipVersion"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
Installation directory: <span data-bind="text: pipInstallDir"></span> ("--user" flag: <span data-bind="text: pipUseUserString"></span>)<br />
|
||||
Virtual environment: <span data-bind="text: pipVirtualEnvString"></span><br />
|
||||
<span data-bind="visible: pipAdditionalArgs">Additional Arguments: <span data-bind="text: pipAdditionalArgs"></span></span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="muted">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="toggle-arrow fa fa-caret-right"></i> <span data-bind="text: noticeCountText"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
<!-- ko if: noticeCount() > 0 --><a href="javascript:void(0)" data-bind="click: function() { reshowNotices(); }">{{ _('Reshow current notices') }}</a> ·<!-- /ko -->
|
||||
<a href="javascript:void(0)" data-bind="click: function() { refreshNotices(); }">{{ _('Refresh notices from repository') }}</a>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
<!-- ko if: noticeCount() > 0 --><a href="javascript:void(0)" data-bind="click: function() { reshowNotices(); }">{{ _('Reshow current notices') }}</a> ·<!-- /ko -->
|
||||
<a href="javascript:void(0)" data-bind="click: function() { refreshNotices(); }">{{ _('Refresh notices from repository') }}</a>
|
||||
</small>
|
||||
|
||||
<div class="tab-pane" id="settings_plugin_pluginmanager_cleanup">
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.requestData({refresh_orphans: true}) }" title="{{ _('Refresh')|edq }}"><i class="fa fa-refresh"></i></button>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Cleanup') }}</h3>
|
||||
|
||||
<div data-bind="visible: orphans.paginatedItems().length > 0">
|
||||
<div id="settings_plugin_pluginmanager_orphanlist">
|
||||
<table class="table table-striped table-hover table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_plugin_plugin_manager_orphans_id">{{ _('Identifier') }}</th>
|
||||
<th class="settings_plugin_plugin_manager_orphans_actions">{{ _('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: orphans.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_plugin_plugin_manager_orphans_id">
|
||||
<span data-bind="text: identifier"></span>
|
||||
</td>
|
||||
<td class="settings_plugin_plugin_manager_orphans_actions">
|
||||
<a href="javascript:void(0)" class="fa fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" data-bind="click: function() { $root.cleanupPlugin($data.identifier) }"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-danger btn-block" data-bind="click: $root.cleanupAll">{{ _('Cleanup all') }}</button>
|
||||
</div>
|
||||
<div data-bind="visible: orphans.paginatedItems().length == 0">
|
||||
{{ _('Nothing to cleanup! There are no settings or data left over from plugins which are no longer installed.') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -122,6 +196,7 @@
|
||||
{{ pluginmanager_printing() }}
|
||||
{{ pluginmanager_nopip() }}
|
||||
{{ pluginmanager_safemode() }}
|
||||
{{ pluginmanager_throttled() }}
|
||||
{{ pluginmanager_offline() }}
|
||||
<h4 style="position: relative">
|
||||
{{ _('... from the <a href="%(url)s" target="_blank">Plugin Repository</a>', url='https://plugins.octoprint.org') }}
|
||||
@@ -142,7 +217,7 @@
|
||||
</h4>
|
||||
|
||||
<form class="form-search" data-bind="submit: performRepositorySearch">
|
||||
<input type="text" class="input-block search-query" data-bind="value: repositorySearchQuery, valueUpdate: 'input'" placeholder="{{ _('Search...') }}">
|
||||
<input type="text" class="input-block search-query" data-bind="value: repositorySearchQuery, valueUpdate: 'input'" placeholder="{{ _('Search...')|edq }}">
|
||||
</form>
|
||||
|
||||
<div data-bind="visible: repositoryAvailable() && repositoryplugins.paginatedItems().length > 0">
|
||||
@@ -191,7 +266,7 @@
|
||||
<form class="form-inline">
|
||||
<div class="control-group row-fluid" data-bind="css: {error: invalidUrl}">
|
||||
<div class="span9">
|
||||
<input type="text" class="input-block-level" data-bind="value: installUrl, valueUpdate: 'input'" placeholder="{{ _('Enter URL...') }}" >
|
||||
<input type="text" class="input-block-level" data-bind="value: installUrl, valueUpdate: 'input'" placeholder="{{ _('Enter URL...')|edq }}" >
|
||||
</div>
|
||||
<button class="btn btn-primary span3" data-bind="enable: enableUrlInstall, css: {disabled: !enableUrlInstall()}, click: function() { if (enableUrlInstall()) { $root.installPlugin(); } }">{{ _('Install') }}</button>
|
||||
</div>
|
||||
@@ -241,18 +316,30 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<legend>{{ _('Confirmations') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('Confirm before disabling a plugin')|edq }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: config_confirmDisable"> {{ _('Confirm before disabling a plugin') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<p>{% trans %}You should normally <strong>not</strong> have to change <strong>any</strong> of the following settings, they are purely provided for convenience here.{% endtrans %}</p>
|
||||
|
||||
<fieldset>
|
||||
<legend>{{ _('Plugin repository configuration') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('URL of the Plugin Repository to use. You should normally not have to change this.') }}">
|
||||
<div class="control-group" title="{{ _('URL of the Plugin Repository to use. You should normally not have to change this.')|edq }}">
|
||||
<label class="control-label">{{ _('Repository URL') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_repositoryUrl">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('How long to cache repository data, in minutes. You should normally not have to change this.') }}">
|
||||
<div class="control-group" title="{{ _('How long to cache repository data, in minutes. You should normally not have to change this.')|edq }}">
|
||||
<label class="control-label">{{ _('Repository cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
@@ -266,13 +353,13 @@
|
||||
<fieldset>
|
||||
<legend>{{ _('Notices configuration') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('URL of the Notices source to use. You should normally not have to change this.') }}">
|
||||
<div class="control-group" title="{{ _('URL of the Notices source to use. You should normally not have to change this.')|edq }}">
|
||||
<label class="control-label">{{ _('Notices URL') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_noticesUrl">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('How long to cache notices, in minutes. You should normally not have to change this.') }}">
|
||||
<div class="control-group" title="{{ _('How long to cache notices, in minutes. You should normally not have to change this.')|edq }}">
|
||||
<label class="control-label">{{ _('Notices cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
@@ -286,7 +373,7 @@
|
||||
<fieldset>
|
||||
<legend>{{ _('pip configuration') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('Additional arguments for the pip command. You should normally not have to change this.') }}">
|
||||
<div class="control-group" title="{{ _('Additional arguments for the pip command. You should normally not have to change this.')|edq }}">
|
||||
<label class="control-label">{{ _('Additional arguments') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_pipAdditionalArgs">
|
||||
|
||||
@@ -189,7 +189,7 @@ __plugin_author__ = "Gina Häußge"
|
||||
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/printer_safety_check.html"
|
||||
__plugin_description__ = "Checks for unsafe printers/printer firmwares"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
||||
"check if the printer it is connected to has a known safety"
|
||||
"check if the printer it is connected to has a known safety "
|
||||
"issue and inform you about that fact.")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = PrinterSafetyCheckPlugin()
|
||||
|
||||
@@ -68,7 +68,7 @@ class AnycubicCheck(Check):
|
||||
def _broken_version(self, line):
|
||||
version_str = line[len(self.VERSION):]
|
||||
version = get_comparable_version(version_str, base=True)
|
||||
if version is not None and version <= self.FIXED_VERSION:
|
||||
if version is not None and version < self.FIXED_VERSION:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -35,9 +35,10 @@ from octoprint.util.pip import LocalPipCaller
|
||||
import octoprint.settings
|
||||
|
||||
|
||||
# OctoPi 0.15+
|
||||
MINIMUM_PYTHON = "2.7.9"
|
||||
MINIMUM_SETUPTOOLS = "5.5.1"
|
||||
MINIMUM_PIP = "9.0.1"
|
||||
MINIMUM_SETUPTOOLS = "39.0.1"
|
||||
MINIMUM_PIP = "9.0.3"
|
||||
|
||||
|
||||
##~~ Plugin
|
||||
@@ -77,6 +78,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
self._console_logger = None
|
||||
|
||||
self._get_throttled = lambda: False
|
||||
|
||||
def initialize(self):
|
||||
self._console_logger = logging.getLogger("octoprint.plugins.softwareupdate.console")
|
||||
|
||||
@@ -119,6 +122,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._console_logger.setLevel(logging.DEBUG)
|
||||
self._console_logger.propagate = False
|
||||
|
||||
helpers = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
||||
if helpers and "get_throttled" in helpers:
|
||||
self._get_throttled = helpers["get_throttled"]
|
||||
if self._settings.get_boolean(["ignore_throttled"]):
|
||||
self._logger.warn("!!! THROTTLE STATE IGNORED !!! You have configured the Software Update plugin to ignore an active throttle state of the underlying system. You might run into stability issues or outright corrupt your install. Consider fixing the throttling issue instead of suppressing it.")
|
||||
|
||||
def on_after_startup(self):
|
||||
self._check_environment()
|
||||
self.get_current_versions()
|
||||
@@ -130,9 +139,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._configured_checks = self._settings.get(["checks"], merged=True)
|
||||
|
||||
update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config")
|
||||
check_providers = self._settings.get(["check_providers"], merged=True)
|
||||
if not isinstance(check_providers, dict):
|
||||
check_providers = dict()
|
||||
check_providers = dict()
|
||||
|
||||
effective_configs = dict()
|
||||
|
||||
@@ -180,9 +187,6 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
for key, config in effective_configs.items():
|
||||
self._configured_checks[key] = config
|
||||
|
||||
self._settings.set(["check_providers"], check_providers)
|
||||
self._settings.save()
|
||||
|
||||
# we only want to process checks that came from plugins for
|
||||
# which the plugins are still installed and enabled
|
||||
config_checks = self._settings.get(["checks"])
|
||||
@@ -291,11 +295,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
},
|
||||
},
|
||||
"pip_command": None,
|
||||
"check_providers": {},
|
||||
|
||||
"cache_ttl": 24 * 60,
|
||||
|
||||
"notify_users": True
|
||||
"notify_users": True,
|
||||
|
||||
"ignore_throttled": False
|
||||
}
|
||||
|
||||
def on_settings_load(self):
|
||||
@@ -303,12 +308,11 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
if "checks" in data:
|
||||
del data["checks"]
|
||||
|
||||
if "check_providers" in data:
|
||||
del data["check_providers"]
|
||||
|
||||
checks = self._get_configured_checks()
|
||||
if "octoprint" in checks:
|
||||
data["octoprint_checkout_folder"] = self._get_octoprint_checkout_folder(checks=checks)
|
||||
data["octoprint_tracked_branch"] = self._get_octoprint_tracked_branch(checks=checks)
|
||||
data["octoprint_pip_target"] = self._get_octoprint_pip_target(checks=checks)
|
||||
data["octoprint_type"] = checks["octoprint"].get("type", None)
|
||||
|
||||
try:
|
||||
@@ -339,6 +343,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
data["octoprint_type"] = None
|
||||
data["octoprint_branch_mappings"] = []
|
||||
|
||||
data["pip_enable_check"] = "pip" in checks
|
||||
|
||||
return data
|
||||
|
||||
def on_settings_save(self, data):
|
||||
@@ -364,6 +370,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
)
|
||||
|
||||
updated_octoprint_check_config = False
|
||||
update_pip_check_config = False
|
||||
|
||||
if "octoprint_checkout_folder" in data:
|
||||
self._settings.set(["checks", "octoprint", "checkout_folder"], data["octoprint_checkout_folder"], defaults=defaults, force=True)
|
||||
@@ -379,11 +386,24 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._settings.set(["checks", "octoprint", "method"], "pip", defaults=defaults)
|
||||
updated_octoprint_check_config = True
|
||||
|
||||
elif octoprint_type == "github_commit":
|
||||
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
|
||||
self._settings.set(["checks", "octoprint", "method"], "pip", defaults=defaults)
|
||||
updated_octoprint_check_config = True
|
||||
|
||||
elif octoprint_type == "git_commit":
|
||||
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
|
||||
self._settings.set(["checks", "octoprint", "method"], "update_script", defaults=defaults)
|
||||
updated_octoprint_check_config = True
|
||||
|
||||
if "octoprint_tracked_branch" in data:
|
||||
self._settings.set(["checks", "octoprint", "branch"], data["octoprint_tracked_branch"], defaults=defaults, force=True)
|
||||
updated_octoprint_check_config = True
|
||||
|
||||
if "octoprint_pip_target" in data:
|
||||
self._settings.set(["checks", "octoprint", "pip"], data["octoprint_pip_target"], defaults=defaults)
|
||||
updated_octoprint_check_config = True
|
||||
|
||||
if "octoprint_release_channel" in data:
|
||||
prerelease_branches = self._settings.get(["checks", "octoprint", "prerelease_branches"])
|
||||
if prerelease_branches and data["octoprint_release_channel"] in [x["branch"] for x in prerelease_branches]:
|
||||
@@ -395,6 +415,18 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._settings.set(["checks", "octoprint", "prerelease_channel"], None, defaults=defaults, force=True)
|
||||
updated_octoprint_check_config = True
|
||||
|
||||
if "pip_enable_check" in data:
|
||||
checks = self._settings.get(["checks"], merged=True)
|
||||
if data["pip_enable_check"] in octoprint.settings.valid_boolean_trues:
|
||||
checks["pip"] = dict(type="pypi_release",
|
||||
package="pip",
|
||||
pip="pip=={target_version}")
|
||||
elif "pip" in checks:
|
||||
del checks["pip"]
|
||||
self._settings.set(["checks"], checks, force=True)
|
||||
self._settings.save()
|
||||
update_pip_check_config = True
|
||||
|
||||
if updated_octoprint_check_config:
|
||||
self._refresh_configured_checks = True
|
||||
try:
|
||||
@@ -403,8 +435,16 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
pass
|
||||
self._version_cache_dirty = True
|
||||
|
||||
if update_pip_check_config:
|
||||
self._refresh_configured_checks = True
|
||||
try:
|
||||
del self._version_cache["pip"]
|
||||
except KeyError:
|
||||
pass
|
||||
self._version_cache_dirty = True
|
||||
|
||||
def get_settings_version(self):
|
||||
return 6
|
||||
return 7
|
||||
|
||||
def on_settings_migrate(self, target, current=None):
|
||||
|
||||
@@ -489,6 +529,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
dummy_defaults["plugins"][self._identifier]["checks"]["octoprint"] = None
|
||||
self._settings.set(["checks", "octoprint"], None, defaults=dummy_defaults)
|
||||
|
||||
if current is None or current < 7:
|
||||
# remove check_providers again
|
||||
self._settings.set(["check_providers"], None, defaults=dict(check_providers=dict()))
|
||||
|
||||
def _clean_settings_check(self, key, data, defaults, delete=None, save=True):
|
||||
if not data:
|
||||
# nothing to do
|
||||
@@ -591,6 +635,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_SOFTWAREUPDATE_UPDATE.require(403)
|
||||
def perform_update(self):
|
||||
throttled = self._get_throttled()
|
||||
if throttled and isinstance(throttled, dict) and throttled.get("current_issue", False) and not self._settings.get_boolean(["ignore_throttled"]):
|
||||
# currently throttled, we refuse to run
|
||||
return flask.make_response("System is currently throttled, refusing to update "
|
||||
"anything due to possible stability issues", 409)
|
||||
|
||||
if self._printer.is_printing() or self._printer.is_paused():
|
||||
# do not update while a print job is running
|
||||
return flask.make_response("Printer is currently printing or paused", 409)
|
||||
@@ -871,6 +921,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
to_be_updated.remove("octoprint")
|
||||
tmp = ["octoprint"] + to_be_updated
|
||||
to_be_updated = tmp
|
||||
if "pip" in to_be_updated:
|
||||
to_be_updated.remove("pip")
|
||||
tmp = ["pip"] + to_be_updated
|
||||
to_be_updated = tmp
|
||||
|
||||
updater_thread = threading.Thread(target=self._update_worker, args=(populated_checks, to_be_updated, force))
|
||||
updater_thread.daemon = False
|
||||
@@ -1063,25 +1117,28 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
raise exceptions.RestartFailed()
|
||||
|
||||
def _populated_check(self, target, check):
|
||||
from flask_babel import gettext
|
||||
|
||||
if not "type" in check:
|
||||
raise exceptions.UnknownCheckType()
|
||||
|
||||
result = dict(check)
|
||||
|
||||
if target == "octoprint":
|
||||
from flask_babel import gettext
|
||||
|
||||
from octoprint.util.version import is_released_octoprint_version, is_stable_octoprint_version
|
||||
|
||||
result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
|
||||
if result["displayName"] is None:
|
||||
displayName = check.get("displayName")
|
||||
if displayName is None:
|
||||
# displayName missing or set to None
|
||||
result["displayName"] = to_unicode(gettext("OctoPrint"), errors="replace")
|
||||
displayName = gettext("OctoPrint")
|
||||
result["displayName"] = to_unicode(displayName, errors="replace")
|
||||
|
||||
result["displayVersion"] = to_unicode(check.get("displayVersion"), errors="replace")
|
||||
if result["displayVersion"] is None:
|
||||
displayVersion = check.get("displayVersion")
|
||||
if displayVersion is None:
|
||||
# displayVersion missing or set to None
|
||||
result["displayVersion"] = "{octoprint_version}"
|
||||
displayVersion = "{octoprint_version}"
|
||||
result["displayVersion"] = to_unicode(displayVersion, errors="replace")
|
||||
|
||||
stable_branch = "master"
|
||||
release_branches = []
|
||||
@@ -1126,6 +1183,23 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
# we force python unequality check for pip installs, to be able to downgrade
|
||||
result["release_compare"] = "python_unequal"
|
||||
|
||||
elif target == "pip":
|
||||
import pkg_resources
|
||||
|
||||
displayName = check.get("displayName")
|
||||
if displayName is None:
|
||||
# displayName missing or set to None
|
||||
displayName = gettext("pip")
|
||||
result["displayName"] = to_unicode(displayName, errors="replace")
|
||||
|
||||
displayVersion = check.get("displayVersion")
|
||||
if displayVersion is None:
|
||||
# displayVersion missing or set to None
|
||||
distribution = pkg_resources.get_distribution("pip")
|
||||
if distribution:
|
||||
displayVersion = distribution.version
|
||||
result["displayVersion"] = to_unicode(displayVersion, errors="replace")
|
||||
|
||||
else:
|
||||
result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
|
||||
if result["displayName"] is None:
|
||||
@@ -1230,6 +1304,24 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
return None
|
||||
|
||||
def _get_octoprint_tracked_branch(self, checks=None):
|
||||
if checks is None:
|
||||
checks = self._get_configured_checks()
|
||||
|
||||
if not "octoprint" in checks:
|
||||
return None
|
||||
|
||||
return checks["octoprint"].get("branch")
|
||||
|
||||
def _get_octoprint_pip_target(self, checks=None):
|
||||
if checks is None:
|
||||
checks = self._get_configured_checks()
|
||||
|
||||
if not "octoprint" in checks:
|
||||
return None
|
||||
|
||||
return checks["octoprint"].get("pip")
|
||||
|
||||
|
||||
def _register_custom_events(*args, **kwargs):
|
||||
return ["update_succeeded", "update_failed"]
|
||||
|
||||
@@ -1 +1 @@
|
||||
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;height:500px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_information .line{display:block}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:700}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:700;color:#666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#900}#settings_plugin_softwareupdate_workingdialog_output .call{color:#009}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:700;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;max-height:500px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_information .line{display:block}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:700}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:700;color:#666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#900}#settings_plugin_softwareupdate_workingdialog_output .call{color:#009}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:700;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
@@ -6,6 +6,11 @@ $(function() {
|
||||
self.printerState = parameters[1];
|
||||
self.settings = parameters[2];
|
||||
self.access = parameters[3];
|
||||
|
||||
// optional
|
||||
|
||||
self.piSupport = parameters[4]; // might be null!
|
||||
|
||||
self.popup = undefined;
|
||||
|
||||
self.updateInProgress = false;
|
||||
@@ -25,7 +30,8 @@ $(function() {
|
||||
self.octoprintReleasedVersion = ko.observable();
|
||||
|
||||
self.octoprintUnconfigured = ko.pureComputed(function() {
|
||||
return self.error_checkoutFolder();
|
||||
return self.settings.settings.plugins.softwareupdate.octoprint_type() === "git_commit"
|
||||
&& self.error_checkoutFolder();
|
||||
});
|
||||
self.octoprintUnreleased = ko.pureComputed(function() {
|
||||
return self.settings.settings.plugins.softwareupdate.octoprint_type() === "github_release"
|
||||
@@ -42,9 +48,12 @@ $(function() {
|
||||
|
||||
self.config_cacheTtl = ko.observable();
|
||||
self.config_notifyUsers = ko.observable();
|
||||
self.config_trackedBranch = ko.observable();
|
||||
self.config_checkoutFolder = ko.observable();
|
||||
self.config_pipTarget = ko.observable();
|
||||
self.config_checkType = ko.observable();
|
||||
self.config_releaseChannel = ko.observable();
|
||||
self.config_pipEnableCheck = ko.observable();
|
||||
|
||||
self.error_checkoutFolder = ko.pureComputed(function() {
|
||||
return self.config_checkType() === "git_commit"
|
||||
@@ -52,11 +61,12 @@ $(function() {
|
||||
});
|
||||
|
||||
self.enableUpdate = ko.pureComputed(function() {
|
||||
return !self.updateInProgress && self.environmentSupported();
|
||||
return !self.updateInProgress && self.environmentSupported() && !self.printerState.isPrinting() && !self.throttled();
|
||||
});
|
||||
|
||||
self.enable_configSave = ko.pureComputed(function() {
|
||||
return self.config_checkType() === "github_release"
|
||||
|| self.config_checkType() === "github_commit"
|
||||
|| (self.config_checkType() === "git_commit" && !self.error_checkoutFolder());
|
||||
});
|
||||
|
||||
@@ -92,6 +102,10 @@ $(function() {
|
||||
return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible; });
|
||||
});
|
||||
|
||||
self.throttled = ko.pureComputed(function() {
|
||||
return self.piSupport && self.piSupport.currentIssue() && !self.settings.settings.plugins.pluginmanager.ignore_throttled();
|
||||
});
|
||||
|
||||
self.onUserPermissionsChanged = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
if (self.loginState.hasPermission(self.access.permissions.PLUGIN_SOFTWAREUPDATE_CHECK)) {
|
||||
self.performCheck();
|
||||
@@ -149,7 +163,10 @@ $(function() {
|
||||
notify_users: self.config_notifyUsers(),
|
||||
octoprint_type: self.config_checkType(),
|
||||
octoprint_release_channel: self.config_releaseChannel(),
|
||||
octoprint_checkout_folder: self.config_checkoutFolder()
|
||||
octoprint_checkout_folder: self.config_checkoutFolder(),
|
||||
octoprint_tracked_branch: self.config_trackedBranch(),
|
||||
octoprint_pip_target: self.config_pipTarget(),
|
||||
pip_enable_check: self.config_pipEnableCheck()
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -168,7 +185,8 @@ $(function() {
|
||||
|
||||
self._copyConfig = function() {
|
||||
var availableCheckTypes = [{"key": "github_release", "name": gettext("Release")},
|
||||
{"key": "git_commit", "name": gettext("Commit")}];
|
||||
{"key": "github_commit", "name": gettext("Github Commit")},
|
||||
{"key": "git_commit", "name": gettext("Local checkout")}];
|
||||
self.config_availableCheckTypes(availableCheckTypes);
|
||||
|
||||
var availableReleaseChannels = [];
|
||||
@@ -183,6 +201,10 @@ $(function() {
|
||||
self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type());
|
||||
self.config_releaseChannel(self.settings.settings.plugins.softwareupdate.octoprint_release_channel());
|
||||
self.config_checkoutFolder(self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder());
|
||||
self.config_trackedBranch(self.settings.settings.plugins.softwareupdate.octoprint_tracked_branch());
|
||||
self.config_pipTarget(self.settings.settings.plugins.softwareupdate.octoprint_pip_target());
|
||||
|
||||
self.config_pipEnableCheck(self.settings.settings.plugins.softwareupdate.pip_enable_check());
|
||||
};
|
||||
|
||||
self._copyConfigBack = function() {
|
||||
@@ -208,11 +230,11 @@ $(function() {
|
||||
}
|
||||
|
||||
var fullNameTemplate = gettext("%(name)s: %(version)s");
|
||||
value.fullNameLocal = _.sprintf(fullNameTemplate, {name: value.displayName, version: value.displayVersion});
|
||||
value.fullNameLocal = _.sprintf(fullNameTemplate, {name: _.escape(value.displayName), version: _.escape(value.displayVersion)});
|
||||
|
||||
var fullNameRemoteVars = {name: value.displayName, version: gettext("unknown")};
|
||||
var fullNameRemoteVars = {name: _.escape(value.displayName), version: gettext("unknown")};
|
||||
if (value.hasOwnProperty("information") && value.information.hasOwnProperty("remote") && value.information.remote.hasOwnProperty("name")) {
|
||||
fullNameRemoteVars.version = value.information.remote.name;
|
||||
fullNameRemoteVars.version = _.escape(value.information.remote.name);
|
||||
}
|
||||
value.fullNameRemote = _.sprintf(fullNameTemplate, fullNameRemoteVars);
|
||||
|
||||
@@ -476,36 +498,46 @@ $(function() {
|
||||
type: "error"
|
||||
});
|
||||
self._updateClicked = false;
|
||||
} else {
|
||||
var html = "<p>" + gettext("This will update the following components and restart the server:") + "</p>";
|
||||
html += "<ul>";
|
||||
_.each(items, function(item) {
|
||||
html += "<li>"
|
||||
+ "<span class=\"name\" title=\"" + item.fullNameRemote + "\">" + item.fullNameRemote + "</span>";
|
||||
if (item.releaseNotes) {
|
||||
html += "<br><a href=\"" + item.releaseNotes + "\" target=\"_blank\" rel=\"noreferrer noopener\">" + gettext("Release Notes") + "</a>"
|
||||
}
|
||||
html += "</li>";
|
||||
});
|
||||
html += "</ul>";
|
||||
html += "<p>" + gettext("Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know <strong>before</strong> upgrading.") + "</p>"
|
||||
+ "<p><strong>" + gettext("This action may disrupt any ongoing print jobs.") + "</strong></p>"
|
||||
+ "<p>" + gettext("Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset.") + "</p>"
|
||||
+ "<p>" + gettext("Are you sure you want to proceed?") + "</p>";
|
||||
showConfirmationDialog({
|
||||
title: gettext("Are you sure you want to update now?"),
|
||||
html: html,
|
||||
proceed: gettext("Proceed"),
|
||||
onproceed: function() {
|
||||
self.performUpdate((force === true),
|
||||
_.map(items, function(info) { return info.key }));
|
||||
},
|
||||
onclose: function() {
|
||||
self._updateClicked = false;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.throttled()) {
|
||||
self._showPopup({
|
||||
title: gettext("Can't update while throttled"),
|
||||
text: gettext("Your system is currently throttled. OctoPrint refuses to run updates while in this state due to possible stability issues."),
|
||||
type: "error"
|
||||
});
|
||||
self._updateClicked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var html = "<p>" + gettext("This will update the following components and restart the server:") + "</p>";
|
||||
html += "<ul>";
|
||||
_.each(items, function(item) {
|
||||
html += "<li>"
|
||||
+ "<span class=\"name\" title=\"" + item.fullNameRemote + "\">" + item.fullNameRemote + "</span>";
|
||||
if (item.releaseNotes) {
|
||||
html += "<br><a href=\"" + item.releaseNotes + "\" target=\"_blank\" rel=\"noreferrer noopener\">" + gettext("Release Notes") + "</a>"
|
||||
}
|
||||
html += "</li>";
|
||||
});
|
||||
html += "</ul>";
|
||||
html += "<p>" + gettext("Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know <strong>before</strong> upgrading.") + "</p>"
|
||||
+ "<p><strong>" + gettext("This action may disrupt any ongoing print jobs.") + "</strong></p>"
|
||||
+ "<p>" + gettext("Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset.") + "</p>"
|
||||
+ "<p>" + gettext("Are you sure you want to proceed?") + "</p>";
|
||||
showConfirmationDialog({
|
||||
title: gettext("Are you sure you want to update now?"),
|
||||
html: html,
|
||||
proceed: gettext("Proceed"),
|
||||
onproceed: function() {
|
||||
self.performUpdate((force === true),
|
||||
_.map(items, function(info) { return info.key }));
|
||||
},
|
||||
onclose: function() {
|
||||
self._updateClicked = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self._showWorkingDialog = function(title) {
|
||||
@@ -627,7 +659,7 @@ $(function() {
|
||||
break;
|
||||
}
|
||||
case "updating": {
|
||||
text = _.sprintf(gettext("Now updating %(name)s to %(version)s"), {name: messageData.name, version: messageData.version});
|
||||
text = _.sprintf(gettext("Now updating %(name)s to %(version)s"), {name: _.escape(messageData.name), version: _.escape(messageData.version)});
|
||||
self.loglines.push({line: "", stream: "separator"});
|
||||
self.loglines.push({line: _.repeat("+", text.length), stream: "separator"});
|
||||
self.loglines.push({line: text, stream: "message"});
|
||||
@@ -781,7 +813,8 @@ $(function() {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: SoftwareUpdateViewModel,
|
||||
dependencies: ["loginStateViewModel", "printerStateViewModel", "settingsViewModel", "accessViewModel"],
|
||||
dependencies: ["loginStateViewModel", "printerStateViewModel", "settingsViewModel", "accessViewModel", "piSupportViewModel"],
|
||||
optional: ["piSupportViewModel"],
|
||||
elements: ["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"]
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
#settings_plugin_softwareupdate_updatelist {
|
||||
display: block;
|
||||
width: auto;
|
||||
height: 500px;
|
||||
max-height: 500px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 2px;
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: config_pipEnableCheck"> {{ _('Enable <code>pip</code> update checks') }}
|
||||
<span class="help-block">{{ _('If you check this, OctoPrint will also notify you of updates of the <code>pip</code> tool used by OctoPrint to install plugins and updates and allow you to update it through OctoPrint. <code>pip</code> is outside of the control of the OctoPrint maintainer, so enable at your own risk.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<div class="control-group" data-bind="visible: config_checkType() === 'github_release' || config_checkType() === 'github_commit'">
|
||||
<label class="control-label">{{ _('OctoPrint <code>pip</code> target') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_pipTarget">
|
||||
<span class="help-block">{{ _('You should normally not have to change this.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<div class="control-group" data-bind="visible: config_checkType() === 'github_commit'">
|
||||
<label class="control-label">{{ _('Tracked branch') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: config_trackedBranch" placeholder="master">
|
||||
</div>
|
||||
</div>
|
||||
@@ -12,7 +12,7 @@
|
||||
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>.
|
||||
<a href="http://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html" target="_blank">Documentation</a>.
|
||||
</p>
|
||||
{% endtrans %}</div>
|
||||
<div class="alert" data-bind="visible: !environmentSupported()">{% trans %}
|
||||
@@ -32,9 +32,29 @@
|
||||
Please take a look at <a href="https://faq.octoprint.org/unsupported-python-environment" target="_blank">this FAQ entry on how to proceed</a>.
|
||||
</p>
|
||||
{% endtrans %}</div>
|
||||
<div class="alert" data-bind="visible: throttled()">{% trans %}
|
||||
<p>
|
||||
<strong>OctoPrint is running on a throttled system, updates are disabled.</strong>
|
||||
</p>
|
||||
<p>
|
||||
To reduce the likelihood of running into update problems on throttled and hence potentially unstable systems
|
||||
as seen in the past, OctoPrint doesn't support updating under such conditions. Please fix the current issue
|
||||
before trying to update. Take a look at the displayed warning in the navigation bar to learn about what is
|
||||
wrong and to get hints on how to solve the problem.
|
||||
</p>
|
||||
{% endtrans %}</div>
|
||||
<div class="alert" data-bind="visible: printerState.isPrinting()">{% trans %}
|
||||
<p>
|
||||
<strong>OctoPrint is currently printing, updates are disabled.</strong>
|
||||
</p>
|
||||
<p>
|
||||
Running updates is not supported while printing in order to not risk any kind of disruption to the print job.
|
||||
Please let the print finish before trying to update.
|
||||
</p>
|
||||
{% endtrans %}</div>
|
||||
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fa fa-wrench"></i></button>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Current versions') }}</h3>
|
||||
@@ -44,10 +64,10 @@
|
||||
<tbody data-bind="foreach: versions.paginatedItems">
|
||||
<tr data-bind="attr: {title: displayName}">
|
||||
<td class="settings_plugin_softwareupdate_column_update">
|
||||
<span data-bind="invisible: !updateAvailable"><i class="fa fa-bell-o" title="{{ _('Update available') }}"></i></span>
|
||||
<span data-bind="invisible: !updateAvailable"><i class="fa fa-bell-o" title="{{ _('Update available')|edq }}"></i></span>
|
||||
</td>
|
||||
<td class="settings_plugin_softwareupdate_column_information">
|
||||
<a href="javascript:void(0)" data-bind="click: function() { $root.update(false, [$data]) }, visible: updateAvailable && updatePossible" class="btn btn-primary pull-right">{{ _('Update') }}</a>
|
||||
<a href="javascript:void(0)" data-bind="click: function() { $root.update(false, [$data]) }, visible: $root.enableUpdate() && updateAvailable && updatePossible" class="btn btn-primary pull-right">{{ _('Update') }}</a>
|
||||
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="fa fa-exclamation-triangle" data-bind="css: {'fa-unlink': !online && information && information.needs_online, 'fa-exclamation-triangle': !(!online && information && information.needs_online)}, attr: {title: $root.iconTitleForEntry($data)}"></i></span><br>
|
||||
<small class="muted">
|
||||
<span class="line">{{ _('Installed:') }} <span data-bind="text: information.local.name"></span></span>
|
||||
@@ -69,7 +89,7 @@
|
||||
<div class="hide">
|
||||
<small class="muted" style="display: block">{{ _('Last cache refresh:') }} <span data-bind="text: cacheTimestampText"></span></small>
|
||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
||||
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.update(true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update now (even if no new versions are available)') }}</button>
|
||||
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.update(true); }, enable: enableUpdate() && !checking(), css: {disabled: !enableUpdate() || checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update now (even if no new versions are available)') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -81,8 +101,11 @@
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
{% include "snippets/plugins/softwareupdate/versionTracking.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/trackedBranch.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/releaseChannel.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/pipTarget.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/pipEnableCheck.jinja2" %}
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Version cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
<h3>{{ _('Software Update') }}</h3>
|
||||
|
||||
{% trans %}<p>
|
||||
By default, OctoPrint will update itself via <code>pip</code> to published releases. OctoPrint can
|
||||
also update itself via <code>git</code> to arbitrary development branches you need to check out manually.
|
||||
By default, OctoPrint will update itself via <code>pip</code> to published releases or commits pushed
|
||||
to Github. OctoPrint can also update itself via <code>git</code> to arbitrary development branches you need to check out manually.
|
||||
If you want to do that though it needs to know its checkout folder. You can configure that here.
|
||||
</p>{% endtrans %}
|
||||
|
||||
<form class="form-horizontal">
|
||||
{% include "snippets/plugins/softwareupdate/versionTracking.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/checkoutFolder.jinja2" %}
|
||||
{% include "snippets/plugins/softwareupdate/trackedBranch.jinja2" %}
|
||||
</form>
|
||||
|
||||
{% trans %}<p>
|
||||
If you are running a release version of OctoPrint, leave at "Release" tracking. If you are running a different
|
||||
branch however, you should setup "Commit" tracking.
|
||||
branch however on a manual checkout, you should setup "Local Checkout" tracking. For more special cases you might
|
||||
want to select "Github Commit" tracking - you normally shouldn't need to however.
|
||||
</p>{% endtrans %}
|
||||
@@ -87,7 +87,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc
|
||||
|
||||
logger.debug("Target: %s, executing pip install %s" % (target, install_arg))
|
||||
pip_args = ["--disable-pip-version-check", "install", install_arg, "--no-cache-dir"]
|
||||
pip_kwargs = dict(env=dict(PYTHONWARNINGS="ignore:DEPRECATION::pip._internal.cli.base_command"))
|
||||
pip_kwargs = dict(env=dict(PYTHONWARNINGS=b"ignore:DEPRECATION::pip._internal.cli.base_command"))
|
||||
if pip_working_directory is not None:
|
||||
pip_kwargs.update(cwd=pip_working_directory)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker, never_current, always_current
|
||||
from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker, never_current, always_current, pypi_release
|
||||
|
||||
def log_github_ratelimit(logger, r):
|
||||
ratelimit = r.headers["X-RateLimit-Limit"] if "X-RateLimit-Limit" in r.headers else "?"
|
||||
|
||||
@@ -9,6 +9,9 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
import requests
|
||||
import logging
|
||||
|
||||
from octoprint.util import sv
|
||||
from octoprint.util.version import get_comparable_version
|
||||
|
||||
RELEASE_URL = "https://api.github.com/repos/{user}/{repo}/releases"
|
||||
|
||||
logger = logging.getLogger("octoprint.plugins.softwareupdate.version_checks.github_release")
|
||||
@@ -69,7 +72,7 @@ def _filter_out_latest(releases,
|
||||
nothing = None, None, None
|
||||
|
||||
if sort_key is None:
|
||||
sort_key = lambda release: release.get("published_at", None)
|
||||
sort_key = lambda release: sv(release.get("published_at", None))
|
||||
|
||||
# filter out prereleases and drafts
|
||||
filter_function = lambda rel: not rel["prerelease"] and not rel["draft"]
|
||||
@@ -117,7 +120,7 @@ def _get_latest_release(user, repo, compare_type,
|
||||
# sanitize
|
||||
required_fields = {"name", "tag_name", "html_url", "draft", "prerelease", "published_at", "target_commitish"}
|
||||
releases = list(filter(lambda rel: set(rel.keys()) & required_fields == required_fields,
|
||||
releases))
|
||||
releases))
|
||||
|
||||
comparable_factory = _get_comparable_factory(compare_type,
|
||||
force_base=force_base)
|
||||
@@ -166,26 +169,6 @@ def _get_base_from_version_tuple(version_tuple):
|
||||
return tuple(base_version)
|
||||
|
||||
|
||||
def _get_comparable_version_pkg_resources(version_string, force_base=True):
|
||||
import pkg_resources
|
||||
|
||||
version = pkg_resources.parse_version(version_string)
|
||||
|
||||
# A leading v is common in github release tags and old setuptools doesn't remove it.
|
||||
if version and isinstance(version, tuple) and version[0].lower() == "*v":
|
||||
version = version[1:]
|
||||
|
||||
if force_base:
|
||||
if isinstance(version, tuple):
|
||||
# old setuptools
|
||||
version = _get_base_from_version_tuple(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
|
||||
|
||||
@@ -208,7 +191,7 @@ def _get_sanitized_compare_type(compare_type, custom=None):
|
||||
|
||||
def _get_comparable_factory(compare_type, force_base=True):
|
||||
if compare_type in ("python", "python_unequal"):
|
||||
return lambda version: _get_comparable_version_pkg_resources(version, force_base=force_base)
|
||||
return lambda version: get_comparable_version(version, base=force_base)
|
||||
elif compare_type in ("semantic", "semantic_unequal"):
|
||||
return lambda version: _get_comparable_version_semantic(version, force_base=force_base)
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import logging
|
||||
import pkg_resources
|
||||
import requests
|
||||
|
||||
from octoprint.util import to_native_str
|
||||
from octoprint.util.version import is_python_compatible, get_comparable_version, is_prerelease
|
||||
|
||||
INFO_URL = "https://pypi.org/pypi/{package}/json"
|
||||
|
||||
logger = logging.getLogger("octoprint.plugins.softwareupdate.version_checks.pypi_release")
|
||||
|
||||
def _filter_out_latest(releases, include_prerelease=False, python_version=None):
|
||||
"""
|
||||
Filters out the newest of all matching releases.
|
||||
|
||||
Tests:
|
||||
|
||||
>>> requires_py2 = ">=2.7.9,<3"
|
||||
>>> requires_py23 = ">=2.7.9, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
|
||||
>>> requires_py3 = ">=3.6, <4"
|
||||
>>> releases = {"1.3.12": [dict(requires_python=requires_py2, upload_time_iso_8601="2019-10-22T10:06:03.190293Z")], "1.4.0rc1": [dict(requires_python=requires_py23, upload_time_iso_8601="2019-11-22T10:06:03.190293Z")], "2.0.0rc1": [dict(requires_python=requires_py3, upload_time_iso_8601="2020-10-22T10:06:03.190293Z")]}
|
||||
>>> to_native_str(_filter_out_latest(releases, python_version="2.7.9"))
|
||||
'1.3.12'
|
||||
>>> to_native_str(_filter_out_latest(releases, include_prerelease=True, python_version="2.7.9"))
|
||||
'1.4.0rc1'
|
||||
>>> to_native_str(_filter_out_latest(releases, include_prerelease=True, python_version="3.6.0"))
|
||||
'2.0.0rc1'
|
||||
>>> to_native_str(_filter_out_latest(releases, python_version="3.6.0"))
|
||||
"""
|
||||
releases = [dict(version=k, data=v[0]) for k, v in releases.items()]
|
||||
|
||||
# filter out prereleases and versions incompatible to our python
|
||||
filter_function = lambda release: not is_prerelease(release["version"]) and is_python_compatible(release["data"].get("requires_python", ""), python_version=python_version)
|
||||
if include_prerelease:
|
||||
filter_function = lambda release: is_python_compatible(release["data"].get("requires_python", ""), python_version=python_version)
|
||||
|
||||
releases = list(filter(filter_function, releases))
|
||||
if not releases:
|
||||
return None
|
||||
|
||||
# sort by upload date
|
||||
releases = sorted(releases, key=lambda release: release["data"].get("upload_time_iso_8601", ""))
|
||||
|
||||
# latest release = last in list
|
||||
latest = releases[-1]
|
||||
|
||||
return latest["version"]
|
||||
|
||||
def _get_latest_release(package, include_prerelease):
|
||||
from ..exceptions import NetworkError
|
||||
|
||||
try:
|
||||
r = requests.get(INFO_URL.format(package=package), timeout=(3.05, 30))
|
||||
except requests.ConnectionError as exc:
|
||||
raise NetworkError(cause=exc)
|
||||
|
||||
if not r.status_code == requests.codes.ok:
|
||||
return None
|
||||
|
||||
data = r.json()
|
||||
if not "info" in data or not "version" in data["info"]:
|
||||
return None
|
||||
|
||||
requires_python = data["info"].get("requires_python")
|
||||
if requires_python and not is_python_compatible(requires_python):
|
||||
return None
|
||||
|
||||
return _filter_out_latest(data["releases"],
|
||||
include_prerelease=include_prerelease)
|
||||
|
||||
def _is_current(release_information):
|
||||
if release_information["remote"]["value"] is None:
|
||||
return True
|
||||
|
||||
local_version = get_comparable_version(release_information["local"]["value"])
|
||||
remote_version = get_comparable_version(release_information["remote"]["value"])
|
||||
|
||||
return remote_version <= local_version
|
||||
|
||||
def get_latest(target, check, online=True):
|
||||
from ..exceptions import CannotUpdateOffline
|
||||
|
||||
if not online and not check.get("offline", False):
|
||||
raise CannotUpdateOffline()
|
||||
|
||||
package = check.get("package")
|
||||
|
||||
distribution = pkg_resources.get_distribution(package)
|
||||
if distribution:
|
||||
local_version = distribution.version
|
||||
else:
|
||||
local_version = None
|
||||
|
||||
remote_version = _get_latest_release(package,
|
||||
include_prerelease=check.get("prerelease", False))
|
||||
|
||||
information = dict(local=dict(name=local_version, value=local_version),
|
||||
remote=dict(name=remote_version, value=remote_version))
|
||||
|
||||
logger.debug("Target: {}, local: {}, remote: {}".format(target, information["local"]["name"], information["remote"]["name"]))
|
||||
|
||||
return information, _is_current(information)
|
||||
@@ -44,6 +44,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._printer_connection_parameters = None
|
||||
self._url = None
|
||||
self._ping_worker = None
|
||||
self._pong_worker = None
|
||||
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
self._record_next_firmware_info = False
|
||||
@@ -60,14 +61,17 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
unique_id=None,
|
||||
server=TRACKING_URL,
|
||||
ping=15*60,
|
||||
events=dict(startup=True,
|
||||
pong=24*60*60,
|
||||
events=dict(pong=True,
|
||||
startup=True,
|
||||
printjob=True,
|
||||
commerror=True,
|
||||
plugin=True,
|
||||
update=True,
|
||||
printer=True,
|
||||
printer_safety_check=True,
|
||||
throttled=True))
|
||||
throttled=True,
|
||||
slicing=True))
|
||||
|
||||
def get_settings_restricted_paths(self):
|
||||
return dict(admin=[["enabled"], ["unique_id"], ["events"]],
|
||||
@@ -121,6 +125,9 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
self._record_next_firmware_info = False
|
||||
self._track_printer_event(event, payload)
|
||||
|
||||
elif event in (Events.SLICING_STARTED,):
|
||||
self._track_slicing_event(event, payload)
|
||||
|
||||
elif hasattr(Events, "PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN") and \
|
||||
event in (Events.PLUGIN_PLUGINMANAGER_INSTALL_PLUGIN, Events.PLUGIN_PLUGINMANAGER_UNINSTALL_PLUGIN,
|
||||
Events.PLUGIN_PLUGINMANAGER_ENABLE_PLUGIN, Events.PLUGIN_PLUGINMANAGER_DISABLE_PLUGIN):
|
||||
@@ -168,11 +175,17 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
return
|
||||
|
||||
if self._ping_worker is None:
|
||||
ping = self._settings.get_int(["ping"])
|
||||
if ping:
|
||||
self._ping_worker = RepeatedTimer(ping, self._track_ping, run_first=True)
|
||||
ping_interval = self._settings.get_int(["ping"])
|
||||
if ping_interval:
|
||||
self._ping_worker = RepeatedTimer(ping_interval, self._track_ping, run_first=True)
|
||||
self._ping_worker.start()
|
||||
|
||||
if self._pong_worker is None:
|
||||
pong_interval = self._settings.get(["pong"])
|
||||
if pong_interval:
|
||||
self._pong_worker = RepeatedTimer(pong_interval, self._track_pong, run_first=True)
|
||||
self._pong_worker.start()
|
||||
|
||||
if self._helpers_get_throttle_state is None:
|
||||
# cautiously look for the get_throttled helper from pi_support
|
||||
pi_helper = self._plugin_manager.get_helpers("pi_support", "get_throttled")
|
||||
@@ -189,6 +202,18 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
uptime = int(monotonic_time() - self._startup_time)
|
||||
self._track("ping", octoprint_uptime=uptime)
|
||||
|
||||
def _track_pong(self):
|
||||
if not self._settings.get_boolean(["events", "pong"]):
|
||||
return
|
||||
|
||||
plugins = self._plugin_manager.enabled_plugins
|
||||
plugins_thirdparty = [plugin for plugin in plugins.values() if not plugin.bundled]
|
||||
payload = dict(plugins=",".join(map(lambda x: "{}:{}".format(x.key.lower(),
|
||||
x.version.lower() if x.version else "?"),
|
||||
plugins_thirdparty)))
|
||||
|
||||
self._track("pong", body=True, **payload)
|
||||
|
||||
def _track_startup(self):
|
||||
if not self._settings.get_boolean(["events", "startup"]):
|
||||
return
|
||||
@@ -305,7 +330,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
elapsed = int(payload.get("time", 0))
|
||||
if elapsed:
|
||||
args["elapsed"] = elapsed
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
track_event = "print_done"
|
||||
elif event == Events.PRINT_FAILED:
|
||||
@@ -313,7 +338,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
elapsed = int(payload.get("time", 0))
|
||||
if elapsed:
|
||||
args["elapsed"] = elapsed
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
args["reason"] = payload.get("reason", "unknown")
|
||||
|
||||
@@ -326,7 +351,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
elapsed = int(payload.get("time", 0))
|
||||
if elapsed:
|
||||
args["elapsed"] = elapsed
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
track_event = "print_cancelled"
|
||||
|
||||
@@ -363,13 +388,20 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
printer_safety_warning_type=payload.get("warning_type", "unknown"),
|
||||
printer_safety_check_name=payload.get("check_name", "unknown"))
|
||||
|
||||
def _track_slicing_event(self, event, payload):
|
||||
if not self._settings.get_boolean(["events", "slicing"]):
|
||||
return
|
||||
|
||||
self._track("slicing_started",
|
||||
slicer=payload.get(b"slicer", "unknown"))
|
||||
|
||||
def _track(self, event, **kwargs):
|
||||
if not self._settings.get_boolean(["enabled"]):
|
||||
return
|
||||
|
||||
self._executor.submit(self._do_track, event, **kwargs)
|
||||
|
||||
def _do_track(self, event, **kwargs):
|
||||
def _do_track(self, event, body=False, **kwargs):
|
||||
if not self._connectivity_checker.online:
|
||||
return
|
||||
|
||||
@@ -389,10 +421,17 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
try:
|
||||
params = urlencode(kwargs, doseq=True).replace("+", "%20")
|
||||
|
||||
requests.get(url,
|
||||
params=params,
|
||||
timeout=3.1,
|
||||
headers=headers)
|
||||
if body:
|
||||
requests.post(url,
|
||||
data=params,
|
||||
timeout=3.1,
|
||||
headers=headers)
|
||||
else:
|
||||
requests.get(url,
|
||||
params=params,
|
||||
timeout=3.1,
|
||||
headers=headers)
|
||||
|
||||
self._logger.info("Sent tracking event {}, payload: {!r}".format(event, kwargs))
|
||||
except Exception:
|
||||
if self._logger.isEnabledFor(logging.DEBUG):
|
||||
|
||||
@@ -11,16 +11,19 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" title="{{ _('Random unique instance ID') }}">{{ _('Instance ID') }}</label>
|
||||
<label class="control-label" title="{{ _('Random unique instance ID')|edq }}">{{ _('Instance ID') }}</label>
|
||||
<div class="controls">
|
||||
<span style="padding-top: 5px; margin-bottom: 5px; display: inline-block" data-bind="text: settings.plugins.tracking.unique_id() || 'N/A'"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" title="{{ _('Events to track. The ping is mandatory.') }}">{{ _('Tracked events') }}</label>
|
||||
<label class="control-label" title="{{ _('Events to track. The ping is mandatory.')|edq }}">{{ _('Tracked events') }}</label>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" checked="checked" disabled="disabled"> {{ _('Regular ping') }}
|
||||
<input type="checkbox" checked="checked" disabled="disabled"> {{ _('Regular ping every 15min (incl. uptime)') }}
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.pong"> {{ _('Regular pong every 24h (incl. plugin list)') }}
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.startup"> {{ _('Server startup & shutdown') }}
|
||||
@@ -46,6 +49,9 @@
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.throttled"> {{ _('System got throttled/unthrottled (currently only detected on RPis)') }}
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.events.slicing"> {{ _('Onboard slicing actions') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -146,7 +146,7 @@ class VirtualPrinter(object):
|
||||
self._temperature_reporter = None
|
||||
self._sdstatus_reporter = None
|
||||
|
||||
self.currentLine = 0
|
||||
self.current_line = 0
|
||||
self.lastN = 0
|
||||
|
||||
self._incoming_lock = threading.RLock()
|
||||
@@ -155,6 +155,7 @@ class VirtualPrinter(object):
|
||||
self._debug_sleep = 0
|
||||
self._sleepAfterNext = dict()
|
||||
self._sleepAfter = dict()
|
||||
self._rerequest_last = False
|
||||
|
||||
self._dont_answer = False
|
||||
|
||||
@@ -213,7 +214,7 @@ class VirtualPrinter(object):
|
||||
|
||||
self._heatingUp = False
|
||||
|
||||
self.currentLine = 0
|
||||
self.current_line = 0
|
||||
self.lastN = 0
|
||||
|
||||
self._debug_awol = False
|
||||
@@ -322,10 +323,10 @@ class VirtualPrinter(object):
|
||||
checksum = int(data[data.rfind(b"*") + 1:])
|
||||
data = data[:data.rfind(b"*")]
|
||||
if not checksum == self._calculate_checksum(data):
|
||||
self._triggerResend(expected=self.currentLine + 1)
|
||||
self._triggerResend(expected=self.current_line + 1)
|
||||
continue
|
||||
|
||||
self.currentLine += 1
|
||||
self.current_line += 1
|
||||
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
|
||||
self._send(self._error("checksum_missing"))
|
||||
continue
|
||||
@@ -334,7 +335,7 @@ class VirtualPrinter(object):
|
||||
if data.startswith(b"N") and b"M110" in data:
|
||||
linenumber = int(re.search(b"N([0-9]+)", data).group(1))
|
||||
self.lastN = linenumber
|
||||
self.currentLine = linenumber
|
||||
self.current_line = linenumber
|
||||
|
||||
self._triggerResendAt100 = True
|
||||
self._triggerResendWithTimeoutAt105 = True
|
||||
@@ -376,6 +377,9 @@ class VirtualPrinter(object):
|
||||
elif isinstance(prepared, basestring):
|
||||
self._send(prepared)
|
||||
continue
|
||||
elif self._rerequest_last:
|
||||
self._triggerResend(actual=linenumber)
|
||||
continue
|
||||
else:
|
||||
self.lastN = linenumber
|
||||
data = data.split(None, 1)[1].strip()
|
||||
@@ -546,9 +550,9 @@ class VirtualPrinter(object):
|
||||
if self._sdCardReady:
|
||||
self._reportSdStatus()
|
||||
|
||||
match = re.search(r"S([0-9]+)", data)
|
||||
if match:
|
||||
interval = int(match.group(1))
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS:
|
||||
interval = int(matchS.group(1))
|
||||
if self._sdstatus_reporter is not None:
|
||||
self._sdstatus_reporter.cancel()
|
||||
|
||||
@@ -580,9 +584,11 @@ class VirtualPrinter(object):
|
||||
|
||||
def _gcode_M113(self, data):
|
||||
# type: (str) -> None
|
||||
interval = int(re.search(r"S([0-9]+)", data).group(1))
|
||||
if 0 <= interval <= 60:
|
||||
self._busyInterval = interval
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
interval = int(matchS.group(1))
|
||||
if 0 <= interval <= 60:
|
||||
self._busyInterval = interval
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def _gcode_M114(self, data):
|
||||
@@ -625,23 +631,29 @@ class VirtualPrinter(object):
|
||||
|
||||
def _gcode_M155(self, data):
|
||||
# type: (str) -> None
|
||||
interval = int(re.search(r"S([0-9]+)", data).group(1))
|
||||
if self._temperature_reporter is not None:
|
||||
self._temperature_reporter.cancel()
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
interval = int(matchS.group(1))
|
||||
if self._temperature_reporter is not None:
|
||||
self._temperature_reporter.cancel()
|
||||
|
||||
if interval > 0:
|
||||
self._temperature_reporter = RepeatedTimer(interval, lambda: self._send(self._generateTemperatureOutput()))
|
||||
self._temperature_reporter.start()
|
||||
else:
|
||||
self._temperature_reporter = None
|
||||
if interval > 0:
|
||||
self._temperature_reporter = RepeatedTimer(interval, lambda: self._send(self._generateTemperatureOutput()))
|
||||
self._temperature_reporter.start()
|
||||
else:
|
||||
self._temperature_reporter = None
|
||||
|
||||
def _gcode_M220(self, data):
|
||||
# type: (str) -> None
|
||||
self._feedrate_multiplier = float(re.search(r'S([0-9]+)', data).group(1))
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
self._feedrate_multiplier = float(matchS.group(1))
|
||||
|
||||
def _gcode_M221(self, data):
|
||||
# type: (str) -> None
|
||||
self._flowrate_multiplier = float(re.search(r'S([0-9]+)', data).group(1))
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
self._flowrate_multiplier = float(matchS.group(1))
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def _gcode_M400(self, data):
|
||||
@@ -825,6 +837,8 @@ class VirtualPrinter(object):
|
||||
prepare_ok <broken ok>
|
||||
| Will cause <broken ok> to be enqueued for use,
|
||||
| will be used instead of actual "ok"
|
||||
rerequest_last
|
||||
| Will cause the last line number + 1 to be rerequest add infinitum
|
||||
|
||||
# Reply Timing / Sleeping
|
||||
|
||||
@@ -886,6 +900,9 @@ class VirtualPrinter(object):
|
||||
elif data == "go_awol":
|
||||
self._send("// Going AWOL")
|
||||
self._debug_awol = True
|
||||
elif data == "rerequest_last":
|
||||
self._send("// Entering rerequest loop")
|
||||
self._rerequest_last = True
|
||||
elif data == "cancel_sd":
|
||||
if self._sdPrinting and self._sdPrinter:
|
||||
self._pauseSdPrint()
|
||||
|
||||
@@ -69,7 +69,7 @@ class PrintTimeEstimator(object):
|
||||
but no intelligent estimate yet, we'll use that for the next step. Otherwise, up to a certain percentage
|
||||
in the print we do a percentage based weighing of the statistical data and the intelligent
|
||||
estimate - the closer to the beginning of the print, the more precedence for the statistical
|
||||
data, the closer to the cut off point, the more precendence for the intelligent estimate. This
|
||||
data, the closer to the cut off point, the more precedence for the intelligent estimate. This
|
||||
is our preliminary total print time.
|
||||
3. If the total print time is set, we do a sanity check for it. Based on the total print time
|
||||
estimate and the time we already spent printing, we calculate at what percentage we SHOULD be
|
||||
|
||||
@@ -320,14 +320,21 @@ class PrinterProfileManager(object):
|
||||
except InvalidProfileError:
|
||||
return None
|
||||
|
||||
def remove(self, identifier):
|
||||
def remove(self, identifier, trigger_event=False):
|
||||
if self._current is not None and self._current["id"] == identifier:
|
||||
return False
|
||||
elif settings().get(["printerProfiles", "default"]) == identifier:
|
||||
return False
|
||||
return self._remove_from_path(self._get_profile_path(identifier))
|
||||
|
||||
def save(self, profile, allow_overwrite=False, make_default=False):
|
||||
removed = self._remove_from_path(self._get_profile_path(identifier))
|
||||
if removed and trigger_event:
|
||||
from octoprint.events import eventManager, Events
|
||||
payload = dict(identifier=identifier)
|
||||
eventManager().fire(Events.PRINTER_PROFILE_DELETED, payload=payload)
|
||||
|
||||
return removed
|
||||
|
||||
def save(self, profile, allow_overwrite=False, make_default=False, trigger_event=False):
|
||||
if "id" in profile:
|
||||
identifier = profile["id"]
|
||||
elif "name" in profile:
|
||||
@@ -342,7 +349,10 @@ class PrinterProfileManager(object):
|
||||
profile = dict_sanitize(profile, self.__class__.default)
|
||||
profile = dict_merge(self.__class__.default, profile)
|
||||
|
||||
self._save_to_path(self._get_profile_path(identifier), profile, allow_overwrite=allow_overwrite)
|
||||
path = self._get_profile_path(identifier)
|
||||
is_overwrite = os.path.exists(path)
|
||||
|
||||
self._save_to_path(path, profile, allow_overwrite=allow_overwrite)
|
||||
|
||||
if make_default:
|
||||
settings().set(["printerProfiles", "default"], identifier)
|
||||
@@ -350,6 +360,13 @@ class PrinterProfileManager(object):
|
||||
|
||||
if self._current is not None and self._current["id"] == identifier:
|
||||
self.select(identifier)
|
||||
|
||||
from octoprint.events import eventManager, Events
|
||||
if trigger_event:
|
||||
payload = dict(identifier=identifier)
|
||||
event = Events.PRINTER_PROFILE_MODIFIED if is_overwrite else Events.PRINTER_PROFILE_ADDED
|
||||
eventManager().fire(event, payload=payload)
|
||||
|
||||
return self.get(identifier)
|
||||
|
||||
def is_default_unmodified(self):
|
||||
|
||||
@@ -30,6 +30,7 @@ from octoprint.util import comm as comm
|
||||
from octoprint.util import InvariantContainer
|
||||
from octoprint.util import to_unicode
|
||||
from octoprint.util import monotonic_time
|
||||
from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
|
||||
|
||||
class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
@@ -179,28 +180,32 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
try:
|
||||
callback.on_printer_add_temperature(data)
|
||||
except Exception:
|
||||
self._logger.exception("Exception while adding temperature data point to callback {}".format(callback))
|
||||
self._logger.exception("Exception while adding temperature data point to callback {}".format(callback),
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
|
||||
def _sendAddLogCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try:
|
||||
callback.on_printer_add_log(data)
|
||||
except Exception:
|
||||
self._logger.exception("Exception while adding communication log entry to callback {}".format(callback))
|
||||
self._logger.exception("Exception while adding communication log entry to callback {}".format(callback),
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
|
||||
def _sendAddMessageCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try:
|
||||
callback.on_printer_add_message(data)
|
||||
except Exception:
|
||||
self._logger.exception("Exception while adding printer message to callback {}".format(callback))
|
||||
self._logger.exception("Exception while adding printer message to callback {}".format(callback),
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
|
||||
def _sendCurrentDataCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try:
|
||||
callback.on_printer_send_current_data(copy.deepcopy(data))
|
||||
except Exception:
|
||||
self._logger.exception("Exception while pushing current data to callback {}".format(callback))
|
||||
self._logger.exception("Exception while pushing current data to callback {}".format(callback),
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
|
||||
#~~ callback from metadata analysis event
|
||||
|
||||
@@ -488,14 +493,18 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
path_on_disk = self._fileManager.path_on_disk(origin, path)
|
||||
path_in_storage = self._fileManager.path_in_storage(origin, path_on_disk)
|
||||
|
||||
recovery_data = self._fileManager.get_recovery_data()
|
||||
if recovery_data:
|
||||
# clean up recovery data if we just selected a different file than is logged in that
|
||||
actual_origin = recovery_data.get("origin", None)
|
||||
actual_path = recovery_data.get("path", None)
|
||||
try:
|
||||
recovery_data = self._fileManager.get_recovery_data()
|
||||
if recovery_data:
|
||||
# clean up recovery data if we just selected a different file
|
||||
actual_origin = recovery_data.get("origin", None)
|
||||
actual_path = recovery_data.get("path", None)
|
||||
|
||||
if actual_origin is None or actual_path is None or actual_origin != origin or actual_path != path_in_storage:
|
||||
self._fileManager.delete_recovery_data()
|
||||
if actual_origin is None or actual_path is None or actual_origin != origin or actual_path != path_in_storage:
|
||||
self._fileManager.delete_recovery_data()
|
||||
except Exception:
|
||||
# anything goes wrong with the recovery data, we ignore it
|
||||
self._logger.exception("Something was wrong with processing the recovery data")
|
||||
|
||||
self._printAfterSelect = printAfterSelect
|
||||
self._posAfterSelect = pos
|
||||
@@ -1008,7 +1017,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._stateMonitor.set_job_data(self._dict(file=job_data["file"],
|
||||
estimatedPrintTime=job_data["estimatedPrintTime"],
|
||||
averagePrintTime=job_data["averagePrintTime"],
|
||||
lastPrintTIme=job_data["lastPrintTime"],
|
||||
lastPrintTime=job_data["lastPrintTime"],
|
||||
filament=job_data["filament"],
|
||||
user=user))
|
||||
|
||||
@@ -1022,7 +1031,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
})
|
||||
callback.on_printer_send_initial_data(data)
|
||||
except Exception:
|
||||
self._logger.exception("Error while trying to send initial state update")
|
||||
self._logger.exception(u"Error while pushing initial state update to callback {}".format(callback),
|
||||
extra=dict(callback=fqcn(callback)))
|
||||
|
||||
def _getStateFlags(self):
|
||||
return self._dict(operational=self.is_operational(),
|
||||
@@ -1089,7 +1099,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._analysisQueue.resume() # printing done, put those cpu cycles to good use
|
||||
|
||||
elif state == comm.MachineCom.STATE_PRINTING:
|
||||
self._analysisQueue.pause() # do not analyse files while printing
|
||||
if settings().get(["gcodeAnalysis", "runAt"]) == "idle":
|
||||
self._analysisQueue.pause() # only analyse files while idle
|
||||
|
||||
if state == comm.MachineCom.STATE_CLOSED or state == comm.MachineCom.STATE_CLOSED_WITH_ERROR:
|
||||
if self._comm is not None:
|
||||
@@ -1371,11 +1382,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
result= dict(name=name,
|
||||
path=path,
|
||||
origin=origin,
|
||||
size=print_job_size,
|
||||
|
||||
# TODO deprecated, remove in 1.4.0
|
||||
file=full_path,
|
||||
filename=name)
|
||||
size=print_job_size)
|
||||
|
||||
if position is not None:
|
||||
result["position"] = position
|
||||
|
||||
@@ -281,7 +281,11 @@ class Server(object):
|
||||
# monkey patch some stuff
|
||||
util.tornado.fix_json_encode()
|
||||
util.flask.fix_flask_jsonify()
|
||||
util.flask.enable_additional_translations(additional_folders=[self._settings.getBaseFolder("translations")])
|
||||
|
||||
additional_translation_folders = []
|
||||
if not safe_mode:
|
||||
additional_translation_folders += [self._settings.getBaseFolder("translations")]
|
||||
util.flask.enable_additional_translations(additional_folders=additional_translation_folders)
|
||||
|
||||
# setup app
|
||||
self._setup_app(app)
|
||||
@@ -302,7 +306,7 @@ class Server(object):
|
||||
### open port and prevent us from firing up Tornado later.
|
||||
###
|
||||
### The intermediary server's socket should have the CLOSE_EXEC flag (or its equivalent) set where possible, but
|
||||
### we can only do that if fcntl is availabel or we are on Windows, so better safe than sorry.
|
||||
### we can only do that if fcntl is available or we are on Windows, so better safe than sorry.
|
||||
###
|
||||
### See also issues #2035 and #2090
|
||||
|
||||
@@ -592,7 +596,9 @@ class Server(object):
|
||||
|
||||
self._router = SockJSRouter(self._create_socket_connection, "/sockjs",
|
||||
session_kls=util.sockjs.ThreadSafeSession,
|
||||
user_settings=dict(websocket_allow_origin="*" if enable_cors else ""))
|
||||
user_settings=dict(websocket_allow_origin="*" if enable_cors else "",
|
||||
jsessionid=False,
|
||||
sockjs_url="../../static/js/lib/sockjs.min.js"))
|
||||
|
||||
upload_suffixes = dict(name=self._settings.get(["server", "uploads", "nameSuffix"]), path=self._settings.get(["server", "uploads", "pathSuffix"]))
|
||||
|
||||
@@ -660,7 +666,7 @@ class Server(object):
|
||||
(r"/downloads/files/local/(.*)", util.tornado.LargeResponseHandler, joined_dict(dict(path=self._settings.getBaseFolder("uploads"),
|
||||
as_attachment=True,
|
||||
name_generator=download_name_generator),
|
||||
download_permission_validator,
|
||||
download_permission_validator,
|
||||
download_handler_kwargs,
|
||||
no_hidden_files_validator,
|
||||
additional_mime_types)),
|
||||
@@ -709,7 +715,11 @@ class Server(object):
|
||||
self._logger.debug("Adding additional route {route} handled by handler {handler} and with additional arguments {kwargs!r}".format(**locals()))
|
||||
server_routes.append((route, handler, kwargs))
|
||||
|
||||
headers = {"X-Robots-Tag": "noindex, nofollow, noimageindex"}
|
||||
headers = {"X-Robots-Tag": "noindex, nofollow, noimageindex",
|
||||
"X-Content-Type-Options": "nosniff"}
|
||||
if not settings().getBoolean(["server", "allowFraming"]):
|
||||
headers["X-Frame-Options"] = "sameorigin"
|
||||
|
||||
removed_headers = ["Server"]
|
||||
|
||||
server_routes.append((r".*", util.tornado.UploadStorageFallbackHandler, dict(fallback=util.tornado.WsgiInputContainer(app.wsgi_app,
|
||||
@@ -788,12 +798,16 @@ class Server(object):
|
||||
|
||||
# auto connect
|
||||
if self._settings.getBoolean(["serial", "autoconnect"]):
|
||||
self._logger.info("Autoconnect on startup is configured, trying to connect to the printer...")
|
||||
try:
|
||||
(port, baudrate) = self._settings.get(["serial", "port"]), self._settings.getInt(["serial", "baudrate"])
|
||||
printer_profile = printerProfileManager.get_default()
|
||||
connectionOptions = printer.__class__.get_connection_options()
|
||||
if port in connectionOptions["ports"] or port == "AUTO":
|
||||
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||
if port in connectionOptions["ports"] or port == "AUTO" or port is None:
|
||||
self._logger.info("Trying to connect to configured serial port {}".format(port))
|
||||
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||
else:
|
||||
self._logger.info("Could not find configured serial port {} in the system, cannot automatically connect to a non existing printer. Is it plugged in and booted up yet?")
|
||||
except Exception:
|
||||
self._logger.exception("Something went wrong while attempting to automatically connect to the printer")
|
||||
|
||||
@@ -1093,10 +1107,20 @@ class Server(object):
|
||||
return "<{tag}>{content}</a>".format(tag=tag, content=content)
|
||||
return html_link_regex.sub(repl, text)
|
||||
|
||||
single_quote_regex = re.compile("(?<!\\\\)'")
|
||||
def escape_single_quote(text):
|
||||
return single_quote_regex.sub("\\'", text)
|
||||
|
||||
double_quote_regex = re.compile('(?<!\\\\)"')
|
||||
def escape_double_quote(text):
|
||||
return double_quote_regex.sub('\\"', text)
|
||||
|
||||
app.jinja_env.filters["regex_replace"] = regex_replace
|
||||
app.jinja_env.filters["offset_html_headers"] = offset_html_headers
|
||||
app.jinja_env.filters["offset_markdown_headers"] = offset_markdown_headers
|
||||
app.jinja_env.filters["externalize_links"] = externalize_links
|
||||
app.jinja_env.filters["escape_single_quote"] = app.jinja_env.filters["esq"] = escape_single_quote
|
||||
app.jinja_env.filters["escape_double_quote"] = app.jinja_env.filters["edq"] = escape_double_quote
|
||||
|
||||
# configure additional template folders for jinja2
|
||||
import jinja2
|
||||
@@ -1107,10 +1131,12 @@ class Server(object):
|
||||
|
||||
loaders = [app.jinja_loader, filesystem_loader]
|
||||
if octoprint.util.is_running_from_source():
|
||||
from markdown import markdown
|
||||
|
||||
root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../.."))
|
||||
allowed = ["AUTHORS.md", "CHANGELOG.md", "SUPPORTERS.md", "THIRDPARTYLICENSES.md"]
|
||||
files = {"_data/" + name: os.path.join(root, name) for name in allowed}
|
||||
loaders.append(octoprint.util.jinja.SelectedFilesLoader(files))
|
||||
allowed = ["AUTHORS.md", "SUPPORTERS.md", "THIRDPARTYLICENSES.md"]
|
||||
files = {"_data/" + name + ".html": os.path.join(root, name) for name in allowed}
|
||||
loaders.append(octoprint.util.jinja.SelectedFilesWithConversionLoader(files, conversion=markdown))
|
||||
|
||||
jinja_loader = jinja2.ChoiceLoader(loaders)
|
||||
app.jinja_loader = jinja_loader
|
||||
|
||||
@@ -21,6 +21,7 @@ from octoprint.settings import settings as s, valid_boolean_trues
|
||||
from octoprint.server.util import noCachingExceptGetResponseHandler, loginFromApiKeyRequestHandler, loginFromAuthorizationHeaderRequestHandler, corsRequestHandler, corsResponseHandler
|
||||
from octoprint.server.util.flask import no_firstrun_access, get_json_command_from_request, passive_login, get_remote_address
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.events import eventManager, Events
|
||||
|
||||
|
||||
#~~ init api blueprint, including sub modules
|
||||
@@ -107,7 +108,7 @@ def pluginCommand(name):
|
||||
return response
|
||||
return NO_CONTENT
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception("Error while excuting SimpleApiPlugin {}".format(name),
|
||||
logging.getLogger(__name__).exception("Error while executing SimpleApiPlugin {}".format(name),
|
||||
extra=dict(plugin=name))
|
||||
return abort(500)
|
||||
|
||||
@@ -242,9 +243,12 @@ def login():
|
||||
|
||||
r = make_response(jsonify(response))
|
||||
r.delete_cookie("active_logout")
|
||||
|
||||
eventManager().fire(Events.USER_LOGGED_IN, payload=dict(username=user.get_id()))
|
||||
|
||||
return r
|
||||
|
||||
return make_response(("User unknown or password incorrect", 401, []))
|
||||
return make_response(("User unknown or password incorrect", 403, []))
|
||||
|
||||
elif "passive" in data:
|
||||
return passive_login()
|
||||
@@ -254,6 +258,10 @@ def login():
|
||||
|
||||
@api.route("/logout", methods=["POST"])
|
||||
def logout():
|
||||
username = None
|
||||
if current_user:
|
||||
username = current_user.get_id()
|
||||
|
||||
# logout from user manager...
|
||||
_logout(current_user)
|
||||
|
||||
@@ -261,9 +269,12 @@ def logout():
|
||||
logout_user()
|
||||
|
||||
# ... and send an active logout session cookie
|
||||
r = make_response(jsonify(octoprint.access.users.AnonymousUser([octoprint.server.groupManager.guest_group])))
|
||||
r = make_response(jsonify(octoprint.server.userManager.anonymous_user_factory()))
|
||||
r.set_cookie("active_logout", "true")
|
||||
|
||||
if username:
|
||||
eventManager().fire(Events.USER_LOGGED_OUT, payload=dict(username=username))
|
||||
|
||||
return r
|
||||
|
||||
|
||||
@@ -468,7 +479,17 @@ def _test_url(data):
|
||||
response_result = dict(headers=dict(response.headers),
|
||||
content_type=content_type)
|
||||
|
||||
if not content_type and data.get("content_type_guess") in valid_boolean_trues:
|
||||
content = response.content
|
||||
content_type = util.guess_mime_type(bytearray(content))
|
||||
|
||||
if not content_type:
|
||||
content_type = "application/octet-stream"
|
||||
|
||||
response_result = dict(assumed_content_type=content_type)
|
||||
|
||||
parsed_content_type = util.parse_mime_type(content_type)
|
||||
|
||||
in_whitelist = content_type_whitelist is None or any(
|
||||
map(lambda x: util.mime_type_matches(parsed_content_type, x), content_type_whitelist))
|
||||
in_blacklist = content_type_blacklist is not None and any(
|
||||
|
||||
@@ -20,6 +20,8 @@ import octoprint.filemanager.util
|
||||
import octoprint.filemanager.storage
|
||||
import octoprint.slicing
|
||||
|
||||
from octoprint.util import sv
|
||||
|
||||
import os
|
||||
import psutil
|
||||
import hashlib
|
||||
@@ -85,7 +87,7 @@ def _create_etag(path, filter, recursive, lm=None):
|
||||
|
||||
if path.endswith("/files") or path.endswith("/files/sdcard"):
|
||||
# include sd data in etag
|
||||
hash_update(repr(sorted(printer.get_sd_files(), key=lambda x: x[0])))
|
||||
hash_update(repr(sorted(printer.get_sd_files(), key=lambda x: sv(x[0]))))
|
||||
|
||||
hash_update(_DATA_FORMAT_VERSION) # increment version if we change the API format
|
||||
|
||||
@@ -390,10 +392,7 @@ def uploadGcodeFile(target):
|
||||
|
||||
eventManager.fire(Events.UPLOAD, {"name": futureFilename,
|
||||
"path": filename,
|
||||
"target": target,
|
||||
|
||||
# TODO deprecated, remove in 1.4.0
|
||||
"file": filename})
|
||||
"target": target})
|
||||
|
||||
files = {}
|
||||
location = url_for(".readGcodeFile", target=FileDestinations.LOCAL, filename=filename, _external=True)
|
||||
|
||||
@@ -91,6 +91,8 @@ def getInstalledLanguagePacks():
|
||||
else:
|
||||
try:
|
||||
core_packs.append(load_meta(entry.path, entry.name))
|
||||
except ValueError:
|
||||
logging.getLogger(__name__).exception("Core language pack {} doesn't appear to actually be one".format(entry.name))
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception("Error while parsing metadata for core language pack {} from {}".format(entry.name,
|
||||
entry.path))
|
||||
|
||||
@@ -507,17 +507,17 @@ def _get_temperature_data(preprocessor):
|
||||
|
||||
|
||||
def _keep_tools(x):
|
||||
return _delete_from_data(x, lambda k: not k.startswith("tool"))
|
||||
return _delete_from_data(x, lambda k: not k.startswith("tool") and k != "history")
|
||||
|
||||
|
||||
def _keep_bed(x):
|
||||
return _delete_from_data(x, lambda k: k != "bed")
|
||||
return _delete_from_data(x, lambda k: k != "bed" and k != "history")
|
||||
|
||||
def _delete_bed(x):
|
||||
return _delete_from_data(x, lambda k: k == "bed")
|
||||
|
||||
def _keep_chamber(x):
|
||||
return _delete_from_data(x, lambda k: k != "chamber")
|
||||
return _delete_from_data(x, lambda k: k != "chamber" and k != "history")
|
||||
|
||||
def _delete_chamber(x):
|
||||
return _delete_from_data(x, lambda k: k == "chamber")
|
||||
@@ -525,7 +525,9 @@ def _delete_chamber(x):
|
||||
|
||||
def _delete_from_data(x, key_matcher):
|
||||
data = dict(x)
|
||||
for k in data.keys():
|
||||
# must make list of keys first to avoid
|
||||
# RuntimeError: dictionary changed size during iteration
|
||||
for k in list(data.keys()):
|
||||
if key_matcher(k):
|
||||
del data[k]
|
||||
return data
|
||||
@@ -94,7 +94,8 @@ def printerProfilesAdd():
|
||||
return make_response("Profile does not contain mandatory 'name' field", 400)
|
||||
|
||||
try:
|
||||
saved_profile = printerProfileManager.save(profile, allow_overwrite=False, make_default=make_default)
|
||||
saved_profile = printerProfileManager.save(profile, allow_overwrite=False, make_default=make_default,
|
||||
trigger_event=True)
|
||||
except InvalidProfileError:
|
||||
return make_response("Profile is invalid", 400)
|
||||
except CouldNotOverwriteError:
|
||||
@@ -126,7 +127,7 @@ def printerProfilesDelete(identifier):
|
||||
if default_profile and default_profile["id"] == identifier:
|
||||
return make_response("Cannot delete default profile: {}".format(identifier), 409)
|
||||
|
||||
printerProfileManager.remove(identifier)
|
||||
printerProfileManager.remove(identifier, trigger_event=True)
|
||||
return NO_CONTENT
|
||||
|
||||
@api.route("/printerprofiles/<string:identifier>", methods=["PATCH"])
|
||||
@@ -162,7 +163,8 @@ def printerProfilesUpdate(identifier):
|
||||
merged_profile["id"] = identifier
|
||||
|
||||
try:
|
||||
saved_profile = printerProfileManager.save(merged_profile, allow_overwrite=True, make_default=make_default)
|
||||
saved_profile = printerProfileManager.save(merged_profile, allow_overwrite=True, make_default=make_default,
|
||||
trigger_event=True)
|
||||
except InvalidProfileError:
|
||||
return make_response("Profile is invalid", 400)
|
||||
except CouldNotOverwriteError:
|
||||
|
||||
@@ -96,7 +96,8 @@ def getSettings():
|
||||
"colorIcon": s.getBoolean(["appearance", "colorIcon"]),
|
||||
"defaultLanguage": s.get(["appearance", "defaultLanguage"]),
|
||||
"showFahrenheitAlso": s.getBoolean(["appearance", "showFahrenheitAlso"]),
|
||||
"fuzzyTimes": s.getBoolean(["appearance", "fuzzyTimes"])
|
||||
"fuzzyTimes": s.getBoolean(["appearance", "fuzzyTimes"]),
|
||||
"closeModalsWithClick": s.getBoolean(["appearance", "closeModalsWithClick"])
|
||||
},
|
||||
"printer": {
|
||||
"defaultExtrusionLength": s.getInt(["printerParameters", "defaultExtrusionLength"])
|
||||
@@ -128,10 +129,14 @@ def getSettings():
|
||||
"keyboardControl": s.getBoolean(["feature", "keyboardControl"]),
|
||||
"pollWatched": s.getBoolean(["feature", "pollWatched"]),
|
||||
"modelSizeDetection": s.getBoolean(["feature", "modelSizeDetection"]),
|
||||
"printStartConfirmation": s.getBoolean(["feature", "printStartConfirmation"]),
|
||||
"printCancelConfirmation": s.getBoolean(["feature", "printCancelConfirmation"]),
|
||||
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
|
||||
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"])
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"runAt": s.get(["gcodeAnalysis", "runAt"])
|
||||
},
|
||||
"serial": {
|
||||
"port": connectionOptions["portPreference"],
|
||||
"baudrate": connectionOptions["baudratePreference"],
|
||||
@@ -177,6 +182,9 @@ def getSettings():
|
||||
"ignoreIdenticalResends": s.getBoolean(["serial", "ignoreIdenticalResends"]),
|
||||
"firmwareDetection": s.getBoolean(["serial", "firmwareDetection"]),
|
||||
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
||||
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
|
||||
"sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]),
|
||||
"ackMax": s.getInt(["serial", "ackMax"]),
|
||||
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
|
||||
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
||||
@@ -237,7 +245,8 @@ def getSettings():
|
||||
"enabled": s.getBoolean(["server", "pluginBlacklist", "enabled"]),
|
||||
"url": s.get(["server", "pluginBlacklist", "url"]),
|
||||
"ttl": int(s.getInt(["server", "pluginBlacklist", "ttl"]) / 60)
|
||||
}
|
||||
},
|
||||
"allowFraming": s.getBoolean(["server", "allowFraming"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,6 +394,7 @@ def _saveSettings(data):
|
||||
if "defaultLanguage" in data["appearance"]: s.set(["appearance", "defaultLanguage"], data["appearance"]["defaultLanguage"])
|
||||
if "showFahrenheitAlso" in data["appearance"]: s.setBoolean(["appearance", "showFahrenheitAlso"], data["appearance"]["showFahrenheitAlso"])
|
||||
if "fuzzyTimes" in data["appearance"]: s.setBoolean(["appearance", "fuzzyTimes"], data["appearance"]["fuzzyTimes"])
|
||||
if "closeModalsWithClick" in data["appearance"]: s.setBoolean(["appearance", "closeModalsWithClick"], data["appearance"]["closeModalsWithClick"])
|
||||
|
||||
if "printer" in data:
|
||||
if "defaultExtrusionLength" in data["printer"]: s.setInt(["printerParameters", "defaultExtrusionLength"], data["printer"]["defaultExtrusionLength"])
|
||||
@@ -416,10 +426,14 @@ def _saveSettings(data):
|
||||
if "keyboardControl" in data["feature"]: s.setBoolean(["feature", "keyboardControl"], data["feature"]["keyboardControl"])
|
||||
if "pollWatched" in data["feature"]: s.setBoolean(["feature", "pollWatched"], data["feature"]["pollWatched"])
|
||||
if "modelSizeDetection" in data["feature"]: s.setBoolean(["feature", "modelSizeDetection"], data["feature"]["modelSizeDetection"])
|
||||
if "printStartConfirmation" in data["feature"]: s.setBoolean(["feature", "printStartConfirmation"], data["feature"]["printStartConfirmation"])
|
||||
if "printCancelConfirmation" in data["feature"]: s.setBoolean(["feature", "printCancelConfirmation"], data["feature"]["printCancelConfirmation"])
|
||||
if "g90InfluencesExtruder" in data["feature"]: s.setBoolean(["feature", "g90InfluencesExtruder"], data["feature"]["g90InfluencesExtruder"])
|
||||
if "autoUppercaseBlacklist" in data["feature"] and isinstance(data["feature"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["feature", "autoUppercaseBlacklist"], data["feature"]["autoUppercaseBlacklist"])
|
||||
|
||||
if "gcodeAnalysis" in data:
|
||||
if "runAt" in data["gcodeAnalysis"]: s.set(["gcodeAnalysis", "runAt"], data["gcodeAnalysis"]["runAt"])
|
||||
|
||||
if "serial" in data:
|
||||
if "autoconnect" in data["serial"]: s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"])
|
||||
if "port" in data["serial"]: s.set(["serial", "port"], data["serial"]["port"])
|
||||
@@ -462,6 +476,12 @@ def _saveSettings(data):
|
||||
if "ignoreIdenticalResends" in data["serial"]: s.setBoolean(["serial", "ignoreIdenticalResends"], data["serial"]["ignoreIdenticalResends"])
|
||||
if "firmwareDetection" in data["serial"]: s.setBoolean(["serial", "firmwareDetection"], data["serial"]["firmwareDetection"])
|
||||
if "blockWhileDwelling" in data["serial"]: s.setBoolean(["serial", "blockWhileDwelling"], data["serial"]["blockWhileDwelling"])
|
||||
if "useParityWorkaround" in data["serial"]:
|
||||
value = data["serial"]["useParityWorkaround"]
|
||||
if value in ("always", "detect", "never"):
|
||||
s.set(["serial", "useParityWorkaround"], value)
|
||||
if "sendM112OnError" in data["serial"]: s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"])
|
||||
if "ackMax" in data["serial"]: s.setInt(["serial", "ackMax"], data["serial"]["ackMax"])
|
||||
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
|
||||
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
|
||||
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
|
||||
@@ -546,6 +566,8 @@ def _saveSettings(data):
|
||||
s.setInt(["server", "pluginBlacklist", "ttl"], ttl * 60)
|
||||
except ValueError:
|
||||
pass
|
||||
if "allowFraming" in data["server"]:
|
||||
s.setBoolean(["server", "allowFraming"], data["server"]["allowFraming"])
|
||||
|
||||
if "plugins" in data:
|
||||
for plugin in octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SettingsPlugin):
|
||||
|
||||
@@ -35,6 +35,8 @@ from octoprint.util import DefaultOrderedDict
|
||||
from octoprint.util.json import JsonEncoding
|
||||
from octoprint.util.net import is_lan_address
|
||||
|
||||
from octoprint.events import eventManager, Events
|
||||
|
||||
from werkzeug.local import LocalProxy
|
||||
from cachelib import BaseCache
|
||||
|
||||
@@ -583,33 +585,41 @@ def passive_login():
|
||||
if hasattr(u, "session"):
|
||||
flask.session["usersession.id"] = u.session
|
||||
flask.g.user = u
|
||||
|
||||
eventManager().fire(Events.USER_LOGGED_IN, payload=dict(username=u.get_id()))
|
||||
|
||||
return u
|
||||
|
||||
if user is not None and user.is_active:
|
||||
# login known user
|
||||
logger.info("Passively logging in user {} from {}".format(user.get_id(), remote_address))
|
||||
user = login(user)
|
||||
def determine_user(u):
|
||||
if not u.is_anonymous and u.is_active:
|
||||
# known active user
|
||||
logger.info("Passively logging in user {} from {}".format(u.get_id(), remote_address))
|
||||
|
||||
elif settings().getBoolean(["accessControl", "autologinLocal"]) \
|
||||
and settings().get(["accessControl", "autologinAs"]) is not None \
|
||||
and settings().get(["accessControl", "localNetworks"]) is not None \
|
||||
and not "active_logout" in flask.request.cookies:
|
||||
elif settings().getBoolean(["accessControl", "autologinLocal"]) \
|
||||
and settings().get(["accessControl", "autologinAs"]) is not None \
|
||||
and settings().get(["accessControl", "localNetworks"]) is not None \
|
||||
and not "active_logout" in flask.request.cookies:
|
||||
# attempt local autologin
|
||||
autologin_as = settings().get(["accessControl", "autologinAs"])
|
||||
local_networks = _local_networks()
|
||||
logger.debug("Checking if remote address {} is in localNetworks ({!r})".format(remote_address, local_networks))
|
||||
|
||||
autologin_as = settings().get(["accessControl", "autologinAs"])
|
||||
local_networks = _local_networks()
|
||||
logger.debug("Checking if remote address {} is in localNetworks ({!r})".format(remote_address, local_networks))
|
||||
try:
|
||||
if netaddr.IPAddress(remote_address) in local_networks:
|
||||
autologin_user = octoprint.server.userManager.find_user(autologin_as)
|
||||
if autologin_user is not None and autologin_user.is_active:
|
||||
logger.info("Passively logging in user {} from {} via autologin".format(autologin_as, remote_address))
|
||||
return autologin_user
|
||||
except Exception:
|
||||
logger.exception("Could not autologin user {} from {} for networks {}".format(autologin_as, remote_address, local_networks))
|
||||
|
||||
try:
|
||||
if netaddr.IPAddress(remote_address) in local_networks:
|
||||
autologin_user = octoprint.server.userManager.findUser(autologin_as)
|
||||
if autologin_user is not None and autologin_user.is_active:
|
||||
autologin_user = octoprint.server.userManager.login_user(autologin_user)
|
||||
if not u.is_active:
|
||||
# inactive user, switch to anonymous
|
||||
u = octoprint.server.userManager.anonymous_user_factory()
|
||||
|
||||
logger.info("Passively logging in user {} from {} via autologin".format(user.get_id(), local_networks))
|
||||
user = login(autologin_user)
|
||||
except Exception:
|
||||
logger.exception("Could not autologin user {} for networks {}".format(autologin_as, local_networks))
|
||||
return u
|
||||
|
||||
user = login(determine_user(user))
|
||||
response = user.as_dict()
|
||||
response["_is_external_client"] = ip_check_enabled and not is_lan_address(remote_address,
|
||||
additional_private=ip_check_trusted)
|
||||
@@ -849,7 +859,7 @@ class PreemptiveCache(object):
|
||||
|
||||
with self._lock:
|
||||
all_data = self.get_all_data()
|
||||
for root, entries in all_data.items():
|
||||
for root, entries in list(all_data.items()):
|
||||
old_count = len(entries)
|
||||
entries = cleanup_function(root, entries)
|
||||
if not entries:
|
||||
@@ -1149,19 +1159,49 @@ def check_lastmodified(lastmodified):
|
||||
|
||||
|
||||
def add_revalidation_response_headers(response):
|
||||
response.headers["Cache-Control"] = "no-cache, must-revalidate"
|
||||
import werkzeug.http
|
||||
|
||||
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
|
||||
if "no-cache" not in cache_control:
|
||||
cache_control["no-cache"] = None
|
||||
if "must-revalidate" not in cache_control:
|
||||
cache_control["must-revalidate"] = None
|
||||
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def add_non_caching_response_headers(response):
|
||||
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0"
|
||||
import werkzeug.http
|
||||
|
||||
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
|
||||
if "no-store" not in cache_control:
|
||||
cache_control["no-store"] = None
|
||||
if "no-cache" not in cache_control:
|
||||
cache_control["no-cache"] = None
|
||||
if "must-revalidate" not in cache_control:
|
||||
cache_control["must-revalidate"] = None
|
||||
if "post-check" not in cache_control or cache_control["post-check"] != "0":
|
||||
cache_control["post-check"] = "0"
|
||||
if "pre-check" not in cache_control or cache_control["pre-check"] != "0":
|
||||
cache_control["pre-check"] = "0"
|
||||
if "max-age" not in cache_control or cache_control["max-age"] != "0":
|
||||
cache_control["max-age"] = "0"
|
||||
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
|
||||
|
||||
response.headers["Pragma"] = "no-cache"
|
||||
response.headers["Expires"] = "-1"
|
||||
return response
|
||||
|
||||
|
||||
def add_no_max_age_response_headers(response):
|
||||
response.headers["Cache-Control"] = "max-age=0"
|
||||
import werkzeug.http
|
||||
|
||||
cache_control = werkzeug.http.parse_dict_header(response.headers.get("Cache-Control", ""))
|
||||
if "max-age" not in cache_control or cache_control["max-age"] != "0":
|
||||
cache_control["max-age"] = "0"
|
||||
response.headers["Cache-Control"] = werkzeug.http.dump_header(cache_control)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@@ -1179,7 +1219,7 @@ def permission_validator(request, permission):
|
||||
"""
|
||||
|
||||
user = get_flask_user_from_request(request)
|
||||
if user is None or not user.is_authenticated or not user.has_permission(permission):
|
||||
if not user.has_permission(permission):
|
||||
raise tornado.web.HTTPError(403)
|
||||
|
||||
@deprecated("admin_validator is deprecated, please use new permission_validator", since="")
|
||||
@@ -1197,7 +1237,7 @@ def get_flask_user_from_request(request):
|
||||
user session if available.
|
||||
|
||||
:param request: flask request from which to retrieve the current user
|
||||
:return: the user or None if no user could be determined
|
||||
:return: the user (might be an anonymous user)
|
||||
"""
|
||||
import octoprint.server.util
|
||||
import flask_login
|
||||
@@ -1206,11 +1246,18 @@ def get_flask_user_from_request(request):
|
||||
|
||||
apikey = octoprint.server.util.get_api_key(request)
|
||||
if apikey is not None:
|
||||
# user from api key?
|
||||
user = octoprint.server.util.get_user_for_apikey(apikey)
|
||||
|
||||
if user is None:
|
||||
# user still None -> current session user
|
||||
user = flask_login.current_user
|
||||
|
||||
if user is None:
|
||||
# user still None -> anonymous
|
||||
from octoprint.server import userManager
|
||||
user = userManager.anonymous_user_factory()
|
||||
|
||||
return user
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +73,13 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection,
|
||||
LoginStatusListener,
|
||||
GroupChangeListener):
|
||||
|
||||
_event_permissions = {Events.USER_LOGGED_IN: [Permissions.ADMIN],
|
||||
Events.USER_LOGGED_OUT: [Permissions.ADMIN],
|
||||
"*": []}
|
||||
|
||||
_event_payload_processors = {Events.CLIENT_OPENED: [lambda user, payload: payload if user.has_permission(Permissions.ADMIN) else dict()],
|
||||
"*": []}
|
||||
|
||||
_emit_permissions = {"connected": [],
|
||||
"reauthRequired": [],
|
||||
"*": [Permissions.STATUS]}
|
||||
@@ -255,6 +262,15 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection,
|
||||
self._emit("history", payload=data_to_send)
|
||||
|
||||
def sendEvent(self, type, payload=None):
|
||||
permissions = self._event_permissions.get(type, self._event_permissions["*"])
|
||||
permissions = [x(self._user) if callable(x) else x for x in permissions]
|
||||
if not self._user or not all(map(lambda p: self._user.has_permission(p), permissions)):
|
||||
return
|
||||
|
||||
processors = self._event_payload_processors.get(type, self._event_payload_processors["*"])
|
||||
for processor in processors:
|
||||
payload = processor(self._user, payload)
|
||||
|
||||
self._emit("event", payload=dict(type=type, payload=payload))
|
||||
|
||||
def sendTimelapseConfig(self, timelapseConfig):
|
||||
@@ -358,8 +374,7 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection,
|
||||
# For now this is the easiest way though to at least inform the user that a timelapse is still ongoing.
|
||||
#
|
||||
# TODO remove when central job management becomes available and takes care of this for us
|
||||
self._emit("event", payload=dict(type=Events.MOVIE_RENDERING,
|
||||
payload=octoprint.timelapse.current_render_job))
|
||||
self.sendEvent(Events.MOVIE_RENDERING, payload=octoprint.timelapse.current_render_job)
|
||||
self._registered = True
|
||||
|
||||
def _unregister(self):
|
||||
@@ -393,6 +408,7 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection,
|
||||
|
||||
if permissions is None:
|
||||
permissions = self._emit_permissions.get(type, self._emit_permissions["*"])
|
||||
permissions = [x() if callable(x) else x for x in permissions]
|
||||
|
||||
if not self._user or not all(map(lambda p: self._user.has_permission(p), permissions)):
|
||||
return
|
||||
|
||||
@@ -74,7 +74,7 @@ class RequestlessExceptionLoggingMixin(tornado.web.RequestHandler):
|
||||
class CorsSupportMixin(tornado.web.RequestHandler):
|
||||
"""
|
||||
`tornado.web.RequestHandler <http://tornado.readthedocs.org/en/branch4.0/web.html#request-handlers>`_ mixin that
|
||||
makes sure to set CORS headers similarily to the Flask backed API endpoints.
|
||||
makes sure to set CORS headers similarly to the Flask backed API endpoints.
|
||||
"""
|
||||
|
||||
ENABLE_CORS = False
|
||||
@@ -460,6 +460,8 @@ class UploadStorageFallbackHandler(RequestlessExceptionLoggingMixin,
|
||||
|
||||
fields = dict((self._suffixes[key], value) for (key, value) in parameters.items())
|
||||
for n, p in fields.items():
|
||||
if n is None or p is None:
|
||||
continue
|
||||
key = name + b"." + octoprint.util.to_bytes(n)
|
||||
self._new_body += b"--%s\r\n" % self._multipart_boundary
|
||||
self._new_body += b"Content-Disposition: form-data; name=\"%s\"\r\n" % key
|
||||
|
||||
@@ -22,7 +22,7 @@ from octoprint.server import app, userManager, groupManager, pluginManager, gett
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.settings import settings
|
||||
from octoprint.filemanager import full_extension_tree, get_all_extensions
|
||||
from octoprint.util import to_unicode, to_bytes
|
||||
from octoprint.util import to_unicode, to_bytes, sv
|
||||
|
||||
import re
|
||||
import base64
|
||||
@@ -164,6 +164,8 @@ def in_cache():
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
from octoprint.server import printer
|
||||
|
||||
global _templates, _plugin_names, _plugin_vars
|
||||
|
||||
preemptive_cache_enabled = settings().getBoolean(["devel", "cache", "preemptive"])
|
||||
@@ -174,8 +176,18 @@ def index():
|
||||
def wizard_active(templates):
|
||||
return templates is not None and bool(templates["wizard"]["order"])
|
||||
|
||||
# we force a refresh if the client forces one or if we have wizards cached
|
||||
force_refresh = util.flask.cache_check_headers() or "_refresh" in request.values or wizard_active(_templates.get(locale))
|
||||
# we force a refresh if the client forces one and we are not printing or if we have wizards cached
|
||||
client_refresh = util.flask.cache_check_headers()
|
||||
request_refresh = "_refresh" in request.values
|
||||
printing = printer.is_printing()
|
||||
if client_refresh and printing:
|
||||
logging.getLogger(__name__).warn("Client requested cache refresh via cache-control headers but we are printing. "
|
||||
"Not invalidating caches due to resource limitation. Append ?_refresh=true to "
|
||||
"the URL if you absolutely require a refresh now")
|
||||
client_refresh = client_refresh and not printing
|
||||
force_refresh = client_refresh \
|
||||
or request_refresh \
|
||||
or wizard_active(_templates.get(locale))
|
||||
|
||||
# if we need to refresh our template cache or it's not yet set, process it
|
||||
fetch_template_data(refresh=force_refresh)
|
||||
@@ -185,6 +197,7 @@ def index():
|
||||
enable_accesscontrol = userManager.enabled
|
||||
enable_gcodeviewer = settings().getBoolean(["gcodeViewer", "enabled"])
|
||||
enable_timelapse = settings().getBoolean(["webcam", "timelapseEnabled"])
|
||||
enable_loading_animation = settings().getBoolean(["devel", "showLoadingAnimation"])
|
||||
|
||||
def default_template_filter(template_type, template_key):
|
||||
if template_type == "navbar":
|
||||
@@ -201,9 +214,11 @@ def index():
|
||||
|
||||
default_additional_etag = [enable_accesscontrol,
|
||||
enable_gcodeviewer,
|
||||
enable_timelapse] + sorted(["{}:{}".format(to_unicode(k, errors="replace"),
|
||||
to_unicode(v, errors="replace"))
|
||||
for k, v in _plugin_vars.items()])
|
||||
enable_timelapse,
|
||||
enable_loading_animation,
|
||||
wizard_active(_templates.get(locale))] + sorted(["{}:{}".format(to_unicode(k, errors="replace"),
|
||||
to_unicode(v, errors="replace"))
|
||||
for k, v in _plugin_vars.items()])
|
||||
|
||||
def get_preemptively_cached_view(key, view, data=None, additional_request_data=None, additional_unless=None):
|
||||
if (data is None and additional_request_data is None) or g.locale is None:
|
||||
@@ -367,6 +382,7 @@ def index():
|
||||
enableTemperatureGraph=settings().get(["feature", "temperatureGraph"]),
|
||||
enableAccessControl=enable_accesscontrol,
|
||||
accessControlActive=accesscontrol_active,
|
||||
enableLoadingAnimation=enable_loading_animation,
|
||||
enableSdSupport=settings().get(["feature", "sdSupport"]),
|
||||
gcodeMobileThreshold=settings().get(["gcodeViewer", "mobileSizeThreshold"]),
|
||||
gcodeThreshold=settings().get(["gcodeViewer", "sizeThreshold"]),
|
||||
@@ -639,7 +655,6 @@ def fetch_template_data(refresh=False):
|
||||
license=("OctoPrint License", dict(template="dialogs/about/license.jinja2", _div="about_license", custom_bindings=False)),
|
||||
thirdparty=("Third Party Licenses", dict(template="dialogs/about/thirdparty.jinja2", _div="about_thirdparty", custom_bindings=False)),
|
||||
authors=("Authors", dict(template="dialogs/about/authors.jinja2", _div="about_authors", custom_bindings=False)),
|
||||
changelog=("Changelog", dict(template="dialogs/about/changelog.jinja2", _div="about_changelog", custom_bindings=False)),
|
||||
supporters=("Supporters", dict(template="dialogs/about/supporters.jinja2", _div="about_sponsors", custom_bindings=False))
|
||||
)
|
||||
|
||||
@@ -749,14 +764,14 @@ def fetch_template_data(refresh=False):
|
||||
def key_func(x):
|
||||
config = templates[t]["entries"][x]
|
||||
entry_order = config_extractor(config, "order", default_value=None)
|
||||
return entry_order is None, entry_order, extractor(config, sort_key)
|
||||
return entry_order is None, sv(entry_order), sv(extractor(config, sort_key))
|
||||
|
||||
sorted_missing = sorted(missing_in_order, key=key_func)
|
||||
else:
|
||||
def key_func(x):
|
||||
config = templates[t]["entries"][x]
|
||||
entry_order = config_extractor(config, "order", default_value=None)
|
||||
return entry_order is None, entry_order
|
||||
return entry_order is None, sv(entry_order)
|
||||
|
||||
sorted_missing = sorted(missing_in_order, key=key_func)
|
||||
|
||||
|
||||
@@ -150,6 +150,10 @@ default_settings = {
|
||||
"supportFAsCommand": False,
|
||||
"firmwareDetection": True,
|
||||
"blockWhileDwelling": False,
|
||||
"useParityWorkaround": "detect",
|
||||
"maxConsecutiveResends": 10,
|
||||
"sendM112OnError": True,
|
||||
"ackMax": 1,
|
||||
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
@@ -217,7 +221,8 @@ default_settings = {
|
||||
"ipCheck": {
|
||||
"enabled": True,
|
||||
"trustedSubnets": []
|
||||
}
|
||||
},
|
||||
"allowFraming": False
|
||||
},
|
||||
"webcam": {
|
||||
"webcamEnabled": True,
|
||||
@@ -253,7 +258,8 @@ default_settings = {
|
||||
"maxExtruders": 10,
|
||||
"throttle_normalprio": 0.01,
|
||||
"throttle_highprio": 0.0,
|
||||
"throttle_lines": 100
|
||||
"throttle_lines": 100,
|
||||
"runAt": "idle" # 'never', 'idle', 'always'
|
||||
},
|
||||
"feature": {
|
||||
"temperatureGraph": True,
|
||||
@@ -261,6 +267,7 @@ default_settings = {
|
||||
"keyboardControl": True,
|
||||
"pollWatched": False,
|
||||
"modelSizeDetection": True,
|
||||
"printStartConfirmation": False,
|
||||
"printCancelConfirmation": True,
|
||||
"autoUppercaseBlacklist": ["M117", "M118"],
|
||||
"g90InfluencesExtruder": False
|
||||
@@ -304,6 +311,7 @@ default_settings = {
|
||||
"defaultLanguage": "_default",
|
||||
"showFahrenheitAlso": False,
|
||||
"fuzzyTimes": True,
|
||||
"closeModalsWithClick": True,
|
||||
"components": {
|
||||
"order": {
|
||||
"navbar": ["settings", "systemmenu", "plugin_announcements", "plugin_pi_support", "login"],
|
||||
@@ -404,6 +412,7 @@ default_settings = {
|
||||
"clean_on_startup": True
|
||||
},
|
||||
"useFrozenDictForPrinterState": True,
|
||||
"showLoadingAnimation": True,
|
||||
"virtualPrinter": {
|
||||
"enabled": False,
|
||||
"okAfterResend": False,
|
||||
@@ -1233,7 +1242,7 @@ class Settings(object):
|
||||
self._logger.info("Migrated {} action to server.commands.{}".format(action, migrate_to))
|
||||
|
||||
to_delete.append(index)
|
||||
self._logger.info("Deleting {} action from configured system commands, superseeded by server.commands.{}".format(action, migrate_to))
|
||||
self._logger.info("Deleting {} action from configured system commands, superseded by server.commands.{}".format(action, migrate_to))
|
||||
|
||||
for index in reversed(to_delete):
|
||||
actions.pop(index)
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
@@ -410,9 +410,9 @@ var doParse = function () {
|
||||
break;
|
||||
case 'g':
|
||||
if(args[j].charAt(1).toLowerCase() === '2')
|
||||
direction=1;
|
||||
if(args[j].charAt(1).toLowerCase() === '3')
|
||||
direction=-1;
|
||||
if(args[j].charAt(1).toLowerCase() === '3')
|
||||
direction=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,13 +73,13 @@ GCODE.gCodeReader = (function(){
|
||||
return tmpModel;
|
||||
};
|
||||
|
||||
var prepareLinesIndex = function(){
|
||||
var prepareLinesIndex = function(m){
|
||||
percentageTree = undefined;
|
||||
|
||||
for (var l = 0; l < model.length; l++) {
|
||||
if (model[l] === undefined) continue;
|
||||
for (var i = 0; i < model[l].length; i++) {
|
||||
var percentage = model[l][i].percentage;
|
||||
for (var l = 0; l < m.length; l++) {
|
||||
if (m[l] === undefined) continue;
|
||||
for (var i = 0; i < m[l].length; i++) {
|
||||
var percentage = m[l][i].percentage;
|
||||
var value = {layer: l, cmd: i};
|
||||
if (!percentageTree) {
|
||||
percentageTree = new AVLTree({key: percentage, value: value}, "key");
|
||||
@@ -105,6 +105,7 @@ GCODE.gCodeReader = (function(){
|
||||
|
||||
var purgeLayers = function(m){
|
||||
if(!m) return;
|
||||
var tmpModel = [];
|
||||
|
||||
var purge;
|
||||
for(var i = 0; i < m.length; i++){
|
||||
@@ -119,13 +120,12 @@ GCODE.gCodeReader = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
if (purge) {
|
||||
m.splice(i, 1);
|
||||
i--;
|
||||
if (!purge) {
|
||||
tmpModel.push(m[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
return tmpModel;
|
||||
};
|
||||
|
||||
// ***** PUBLIC *******
|
||||
@@ -181,8 +181,9 @@ GCODE.gCodeReader = (function(){
|
||||
var m = model;
|
||||
if (gCodeOptions["sortLayers"]) m = sortLayers(m);
|
||||
if (gCodeOptions["purgeEmptyLayers"]) m = purgeLayers(m);
|
||||
prepareLinesIndex();
|
||||
prepareLinesIndex(m);
|
||||
GCODE.renderer.doRender(m, 0);
|
||||
return m;
|
||||
},
|
||||
|
||||
processLayerFromWorker: function(msg){
|
||||
|
||||
@@ -59,7 +59,7 @@ GCODE.ui = (function(){
|
||||
setProgress("done", 100);
|
||||
|
||||
GCODE.gCodeReader.processAnalyzeModelDone(data.msg);
|
||||
GCODE.gCodeReader.passDataToRenderer();
|
||||
var activeModel = GCODE.gCodeReader.passDataToRenderer();
|
||||
|
||||
if (uiOptions["onModelLoaded"]) {
|
||||
uiOptions.onModelLoaded({
|
||||
@@ -70,7 +70,8 @@ GCODE.ui = (function(){
|
||||
printTime: data.msg.printTime,
|
||||
layerHeight: data.msg.layerHeight,
|
||||
layersPrinted: data.msg.layerCnt,
|
||||
layersTotal: data.msg.layerTotal
|
||||
layersTotal: data.msg.layerTotal,
|
||||
layersActive: activeModel.length
|
||||
});
|
||||
}
|
||||
switchLayer(0);
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
return entry;
|
||||
}
|
||||
|
||||
if (!entry.hasOwnProperty("children")) {
|
||||
if (!entry.hasOwnProperty("children") || !entry.children) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 188 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user