Compare commits
313
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f7c4d8a1 | ||
|
|
10079b8d9d | ||
|
|
c31566a626 | ||
|
|
0cfc7a2976 | ||
|
|
de5a10163e | ||
|
|
0a22c4e66c | ||
|
|
a88d95af77 | ||
|
|
010221ab5b | ||
|
|
6471a04a86 | ||
|
|
7b2762c590 | ||
|
|
de0b97b99c | ||
|
|
60d2bd1ac1 | ||
|
|
4d716647e5 | ||
|
|
43ab47a260 | ||
|
|
88ecfbdb65 | ||
|
|
8087967683 | ||
|
|
cb43197105 | ||
|
|
b1b9329614 | ||
|
|
7317814ce0 | ||
|
|
66ef7b66bb | ||
|
|
be3ff5f043 | ||
|
|
c36fa6da90 | ||
|
|
aadcf650c7 | ||
|
|
95c3fa0b04 | ||
|
|
1d0829a1db | ||
|
|
8d31d6687e | ||
|
|
3f3cb556a7 | ||
|
|
4460c8bee0 | ||
|
|
89b597a656 | ||
|
|
e1a25a8913 | ||
|
|
482c2f7115 | ||
|
|
7fa4ebd1ec | ||
|
|
9c3b552aa8 | ||
|
|
3229e65a8d | ||
|
|
7191d39b51 | ||
|
|
58bc5171ee | ||
|
|
74f3bc9ae6 | ||
|
|
464d9c0757 | ||
|
|
94ae90ab80 | ||
|
|
33b89550a4 | ||
|
|
9661469532 | ||
|
|
b06c222a7d | ||
|
|
9f85b54681 | ||
|
|
5d1ad5d75d | ||
|
|
dc32f955b7 | ||
|
|
220592c267 | ||
|
|
0faa6879b4 | ||
|
|
71b5de91bf | ||
|
|
928d62a517 | ||
|
|
78bd3b1a52 | ||
|
|
b9bab0577b | ||
|
|
c41551a643 | ||
|
|
6c92dd1303 | ||
|
|
124f01ca2d | ||
|
|
0dece85fa7 | ||
|
|
caebf90ee9 | ||
|
|
0c77014903 | ||
|
|
231a796200 | ||
|
|
fe755405e8 | ||
|
|
2200f2186c | ||
|
|
b57b7cb606 | ||
|
|
f2b2496e58 | ||
|
|
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.4.1
|
||||
# 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.4.1 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
|
||||
fix/.* 1.4.1 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
|
||||
improve/.* 1.4.1 2da7aa358d950b4567aaab8f18d6b5779193e077 pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.3.11rc4
|
||||
# staging/maintenance is currently the branch for preparation of 1.4.0rc5
|
||||
# so is regressionfix/...
|
||||
staging/maintenance 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev
|
||||
regressionfix/.* 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev
|
||||
staging/maintenance 1.4.0rc5 7b2762c5904595111b77f6e5dda283663b6e325f pep440-dev
|
||||
regressionfix/.* 1.4.0rc5 7b2762c5904595111b77f6e5dda283663b6e325f 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.0rc5
|
||||
staging/devel 1.4.0rc5 7b2762c5904595111b77f6e5dda283663b6e325f 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.
|
||||
+19
-11
@@ -6,52 +6,60 @@ thanks to everyone who contributed!
|
||||
|
||||
## Patreon Patrons
|
||||
|
||||
* Andre Bubel
|
||||
* Andrew Moorby
|
||||
* Arnljot Arntsen
|
||||
* Bjorn Breckenridge
|
||||
* BigTreeTech
|
||||
* Boris Hussein
|
||||
* Brad Jackson
|
||||
* Christian Petropolis
|
||||
* Christian Wolf
|
||||
* COLLE+McVOY
|
||||
* D Brian Kimmel
|
||||
* DeltaMaker 3D Printers
|
||||
* Dennis Breining
|
||||
* Dorian Gray
|
||||
* E3D BigBox
|
||||
* Eric Betts
|
||||
* Ernesto Martinez
|
||||
* Franziska Kunsmann
|
||||
* GadgetAngel
|
||||
* George Robles
|
||||
* Greg Holloway
|
||||
* Hugh Blemings
|
||||
* jean-claude migneault
|
||||
* Jeff Renfer
|
||||
* Jefferson Hunt
|
||||
* Jeremiah Avery
|
||||
* Joseph Payne
|
||||
* Joshua Wills
|
||||
* Justin Kaufman
|
||||
* Kaile Riser
|
||||
* Kale Stedman
|
||||
* Kazuhiro Ogura
|
||||
* Kenneth Jiang
|
||||
* Kurt Wubbels
|
||||
* Kyle Menigoz
|
||||
* LA 3D Printer Repair
|
||||
* LulzBot®
|
||||
* Lee Dohm
|
||||
* Makespace Madrid
|
||||
* Mark Walker
|
||||
* Martin Majewski
|
||||
* Michael Aumock
|
||||
* Miles Flavel
|
||||
* Mosaic Manufacturing
|
||||
* OMER MEHMET SUTAS
|
||||
* Neil R. Goldberg
|
||||
* Patrick Glyré
|
||||
* Patrick McGinnis
|
||||
* Prof Yuh Wen Chen
|
||||
* Randy C. Will
|
||||
* Ranjib Dey
|
||||
* Richard Michaud
|
||||
* Rigid3D
|
||||
* Robert Gusek
|
||||
* Samer Najia
|
||||
* Ronald Griehsler
|
||||
* Sacha Telgenhof
|
||||
* sghnsk
|
||||
* Shawn Lewis
|
||||
* Simon Hallam
|
||||
* Stefan Krister
|
||||
* Sven Mueller
|
||||
* TEVO 3D Printers
|
||||
* Trent Shumay
|
||||
* Ulrich Kempken
|
||||
|
||||
and 1544 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
and 1746 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
|
||||
@@ -0,0 +1,529 @@
|
||||
.. _sec-api-access:
|
||||
|
||||
**************
|
||||
Access control
|
||||
**************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-access-permissions:
|
||||
|
||||
Permissions
|
||||
===========
|
||||
|
||||
.. _sec-api-access-permissions-list:
|
||||
|
||||
List all permissions
|
||||
--------------------
|
||||
|
||||
.. http:get:: /api/access/permissions
|
||||
|
||||
Retrieves all permissions available in the system.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`permission list <sec-api-access-datamodel-permissions-list>`
|
||||
as body.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-access-groups:
|
||||
|
||||
Groups
|
||||
======
|
||||
|
||||
.. _sec-api-access-groups-list:
|
||||
|
||||
Get group list
|
||||
--------------
|
||||
|
||||
.. http:get:: /api/access/groups
|
||||
|
||||
Retrieves all groups registered in the system.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`group list <sec-api-access-datamodel-groups-list>`
|
||||
as body.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-access-groups-add:
|
||||
|
||||
Add a new group
|
||||
---------------
|
||||
|
||||
.. http:post:: /api/access/groups
|
||||
|
||||
Adds a new group to the system.
|
||||
|
||||
Expects a :ref:`group registration request <sec-api-access-datamodel-groups-addgrouprequest>` as request body.
|
||||
|
||||
Will return a :ref:`group list response <sec-api-access-datamodel-groups-list>` on success.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:json key: The group's identifier
|
||||
:json name: The user's name
|
||||
:json description: A human readable description of the group
|
||||
:json permissions: The permissions to assign to the group
|
||||
:json subgroups: Subgroups assigned to the group
|
||||
:json default: Whether the group should be assigned to new users by default or not
|
||||
:status 200: No error
|
||||
:status 400: If any of the mandatory fields is missing or the request is otherwise
|
||||
invalid
|
||||
:status 409: A group with the provided key does already exist
|
||||
|
||||
.. _sec-api-access-groups-retrieve:
|
||||
|
||||
Retrieve a group
|
||||
----------------
|
||||
|
||||
.. http:get:: /api/access/groups/(string:key)
|
||||
|
||||
Retrieves an individual group record.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`group record <sec-api-access-datamodel-groups-grouprecord>`
|
||||
as body.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-access-groups-modify:
|
||||
|
||||
Update a group
|
||||
--------------
|
||||
|
||||
.. http:put:: /api/access/groups/(string:key)
|
||||
|
||||
Updates an existing group.
|
||||
|
||||
Expects a :ref:`group update request <sec-api-access-datamodel-groups-updategrouprequest>` as request body.
|
||||
|
||||
Will return a :ref:`group list response <sec-api-access-datamodel-groups-list>` on success.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:json description: A human readable description of the group
|
||||
:json permissions: The permissions to assign to the group
|
||||
:json subgroups: Subgroups assigned to the group
|
||||
:json default: Whether the group should be assigned to new users by default or not
|
||||
:status 200: No error
|
||||
:status 400: If any of the mandatory fields is missing or the request is otherwise
|
||||
invalid
|
||||
|
||||
.. _sec-api-access-groups-delete:
|
||||
|
||||
Delete a group
|
||||
--------------
|
||||
|
||||
.. http:delete:: /api/access/groups/(string:key)
|
||||
|
||||
Deletes a group.
|
||||
|
||||
Will return a :ref:`group list response <sec-api-access-datamodel-groups-list>` on success.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-access-users:
|
||||
|
||||
Users
|
||||
=====
|
||||
|
||||
.. _sec-api-access-users-list:
|
||||
|
||||
Retrieve a list of users
|
||||
========================
|
||||
|
||||
.. http:get:: /api/access/users
|
||||
|
||||
Retrieves a list of all registered users in OctoPrint.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`user list response <sec-api-access-datamodel-users-userlistresponse>`
|
||||
as body.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-access-users-retrieve:
|
||||
|
||||
Retrieve a user
|
||||
---------------
|
||||
|
||||
.. http:get:: /api/access/users/(string:username)
|
||||
|
||||
Retrieves information about a user.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`user record <sec-api-access-datamodel-users-userrecord>`
|
||||
as body.
|
||||
|
||||
Requires either the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user which to retrieve
|
||||
:status 200: No error
|
||||
:status 404: Unknown user
|
||||
|
||||
.. _sec-api-access-users-add:
|
||||
|
||||
Add a new user
|
||||
--------------
|
||||
|
||||
.. http:post:: /api/access/users
|
||||
|
||||
Adds a user to OctoPrint.
|
||||
|
||||
Expects a :ref:`user registration request <sec-api-access-datamodel-users-adduserrequest>`
|
||||
as request body.
|
||||
|
||||
Returns a list of registered users on success, see :ref:`Retrieve a list of users <sec-api-access-users-list>`.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:json name: The user's name
|
||||
:json password: The user's password
|
||||
:json active: Whether to activate the account (true) or not (false)
|
||||
:json admin: Whether to give the account admin rights (true) or not (false)
|
||||
:status 200: No error
|
||||
:status 400: If any of the mandatory fields is missing or the request is otherwise
|
||||
invalid
|
||||
:status 409: A user with the provided name does already exist
|
||||
|
||||
.. _sec-api-access-users-modify:
|
||||
|
||||
Update a user
|
||||
-------------
|
||||
|
||||
.. http:put:: /api/access/users/(string:username)
|
||||
|
||||
Updates a user record.
|
||||
|
||||
Expects a :ref:`user update request <sec-api-access-datamodel-users-updateuserrequest>`
|
||||
as request body.
|
||||
|
||||
Returns a list of registered users on success, see :ref:`Retrieve a list of users <sec-api-access-users-list>`.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:param username: Name of the user to update
|
||||
:json admin: Whether to mark the user as admin (true) or not (false), can be left out (no change)
|
||||
:json active: Whether to mark the account as activated (true) or deactivated (false), can be left out (no change)
|
||||
:status 200: No error
|
||||
:status 404: Unknown user
|
||||
|
||||
.. _sec-api-access-users-delete:
|
||||
|
||||
Delete a user
|
||||
-------------
|
||||
|
||||
.. http:delete:: /api/access/users/(string:username)
|
||||
|
||||
Delete a user record.
|
||||
|
||||
Returns a list of registered users on success, see :ref:`Retrieve a list of users <sec-api-access-users-list>`.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:param username: Name of the user to delete
|
||||
:status 200: No error
|
||||
:status 404: Unknown user
|
||||
|
||||
.. _sec-api-access-users-password:
|
||||
|
||||
Change a user's password
|
||||
------------------------
|
||||
|
||||
.. http:put:: /api/access/users/(string:username)/password
|
||||
|
||||
Changes the password of a user.
|
||||
|
||||
Expects a JSON object with a single property ``password`` as request body.
|
||||
|
||||
Requires the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to change the password for
|
||||
:json password: The new password to set
|
||||
:status 200: No error
|
||||
:status 400: If the request doesn't contain a ``password`` property or the request
|
||||
is otherwise invalid
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-access-users-settings-get:
|
||||
|
||||
Get a user's settings
|
||||
---------------------
|
||||
|
||||
.. http:get:: /api/access/users/(string:username)/settings
|
||||
|
||||
Retrieves a user's settings.
|
||||
|
||||
Will return a :http:statuscode:`200` with a JSON object representing the user's
|
||||
personal settings (if any) as body.
|
||||
|
||||
Requires the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 200: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-access-users-settings-set:
|
||||
|
||||
Update a user's settings
|
||||
------------------------
|
||||
|
||||
.. http:patch:: /api/access/users/(string:username)/settings
|
||||
|
||||
Updates a user's settings.
|
||||
|
||||
Expects a new settings JSON object to merge with the current settings as
|
||||
request body.
|
||||
|
||||
Requires the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 204: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-access-users-apikey-generate:
|
||||
|
||||
Regenerate a user's api key
|
||||
---------------------------
|
||||
|
||||
.. http:post:: /api/access/users/(string:username)/apikey
|
||||
|
||||
Generates a new API key for the user.
|
||||
|
||||
Does not expect a body. Will return the generated API key as ``apikey``
|
||||
property in the JSON object contained in the response body.
|
||||
|
||||
Requires the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 200: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-access-users-apikey-delete:
|
||||
|
||||
Delete a user's api key
|
||||
-----------------------
|
||||
|
||||
.. http:delete:: /api/access/users/(string:username)/apikey
|
||||
|
||||
Deletes a user's personal API key.
|
||||
|
||||
Requires the ``SETTINGS`` permission or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 204: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-access-datamodel:
|
||||
|
||||
Data model
|
||||
==========
|
||||
|
||||
.. _sec-api-access-datamodel-permissions:
|
||||
|
||||
Permissions
|
||||
-----------
|
||||
|
||||
.. _sec-api-access-datamodel-permissions-list:
|
||||
|
||||
Permission list response
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``permissions``
|
||||
- 0..n
|
||||
- List of :ref:`permission records <sec-api-datamodel-access-permissions>`
|
||||
- The list of permissions
|
||||
|
||||
|
||||
.. _sec-api-access-datamodel-groups:
|
||||
|
||||
Groups
|
||||
------
|
||||
|
||||
.. _sec-api-access-datamodel-groups-list:
|
||||
|
||||
Group list response
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``groups``
|
||||
- 0..n
|
||||
- List of :ref:`group records <sec-api-datamodel-access-groups>`
|
||||
- The list of groups
|
||||
|
||||
.. _sec-api-access-datamodel-groups-addgrouprequest:
|
||||
|
||||
Group registration request
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``key``
|
||||
- 1
|
||||
- string
|
||||
- The group's identifier
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The group's name
|
||||
* - ``description``
|
||||
- 0..1
|
||||
- string
|
||||
- The group's description. Set to empty if not provided.
|
||||
* - ``permissions``
|
||||
- 1..n
|
||||
- List of string
|
||||
- A list of identifier's of permissions to assign to the group
|
||||
* - ``subgroups``
|
||||
- 0..n
|
||||
- List of string
|
||||
- A list of identifier's of groups to assign to the group as subgroups
|
||||
* - ``default``
|
||||
- 0..1
|
||||
- boolean
|
||||
- Whether to assign the group to new users by default (true) or not (false, default value)
|
||||
|
||||
.. _sec-api-access-datamodel-groups-updategrouprequest:
|
||||
|
||||
Group update request
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``description``
|
||||
- 0..1
|
||||
- string
|
||||
- The group's description. Set to empty if not provided.
|
||||
* - ``permissions``
|
||||
- 1..n
|
||||
- List of string
|
||||
- A list of identifier's of permissions to assign to the group
|
||||
* - ``subgroups``
|
||||
- 0..n
|
||||
- List of string
|
||||
- A list of identifier's of groups to assign to the group as subgroups
|
||||
* - ``default``
|
||||
- 0..1
|
||||
- boolean
|
||||
- Whether to assign the group to new users by default (true) or not (false, default value)
|
||||
|
||||
|
||||
.. _sec-api-access-datamodel-users:
|
||||
|
||||
Users
|
||||
-----
|
||||
|
||||
.. _sec-api-access-datamodel-users-userlistresponse:
|
||||
|
||||
User list response
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``users``
|
||||
- 0..n
|
||||
- List of :ref:`user records <sec-api-datamodel-access-users>`
|
||||
- The list of users
|
||||
|
||||
.. _sec-api-access-datamodel-users-adduserrequest:
|
||||
|
||||
User registration request
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The user's name
|
||||
* - ``password``
|
||||
- 1
|
||||
- string
|
||||
- The user's password
|
||||
* - ``active``
|
||||
- 1
|
||||
- bool
|
||||
- Whether to activate the account (true) or not (false)
|
||||
* - ``groups``
|
||||
- 0..n
|
||||
- List of string
|
||||
- A list of identifiers of groups to assign to the user
|
||||
* - ``permissions``
|
||||
- 0..n
|
||||
- List of string
|
||||
- A list of identifiers of permissions to assign to the user
|
||||
|
||||
.. _sec-api-access-datamodel-users-updateuserrequest:
|
||||
|
||||
User update request
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``active``
|
||||
- 0..1
|
||||
- bool
|
||||
- If present will set the user's active flag to the provided value. True for
|
||||
activating the account, false for deactivating it.
|
||||
* - ``groups``
|
||||
- 0..n
|
||||
- List of string
|
||||
- A list of identifiers of groups to assign to the user
|
||||
* - ``permissions``
|
||||
- 0..n
|
||||
- List of string
|
||||
- A list of identifiers of permissions to assign to the user
|
||||
@@ -16,6 +16,8 @@ Get connection settings
|
||||
Retrieve the current connection settings, including information regarding the available baudrates and
|
||||
serial ports and the current connection state.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -81,7 +83,7 @@ Issue a connection command
|
||||
for the lost acknowledgment should always be properly investigated and removed instead of depending on this
|
||||
"symptom solver".
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``CONNECTION`` permission.
|
||||
|
||||
**Example Connect Request**
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -469,3 +480,173 @@ References
|
||||
- URL
|
||||
- The model from which this file was generated (e.g. an STL, currently not used). Never present for
|
||||
folders.
|
||||
|
||||
.. _sec-api-datamodel-access:
|
||||
|
||||
Access control
|
||||
==============
|
||||
|
||||
.. _sec-api-datamodel-access-users:
|
||||
|
||||
User record
|
||||
-----------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The user's name
|
||||
* - ``active``
|
||||
- 1
|
||||
- bool
|
||||
- Whether the user's account is active (true) or not (false)
|
||||
* - ``user``
|
||||
- 1
|
||||
- bool
|
||||
- Whether the user has user rights. Should always be true. Deprecated as of 1.4.0, use the ``users`` group instead.
|
||||
* - ``admin``
|
||||
- 1
|
||||
- bool
|
||||
- Whether the user has admin rights (true) or not (false). Deprecated as of 1.4.0, use the ``admins`` group instead.
|
||||
* - ``apikey``
|
||||
- 0..1
|
||||
- string
|
||||
- The user's personal API key
|
||||
* - ``settings``
|
||||
- 1
|
||||
- object
|
||||
- The user's personal settings, might be an empty object.
|
||||
* - ``groups``
|
||||
- 1..n
|
||||
- List of string
|
||||
- Groups assigned to the user
|
||||
* - ``needs``
|
||||
- 1
|
||||
- :ref:`Needs object <sec-api-datamodel-access-needs>`
|
||||
- Effective needs of the user
|
||||
* - ``permissions``
|
||||
- 0..n
|
||||
- List of :ref:`Permissions <sec-api-datamodel-access-permissions>`
|
||||
- The list of permissions assigned to the user (note: this does not include implicit permissions inherit from groups).
|
||||
|
||||
.. _sec-api-datamodel-access-permissions:
|
||||
|
||||
Permission record
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``key``
|
||||
- 1
|
||||
- string
|
||||
- The permission's identifier
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The permission's name
|
||||
* - ``dangerous``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether the permission should be considered dangerous due to a high reponsibility (true) or not (false).
|
||||
* - ``default_groups``
|
||||
- 1
|
||||
- List of string
|
||||
- List of group identifiers for which this permission is enabled by default
|
||||
* - ``description``
|
||||
- 1
|
||||
- string
|
||||
- Human readable description of the permission
|
||||
* - ``needs``
|
||||
- 1
|
||||
- :ref:`Needs object <sec-api-access-datamodel-general-needs>`
|
||||
- Needs assigned to the permission
|
||||
|
||||
.. _sec-api-datamodel-access-groups:
|
||||
|
||||
Group record
|
||||
------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``key``
|
||||
- 1
|
||||
- string
|
||||
- The group's identifier
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The group's name
|
||||
* - ``description``
|
||||
- 1
|
||||
- string
|
||||
- A human readable description of the group
|
||||
* - ``permissions``
|
||||
- 0..n
|
||||
- List of :ref:`Permissions <sec-api-datamodel-access-permissions>`
|
||||
- The list of permissions assigned to the group (note: this does not include implicit permissions inherited from
|
||||
subgroups).
|
||||
* - ``subgroups``
|
||||
- 0..n
|
||||
- List of :ref:`Groups <sec-api-datamodel-access-groups>`
|
||||
- Subgroups assigned to the group
|
||||
* - ``needs``
|
||||
- 1
|
||||
- :ref:`Needs object <sec-api-datamodel-access-needs>`
|
||||
- Effective needs of the group
|
||||
* - ``default``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether this is a default group (true) or not (false)
|
||||
* - ``removable``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether this group can be removed (true) or not (false)
|
||||
* - ``changeable``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether this group can be modified (true) or not (false)
|
||||
* - ``toggleable``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether this group can be assigned to users or other groups (true) or not (false)
|
||||
|
||||
.. _sec-api-datamodel-access-needs:
|
||||
|
||||
Needs
|
||||
-----
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``role``
|
||||
- 0..1
|
||||
- List of string
|
||||
- List of ``role`` needs
|
||||
* - ``group``
|
||||
- 0..1
|
||||
- List of string
|
||||
- List of ``group`` needs
|
||||
+15
-3
@@ -21,6 +21,8 @@ Retrieve all files
|
||||
|
||||
Returns a :ref:`Retrieve response <sec-api-fileops-datamodel-retrieveresponse>`.
|
||||
|
||||
Requires the ``FILES_LIST`` permission.
|
||||
|
||||
**Example 1**:
|
||||
|
||||
Fetch only the files and folders from the root folder.
|
||||
@@ -250,6 +252,8 @@ Retrieve files from specific location
|
||||
|
||||
Returns a :ref:`Retrieve response <sec-api-fileops-datamodel-retrieveresponse>`.
|
||||
|
||||
Requires the ``FILES_LIST`` permission.
|
||||
|
||||
**Example**:
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -327,7 +331,7 @@ Upload file or create folder
|
||||
Returns a :http:statuscode:`201` response with a ``Location`` header set to the management URL of the uploaded
|
||||
file and an :ref:`Upload Response <sec-api-fileops-datamodel-uploadresponse>` as the body upon successful completion.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``FILES_UPLOAD`` permission.
|
||||
|
||||
**Example for uploading a file**
|
||||
|
||||
@@ -504,6 +508,8 @@ Retrieve a specific file's or folder's information
|
||||
On success, a :http:statuscode:`200` is returned, with a :ref:`file information item <sec-api-datamodel-files-file>`
|
||||
as the response body.
|
||||
|
||||
Requires the ``FILES_LIST`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -568,6 +574,8 @@ Issue a file command
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
Requires the ``FILES_SELECT`` permission.
|
||||
|
||||
slice
|
||||
Slices an STL file into GCODE. Note that this is an asynchronous operation that will take place in the background
|
||||
after the response has been sent back to the client. Additional parameters are:
|
||||
@@ -598,6 +606,8 @@ Issue a file command
|
||||
Upon success, a status code of :http:statuscode:`202` and a :ref:`sec-api-datamodel-files-fileabridged` in the response
|
||||
body will be returned.
|
||||
|
||||
Requires the ``SLICE`` permission.
|
||||
|
||||
copy
|
||||
Copies the file or folder to a new ``destination`` on the same ``location``. Additional parameters are:
|
||||
|
||||
@@ -609,6 +619,8 @@ Issue a file command
|
||||
Upon success, a status code of :http:statuscode:`201` and a :ref:`sec-api-datamodel-files-fileabridged` in the response
|
||||
body will be returned.
|
||||
|
||||
Requires the ``FILES_UPLOAD`` permission.
|
||||
|
||||
move
|
||||
Moves the file or folder to a new ``destination`` on the same ``location``. Additional parameters are:
|
||||
|
||||
@@ -622,7 +634,7 @@ Issue a file command
|
||||
Upon success, a status code of :http:statuscode:`201` and a :ref:`sec-api-datamodel-files-fileabridged` in the response
|
||||
body will be returned.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``FILES_UPLOAD`` permission.
|
||||
|
||||
**Example Select Request**
|
||||
|
||||
@@ -773,7 +785,7 @@ Delete file
|
||||
|
||||
Returns a :http:statuscode:`204` after successful deletion.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``FILES_DELETE`` permission.
|
||||
|
||||
**Example Request**
|
||||
|
||||
|
||||
+56
-33
@@ -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:
|
||||
|
||||
@@ -175,6 +180,20 @@ Logout
|
||||
|
||||
:status 204: No error
|
||||
|
||||
.. _sec-api-general-currentuser:
|
||||
|
||||
Current User
|
||||
============
|
||||
|
||||
.. http:get:: /api/currentuser
|
||||
|
||||
Retrieves information about the current user.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`current user object <sec-api-general-datamodel-currentuser>`
|
||||
as body.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-general-datamodel:
|
||||
|
||||
Data model
|
||||
@@ -185,6 +204,30 @@ Data model
|
||||
Login response
|
||||
--------------
|
||||
|
||||
The Login response is a :ref:`user record <sec-api-datamodel-access-users>` extended by the following fields:
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``session``
|
||||
- 1
|
||||
- string
|
||||
- The session key, can be used to authenticate with the ``auth`` message on the :ref:`push API <sec-api-push>`.
|
||||
* - ``_is_external_client``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether the client that made the request got detected as external from the local network or not.
|
||||
|
||||
.. _sec-api-general-datamodel-currentuser:
|
||||
|
||||
Current user
|
||||
------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
@@ -196,32 +239,12 @@ Login response
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- the user's name/id
|
||||
* - ``active``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether the user's account is active or not
|
||||
* - ``admin``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether the user has admin rights or not
|
||||
* - ``user``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether the user has user rights or not (always ``true``)
|
||||
* - ``apikey``
|
||||
- 1
|
||||
- string or None
|
||||
- The user's API key, if set
|
||||
* - ``settings``
|
||||
- 1
|
||||
- dict
|
||||
- The user's settings, if any
|
||||
* - ``session``
|
||||
- 1
|
||||
- string
|
||||
- The session key, can be used to authenticate with the ``auth`` message on the :ref:`push API <sec-api-push>`.
|
||||
* - ``_is_external_client``
|
||||
- 1
|
||||
- boolean
|
||||
- Whether the client that made the request got detected as external from the local network or not.
|
||||
- The id of the current user. Unset if guest.
|
||||
* - ``permissions``
|
||||
- 0..n
|
||||
- List of :ref:`permission records <sec-api-datamodel-access-permissions>`
|
||||
- The effective list of permissions assigned to the user
|
||||
* - ``groups``
|
||||
- 0..n
|
||||
- List of :ref:`permission records <sec-api-datamodel-access-groups>`
|
||||
- The list of groups assigned to the user
|
||||
+1
-2
@@ -9,7 +9,6 @@ REST API
|
||||
|
||||
general.rst
|
||||
version.rst
|
||||
apps.rst
|
||||
connection.rst
|
||||
files.rst
|
||||
job.rst
|
||||
@@ -21,7 +20,7 @@ REST API
|
||||
slicing.rst
|
||||
system.rst
|
||||
timelapse.rst
|
||||
users.rst
|
||||
access.rst
|
||||
util.rst
|
||||
wizard.rst
|
||||
push.rst
|
||||
|
||||
+3
-1
@@ -57,7 +57,7 @@ Issue a job command
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``PRINT`` permission.
|
||||
|
||||
**Example Start Request**
|
||||
|
||||
@@ -180,6 +180,8 @@ Retrieve information about the current job
|
||||
|
||||
Returns a :http:statuscode:`200` with a :ref:`sec-api-job-datamodel-response` in the body.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@@ -6,7 +6,7 @@ Languages
|
||||
|
||||
.. note::
|
||||
|
||||
All language pack management operations require admin rights.
|
||||
All language pack management operations require the ``SETTINGS`` permission.
|
||||
|
||||
.. contents::
|
||||
|
||||
|
||||
+59
-11
@@ -80,6 +80,8 @@ Retrieve the current printer state
|
||||
Returns a :http:statuscode:`200` with a :ref:`Full State Response <sec-api-printer-datamodel-fullstate>` in the
|
||||
body upon success.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
**Example 1**
|
||||
|
||||
Include temperature history data, but limit it to two entries.
|
||||
@@ -241,7 +243,7 @@ Issue a print head command
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
**Example Jog Request**
|
||||
|
||||
@@ -350,7 +352,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:
|
||||
@@ -380,7 +382,7 @@ Issue a tool command
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
@@ -555,6 +557,8 @@ Retrieve the current tool state
|
||||
|
||||
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
.. note::
|
||||
If you want both tool and bed temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
@@ -630,7 +634,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:
|
||||
@@ -645,7 +649,7 @@ Issue a bed command
|
||||
If no heated bed is configured for the currently selected printer profile, the resource will return
|
||||
an :http:statuscode:`409`.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
@@ -714,6 +718,8 @@ Retrieve the current bed state
|
||||
If no heated bed is configured for the currently selected printer profile, the resource will return
|
||||
an :http:statuscode:`409`.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
.. note::
|
||||
If you want tool, bed and chamber temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
@@ -770,7 +776,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 +784,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,10 +796,10 @@ 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.
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
@@ -862,6 +868,8 @@ Retrieve the current chamber state
|
||||
If no heated chamber is configured for the currently selected printer profile, the resource will return
|
||||
an :http:statuscode:`409`.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
.. note::
|
||||
If you want tool, bed and chamber temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
@@ -944,7 +952,7 @@ Issue an SD command
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
**Example Init Request**
|
||||
|
||||
@@ -1022,6 +1030,8 @@ Retrieve the current SD state
|
||||
Returns a :http:statuscode:`200` with an :ref:`SD State Response <sec-api-printer-datamodel-sdstate>` in the body
|
||||
upon success.
|
||||
|
||||
Requires the ``STATUS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
Read the current state of the SD card.
|
||||
@@ -1058,7 +1068,7 @@ Send an arbitrary command to the printer
|
||||
|
||||
If successful returns a :http:statuscode:`204` and an empty body.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
**Example for sending a single command**
|
||||
|
||||
@@ -1101,6 +1111,26 @@ Send an arbitrary command to the printer
|
||||
:json string commands: List of commands to send to the printer, mutually exclusive with ``command``.
|
||||
:statuscode 204: No error
|
||||
|
||||
.. _sec-api-printer-customcontrols:
|
||||
|
||||
Retrieve custom controls
|
||||
========================
|
||||
|
||||
.. http:get:: /api/printer/command/custom
|
||||
|
||||
Retrieves the :ref:`custom controls <sec-features-custom_controls>` as configured in
|
||||
:ref:`config.yaml <sec-configuration-config_yaml>`.
|
||||
|
||||
Please refer to the documentation of :ref:`custom controls <sec-features-custom_controls>` on what
|
||||
data structure to expect here.
|
||||
|
||||
Returns a :http:statuscode:`200` with an :ref:`Custom Controls Response <sec-api-printer-datamodel-customcontrols>`
|
||||
in the body upon success.
|
||||
|
||||
Requires the ``CONTROL`` permission.
|
||||
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-printer-datamodel:
|
||||
|
||||
Data model
|
||||
@@ -1211,3 +1241,21 @@ Arbitrary Command Request
|
||||
- 0..1
|
||||
- Map of key value pairs
|
||||
- (only if ``script`` is set) additional template variables to provide to the script renderer
|
||||
|
||||
.. _sec-api-printer-datamodel-customcontrols:
|
||||
|
||||
Custom Controls Response
|
||||
------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``controls``
|
||||
- 0..n
|
||||
- List of :ref:`custom controls <sec-features-custom_controls>`
|
||||
- A list of custom control definitions as defined in ``config.yaml``.
|
||||
@@ -21,6 +21,8 @@ Retrieve all printer profiles
|
||||
|
||||
Returns a :http:statuscode:`200` with a list of :ref:`profiles <sec-api-printerprofiles-datamodel-profile>`.
|
||||
|
||||
Requires the ``CONNECTION`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -124,6 +126,22 @@ Retrieve all printer profiles
|
||||
}
|
||||
|
||||
|
||||
.. _sec-api-printerprofiles-get:
|
||||
|
||||
Retrieve a single printer profile
|
||||
=================================
|
||||
|
||||
.. http:get:: /api/printerprofiles/(string:identifier)
|
||||
|
||||
Retrieves an existing single printer profile.
|
||||
|
||||
Returns a :http:statuscode:`200` with a :ref:`profile <sec-api-printerprofiles-datamodel-profile>`.
|
||||
|
||||
Requires the ``CONNECTION`` permission.
|
||||
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: The profile does not exist
|
||||
|
||||
.. _sec-api-printerprofiles-add:
|
||||
|
||||
Add a new printer profile
|
||||
@@ -143,7 +161,7 @@ Add a new printer profile
|
||||
Returns a :http:statuscode:`200` with the saved profile as property ``profile``
|
||||
in the JSON body upon success.
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
**Example 1**
|
||||
|
||||
@@ -314,7 +332,7 @@ Update an existing printer profile
|
||||
Returns a :http:statuscode:`200` with the saved profile as property ``profile``
|
||||
in the JSON body upon success.
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
@@ -400,7 +418,7 @@ Remove an existing printer profile
|
||||
|
||||
Returns a :http:statuscode:`204` an empty body upon success.
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
|
||||
+2
-3
@@ -51,9 +51,8 @@ OctoPrint's SockJS socket also accepts two commands from the client to the serve
|
||||
|
||||
* ``auth`` (since 1.3.10): With the ``auth`` message, clients may associate an
|
||||
existing user session with the socket. That is of special importance to receive
|
||||
any kind of messages if the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` is enabled
|
||||
(as it is by default), since it will prevent any kind of status messages to be sent to connected unauthenticated
|
||||
clients.
|
||||
any kind of messages, since the permission system will prevent any kind of status messages to be sent to connected
|
||||
clients lacking the ``STATUS`` permission.
|
||||
|
||||
The ``auth`` message expects the user id of the user to authenticate followed by ``:`` and a session key to be
|
||||
obtained from the successful payload of a :ref:`(passive or active) login via the API <sec-api-general-login>`.
|
||||
|
||||
@@ -21,6 +21,8 @@ Retrieve current settings
|
||||
The :ref:`data model <sec-api-settings-datamodel>` is similar to what can be found in
|
||||
:ref:`config.yaml <sec-configuration-config_yaml>`, see below for details.
|
||||
|
||||
Requires the ``SETTINGS_READ`` permission.
|
||||
|
||||
.. _sec-api-settings-save:
|
||||
|
||||
Save settings
|
||||
@@ -36,7 +38,7 @@ Save settings
|
||||
|
||||
Returns the currently active settings on success, as part of a :http:statuscode:`200` response.
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
|
||||
+62
-2
@@ -28,6 +28,8 @@ List All Slicers and Slicing Profiles
|
||||
Returns a :http:statuscode:`200` response with a :ref:`Slicer list <sec-api-slicing-datamodel-slicerlist>`
|
||||
as the body upon successful completion.
|
||||
|
||||
Requires the ``SLICE`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -77,6 +79,8 @@ List Slicing Profiles of a Specific Slicer
|
||||
Returns a :http:statuscode:`200` response with a :ref:`Profile list <sec-api-slicing-datamodel-profilelist>`
|
||||
as the body upon successful completion.
|
||||
|
||||
Requires the ``SLICE`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -121,6 +125,8 @@ Retrieve Specific Profile
|
||||
Returns a :http:statuscode:`200` response with a :ref:`full Profile <sec-api-slicing-datamodel-profile>`
|
||||
as the body upon successful completion.
|
||||
|
||||
Requires the ``SLICE`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
@@ -168,7 +174,7 @@ Add Slicing Profile
|
||||
Returns a :http:statuscode:`201` and an :ref:`abridged Profile <sec-api-slicing-datamodel-profile>` in the body
|
||||
upon successful completion.
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
@@ -206,6 +212,31 @@ Add Slicing Profile
|
||||
:statuscode 201: No error
|
||||
:statuscode 404: If the ``slicer`` was unknown to the system.
|
||||
|
||||
.. _sec-api-slicing-patch:
|
||||
|
||||
Update Slicing Profile
|
||||
======================
|
||||
|
||||
.. http:patch:: /api/slicing/(string:slicer)/profiles/(string:key)
|
||||
|
||||
Updates the slicing profile identified by ``key`` for the slicer ``slicer``.
|
||||
|
||||
Expects a :ref:`profile update request <sec-api-slicing-datamodel-profileupdate>` as body.
|
||||
|
||||
Returns a :http:statuscode:`201` and an :ref:`abridged Profile <sec-api-slicing-datamodel-profile>` in the body
|
||||
upon successful completion.
|
||||
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:param slicer: The identifying key of the slicer for which to update the profile
|
||||
:param key: The identifying key of the profile to update
|
||||
:json data: New profile overrides to apply
|
||||
:json displayName: New display name
|
||||
:json description: New description
|
||||
:json default: Whether to make the profile default (true) or not (false) for the slicer
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: Slicer or profile do not exist
|
||||
|
||||
.. _sec-api-slicing-delete:
|
||||
|
||||
Delete Slicing Profile
|
||||
@@ -216,7 +247,7 @@ Delete Slicing Profile
|
||||
Delete the slicing profile identified by ``key`` for the slicer ``slicer``. If the profile doesn't exist, the
|
||||
request will succeed anyway.
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``SETTINGS`` permission.
|
||||
|
||||
:param slicer: The identifying key of the slicer for which to delete the profile
|
||||
:param key: The identifying key of the profile to delete
|
||||
@@ -340,3 +371,32 @@ Profile
|
||||
only the keys differing from the defaults when saving/updating a profile. The keys to be found in here a slicer
|
||||
specific. Will be left out for list responses.
|
||||
|
||||
.. _sec-api-slicing-datamodel-profileupdate:
|
||||
|
||||
Profile Update Request
|
||||
----------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``data``
|
||||
- 0..1
|
||||
- Object
|
||||
- The profile data
|
||||
* - ``displayName``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- The new display name for the profile
|
||||
* - ``description``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- The new description for the profile
|
||||
* - ``default``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
- Whether to mark the profile as default for the slicer (true) or not (false)
|
||||
+3
-1
@@ -6,7 +6,7 @@ System
|
||||
|
||||
.. note::
|
||||
|
||||
All system operations require admin rights.
|
||||
All system operations require the ``SYSTEM`` permission.
|
||||
|
||||
.. _sec-api-system-command-list:
|
||||
|
||||
@@ -20,6 +20,8 @@ List all registered system commands
|
||||
A :http:statuscode:`200` with a :ref:`List all response <sec-api-system-commands-listall>`
|
||||
will be returned.
|
||||
|
||||
Requires the ``SYSTEM`` permission.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@@ -18,6 +18,8 @@ Retrieve a list of timelapses and the current config
|
||||
Returns a :ref:`timelapse list <sec-api-timelapse-datamodel-list>` in the
|
||||
response body.
|
||||
|
||||
Requires the ``TIMELAPSE_LIST`` permission.
|
||||
|
||||
:param unrendered: If provided and true, also include unrendered timelapses
|
||||
|
||||
.. _sec-api-timelapse-delete:
|
||||
@@ -29,7 +31,7 @@ Delete a timelapse
|
||||
|
||||
Delete the timelapse ``filename``.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``TIMELAPSE_DELETE`` permission.
|
||||
|
||||
.. _sec-api-timelapse-render:
|
||||
|
||||
@@ -41,7 +43,7 @@ Issue a command for an unrendered timelapse
|
||||
Current only supports to render the unrendered timelapse ``name`` via the
|
||||
``render`` command.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``TIMELAPSE_ADMIN`` permission.
|
||||
|
||||
:json command: The command to issue, currently only ``render`` is supported
|
||||
|
||||
@@ -54,7 +56,7 @@ Delete an unrendered timelapse
|
||||
|
||||
Delete the unrendered timelapse ``name``.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``TIMELAPSE_DELETE`` permission.
|
||||
|
||||
.. _sec-api-timelapse-saveconfig:
|
||||
|
||||
@@ -67,7 +69,7 @@ Change current timelapse config
|
||||
|
||||
The configuration is expected as the request body.
|
||||
|
||||
Requires user rights.
|
||||
Requires the ``TIMELAPSE_ADMIN`` permission.
|
||||
|
||||
.. _sec-api-timelapse-datamodel:
|
||||
|
||||
|
||||
+2
-307
@@ -4,311 +4,6 @@
|
||||
User
|
||||
****
|
||||
|
||||
.. contents::
|
||||
.. note::
|
||||
|
||||
.. _sec-api-users-list:
|
||||
|
||||
Retrieve a list of users
|
||||
========================
|
||||
|
||||
.. http:get:: /api/users
|
||||
|
||||
Retrieves a list of all registered users in OctoPrint.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`user list response <sec-api-users-datamodel-userlistresponse>`
|
||||
as body.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:status 200: No error
|
||||
|
||||
.. _sec-api-users-retrieve:
|
||||
|
||||
Retrieve a user
|
||||
===============
|
||||
|
||||
.. http:get:: /api/users/(string:username)
|
||||
|
||||
Retrieves information about a user.
|
||||
|
||||
Will return a :http:statuscode:`200` with a :ref:`user record <sec-api-users-datamodel-userrecord>`
|
||||
as body.
|
||||
|
||||
Requires either admin rights or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user which to retrieve
|
||||
:status 200: No error
|
||||
:status 404: Unknown user
|
||||
|
||||
.. _sec-api-users-add:
|
||||
|
||||
Add a user
|
||||
==========
|
||||
|
||||
.. http:post:: /api/users
|
||||
|
||||
Adds a user to OctoPrint.
|
||||
|
||||
Expects a :ref:`user registration request <sec-api-users-datamodel-adduserrequest>`
|
||||
as request body.
|
||||
|
||||
Returns a list of registered users on success, see :ref:`Retrieve a list of users <sec-api-users-list>`.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:json name: The user's name
|
||||
:json password: The user's password
|
||||
:json active: Whether to activate the account (true) or not (false)
|
||||
:json admin: Whether to give the account admin rights (true) or not (false)
|
||||
:status 200: No error
|
||||
:status 400: If any of the mandatory fields is missing or the request is otherwise
|
||||
invalid
|
||||
:status 409: A user with the provided name does already exist
|
||||
|
||||
.. _sec-api-users-update:
|
||||
|
||||
Update a user
|
||||
=============
|
||||
|
||||
.. http:put:: /api/users/(string:username)
|
||||
|
||||
Updates a user record.
|
||||
|
||||
Expects a :ref:`user update request <sec-api-users-datamodel-updateuserrequest>`
|
||||
as request body.
|
||||
|
||||
Returns a list of registered users on success, see :ref:`Retrieve a list of users <sec-api-users-list>`.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:param username: Name of the user to update
|
||||
:json admin: Whether to mark the user as admin (true) or not (false), can be left out (no change)
|
||||
:json active: Whether to mark the account as activated (true) or deactivated (false), can be left out (no change)
|
||||
:status 200: No error
|
||||
:status 404: Unknown user
|
||||
|
||||
.. _sec-api-users-delete:
|
||||
|
||||
Delete a user
|
||||
=============
|
||||
|
||||
.. http:delete:: /api/users/(string:username)
|
||||
|
||||
Delete a user record.
|
||||
|
||||
Returns a list of registered users on success, see :ref:`Retrieve a list of users <sec-api-users-list>`.
|
||||
|
||||
Requires admin rights.
|
||||
|
||||
:param username: Name of the user to delete
|
||||
:status 200: No error
|
||||
:status 404: Unknown user
|
||||
|
||||
.. _sec-api-users-resetpassword:
|
||||
|
||||
Reset a user's password
|
||||
=======================
|
||||
|
||||
.. http:put:: /api/users/(string:username)/password
|
||||
|
||||
Changes the password of a user.
|
||||
|
||||
Expects a JSON object with a single property ``password`` as request body.
|
||||
|
||||
Requires admin rights or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to change the password for
|
||||
:json password: The new password to set
|
||||
:status 200: No error
|
||||
:status 400: If the request doesn't contain a ``password`` property or the request
|
||||
is otherwise invalid
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-users-getsettings:
|
||||
|
||||
Retrieve a user's settings
|
||||
==========================
|
||||
|
||||
.. http:get:: /api/users/(string:username)/settings
|
||||
|
||||
Retrieves a user's settings.
|
||||
|
||||
Will return a :http:statuscode:`200` with a JSON object representing the user's
|
||||
personal settings (if any) as body.
|
||||
|
||||
Requires admin rights or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 200: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-users-updatesettings:
|
||||
|
||||
Update a user's settings
|
||||
========================
|
||||
|
||||
.. http:patch:: /api/users/(string:username)/settings
|
||||
|
||||
Updates a user's settings.
|
||||
|
||||
Expects a new settings JSON object to merge with the current settings as
|
||||
request body.
|
||||
|
||||
Requires admin rights or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 204: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-users-generateapikey:
|
||||
|
||||
Regenerate a user's personal API key
|
||||
====================================
|
||||
|
||||
.. http:post:: /api/users/(string:username)/apikey
|
||||
|
||||
Generates a new API key for the user.
|
||||
|
||||
Does not expect a body. Will return the generated API key as ``apikey``
|
||||
property in the JSON object contained in the response body.
|
||||
|
||||
Requires admin rights or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 200: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-users-deleteapikey:
|
||||
|
||||
Delete a user's personal API key
|
||||
================================
|
||||
|
||||
.. http:delete:: /api/users/(string:username)/apikey
|
||||
|
||||
Deletes a user's personal API key.
|
||||
|
||||
Requires admin rights or to be logged in as the user.
|
||||
|
||||
:param username: Name of the user to retrieve the settings for
|
||||
:status 204: No error
|
||||
:status 403: No admin rights and not logged in as the user
|
||||
:status 404: The user is unknown
|
||||
|
||||
.. _sec-api-users-datamodel:
|
||||
|
||||
Data model
|
||||
==========
|
||||
|
||||
.. _sec-api-users-datamodel-userlistresponse:
|
||||
|
||||
User list response
|
||||
------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``users``
|
||||
- 0..n
|
||||
- List of :ref:`user records <sec-api-users-datamodel-userrecord>`
|
||||
- The list of registered users
|
||||
|
||||
.. _sec-api-users-datamodel-userrecord:
|
||||
|
||||
User record
|
||||
-----------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The user's name
|
||||
* - ``active``
|
||||
- 1
|
||||
- bool
|
||||
- Whether the user's account is active (true) or not (false)
|
||||
* - ``user``
|
||||
- 1
|
||||
- bool
|
||||
- Whether the user has user rights. Should always be true.
|
||||
* - ``admin``
|
||||
- 1
|
||||
- bool
|
||||
- Whether the user has admin rights (true) or not (false)
|
||||
* - ``apikey``
|
||||
- 0..1
|
||||
- string
|
||||
- The user's personal API key
|
||||
* - ``settings``
|
||||
- 1
|
||||
- object
|
||||
- The user's personal settings, might be an empty object.
|
||||
|
||||
.. _sec-api-users-datamodel-adduserrequest:
|
||||
|
||||
User registration request
|
||||
-------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- string
|
||||
- The user's name
|
||||
* - ``password``
|
||||
- 1
|
||||
- string
|
||||
- The user's password
|
||||
* - ``active``
|
||||
- 1
|
||||
- bool
|
||||
- Whether to activate the account (true) or not (false)
|
||||
* - ``admin``
|
||||
- 0..1
|
||||
- bool
|
||||
- Whether to give the user admin rights (true) or not (false or not present)
|
||||
|
||||
.. _sec-api-users-datamodel-updateuserrequest:
|
||||
|
||||
User update request
|
||||
-------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``active``
|
||||
- 0..1
|
||||
- bool
|
||||
- If present will set the user's active flag to the provided value. True for
|
||||
activating the account, false for deactivating it.
|
||||
* - ``admin``
|
||||
- 0..1
|
||||
- bool
|
||||
- If present will set the user's admin flag to the provided value. True for
|
||||
admin rights, false for no admin rights.
|
||||
This API endpoint has been moved and is now part of :ref:`Access Control <sec-api-access-users>`.
|
||||
+1
-1
@@ -99,7 +99,7 @@ Test paths or URLs
|
||||
The ``server`` command returns :http:statuscode:`200` with a :ref:`Server test result <sec-api-util-datamodel-servertestresult>`
|
||||
when the test could be performed. The status code of the response does NOT reflect the test result!
|
||||
|
||||
Requires admin rights.
|
||||
Requires the ``ADMIN`` permission.
|
||||
|
||||
**Example 1**
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ Wizard
|
||||
|
||||
.. note::
|
||||
|
||||
All wizard operations require either admin rights or the ``firstRun`` flag to be ``true``.
|
||||
All wizard operations require either the ``ADMIN`` permission or the ``firstRun`` flag to be ``true``.
|
||||
|
||||
.. contents::
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+49
-6
@@ -100,20 +100,44 @@ Shutdown
|
||||
The server is shutting down.
|
||||
|
||||
ClientOpened
|
||||
A client has connected to the web server.
|
||||
A client has connected to the push socket.
|
||||
|
||||
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
|
||||
|
||||
ClientClosed
|
||||
A client has disconnected from the webserver
|
||||
ClientAuthed
|
||||
A client has authenticated a user session on the push socket.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``remoteAddress``: the remote address (IP) of the client that disconnected
|
||||
* ``remoteAddress``: the remote address (IP) of the client that authed. On the push socket only available with a
|
||||
valid login session.
|
||||
* ``username``: the name of the user who authed. On the push socket only available with a valid login session.
|
||||
|
||||
ClientClosed
|
||||
A client has disconnected from the push socket.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``remoteAddress``: the remote address (IP) of the client that disconnected. On the push socket only available
|
||||
with a valid login session.
|
||||
|
||||
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 +175,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 +615,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 +627,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 +640,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 +651,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 +667,7 @@ SlicingProfileAdded
|
||||
* ``profile``: the profile that was added
|
||||
|
||||
SlicingProfileModified
|
||||
A new slicing profile was modified.
|
||||
A slicing profile was modified.
|
||||
|
||||
Payload:
|
||||
|
||||
@@ -661,3 +692,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
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ We'll start at the most basic form a plugin can take - just a few simple lines o
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_version__ = "1.0.0"
|
||||
__plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
|
||||
Saving this as ``helloworld.py`` in ``~/.octoprint/plugins`` yields you something resembling these log entries upon server startup::
|
||||
|
||||
@@ -75,7 +76,10 @@ Saving this as ``helloworld.py`` in ``~/.octoprint/plugins`` yields you somethin
|
||||
|
||||
OctoPrint found that plugin in the folder and took a look into it. The name and the version it displays in that log
|
||||
entry it got from the ``__plugin_name__`` and ``__plugin_version__`` lines. It also read the description from
|
||||
``__plugin_description__`` and stored it in an internal data structure, but we'll just ignore this for now.
|
||||
``__plugin_description__`` and stored it in an internal data structure, but we'll just ignore this for now. Additionally
|
||||
there is ``__plugin_pythoncompat__`` which tells OctoPrint here that your plugin can be run under any Python versions
|
||||
between 2.7 and 4. That is necessary so that your plugin will be loadable in OctoPrint instances running under either
|
||||
Python 2 or Python 3, and compatibility to both should be your goal.
|
||||
|
||||
.. _sec-plugins-gettingstarted-sayinghello:
|
||||
|
||||
@@ -86,7 +90,7 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t
|
||||
"Hello World!" to the log upon server startup. Modify our ``helloworld.py`` like this:
|
||||
|
||||
.. code-block:: python
|
||||
:emphasize-lines: 4-8,13
|
||||
:emphasize-lines: 4-8,14
|
||||
:linenos:
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
@@ -101,6 +105,7 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_version__ = "1.0.0"
|
||||
__plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
and restart OctoPrint. You now get this output in the log::
|
||||
@@ -284,7 +289,7 @@ of information now defined twice:
|
||||
|
||||
The nice thing about our plugin now being a proper Python package is that OctoPrint can and will access the metadata defined
|
||||
within ``setup.py``! So, we don't really need to define all this data twice. Remove ``__plugin_name__``, ``__plugin_version__``
|
||||
and ``__plugin_description__`` from ``__init__.py``:
|
||||
and ``__plugin_description__`` from ``__init__.py``, but leave ``__plugin_implementation__`` and ``__plugin_pythoncompat__``:
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
@@ -298,6 +303,7 @@ and ``__plugin_description__`` from ``__init__.py``:
|
||||
def on_after_startup(self):
|
||||
self._logger.info("Hello World!")
|
||||
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
and restart OctoPrint::
|
||||
@@ -324,6 +330,7 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the
|
||||
self._logger.info("Hello World!")
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
|
||||
@@ -373,6 +380,7 @@ add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class:
|
||||
self._logger.info("Hello World!")
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
Next, we'll create a sub folder ``templates`` underneath our ``octoprint_helloworld`` folder, and within that a file
|
||||
@@ -443,6 +451,7 @@ Let's take a look at how all that would look in our plugin's ``__init__.py``:
|
||||
return dict(url="https://en.wikipedia.org/wiki/Hello_world")
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
Restart OctoPrint. You should see something like this::
|
||||
@@ -480,6 +489,7 @@ Adjust your plugin's ``__init__.py`` like this:
|
||||
return dict(url=self._settings.get(["url"]))
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this:
|
||||
@@ -590,6 +600,7 @@ again since we don't use that anymore:
|
||||
]
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
Restart OctoPrint and shift-reload your browser. Your link in the navigation bar should still point to the URL we
|
||||
@@ -693,6 +704,7 @@ like so:
|
||||
)
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
Note how we did not add another entry to the return value of :func:`~octoprint.plugin.TemplatePlugin.get_template_configs`.
|
||||
@@ -875,6 +887,7 @@ a reference to our CSS file:
|
||||
)
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
OctoPrint by default bundles all CSS, JavaScript and LESS files to reduce the amount of requests necessary to fully
|
||||
@@ -961,6 +974,7 @@ Then adjust our returned assets to include our LESS file as well:
|
||||
)
|
||||
|
||||
__plugin_name__ = "Hello World"
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
__plugin_implementation__ = HelloWorldPlugin()
|
||||
|
||||
|
||||
|
||||
+88
-34
@@ -200,6 +200,94 @@ Available plugin hooks
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
.. _sec-plugins-hook-permissions:
|
||||
|
||||
octoprint.access.permissions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: additional_permissions_hook(*args, **kwargs)
|
||||
|
||||
Return a list of additional permissions to register in the system on behalf of the plugin. Use this
|
||||
to add granular permissions to your plugin which can be configured for users and user groups in the general
|
||||
access control settings of OctoPrint.
|
||||
|
||||
Additional permissions must be modelled as ``dict``s with at least a ``key`` and ``name`` field. Possible
|
||||
fields are as follows:
|
||||
|
||||
* ``key``: A key for the permission to be used for referring to it from source code. This will turned uppercase
|
||||
and prefixed with ``PLUGIN_<PLUGIN IDENTIFIER>_`` before being made available on ``octoprint.access.permissions.Permissions``,
|
||||
e.g. ``my_permission`` on the plugin with identifier ``example`` turns into ``PLUGIN_EXAMPLE_MY_PERMISSION`` and
|
||||
can be accessed as ``octoprint.access.permissions.Permissions.PLUGIN_EXAMPLE_MY_PERMISSION`` on the server and
|
||||
``permissions.PLUGIN_EXAMPLE_MY_PERMISSION`` on the ``AccessViewModel`` on the client. Must only contain a-z, A-Z, 0-9 and _.
|
||||
* ``name``: A human readable name for the permission.
|
||||
* ``description``: A human readable description of the permission.
|
||||
* ``permissions``: A list of permissions this permission includes, by key.
|
||||
* ``roles``: A list of roles this permission includes. Roles are simple strings you define. Usually one role will
|
||||
suffice.
|
||||
* ``dangerous``: Whether this permission should be considered dangerous (``True``) or not (``False``)
|
||||
* ``default_groups``: A list of standard groups this permission should be apply to by default. Standard groups
|
||||
are ``admins``, ``users``, ``readonly`` and ``guests``
|
||||
|
||||
The following example is based on some actual code included in the bundled Application Keys plugin and defines
|
||||
one additional permission called ``ADMIN`` with a role ``admin`` which is marked as dangerous (since it gives
|
||||
access to the management to other user's application keys) and by default will only be given to the standard admin
|
||||
group:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def get_additional_permissions(*args, **kwargs):
|
||||
return [
|
||||
dict(key="ADMIN",
|
||||
name="Admin access",
|
||||
description=gettext("Allows administrating all application keys"),
|
||||
roles=["admin"],
|
||||
dangerous=True,
|
||||
default_groups=[ADMIN_GROUP])
|
||||
]
|
||||
|
||||
__plugin_hooks__ = {
|
||||
"octoprint.access.permissions": get_additional_permissions
|
||||
}
|
||||
|
||||
Once registered it can be referenced under the key ``PLUGIN_APPKEYS_ADMIN``.
|
||||
|
||||
:return: A list of additional permissions to register in the system.
|
||||
:rtype: A list of dicts.
|
||||
|
||||
.. _sec-plugins-hook-users-factory:
|
||||
|
||||
octoprint.access.users.factory
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: user_manager_factory_hook(components, settings, *args, **kwargs)
|
||||
|
||||
Return a :class:`~octoprint.access.users.UserManager` instance to use as global user manager object. This will
|
||||
be called only once during initial server startup.
|
||||
|
||||
The provided ``components`` is a dictionary containing the already initialized system components:
|
||||
|
||||
* ``plugin_manager``: The :class:`~octoprint.plugin.core.PluginManager`
|
||||
* ``printer_profile_manager``: The :class:`~octoprint.printer.profile.PrinterProfileManager`
|
||||
* ``event_bus``: The :class:`~octoprint.events.EventManager`
|
||||
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
||||
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
||||
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
||||
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
||||
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
||||
|
||||
If the factory returns anything but ``None``, it will be assigned to the global ``userManager`` instance.
|
||||
|
||||
If none of the registered factories return a user manager instance, the class referenced by the ``config.yaml``
|
||||
entry ``accessControl.userManager`` will be initialized if possible, otherwise a stock
|
||||
:class:`~octoprint.access.users.FilebasedUserManager` will be instantiated, linked to the default user storage
|
||||
file ``~/.octoprint/users.yaml``.
|
||||
|
||||
:param dict components: System components to use for user manager instance initialization
|
||||
:param SettingsManager settings: The global settings manager instance to fetch configuration values from if necessary
|
||||
:return: The ``userManager`` instance to use globally.
|
||||
:rtype: UserManager subclass or None
|
||||
|
||||
|
||||
.. _sec-plugins-hook-accesscontrol-keyvalidator:
|
||||
|
||||
octoprint.accesscontrol.keyvalidator
|
||||
@@ -1525,40 +1613,6 @@ octoprint.ui.web.templatetypes
|
||||
:return: a list of 3-tuples (template type, rule, sorting spec)
|
||||
:rtype: list
|
||||
|
||||
.. _sec-plugins-hook-users-factory:
|
||||
|
||||
octoprint.access.users.factory
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. py:function:: user_manager_factory_hook(components, settings, *args, **kwargs)
|
||||
|
||||
Return a :class:`~octoprint.access.users.UserManager` instance to use as global user manager object. This will
|
||||
be called only once during initial server startup.
|
||||
|
||||
The provided ``components`` is a dictionary containing the already initialized system components:
|
||||
|
||||
* ``plugin_manager``: The :class:`~octoprint.plugin.core.PluginManager`
|
||||
* ``printer_profile_manager``: The :class:`~octoprint.printer.profile.PrinterProfileManager`
|
||||
* ``event_bus``: The :class:`~octoprint.events.EventManager`
|
||||
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
||||
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
||||
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
||||
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
||||
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
||||
|
||||
If the factory returns anything but ``None``, it will be assigned to the global ``userManager`` instance.
|
||||
|
||||
If none of the registered factories return a user manager instance, the class referenced by the ``config.yaml``
|
||||
entry ``accessControl.userManager`` will be initialized if possible, otherwise a stock
|
||||
:class:`~octoprint.access.users.FilebasedUserManager` will be instantiated, linked to the default user storage
|
||||
file ``~/.octoprint/users.yaml``.
|
||||
|
||||
:param dict components: System components to use for user manager instance initialization
|
||||
:param SettingsManager settings: The global settings manager instance to fetch configuration values from if necessary
|
||||
:return: The ``userManager`` instance to use globally.
|
||||
:rtype: UserManager subclass or None
|
||||
|
||||
|
||||
.. _sec-plugins-hook-timelapse-capture-pre:
|
||||
|
||||
octoprint.timelapse.capture.pre
|
||||
|
||||
@@ -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,18 +32,18 @@ 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
|
||||
|
||||
"Flask-Login>=0.4.1,<0.5",
|
||||
"Flask-Principal>=0.4,<0.5",
|
||||
"Flask-Babel>=0.12,<0.13",
|
||||
"Flask-Assets>=0.12,<0.13",
|
||||
"werkzeug>=0.15.1,<0.16",
|
||||
"blinker>=1.4,<1.5", # dependency of the now vendor bundled flask_principal
|
||||
"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 = []
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
#import sys
|
||||
#if sys.version_info[0] >= 3:
|
||||
# raise RuntimeError("Sorry, OctoPrint does not yet support Python 3")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import octoprint
|
||||
octoprint.main()
|
||||
@@ -18,32 +18,7 @@ from octoprint.settings import settings
|
||||
from octoprint.util import atomic_write
|
||||
from octoprint.access import ADMIN_GROUP, USER_GROUP, GUEST_GROUP, READONLY_GROUP
|
||||
from octoprint.access.permissions import Permissions, OctoPrintPermission
|
||||
from flask_principal import Need, Permission
|
||||
|
||||
DEFAULT_ADMIN_PERMISSIONS = [Permissions.ADMIN]
|
||||
"""Default admin permissions are the legacy permissions from before 1.4.0"""
|
||||
|
||||
DEFAULT_USER_PERMISSIONS = [Permissions.STATUS,
|
||||
Permissions.CONNECTION,
|
||||
Permissions.WEBCAM,
|
||||
Permissions.FILES_UPLOAD,
|
||||
Permissions.FILES_DOWNLOAD,
|
||||
Permissions.FILES_DELETE,
|
||||
Permissions.FILES_SELECT,
|
||||
Permissions.PRINT,
|
||||
Permissions.MONITOR_TERMINAL,
|
||||
Permissions.CONTROL,
|
||||
Permissions.SLICE,
|
||||
Permissions.TIMELAPSE_LIST,
|
||||
Permissions.TIMELAPSE_ADMIN]
|
||||
"""Default user permissions are the legacy permissions from before 1.4.0"""
|
||||
|
||||
DEFAULT_GUEST_PERMISSIONS = [Permissions.STATUS,
|
||||
Permissions.WEBCAM,
|
||||
Permissions.FILES_DOWNLOAD,
|
||||
Permissions.TIMELAPSE_LIST,
|
||||
Permissions.MONITOR_TERMINAL]
|
||||
"""Default guest permissions are the legacy permissions from before 1.4.0"""
|
||||
from octoprint.vendor.flask_principal import Need, Permission
|
||||
|
||||
|
||||
GroupNeed = partial(Need, 'group')
|
||||
|
||||
@@ -8,7 +8,7 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms
|
||||
from future.utils import with_metaclass
|
||||
from flask import g, abort
|
||||
from flask_babel import gettext
|
||||
from flask_principal import Permission, PermissionDenied, RoleNeed, Need
|
||||
from octoprint.vendor.flask_principal import Permission, PermissionDenied, RoleNeed, Need
|
||||
|
||||
from functools import wraps
|
||||
from collections import OrderedDict, defaultdict
|
||||
@@ -79,6 +79,22 @@ class OctoPrintPermission(Permission):
|
||||
def get_description(self):
|
||||
return self._description
|
||||
|
||||
def allows(self, identity):
|
||||
"""Whether the identity can access this permission.
|
||||
Overridden from Permission.allows to make sure the Identity provides ALL
|
||||
required needs instead of ANY required need.
|
||||
|
||||
:param identity: The identity
|
||||
"""
|
||||
if self.needs and len(self.needs.intersection(identity.provides)) != len(self.needs):
|
||||
return False
|
||||
|
||||
if self.excludes and self.excludes.intersection(identity.provides):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def union(self, other):
|
||||
"""Create a new OctoPrintPermission with the requirements of the union of this
|
||||
and other.
|
||||
@@ -259,8 +275,9 @@ class Permissions(with_metaclass(PermissionsMetaClass)):
|
||||
default_groups=[ADMIN_GROUP])
|
||||
|
||||
STATUS = OctoPrintPermission("Status",
|
||||
gettext("Allows to gather status information, e.g. job progress, "
|
||||
"printer state, temperatures, ..."),
|
||||
gettext("Allows to gather basic status information, e.g. job progress, "
|
||||
"printer state, temperatures, ... Mandatory for the default UI "
|
||||
"to work"),
|
||||
RoleNeed("status"),
|
||||
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||
|
||||
@@ -292,27 +309,26 @@ class Permissions(with_metaclass(PermissionsMetaClass)):
|
||||
FILES_DOWNLOAD = OctoPrintPermission("File Download",
|
||||
gettext("Allows users to download files. The GCODE viewer is "
|
||||
"affected by this as well."),
|
||||
RoleNeed("files_download"), FILES_LIST,
|
||||
RoleNeed("files_download"),
|
||||
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||
FILES_DELETE = OctoPrintPermission("File Delete",
|
||||
gettext("Allows users to delete files"),
|
||||
RoleNeed("files_delete"), FILES_LIST,
|
||||
RoleNeed("files_delete"),
|
||||
default_groups=[USER_GROUP])
|
||||
FILES_SELECT = OctoPrintPermission("File Select",
|
||||
gettext("Allows to select a file for printing"),
|
||||
RoleNeed("files_select"), FILES_LIST,
|
||||
RoleNeed("files_select"),
|
||||
default_groups=[USER_GROUP])
|
||||
|
||||
PRINT = OctoPrintPermission("Print",
|
||||
gettext("Allows to start, pause and cancel a print job. Includes the \"Select\" "
|
||||
"permission"),
|
||||
RoleNeed("print"), FILES_SELECT,
|
||||
gettext("Allows to start, pause and cancel a print job"),
|
||||
RoleNeed("print"),
|
||||
default_groups=[USER_GROUP])
|
||||
|
||||
GCODE_VIEWER = OctoPrintPermission("GCODE viewer",
|
||||
gettext("Allows access to the GCODE viewer. Includes the \"File Download\""
|
||||
"permission."),
|
||||
RoleNeed("gcodeviewer"), FILES_DOWNLOAD,
|
||||
gettext("Allows access to the GCODE viewer if the \"File Download\""
|
||||
"permission is also set."),
|
||||
RoleNeed("gcodeviewer"),
|
||||
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||
|
||||
MONITOR_TERMINAL = OctoPrintPermission("Terminal",
|
||||
@@ -351,8 +367,13 @@ class Permissions(with_metaclass(PermissionsMetaClass)):
|
||||
RoleNeed("timelapse_admin"), TIMELAPSE_LIST, TIMELAPSE_DOWNLOAD,
|
||||
default_groups=[USER_GROUP])
|
||||
|
||||
SETTINGS = OctoPrintPermission("Settings",
|
||||
gettext("Allows to manage settings"),
|
||||
SETTINGS_READ = OctoPrintPermission("Settings Access",
|
||||
gettext("Allows to read non sensitive settings. Mandatory for the "
|
||||
"default UI to work."),
|
||||
RoleNeed("settings_read"),
|
||||
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||
SETTINGS = OctoPrintPermission("Settings Admin",
|
||||
gettext("Allows to manage settings and also to read sensitive settings"),
|
||||
RoleNeed("settings"),
|
||||
dangerous=True)
|
||||
|
||||
|
||||
@@ -19,15 +19,18 @@ import logging
|
||||
# noinspection PyCompatibility
|
||||
from builtins import range, bytes
|
||||
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import atomic_write, to_bytes, deprecated, monotonic_time
|
||||
from octoprint.settings import settings as s
|
||||
|
||||
from octoprint.util import atomic_write, to_bytes, deprecated, monotonic_time, generate_api_key
|
||||
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):
|
||||
@@ -48,7 +55,10 @@ class UserManager(GroupChangeListener, object):
|
||||
if self.enabled:
|
||||
return AnonymousUser([self._group_manager.guest_group])
|
||||
else:
|
||||
return AdminUser([self._group_manager.admin_group])
|
||||
return AdminUser([self._group_manager.admin_group, self._group_manager.user_group])
|
||||
|
||||
def api_user_factory(self):
|
||||
return ApiUser([self._group_manager.admin_group, self._group_manager.user_group])
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
@@ -92,14 +102,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 +135,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 +168,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 +278,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 +289,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 +319,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 +449,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 +558,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 +697,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
|
||||
@@ -718,7 +746,7 @@ class FilebasedUserManager(UserManager):
|
||||
raise UnknownUser(username)
|
||||
|
||||
user = self._users[username]
|
||||
user._apikey = ''.join('%02X' % z for z in bytes(uuid.uuid4().bytes))
|
||||
user._apikey = generate_api_key()
|
||||
self._dirty = True
|
||||
self._save()
|
||||
return user._apikey
|
||||
@@ -1097,6 +1125,12 @@ class User(UserMixin):
|
||||
def groups(self):
|
||||
return list(self._groups)
|
||||
|
||||
@property
|
||||
def effective_permissions(self):
|
||||
if self._permissions is None:
|
||||
return []
|
||||
return list(filter(lambda p: p is not None and self.has_permission(p), Permissions.all()))
|
||||
|
||||
@property
|
||||
def needs(self):
|
||||
needs = set()
|
||||
@@ -1115,8 +1149,6 @@ class User(UserMixin):
|
||||
return self.has_needs(*permission.needs)
|
||||
|
||||
def has_needs(self, *needs):
|
||||
if Permissions.ADMIN in self._permissions:
|
||||
return True
|
||||
return set(needs).issubset(self.needs)
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -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", [])))
|
||||
@@ -46,6 +46,12 @@ class Events(object):
|
||||
# connect/disconnect by client
|
||||
CLIENT_OPENED = "ClientOpened"
|
||||
CLIENT_CLOSED = "ClientClosed"
|
||||
CLIENT_AUTHED = "ClientAuthed"
|
||||
CLIENT_DEAUTHED = "ClientDeauthed"
|
||||
|
||||
# user login/logout
|
||||
USER_LOGGED_IN = "UserLoggedIn"
|
||||
USER_LOGGED_OUT = "UserLoggedOut"
|
||||
|
||||
# File management
|
||||
UPLOAD = "Upload"
|
||||
@@ -227,14 +233,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:
|
||||
@@ -1008,7 +1008,7 @@ class PluginManager(object):
|
||||
# 1st pass: loading the plugins
|
||||
for name, plugin in added.items():
|
||||
try:
|
||||
if not plugin.blacklisted and not plugin.forced_disabled:
|
||||
if not plugin.blacklisted and not plugin.forced_disabled and not plugin.incompatible:
|
||||
self.load_plugin(name, plugin, startup=startup, initialize_implementation=initialize_implementations)
|
||||
except PluginNeedsRestart:
|
||||
pass
|
||||
@@ -1022,7 +1022,7 @@ class PluginManager(object):
|
||||
# 2nd pass: enabling those plugins that need enabling
|
||||
for name, plugin in added.items():
|
||||
try:
|
||||
if plugin.loaded and not plugin.forced_disabled:
|
||||
if plugin.loaded and not plugin.forced_disabled and not plugin.incompatible:
|
||||
if plugin.blacklisted:
|
||||
self.logger.warning("Plugin {} is blacklisted. Not enabling it.".format(plugin))
|
||||
continue
|
||||
@@ -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
|
||||
|
||||
@@ -15,12 +15,11 @@ import octoprint.plugin
|
||||
from octoprint.settings import valid_boolean_trues
|
||||
from octoprint.server.util.flask import restricted_access, no_firstrun_access
|
||||
from octoprint.server import NO_CONTENT, current_user, admin_permission
|
||||
from octoprint.util import atomic_write, monotonic_time, ResettableTimer
|
||||
from octoprint.util import atomic_write, monotonic_time, ResettableTimer, generate_api_key
|
||||
|
||||
from octoprint.access import ADMIN_GROUP
|
||||
from octoprint.access.permissions import Permissions
|
||||
|
||||
|
||||
CUTOFF_TIME = 10 * 60 # 10min
|
||||
POLL_TIMEOUT = 5 # 5 seconds
|
||||
|
||||
@@ -45,6 +44,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 +61,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 +86,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 +150,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 +380,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 +398,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
|
||||
return result
|
||||
|
||||
def _generate_key(self):
|
||||
return hexlify(os.urandom(16))
|
||||
return generate_api_key()
|
||||
|
||||
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://a09b5f846ab8459c88b61d01dfc97664@sentry.io/1373987"
|
||||
SENTRY_URL_COREUI = "https://86119a0040914e13b37b8bf47c35fffc@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>
|
||||
|
||||
@@ -12,6 +12,9 @@ import sarge
|
||||
from flask_babel import gettext
|
||||
from octoprint.util import RepeatedTimer
|
||||
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.access.groups import USER_GROUP
|
||||
|
||||
import octoprint.plugin
|
||||
import octoprint.events
|
||||
|
||||
@@ -19,14 +22,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 +147,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))
|
||||
|
||||
@@ -175,6 +190,17 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin,
|
||||
self._throttle_overheat = False
|
||||
self._throttle_functional = True
|
||||
|
||||
# Additional permissions hook
|
||||
|
||||
def get_additional_permissions(self):
|
||||
return [
|
||||
dict(key="STATUS",
|
||||
name="Status",
|
||||
description=gettext("Allows to check for the Pi's throttling status and environment info"),
|
||||
roles=["check"],
|
||||
default_groups=[USER_GROUP])
|
||||
]
|
||||
|
||||
#~~ EnvironmentDetectionPlugin
|
||||
|
||||
def get_additional_environment(self):
|
||||
@@ -188,6 +214,8 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin,
|
||||
#~~ SimpleApiPlugin
|
||||
|
||||
def on_api_get(self, request):
|
||||
if not Permissions.PLUGIN_PI_SUPPORT_STATUS.can():
|
||||
return flask.abort(403)
|
||||
result = dict(throttle_state=self._throttle_state.as_dict())
|
||||
result.update(self.get_additional_environment())
|
||||
return flask.jsonify(**result)
|
||||
@@ -237,11 +265,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 +331,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"
|
||||
|
||||
@@ -326,7 +352,8 @@ def __plugin_load__():
|
||||
|
||||
global __plugin_hooks__
|
||||
__plugin_hooks__ = {
|
||||
"octoprint.events.register_custom_events": register_custom_events
|
||||
"octoprint.events.register_custom_events": register_custom_events,
|
||||
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions
|
||||
}
|
||||
|
||||
global __plugin_helpers__
|
||||
|
||||
@@ -3,6 +3,9 @@ $(function() {
|
||||
function PiSupportViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = parameters[0];
|
||||
self.access = parameters[1];
|
||||
|
||||
self.model = ko.observable();
|
||||
|
||||
self.currentUndervoltage = ko.observable(false);
|
||||
@@ -13,6 +16,10 @@ $(function() {
|
||||
self.pastIssue = ko.observable(false);
|
||||
|
||||
self.requestData = function() {
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_PI_SUPPORT_STATUS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
OctoPrint.plugins.pi_support.get()
|
||||
.done(function(response) {
|
||||
// Raspberry Pi model
|
||||
@@ -70,11 +77,7 @@ $(function() {
|
||||
+ "<p><small>" + gettext("Click the symbol in the navbar for more information.") + "</small></p>";
|
||||
});
|
||||
|
||||
self.onStartup = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
self.onServerReconnect = function() {
|
||||
self.onStartup = self.onServerReconnect = self.onUserLoggedIn = self.onUserLoggedOut = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
@@ -82,6 +85,7 @@ $(function() {
|
||||
if (plugin !== "pi_support") return;
|
||||
if (!data.hasOwnProperty("state") || !data.hasOwnProperty("type")) return;
|
||||
if (data.type !== "throttle_state") return;
|
||||
if (!self.loginState.hasPermission(self.access.permissions.PLUGIN_PI_SUPPORT_STATUS)) return;
|
||||
|
||||
self.fromThrottleState(data.state);
|
||||
}
|
||||
@@ -89,6 +93,7 @@ $(function() {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: PiSupportViewModel,
|
||||
elements: ["#navbar_plugin_pi_support"]
|
||||
elements: ["#navbar_plugin_pi_support"],
|
||||
dependencies: ["loginStateViewModel", "accessViewModel"]
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
@@ -968,6 +1182,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
enabled=plugin.enabled,
|
||||
blacklisted=plugin.blacklisted,
|
||||
forced_disabled=plugin.forced_disabled,
|
||||
incompatible=plugin.incompatible,
|
||||
safe_mode_victim=getattr(plugin, "safe_mode_victim", False),
|
||||
pending_enable=(not plugin.enabled and not getattr(plugin, "safe_mode_victim", False) and plugin.key in self._pending_enable),
|
||||
pending_disable=((plugin.enabled or getattr(plugin, "safe_mode_victim", False)) and plugin.key in self._pending_disable),
|
||||
|
||||
@@ -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,29 +184,40 @@ $(function() {
|
||||
});
|
||||
|
||||
self.enableManagement = ko.pureComputed(function() {
|
||||
return !self.printerState.isPrinting();
|
||||
return !self.printerState.isBusy();
|
||||
});
|
||||
|
||||
self.enableToggle = function(data) {
|
||||
var command = self._getToggleCommand(data);
|
||||
var not_safemode_victim = !data.safe_mode_victim;
|
||||
var not_blacklisted = !data.blacklisted;
|
||||
return self.enableManagement() && (command == "disable" || (not_safemode_victim && not_blacklisted)) && data.key != 'pluginmanager';
|
||||
var not_incompatible = !data.incompatible;
|
||||
return self.enableManagement() && (command === "disable" || (not_safemode_victim && not_blacklisted && not_incompatible)) && data.key != 'pluginmanager';
|
||||
};
|
||||
|
||||
self.enableUninstall = function(data) {
|
||||
return self.enableManagement()
|
||||
&& (data.origin != "entry_point" || self.pipAvailable())
|
||||
&& (data.origin !== "entry_point" || self.pipAvailable())
|
||||
&& data.managable
|
||||
&& !data.bundled
|
||||
&& data.key != 'pluginmanager'
|
||||
&& data.key !== 'pluginmanager'
|
||||
&& !data.pending_uninstall;
|
||||
};
|
||||
|
||||
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.online() && self.isCompatible(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 +242,7 @@ $(function() {
|
||||
return self.enableManagement()
|
||||
&& self.pipAvailable()
|
||||
&& !self.safeMode()
|
||||
&& !self.throttled()
|
||||
&& self.online()
|
||||
&& url !== undefined
|
||||
&& url.trim() !== ""
|
||||
@@ -217,6 +268,7 @@ $(function() {
|
||||
return self.enableManagement()
|
||||
&& self.pipAvailable()
|
||||
&& !self.safeMode()
|
||||
&& !self.throttled()
|
||||
&& name !== undefined
|
||||
&& name.trim() !== ""
|
||||
&& !self.invalidArchive();
|
||||
@@ -267,9 +319,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 +346,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 +380,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 +423,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 +469,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 +485,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 +533,10 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.throttled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (url === undefined) {
|
||||
url = self.installUrl();
|
||||
}
|
||||
@@ -460,13 +550,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 +600,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 +781,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 +800,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 +857,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 +1049,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 +1254,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 +1278,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 class="fa fa-bolt" title="{{ _('Incompatible to OctoPrint or the underlying Python environment')|edq }}" data-bind="visible: incompatible"></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()
|
||||
|
||||
Loaded 100 of 220 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user