Compare commits
395
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b94e513960 | ||
|
|
875f69ea50 | ||
|
|
5b7639590c | ||
|
|
2cd627ec6a | ||
|
|
3cdc59d7f1 | ||
|
|
5156cdbe68 | ||
|
|
0915c45f72 | ||
|
|
b2c1bb4b53 | ||
|
|
8ad165c625 | ||
|
|
841b86a017 | ||
|
|
c0c249ece9 | ||
|
|
5fc194accd | ||
|
|
ed6c01c12a | ||
|
|
e309646504 | ||
|
|
96ee80afd2 | ||
|
|
8aec836d22 | ||
|
|
697df4f3ce | ||
|
|
ac3f4d598c | ||
|
|
836fbef6d8 | ||
|
|
ce4cf38547 | ||
|
|
38a5da1c35 | ||
|
|
b205e84d4b | ||
|
|
7ab4d12548 | ||
|
|
f6c3e5991d | ||
|
|
188b59a319 | ||
|
|
b3594e367e | ||
|
|
12d40122d1 | ||
|
|
2e11a7b860 | ||
|
|
f20185db3a | ||
|
|
0db323d0c5 | ||
|
|
639d8d4c5f | ||
|
|
5e0b53b651 | ||
|
|
1ebfa4b1dd | ||
|
|
35c45df86c | ||
|
|
a50e8bbbb5 | ||
|
|
4665070601 | ||
|
|
b34fc8e05e | ||
|
|
a3ece229f2 | ||
|
|
fc53febb87 | ||
|
|
dad956b5c9 | ||
|
|
981110d4b2 | ||
|
|
cbd94a9020 | ||
|
|
77db00a2ea | ||
|
|
665078e1a4 | ||
|
|
cfae406a4c | ||
|
|
00c14e6936 | ||
|
|
6a1b162e7b | ||
|
|
a2fd39b3c4 | ||
|
|
bda2fd94e3 | ||
|
|
9e207ca8a1 | ||
|
|
5d321926bb | ||
|
|
3d3e0212c6 | ||
|
|
e3d44d7d06 | ||
|
|
d39c124f35 | ||
|
|
8603ea4b6f | ||
|
|
a681048df6 | ||
|
|
d689496802 | ||
|
|
5a23b46c11 | ||
|
|
2b96e57923 | ||
|
|
885e88a5e0 | ||
|
|
fe481e12b3 | ||
|
|
cbdf85c27a | ||
|
|
674637f6b2 | ||
|
|
9056f5d610 | ||
|
|
b55c4ef5ca | ||
|
|
b9747d0f0e | ||
|
|
0feae3ba18 | ||
|
|
1cc3ddb03c | ||
|
|
33cafbbd8a | ||
|
|
d274a9c73d | ||
|
|
c3619a3795 | ||
|
|
dffb33727d | ||
|
|
78724163b1 | ||
|
|
b6a09abb83 | ||
|
|
77b6d83e0b | ||
|
|
7c6b85a0ad | ||
|
|
df038e6a4d | ||
|
|
ce1541e956 | ||
|
|
bd1d0e6073 | ||
|
|
ff89cdf6d0 | ||
|
|
76f58e05ec | ||
|
|
2a600d7d00 | ||
|
|
4a84fa95e4 | ||
|
|
557c761e80 | ||
|
|
10cb60acca | ||
|
|
5e55d637af | ||
|
|
8942d7d50d | ||
|
|
0ad09e422d | ||
|
|
0657160389 | ||
|
|
cfde6342a8 | ||
|
|
832c27ed18 | ||
|
|
59d78ba893 | ||
|
|
7770ee3d08 | ||
|
|
2d9ad41e49 | ||
|
|
821156c9d6 | ||
|
|
9e5982be29 | ||
|
|
39c87d19b7 | ||
|
|
d029abc8f3 | ||
|
|
7b5848b9c3 | ||
|
|
53bfbf5acf | ||
|
|
917c9e54ba | ||
|
|
d8d9c7fe64 | ||
|
|
6c0f2de780 | ||
|
|
700975d670 | ||
|
|
9fac314d71 | ||
|
|
9dfee34f01 | ||
|
|
dc8473bc4d | ||
|
|
c1c75f032d | ||
|
|
9ad180c02a | ||
|
|
7795320fc8 | ||
|
|
a54c8fbeb7 | ||
|
|
337957198b | ||
|
|
2bae87b85a | ||
|
|
51959319eb | ||
|
|
6d73e6557b | ||
|
|
4c65313c7f | ||
|
|
41cf85d9db | ||
|
|
3fbd477d15 | ||
|
|
2c73dd36c5 | ||
|
|
c91fe0c4fc | ||
|
|
3bfc4725d2 | ||
|
|
b6fbe6fafd | ||
|
|
263c297bed | ||
|
|
dba95ee94f | ||
|
|
f0b63a8e7f | ||
|
|
e166765f7f | ||
|
|
15e8bbe147 | ||
|
|
853bb2fc16 | ||
|
|
ccc3c4ef32 | ||
|
|
72898360f3 | ||
|
|
2caa10f15e | ||
|
|
399ec5a909 | ||
|
|
c844217f82 | ||
|
|
f32d7c434d | ||
|
|
844494a9d5 | ||
|
|
f1254622c5 | ||
|
|
060aa1274a | ||
|
|
fe0aa0301f | ||
|
|
cda48f3b71 | ||
|
|
c69ef1598a | ||
|
|
0161d915d6 | ||
|
|
f5fad5186e | ||
|
|
2817979c3d | ||
|
|
cc44c1a981 | ||
|
|
dda3a303d2 | ||
|
|
b79606da70 | ||
|
|
fb9131f67a | ||
|
|
358a252736 | ||
|
|
fd7c81c7fb | ||
|
|
a09b54d374 | ||
|
|
2a7cebfe55 | ||
|
|
0f6edabea3 | ||
|
|
45231ea7f8 | ||
|
|
c00b46ef5c | ||
|
|
251a1ea4b5 | ||
|
|
bba9d6cc18 | ||
|
|
9bcce4e56a | ||
|
|
6465175e09 | ||
|
|
fe585e7115 | ||
|
|
b84432c8a5 | ||
|
|
c6623c8883 | ||
|
|
ef01560199 | ||
|
|
1666a1f607 | ||
|
|
4109b2f6c2 | ||
|
|
9f32e91e05 | ||
|
|
7c8f148fa8 | ||
|
|
d1c6381792 | ||
|
|
a477268beb | ||
|
|
346f818707 | ||
|
|
956d9581c5 | ||
|
|
7828ab0bf9 | ||
|
|
41e9d96815 | ||
|
|
09d1025dfc | ||
|
|
163fd83bf5 | ||
|
|
e109bf0ca6 | ||
|
|
4d324c5239 | ||
|
|
8cbf5a74b3 | ||
|
|
b24851ca05 | ||
|
|
1219939189 | ||
|
|
d72c7c144e | ||
|
|
5c0a564592 | ||
|
|
d27dd26a61 | ||
|
|
52633d0433 | ||
|
|
ea3b7ab1da | ||
|
|
a01b9fe8d4 | ||
|
|
f1cf482919 | ||
|
|
18e14aa412 | ||
|
|
c3ad1d3691 | ||
|
|
35d9775e51 | ||
|
|
fda67f48ff | ||
|
|
e97c9f954d | ||
|
|
01ad9b8b14 | ||
|
|
2d105517c9 | ||
|
|
41d8b3476c | ||
|
|
97b2a02926 | ||
|
|
517fd6f3ab | ||
|
|
fb2f9ba593 | ||
|
|
3ec2d7bd14 | ||
|
|
675a54aa05 | ||
|
|
880b99faaf | ||
|
|
5535a9aeb0 | ||
|
|
3bc77ffe3d | ||
|
|
896aad3ab0 | ||
|
|
01e970553f | ||
|
|
6613d580f2 | ||
|
|
ac6900ffb6 | ||
|
|
6465b58384 | ||
|
|
fa73fd3c14 | ||
|
|
0a69dbeddb | ||
|
|
13714dc8d9 | ||
|
|
5a6edefec1 | ||
|
|
87be930a68 | ||
|
|
627d11fa51 | ||
|
|
315a80a7a7 | ||
|
|
1b91790f5f | ||
|
|
3e5923b21e | ||
|
|
c1fdbaa1e7 | ||
|
|
1c132c39ad | ||
|
|
7114462024 | ||
|
|
11b96005a9 | ||
|
|
fea6b5096c | ||
|
|
40e2fa6bf4 | ||
|
|
3006bde972 | ||
|
|
c7ae580c54 | ||
|
|
55762ee71a | ||
|
|
ebae1b475b | ||
|
|
61fbde4e51 | ||
|
|
6e793c2ba3 | ||
|
|
b38884db63 | ||
|
|
a49772fcf3 | ||
|
|
052796d5d2 | ||
|
|
559238ca3c | ||
|
|
fa16037e9a | ||
|
|
d298c3c672 | ||
|
|
d7b29a8725 | ||
|
|
136736d307 | ||
|
|
5d1a0eaa16 | ||
|
|
2d9c16e859 | ||
|
|
8a4934e6f8 | ||
|
|
a0e5f79483 | ||
|
|
ef6159cc96 | ||
|
|
ab42cc2a7f | ||
|
|
01cffafe77 | ||
|
|
d8f2630fd4 | ||
|
|
811c91955c | ||
|
|
01ebf8fba7 | ||
|
|
2dcd6e02b1 | ||
|
|
d845257cf4 | ||
|
|
c765e6e228 | ||
|
|
20e1219d9e | ||
|
|
14120f732b | ||
|
|
b7e2b0f794 | ||
|
|
f02fac20ed | ||
|
|
755bcaa311 | ||
|
|
aab98a7c9f | ||
|
|
3a984d41ff | ||
|
|
28d01e2fa6 | ||
|
|
2198add8e6 | ||
|
|
1de307e15d | ||
|
|
aab7b7f797 | ||
|
|
162e8c50d3 | ||
|
|
636d8e0faa | ||
|
|
62890ef73a | ||
|
|
79af90dd6a | ||
|
|
d15262e7cc | ||
|
|
41f0ed0124 | ||
|
|
ff595a7e31 | ||
|
|
444312d7d9 | ||
|
|
c3740dd59d | ||
|
|
c203d79434 | ||
|
|
6dce2bc250 | ||
|
|
cad66fcea7 | ||
|
|
ed46d9967a | ||
|
|
6aae0017c4 | ||
|
|
ebe93f9a6d | ||
|
|
a16680b453 | ||
|
|
9f963696c8 | ||
|
|
7f0eb8d895 | ||
|
|
e1eaf4eb8e | ||
|
|
b8cbe02b7a | ||
|
|
4cc410133b | ||
|
|
216f05d553 | ||
|
|
7beabf953c | ||
|
|
b7c078f429 | ||
|
|
7331bc2bf5 | ||
|
|
59f49f392e | ||
|
|
997e0b510b | ||
|
|
1f9b8f40cd | ||
|
|
8630ec5beb | ||
|
|
e8349d6593 | ||
|
|
9b457cce9e | ||
|
|
b2229ae24a | ||
|
|
189c842881 | ||
|
|
6963e5e495 | ||
|
|
7b6642f7c2 | ||
|
|
5d97dc4b40 | ||
|
|
b453897ea3 | ||
|
|
54a9a7b906 | ||
|
|
a3f24c59e9 | ||
|
|
42f4fad257 | ||
|
|
eaadf8743b | ||
|
|
b0cd742bf4 | ||
|
|
7ab3eabe0f | ||
|
|
8f3b6dca79 | ||
|
|
29a2c6abec | ||
|
|
9a464e01d8 | ||
|
|
37966644aa | ||
|
|
6393de8c7d | ||
|
|
9250cd0c3b | ||
|
|
6b2f28240e | ||
|
|
c8dfe363bc | ||
|
|
e20fcd9ce5 | ||
|
|
adbd6b7fa1 | ||
|
|
3da3cfd8a0 | ||
|
|
88a8bdf7b3 | ||
|
|
a948050c54 | ||
|
|
0d76df2cd5 | ||
|
|
3b5c2fe519 | ||
|
|
6f5ee4d291 | ||
|
|
507ddde9dd | ||
|
|
a646fff5ff | ||
|
|
6268e27dd7 | ||
|
|
caa84d7918 | ||
|
|
6d1e28ae9c | ||
|
|
1e482369b8 | ||
|
|
a6c4f8ba3b | ||
|
|
6bd788a83f | ||
|
|
4c971a92db | ||
|
|
5b3a7bed93 | ||
|
|
1f0e67f85e | ||
|
|
74597483dc | ||
|
|
cb89509bb2 | ||
|
|
c194fdbb28 | ||
|
|
b1057a4cc8 | ||
|
|
20cd13904d | ||
|
|
95e4ad82b4 | ||
|
|
9e3d2bed65 | ||
|
|
7f3d4a8380 | ||
|
|
e6dd37e26e | ||
|
|
d69c166f10 | ||
|
|
f6875c0df4 | ||
|
|
3ef7b37dc9 | ||
|
|
03085ab39b | ||
|
|
de0ee08e05 | ||
|
|
881d3bb212 | ||
|
|
fb5d5682e6 | ||
|
|
071c32fff1 | ||
|
|
7c74594f06 | ||
|
|
d83440d32d | ||
|
|
c0dff1359b | ||
|
|
2ab7fa4d3a | ||
|
|
f20e985d0d | ||
|
|
58f934e2c1 | ||
|
|
06eae381e4 | ||
|
|
50965d69ce | ||
|
|
6e474d9096 | ||
|
|
63c588fce9 | ||
|
|
f3f60674fc | ||
|
|
dc3182c872 | ||
|
|
6c9cac0eca | ||
|
|
101471235c | ||
|
|
6cc84a1473 | ||
|
|
ce1344eb0c | ||
|
|
84e8f8e1ca | ||
|
|
2669e79778 | ||
|
|
42e3922053 | ||
|
|
e121569e40 | ||
|
|
a735bcc18d | ||
|
|
726787e4db | ||
|
|
ce4e04cabf | ||
|
|
fcb0e382b5 | ||
|
|
0560009204 | ||
|
|
cb9fba73a2 | ||
|
|
cbbfb4af20 | ||
|
|
50e55ed30d | ||
|
|
d0ff9cb65e | ||
|
|
e458e3dd18 | ||
|
|
6773ae221d | ||
|
|
ccbf71a96a | ||
|
|
102727b122 | ||
|
|
d1f7d39ca9 | ||
|
|
81d426e5dd | ||
|
|
0e1f074634 | ||
|
|
3b2b262420 | ||
|
|
3caac586fc | ||
|
|
7f5d03d054 | ||
|
|
558a8957f9 | ||
|
|
8d2681ae3f | ||
|
|
0de6718af3 | ||
|
|
6d158cb0d0 | ||
|
|
e52fbf061d | ||
|
|
2aa74866ac | ||
|
|
3764eec9eb | ||
|
|
083601c978 | ||
|
|
4683fa3d25 |
No files matched your search
+45
-16
@@ -1,24 +1,34 @@
|
||||
READ THE FOLLOWING FIRST:
|
||||
|
||||
If not already done, please read the "guidelines for contributing"
|
||||
that are linked ^-- just up there in the big yellow box. Also read
|
||||
the FAQ: https://github.com/foosel/OctoPrint/wiki/FAQ.
|
||||
aka the Contribution Guidelines that are linked ^-- just up there
|
||||
in the big yellow box.
|
||||
|
||||
Also read the FAQ: https://github.com/foosel/OctoPrint/wiki/FAQ.
|
||||
|
||||
This is a bug and feature tracker, please only use it to report bugs
|
||||
or request features within OctoPrint (not OctoPi, not any OctoPrint
|
||||
plugins and not unofficial OctoPrint versions).
|
||||
|
||||
Do not seek support here ("I need help with ..."), that belongs on
|
||||
the mailing list or the G+ community (both linked in the "guidelines
|
||||
for contributing" linked above, read it!), NOT here.
|
||||
Do not seek support here ("I need help with ...", "I have a
|
||||
question ..."), that belongs on the mailing list or the G+ community
|
||||
(both linked in the "guidelines for contributing" linked above, read
|
||||
them!), NOT here.
|
||||
|
||||
Mark requests with a "[Request]" prefix in the title please. Fully fill
|
||||
out the bug reporting template for bug reports (if you don't know where
|
||||
to find some information - it's all described in the contribution
|
||||
guidelines linked up there in the big yellow box). Do not delete any
|
||||
lines from the template but those enclosed in [ and ] - and those please
|
||||
DO delete, they are only provided for your information and removing them
|
||||
makes your ticket more readable :)
|
||||
Mark requests with a "[Request]" prefix in the title please. For bug
|
||||
reports fully fill out the bug reporting template (if you don't know
|
||||
where to find some information - it's all described in the Contribution
|
||||
Guidelines linked up there in the big yellow box).
|
||||
|
||||
When reporting a bug do NOT delete ANY lines from the template but
|
||||
those enclosed in [ and ] - and those please DO delete, they are
|
||||
only provided for your information and removing them makes your
|
||||
ticket more readable :)
|
||||
|
||||
Make sure any bug you want to report is still present with the CURRENT
|
||||
OctoPrint version and that it does not vanish when you start OctoPrint
|
||||
in safe mode - how to do that is also explained in the Contribution
|
||||
Guidelines linked up there in the big yellow box.
|
||||
|
||||
Thank you!
|
||||
|
||||
@@ -34,6 +44,12 @@ by heart ;))
|
||||
reproduce your issue in order to fix it and that is not possible if they
|
||||
don't know what you did to get it to happen in the first place.
|
||||
|
||||
Ideally provide exact steps to follow in order to reproduce your problem:
|
||||
|
||||
1. ...
|
||||
2. ...
|
||||
3. ...
|
||||
|
||||
If you encountered a problem with specific files of any sorts, make sure
|
||||
to also include a link to a file with which to reproduce the problem.]
|
||||
|
||||
@@ -41,10 +57,20 @@ to also include a link to a file with which to reproduce the problem.]
|
||||
|
||||
#### What happened instead?
|
||||
|
||||
#### Did the same happen when running OctoPrint in safe mode?
|
||||
|
||||
[Try to reproduce your problem in safe mode. You can find information
|
||||
on how to enable safe mode in the Contribution Guidelines.]
|
||||
|
||||
#### Branch & Commit or Version of OctoPrint
|
||||
|
||||
[Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.]
|
||||
|
||||
#### Operating System running OctoPrint
|
||||
|
||||
[OctoPi, Linux, Windows, MacOS, something else? With version please.
|
||||
OctoPi's version can be found in /etc/octopi_version]
|
||||
|
||||
#### Printer model & used firmware incl. version
|
||||
|
||||
[If applicable, always include if unsure.]
|
||||
@@ -55,7 +81,8 @@ to also include a link to a file with which to reproduce the problem.]
|
||||
|
||||
#### Link to octoprint.log
|
||||
|
||||
[On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.]
|
||||
[On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
|
||||
The Contribution Guidelines tell you where to find that.]
|
||||
|
||||
#### Link to contents of terminal tab or serial.log
|
||||
|
||||
@@ -65,14 +92,16 @@ reporting communication issues. Never truncate.
|
||||
serial.log is usually not written due to performance reasons and must be
|
||||
enabled explicitly. Provide at the very least the FULL contents of your
|
||||
terminal tab at the time of the bug occurrence, even if you do not have
|
||||
a serial.log.]
|
||||
a serial.log (which the Contribution Guidelines tell you where to find).]
|
||||
|
||||
#### Link to contents of Javascript console in the browser
|
||||
|
||||
[On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
|
||||
always include if unsure or reporting UI issues.]
|
||||
always include if unsure or reporting UI issues.
|
||||
|
||||
#### Screenshot(s) showing the problem:
|
||||
The Contribution Guidelines tell you where to find that.]
|
||||
|
||||
#### Screenshot(s)/video(s) showing the problem:
|
||||
|
||||
[If applicable. Always include if unsure or reporting UI issues.]
|
||||
|
||||
|
||||
@@ -14,14 +14,15 @@ 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 (not master,
|
||||
maintenance or anything else)
|
||||
* [ ] Your PR targets OctoPrint's devel branch, or maintenance if it's
|
||||
a bug fix for an issue present in the current stable version (no PRs
|
||||
against master or anything else)
|
||||
* [ ] Your PR was opened from a custom branch on your repository
|
||||
(no PRs from your version of master, maintenance or devel please),
|
||||
e.g. dev/my_new_feature
|
||||
* [ ] Your PR only contains relevant changes: no unrelated files,
|
||||
no dead code, ideally only one commit - rebase your PR if necessary!
|
||||
* [ ] Your changes follow the coding style
|
||||
* [ ] Your changes follow the existing coding style
|
||||
* [ ] If your changes include style sheets: You have modified the
|
||||
.less source files, not the .css files (those are generated with
|
||||
lessc)
|
||||
|
||||
+9
-6
@@ -16,11 +16,14 @@ prerelease
|
||||
HEAD
|
||||
\(detached.*
|
||||
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.2.17
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.3.5
|
||||
# so are any fix/... and improve/... branches
|
||||
maintenance 1.2.17 354042b84d488db38ac1917bb69bd164f4e7f750 pep440-dev
|
||||
fix/.* 1.2.17 354042b84d488db38ac1917bb69bd164f4e7f750 pep440-dev
|
||||
improve/.* 1.2.17 354042b84d488db38ac1917bb69bd164f4e7f750 pep440-dev
|
||||
maintenance 1.3.5 fe481e12b3c50a2def3b41515200e13a8c6a5c72 pep440-dev
|
||||
fix/.* 1.3.5 fe481e12b3c50a2def3b41515200e13a8c6a5c72 pep440-dev
|
||||
improve/.* 1.3.5 fe481e12b3c50a2def3b41515200e13a8c6a5c72 pep440-dev
|
||||
|
||||
# every other branch is a development branch and thus gets resolved to 1.3.0-dev for now
|
||||
.* 1.3.0 198d3450d94be1a2 pep440-dev
|
||||
# staging/maintenance is currently the branch for preparation of 1.3.5rc1
|
||||
staging/maintenance 1.3.5rc1 fe481e12b3c50a2def3b41515200e13a8c6a5c72 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
|
||||
@@ -74,6 +74,13 @@ date of first contribution):
|
||||
* [Mathias Rangel Wulff](https://github.com/mathiasrw)
|
||||
* [Clemens Niemeyer](https://github.com/clemniem)
|
||||
* ["I-am-me"](https://github.com/I-am-me)
|
||||
* [Noah Martin](https://github.com/noahsmartin)
|
||||
* [Eyal Soha](https://github.com/eyal0)
|
||||
* [Greg Hulands](https://github.com/ghulands)
|
||||
* [Andreas Werner](https://github.com/gallore)
|
||||
* [Shawn Bruce](https://github.com/kantlivelong)
|
||||
* [Claudiu Ceia] (https://github.com/ClaudiuCeia)
|
||||
* [Goswin von Brederlow](https://github.com/mrvn)
|
||||
|
||||
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
|
||||
|
||||
+307
-86
@@ -1,85 +1,270 @@
|
||||
# OctoPrint Changelog
|
||||
|
||||
## 1.3.0rc3 (2016-12-02)
|
||||
## 1.3.4 (2017-06-01)
|
||||
|
||||
### Improvements
|
||||
### Note for owners of Malyan M200/Monoprice Select Mini
|
||||
|
||||
* Added note to JS client docs that it depends on JQuery and Lodash.
|
||||
* Improved a (manual) doctest
|
||||
OctoPrint's firmware autodetection is now able to detect this printer. Currently when this printer is detected, the following firmware specific features will be enabled automatically:
|
||||
|
||||
* Always assume SD card is present (`feature.sdAlwaysAvailable`)
|
||||
* Send a checksum with the command: Always (`feature.alwaysSendChecksum`)
|
||||
|
||||
Since the firmware is a very special kind of beast and its sources are so far unavailable, only tests with a real printer will show if those are sufficient settings for communication with this printer to fully function correctly. Thus, if you run into any issues with enabled firmware autodetection on this printer model, please add a comment in [#1762](https://github.com/foosel/OctoPrint/issues/1762) and explain what kind of communication problem you are seeing. Also make sure to include a [`serial.log`](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md#where-can-i-find-those-log-files-you-keep-talking-about)!
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* [#1599](https://github.com/foosel/OctoPrint/issues/1599) - Properly handle exceptions that arise within the update script during runtime.
|
||||
* Fix a rare race condition in the command line helper and the update script that could cause the code to hang due to waiting on an event that would never be set.
|
||||
* Fix issue with handling new settings substructures when they are compared to existing settings data in order to find the structural diff.
|
||||
* Fix for `/api/settings` not being properly invalidated for plugin settings that do not have a representation in `config.yaml` but are only added at runtime (and hence are not captured by `config.effective`).
|
||||
* Fix for the temperature graph not displaying the data history on site reload.
|
||||
* [#1942](https://github.com/foosel/OctoPrint/issues/1942) - Fixed crash on startup in case of an invalid default printer profile combined with "auto-connect on startup" being selected and the printer available to connect to.
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.0rc2...1.3.0rc3))
|
||||
### More information
|
||||
|
||||
## 1.3.0rc2 (2016-11-24)
|
||||
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.1...1.3.2)
|
||||
* Release Candidates:
|
||||
* None since this constitutes a hotfix release to fix an apparently very rare bug introduced with 1.3.3 that seems to be affecting a small number of users.
|
||||
|
||||
## 1.3.3 (2017-05-31)
|
||||
|
||||
### Note for owners of Malyan M200/Monoprice Select Mini
|
||||
|
||||
OctoPrint's firmware autodetection is now able to detect this printer. Currently when this printer is detected, the following firmware specific features will be enabled automatically:
|
||||
|
||||
* Always assume SD card is present (`feature.sdAlwaysAvailable`)
|
||||
* Send a checksum with the command: Always (`feature.alwaysSendChecksum`)
|
||||
|
||||
Since the firmware is a very special kind of beast and its sources are so far unavailable, only tests with a real printer will show if those are sufficient settings for communication with this printer to fully function correctly. Thus, if you run into any issues with enabled firmware autodetection on this printer model, please add a comment in [#1762](https://github.com/foosel/OctoPrint/issues/1762) and explain what kind of communication problem you are seeing. Also make sure to include a [`serial.log`](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md#where-can-i-find-those-log-files-you-keep-talking-about)!
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#478](https://github.com/foosel/OctoPrint/issues/478) - Made webcam stream container fixed height (with selectable aspect ratio) to prevent jumps of the controls beneath it on load.
|
||||
* [#748](https://github.com/foosel/OctoPrint/issues/748) - Added delete confirmation and bulk delete for timelapses. See also the discussion in brainstorming ticket [#1807](https://github.com/foosel/OctoPrint/issues/1807).
|
||||
* [#1092](https://github.com/foosel/OctoPrint/issues/1092) - Added new events to the file manager: `FileAdded`, `FileRemoved`, `FolderAdded`, `FolderRemoved`. Contrary to the `Upload` event, `FileAdded` will always fire when a file was added to storage through the file manager, not only when added through the web interface. Extended documentation accordingly.
|
||||
* [#1521](https://github.com/foosel/OctoPrint/issues/1521) - Software update plugin: Display timestamp of last version cache refresh in "Advanced options" area.
|
||||
* [#1734](https://github.com/foosel/OctoPrint/issues/1734) - Treat default/initial printer profile like all other printer profiles, persisting it to disk instead of `config.yaml` and allowing deletion. OctoPrint will migrate the existing default profile to the new location on first start.
|
||||
* [#1734](https://github.com/foosel/OctoPrint/issues/1734) - Better communication of what actions are available for printer profiles.
|
||||
* [#1739](https://github.com/foosel/OctoPrint/issues/1739) - Software update plugin: Added option to hide update notification from users without admin rights, added "ignore" button and note to get in touch with an admit to update notifications for non admin users.
|
||||
* [#1762](https://github.com/foosel/OctoPrint/issues/1762) - Added Malyan M200/Monoprice Select Mini to firmware autodetection.
|
||||
* [#1811](https://github.com/foosel/OctoPrint/issues/1811) - Slight rewording and rearrangement in timelapse configuration, better feedback if settings have been saved.
|
||||
* [#1818](https://github.com/foosel/OctoPrint/issues/1818) - Support both Marlin/Repetier and Smoothieware interpretations of `G90` after an `M83` in GCODE viewer and analysis. Select "G90/G91 overrides relative extruder mode" in Settings > Features for the Smoothieware interpretation.
|
||||
* [#1858](https://github.com/foosel/OctoPrint/issues/1858) - Announcement plugin: Images from registered feeds now are lazy loading.
|
||||
* [#1862](https://github.com/foosel/OctoPrint/issues/1862) - Automatically re-enable fancy terminal functionality when performance recovers.
|
||||
* [#1875](https://github.com/foosel/OctoPrint/issues/1875) - Marked the command input field in the Terminal tab as not supporting autocomplete to work around an issue in Safari. Note that this is probably only a temporary workaround due to browser vendors [working on deprecating `autocomplete="off"` support](https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164) and a different solution will need to be found in the future.
|
||||
* Added link to [`SerialException` FAQ entry](https://github.com/foosel/OctoPrint/wiki/FAQ#octoprint-randomly-loses-connection-to-the-printer-with-a-serialexception) to terminal output when such an error is encountered, as suggested in [#1876](https://github.com/foosel/OctoPrint/issues/1876).
|
||||
* Force refresh of settings on login/logout.
|
||||
* Made system wide API key management mirror user API key management.
|
||||
* Make sure to always migrate and merge saved printer profiles with default profile to ensure all parameters are set. Should avoid issues with plugins trying to save outdated/incomplete profiles.
|
||||
* Added note on lack of language pack repository & to use the wiki for now.
|
||||
* Earlier validation of file to select for printing.
|
||||
* Limit verbosity of failed system event handlers.
|
||||
* Made bundled python client `octoprint_client` support multiple client instances.
|
||||
* Disable "Reload" button in the "Please reload" overlay once clicked, added spinner.
|
||||
* Updated pnotify to 2.1.0.
|
||||
* Get rid of ridiculous float precision in temperature commands.
|
||||
* Detect invalid settings data to persist (not a dict), send 400 status in such a case.
|
||||
* More logging for preemptive caching, to help narrow down any performance issues that might be related to this.
|
||||
* Further decoupling of some startup tasks from initial server startup thread for better parallelization and improved startup times.
|
||||
* Announcement plugin: Added combined OctoBlog feed, replacing news and spotlight feed, added corresponding config migration.
|
||||
* Announcement plugin: Subscribe to all registered feeds by default to ensure better communication flow (all subscriptions but the "Important" channel can however be unsubscribed easily, added corresponding note to the notifications and also a configuration button to the announcement reader).
|
||||
* Announcement plugin: Auto-hide announcements on logout.
|
||||
* Announcement plugin: Order channels server-side based on new order config setting.
|
||||
* Plugin manager: Show warning when disabling a bundled plugin that is not recommended to be disabled, including a reason why disabling it is not recommended. Applies to the bundled announcement, core wizard, discovery and software update plugins.
|
||||
* Plugin manager: Support for plugin notices for specific plugins from the plugin repository, e.g. to inform users of specific plugins about known issues with the plugin or instruct to update when the software update mechanism of the current plugin version turns out to be misconfigured. Supports matching installed plugin versions and OctoPrint versions to target only affected users.
|
||||
* Plugin manager: Better visualization of plugins disabled on the repository, no longer shown as "incompatible" but "disabled", with link to the plugin repository page that contains more information.
|
||||
* Plugin manager: Detect necessity to reinstall a plugin provided through archive URL or upload and immediately do that instead of reporting an "unknown error" without further information.
|
||||
* Plugin manager: Added `freebsd` for compatibility check.
|
||||
* Plugin manager: More general flexibility for OS compatibility check:
|
||||
* Support for arbitrary values to match against
|
||||
* Allow 1:1 check again `sys.platform` values (with `startswith`).
|
||||
* Support black listing (`!windows`) additionally to white listing. A detected OS must match all provided white list elements (if the white list is empty that is considered to be always the case) and none of the black list elements (if the black list is empty that is also considered to be always the case).
|
||||
* Software update plugin: New check type `bitbucket_commit` (see also [#1898](https://github.com/foosel/OctoPrint/pull/1898))
|
||||
* Docs: Now referring to dedicated Jinja 2.8 documentation as hosted at [jinja.octoprint.org](http://jinja.octoprint.org) for all template needs, to avoid confusion when consulting current Jinja documentation as available on its project page (2.9+, which OctoPrint can't upgrade to due to backwards incompatible changes).
|
||||
* Docs: Better documentation of what kind of input the `FileManager` accepts for `select_file`.
|
||||
* Docs: Specified OctoPrint version required for plugin tutorial.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* [#202](https://github.com/foosel/OctoPrint/issues/202) - Fixed an issue with the drag-n-drop area flickering if the mouse was moved too slow while dragging (see also [#1867](https://github.com/foosel/OctoPrint/pull/1867)).
|
||||
* [#1671](https://github.com/foosel/OctoPrint/issues/1671) - Removed obsolete entry of no longer available filter for empty folders from file list options.
|
||||
* [#1821](https://github.com/foosel/OctoPrint/issues/1821) - Properly reset "Capture post roll images" setting in timelapse configuration when switching from "off" to "timed" timelapse mode.
|
||||
* [#1822](https://github.com/foosel/OctoPrint/issues/1822) - Properly reset file metadata when a file is overwritten with a new version.
|
||||
* [#1836](https://github.com/foosel/OctoPrint/issues/1836) - Fixed order of `PrintCancelled` and `PrintFailed` events on print cancel.
|
||||
* [#1837](https://github.com/foosel/OctoPrint/issues/1837) - Fixed a race condition causing OctoPrint trying to read data from the current job on job cancel that was no longer there.
|
||||
* [#1838](https://github.com/foosel/OctoPrint/issues/1838) - Fixed a rare race condition causing an error right at the very start of a print.
|
||||
* [#1863](https://github.com/foosel/OctoPrint/issues/1863) - Fixed an issue in the analysis of GCODE files containing coordinate offsets for X, Y or Z via `G92`, leading to a wrong calculation of the model size thanks to accumulating offsets.
|
||||
* [#1882](https://github.com/foosel/OctoPrint/issues/1882) - Fixed a rare race condition occurring at the start of streaming a file to the printer's SD card, leading to endless line number mismatches.
|
||||
* [#1884](https://github.com/foosel/OctoPrint/issues/1884) - CuraEngine plugin: Fixed a potential encoding issue when logging non-ASCII parameters supplied to CuraEngine
|
||||
* [#1891](https://github.com/foosel/OctoPrint/issues/1891) - Fixed error when handling unicode passwords.
|
||||
* [#1893](https://github.com/foosel/OctoPrint/issues/1893) - CuraEngine plugin: Fixed handling of multiple consecutive uploads of slicing profiles (see also [#1894](https://github.com/foosel/OctoPrint/issues/1894))
|
||||
* [#1897](https://github.com/foosel/OctoPrint/issues/1897) - Removed possibility to concurrently try to perform multiple tests of the configured snapshot URL.
|
||||
* [#1906](https://github.com/foosel/OctoPrint/issues/1906) - Fixed interpretation of `G92` in GCODE analysis.
|
||||
* [#1907](https://github.com/foosel/OctoPrint/issues/1907) - Don't send temperature commands with tool parameter when a shared nozzle is defined.
|
||||
* [#1917](https://github.com/foosel/OctoPrint/issues/1917) (regression) - Fix job data resetting on print job completion.
|
||||
* [#1918](https://github.com/foosel/OctoPrint/issues/1918) (regression) - Fix "save as default" checkbox not being disabled when other controls are disabled.
|
||||
* [#1919](https://github.com/foosel/OctoPrint/issues/1919) (regression) - Fix call to no longer existing function in Plugin Manager UI.
|
||||
* [#1934](https://github.com/foosel/OctoPrint/issues/1934) (regression) - Fix consecutive timed timelapse captures without configured post roll.
|
||||
* Fixed API key QR Code being shown (for "n/a" value) when no API key was set.
|
||||
* Fixed timelapse configuration API not returning 400 status code on some bad parameters.
|
||||
* Fixed a typo (see also [#1826](https://github.com/foosel/OctoPrint/pull/1826)).
|
||||
* Fixed `filter` and `force` parameters on `/api/files/<origin>`.
|
||||
* Fixed message catchall `*` not working in the socket client library.
|
||||
* Fixed analysis backlog calculation for sub folders.
|
||||
* Fixed `PrinterInterface.is_ready` to behave as documented.
|
||||
* Use black listing instead of white listing again to detect if the `daemon` sub command is supported or not. Should resolve issues users of FreeBSD and the like where having with `octoprint daemon`.
|
||||
* Use `pip` instead of `python setup.py develop` in `octoprint dev plugin:install` command to avoid issues on Windows.
|
||||
* Docs: Fixed a wrong command in the plugin tutorial (see also [#1860](https://github.com/foosel/OctoPrint/pull/1860)).
|
||||
|
||||
### More information
|
||||
|
||||
- [Commits](https://github.com/foosel/OctoPrint/compare/1.3.2...1.3.3)
|
||||
- Release Candidates:
|
||||
- [1.3.3rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.3rc1)
|
||||
- [1.3.3rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.3rc2)
|
||||
- [1.3.3rc3](https://github.com/foosel/OctoPrint/releases/tag/1.3.3rc3)
|
||||
|
||||
## 1.3.2 (2017-03-16)
|
||||
|
||||
### Note for plugin authors
|
||||
|
||||
**If you maintain a plugin that extends OctoPrint's [JavaScript Client Library](http://docs.octoprint.org/en/master/jsclientlib/index.html)** like demonstrated in e.g. the bundled Software Update Plugin you'll need to update the way you register your plugin to depend on `OctoPrintClient` and registering your extension as shown [here](https://github.com/foosel/OctoPrint/blob/6e793c2/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js#L1-L84) instead of directly writing to `OctoPrint.plugins` (like it was still done [here](https://github.com/foosel/OctoPrint/blob/23744cd/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js#L1-L81)). That way your extensions will be available on all instances of `OctoPrintClient`, not just the global instance `OctoPrint` that gets created on startup of the core web interface.
|
||||
|
||||
If all you plugin does with regards to JavaScript is registering a custom view model and you have no idea what I'm talking about regarding extending the client library, no action is necessary. This heads-up is really only relevant if you extended the JavaScript Client Library.
|
||||
|
||||
### Improvements
|
||||
|
||||
- [#732](https://github.com/foosel/OctoPrint/pull/732) - Have OctoPrint's `python setup.py clean` build on stock
|
||||
`python setup.py clean` for better compatibility with packaging systems
|
||||
- [#1506](https://github.com/foosel/OctoPrint/issues/1506) - Better handle really long "dwell"/`G4` commands on Repetier firmware (as for example apparently recommended to use with Wanhao D6 and similar printers for nozzle cooling) by actively stalling communication from OctoPrint's side as well. That way we no longer run into a communication timeout produced by a 5min dwell immediately happily acknowledged by the printer with an `ok`.
|
||||
- [#1542](https://github.com/foosel/OctoPrint/issues/1542) - Support for multi-extruder setups with a shared single nozzle and heater (e.g. E3D Cyclops, Diamond hotend, etc).
|
||||
- [#1676](https://github.com/foosel/OctoPrint/issues/1676) - Trigger line number reset when connected to printer and seeing `start` message. This should fix issues with printer communication when printer resets but reset goes otherwise undetected.
|
||||
- [#1681](https://github.com/foosel/OctoPrint/issues/1681) - Support for connecting to multiple OctoPrint instances via the [JavaScript Client Library](http://docs.octoprint.org/en/master/jsclientlib/index.html).
|
||||
- [#1712](https://github.com/foosel/OctoPrint/issues/1712) - Display current folder name in file list if in sub folder.
|
||||
- [#1723](https://github.com/foosel/OctoPrint/issues/1723) - Ignore leading `v` or `V` on plugin version numbers for version checks in plugin manager and software updater (see also [#1724](https://github.com/foosel/OctoPrint/pull/1724))
|
||||
- [#1770](https://github.com/foosel/OctoPrint/issues/1770) - Better resilience against null bytes received from the printer for whatever reason.
|
||||
- [#1770](https://github.com/foosel/OctoPrint/issues/1770) - Detect printer as connected even when only receiving a `wait` instead of `ok`. Should solve issues with initial connect where printer sends garbage over the line that eats/covers the `ok` if printer also sends regular `wait` messages when idle.
|
||||
- [#1780](https://github.com/foosel/OctoPrint/issues/1780) - Work around for Safari re-opening one copy of the webcam stream after the other and eating up bandwidth unnecessarily (see also [#1786](https://github.com/foosel/OctoPrint/issues/1786))
|
||||
- [#1790](https://github.com/foosel/OctoPrint/issues/1790) - Removed unused "color" property from printer profile editor.
|
||||
- [#1805](https://github.com/foosel/OctoPrint/issues/1805) - Better error resilience against invalid print history data from plugins that replace the printer communication.
|
||||
- Better error resilience in Plugin Manager against wonky version data in repository file.
|
||||
- Added a "Restart in safe mode" system menu entry that will always be available if the restart command is configured
|
||||
- CLI: Only offer `daemon` sub command on Linux (since that it's the only OS it works on)
|
||||
- Less throttling of analysis of GCODE files from the analysis backlog. Should still leave Pi and friends air to breathe but allow a slightly faster processing of the backlog.
|
||||
- Added an explanation of safe mode to the docs.
|
||||
- Log OctoPrint version & plugin list when detecting log rollover.
|
||||
- Allow `UiPlugin`s to define additional fields for ETag generation.
|
||||
- Allow `UiPlugin`s utilizing OctoPrint's stock templates to filter out what they don't need.
|
||||
- Locales contained in `translations` of plugins will now be registered with the system. That way it's possible to provide translations for the full application through plugins.
|
||||
- Abort file analysis if file is about to be overwritten
|
||||
- Software Update Plugin: Refresh cache on startup, prevent concurrent refresh
|
||||
- More solid parsing of request line number for resend requests. Should improve compatibility with Teacup firmwares. Based on issue reported via PR [#300](https://github.com/foosel/OctoPrint/pull/300)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- [#733](https://github.com/foosel/OctoPrint/issues/733) - Fixed multiple event handler commands running concurrently. Now they run one after the other, as expected.
|
||||
- [#1317](https://github.com/foosel/OctoPrint/issues/1317) - Fixed a color distortion issue when rendering timelapses from higher resolution source snapshots that also need to be rotated by adjusting `ffmpeg` parameters to avoid an unexpected behaviour when a pixel format and a filter chain are required for processing.
|
||||
- [#1560](https://github.com/foosel/OctoPrint/issues/1560) - Make sure we don't try to use an empty `logging.yaml`
|
||||
- [#1631](https://github.com/foosel/OctoPrint/issues/1631) - Disable "Slice" button in slice dialog if a print is ongoing and a slicer is selected that runs on the same device as OctoPrint. The server would already deny such requests (simply due to performance reasons), but the UI didn't properly reflect that yet.
|
||||
- [#1671](https://github.com/foosel/OctoPrint/issues/1671) - Removed "Hide empty folders" option from file list. Didn't really add value and caused usability issues.
|
||||
- [#1771](https://github.com/foosel/OctoPrint/issues/1771) - Fixed `_config_version` in plugin settings not being properly updated.
|
||||
- [#1732](https://github.com/foosel/OctoPrint/issues/1732) - Fixed a bug in the documentation for the printer profile API
|
||||
- [#1760](https://github.com/foosel/OctoPrint/issues/1760) - Fixed missing reselect of selected file when updating via the watched folder, causing wrong progress percentages to be reported.
|
||||
- [#1765](https://github.com/foosel/OctoPrint/issues/1765) - Fixed watched folder not waiting with file move until file stopped growing, causing wrong progress percentages to be reported.
|
||||
- [#1777](https://github.com/foosel/OctoPrint/issues/1777) - Fixed z-change based timelapses with Slic3r generated z-hops not properly triggering snapshots.
|
||||
- [#1792](https://github.com/foosel/OctoPrint/issues/1792) - Don't tell Safari we are "web-app-capable" because that means it will throw away all cookies and the user will have to constantly log in again when using a desktop shortcut for the OctoPrint instance.
|
||||
- [#1812](https://github.com/foosel/OctoPrint/issues/1812) - Don't scroll up navigation in settings when switching between settings screens, very annoying on smaller resolutions (see also [#1814](https://github.com/foosel/OctoPrint/pull/1814))
|
||||
- Fix settings helper not allowing to delete values for keys that are present in the local config but not in the defaults.
|
||||
- Fix wrong replacement value for `__progress` in registered command line or GCODE [event handlers](http://docs.octoprint.org/en/master/events/index.html).
|
||||
- Various fixes in the Software Update Plugin:
|
||||
- Don't remove manual software update configurations on settings migration.
|
||||
- Properly delete old restart/reboot commands that are now defined globally since config version 4. An issue with the settings helper prevented us from properly deleting them during migration to version 4.
|
||||
- Fixed `python_checker` version check method and `python_updater` update method.
|
||||
- Fixed update configs without a restart of any kind causing an issue due to an undefined variable.
|
||||
- Fixed broken doctests.
|
||||
- Upgrade LESS.min.js from 2.7.1 to 2.7.2 to fix the broken contrast function
|
||||
- Always create a new user session for requests with an API key
|
||||
- Fixed an error when reading all user settings via the API
|
||||
- Fixed a bunch of caching issues for the page, was not properly updated on change of snapshot URL presence, system menu entry presence, gcode viewer enabled/disabled, changes in access control availability.
|
||||
- Fixed wrong bundling of core and plugin assets
|
||||
- Software Update Plugin: Fixed wrong ETag calculation
|
||||
- Disable external heatup detection until firmware is detected
|
||||
- Fixed login dropdown not closing on click outside of it
|
||||
- Fixed new user settings getting lost until restart
|
||||
- Don't call `onUserLoggedIn`/`onUserLoggedOut` on user reload
|
||||
|
||||
### More information
|
||||
|
||||
- [Commits](https://github.com/foosel/OctoPrint/compare/1.3.1...1.3.2)
|
||||
- Release Candidates:
|
||||
- [1.3.2rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.2rc1)
|
||||
|
||||
## 1.3.1 (2017-01-25)
|
||||
|
||||
### Note for upgraders
|
||||
|
||||
#### If you installed OctoPrint manually and used the included init script, you need to update that
|
||||
|
||||
The init script so far shipped with OctoPrint contained a [bug](https://github.com/foosel/OctoPrint/issues/1657) that causes issues with OctoPrint 1.3.0 and higher. Please update your init script to the fixed version OctoPrint now ships under `scripts`:
|
||||
|
||||
```
|
||||
sudo cp /path/to/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint
|
||||
```
|
||||
|
||||
If you are running OctoPi, this does **not** apply to you and you do not need to do anything here!
|
||||
|
||||
#### Change in stock terminal filter configuration
|
||||
|
||||
1.3.1 fixes an issue with the two terminal filters for suppressing temperature and SD status messages and adds a new filter for filtering out firmware `wait` messages. These changes will only be active automatically though for stock terminal filter configurations. If you have customized your terminal filters, you'll need to apply these changes manually under "Settings > Terminal filters":
|
||||
- Changed "Suppress temperature messages" filter, new regex is `(Send: (N\d+\s+)?M105)|(Recv: ok (B|T\d*):)`
|
||||
- Changed "Suppress SD status messages" filter, new regex is `(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)`
|
||||
- New "Suppress wait responses" filter, regex is `Recv: wait`
|
||||
|
||||
### Improvements
|
||||
- [#1607](https://github.com/foosel/OctoPrint/issues/1607) - Way better support for password managers (e.g. browser built-in, 1Password, Lastpass, Dashlane)
|
||||
- [#1638](https://github.com/foosel/OctoPrint/issues/1638) - Make confirmation dialog when cancelling a print optional.
|
||||
- [#1656](https://github.com/foosel/OctoPrint/issues/1656) - Make wording of buttons on print cancel dialog less confusing.
|
||||
- [#1705](https://github.com/foosel/OctoPrint/pull/1705) - Simplified install process on Mac by removing dependency on pyobjc.
|
||||
- [#1706](https://github.com/foosel/OctoPrint/pull/1706) - Added a mask icon for Safari pinned tab and touchbar.
|
||||
- Support extraction of filament diameter for volume calculation from GCODE files sliced through Simplify3D.
|
||||
- Abort low priority jobs in the file analysis queue when a high priority job comes in - should make file analysis and hence time estimates show up faster for newly uploaded files.
|
||||
- Added a terminal filter for firmware `wait` messages to the stock terminal filters. If you did modify your terminal filter configuration, you might want to add this manually:
|
||||
- New "Suppress wait responses" filter: `Recv: wait`
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- [#1344](https://github.com/foosel/OctoPrint/issues/1344) - Fix ProgressBarPlugins to not correctly be triggered for 0% (second try, this time hopefully for good).
|
||||
- [#1637](https://github.com/foosel/OctoPrint/issues/1637) - Fix issue preventing a folder to be deleted that has a name which is a common prefix of the file currently being printed.
|
||||
- [#1641](https://github.com/foosel/OctoPrint/issues/1641) - Fix issue with `octoprint --daemon` not working.
|
||||
- [#1647](https://github.com/foosel/OctoPrint/issues/1647) - Fix issue with `octoprint` command throwing an error if an environment variable `OCTOPRINT_VERSION` was set to its version number.
|
||||
- [#1648](https://github.com/foosel/OctoPrint/issues/1648) - Added missing `websocket-client` dependency of `octoprint client` to install script.
|
||||
- [#1653](https://github.com/foosel/OctoPrint/issues/1653) - Fix for an issue with the included init script on the BBB (see also [#1654](https://github.com/foosel/OctoPrint/issues/1654))
|
||||
- [#1657](https://github.com/foosel/OctoPrint/issues/1657) - Fix init script regarding check for configured `CONFIGFILE` variable.
|
||||
- [#1657](https://github.com/foosel/OctoPrint/issues/1657) - Don't care about ordering of common parameters (like `--basedir`, `--config`) on CLI.
|
||||
- [#1660](https://github.com/foosel/OctoPrint/issues/1660) - Do not show hint regarding keyboard controls beneath webcam stream if keyboard control feature is disabled.
|
||||
- [#1667](https://github.com/foosel/OctoPrint/issues/1667) - Fix for matching folders not getting listed in the results when performing a search in the file list.
|
||||
- [#1675](https://github.com/foosel/OctoPrint/issues/1675) - Fix model size calculation in GCODE analysis, produced wrong values in some cases. Also adjusted calculation to match implementation in GCODE viewer, now both produce identical results.
|
||||
- [#1685](https://github.com/foosel/OctoPrint/issues/1685) - Cura Plugin: Fix filament extraction from CuraEngine slicing output
|
||||
- [#1692](https://github.com/foosel/OctoPrint/issues/1692) - Cura Plugin: Fix solid layer calculation (backport from [Ultimaker/CuraEngine#140](https://github.com/Ultimaker/CuraEngine/issues/140))
|
||||
- [#1693](https://github.com/foosel/OctoPrint/issues/1693) - Cura Plugin: Support `perimeter_before_infill` profile setting. Additionally added support for `solidarea_speed`, `raft_airgap_all`, `raft_surface_thickness`, `raft_surface_linewidth` profile settings and adjusted mapping for engine settings `raftAirGapLayer0`, `raftFanSpeed`, `raftSurfaceThickness`and `raftSurfaceLinewidth` according to current mapping in Cura Legacy and adjusted Mach3 GCODE flavor to substitute `S` with `P` in temperature commands of generated start code, also like in Cura Legacy.
|
||||
- [#1697](https://github.com/foosel/OctoPrint/issues/1697) - Pin Jinja to versions <2.9 for now due to a backwards compatibility issue with templates for versions newer than that. Also pushed as a hotfix to 1.3.0 (as 1.3.0post1).
|
||||
- [#1708](https://github.com/foosel/OctoPrint/issues/1708) - Cura Plugin: Fixed selection of `start.gcode` for sliced file
|
||||
- Allow a retraction z-hop of 0 in timelapse configuration.
|
||||
- Fix files in sub folders to not be processed by the initial analysis backlog check during startup of the server.
|
||||
- Various fixes in the file analysis queue:
|
||||
- High priority items are now really high priority
|
||||
- Abort analysis for items that are to be deleted/moved to get around an issue with file access under Windows systems.
|
||||
- Fix stock terminal filters for suppressing temperature messages and SD status messages to also be able to deal with line number prefixes. If you have added additional terminal filters, you will have to apply this fix manually:
|
||||
- Changed "Suppress temperature messages" filter: `(Send: (N\d+\s+)?M105)|(Recv: ok (B|T\d*):)`
|
||||
- Changed "Suppress SD status messages" filter: `(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)`
|
||||
- Fix issue in german translation.
|
||||
|
||||
### More information
|
||||
|
||||
- [Commits](https://github.com/foosel/OctoPrint/compare/1.3.0...1.3.1)
|
||||
- Release Candidates:
|
||||
- [1.3.1rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.1rc1)
|
||||
- [1.3.1rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.1rc2)
|
||||
|
||||
## 1.3.0 (2016-12-08)
|
||||
|
||||
### Features
|
||||
|
||||
* OctoPrint will now track the current print head position on pause and cancel and provide it as new template variables ``pause_position``/``cancel_position`` for the relevant GCODE scripts. This will allow more intelligent pause codes that park the print head at a rest position during pause and move it back to the exact position it was before the pause on resume ([Example](https://gist.github.com/foosel/1c09e269b1c0bb7a471c20eef50c8d3e)). Note that this is NOT enabled by default and for now will necessitate adjusting the pause and resume GCODE scripts yourself since position tracking with multiple extruders or when printing from SD is currently not fool proof thanks to firmware limitations regarding reliable tracking of the various ``E`` values and the currently selected tool ``T``. In order to fully implement this feature, the following improvements were also done:
|
||||
* New ``PositionUpdated`` event when OctoPrint receives a response to an ``M114`` position query.
|
||||
* Extended ``PrintPaused`` and ``PrintCancelled`` events with position data from ``M114`` position query on print interruption/end.
|
||||
* Added (optional) firmware auto detection. If enabled (which it is by default), OctoPrint will now send an ``M115`` to the printer on initial connection in order to try to figure out what kind of firmware it is. For FIRMWARE_NAME values containing "repetier" (case insensitive), all Repetier-specific flags will be set on the comm layer. For FIRMWARE_NAME values containing "reprapfirmware" (also case insensitive), all RepRapFirmware-specific flags will be set on the comm layer. For now no other handling will be performed.
|
||||
* Added safe mode flag ``--safe`` and config setting ``startOnceInSafeMode`` that disables all third party plugins when active. The config setting will automatically be removed from `config.yaml` after the server has started through successfully.
|
||||
* Added ``octoprint config`` CLI that allows easier manipulation of config.yaml entries from the command line. Example: ``octoprint config set --bool server.startOnceInSafeMode true``
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#1422](https://github.com/foosel/OctoPrint/issues/1422) - Added option for post roll for timed timelapse to duplicate last frame instead of capturing new frames. That makes for a faster render at the cost of a still frame at the end of the rendered video. See also [#1553](https://github.com/foosel/OctoPrint/pull/1553).
|
||||
* [#1551](https://github.com/foosel/OctoPrint/issues/1551) - Allow to define a custom bounding box for valid printer head movements in the printer profile, to make print dimension check more flexible.
|
||||
* [#1583](https://github.com/foosel/OctoPrint/pull/1583) - Strip invalid `pip` arguments from `pip uninstall` commands, if provided by the user as additional pip arguments.
|
||||
* [#1593](https://github.com/foosel/OctoPrint/issues/1593) - Automatically migrate old manual system commands for restarting OctoPrint and rebooting or shutting down the server to the new system wide configuration settings. Make a backup copy of the old `config.yaml` before doing so in case a manual rollback is required.
|
||||
* Support ``M114`` responses without whitespace between coordinates (protocol consistency - who needs it?).
|
||||
* Don't focus files in the file list after deleting a file - made the list too jumpy.
|
||||
* Better error resilience against errors in UI components.
|
||||
* `M600` is now marked as a long running command by default.
|
||||
* Plugin Manager: Allow closing of all notifications and close them automatically on detected server disconnect. No need to keep a "Restart needed" message around if a restart is in progress.
|
||||
* Software Update: "busy" spinner on check buttons while already checking for updates.
|
||||
* Software Update: Prevent update notification when wizard is open.
|
||||
* Plugin Manager / Software Update: The "There's a new version of pip" message during plugin installs and software updates is no longer displayed like an error.
|
||||
* Plugin Manager / Software Update: The "busy" dialog can no longer be closed accidentally.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* [#1148](https://github.com/foosel/OctoPrint/issues/1148) - Fixed retraction z hop setting for Z-triggered timelapses. Was not correctly propagated to the backend and hence not taking effect.
|
||||
* [#1567](https://github.com/foosel/OctoPrint/issues/1567) - Invalidate ``/api/settings`` cache on change of the user's login state (include user roles into ETag calculation).
|
||||
* [#1586](https://github.com/foosel/OctoPrint/issues/1586) - Fixed incompatibility of update script and command line helper with non-ASCII output from called commands.
|
||||
* [#1588](https://github.com/foosel/OctoPrint/issues/1588) - Fixed feedback controls again.
|
||||
* Invalidate ``/api/settings`` cache on change of the currently enabled plugins (by including plugin names into ETag calculation) and/or on change of the current effective config.
|
||||
* Invalidate ``/api/timelapse`` cache on change of the current timelapse configuration.
|
||||
* Fixed an issue causing the version number not to be properly extracted from ``sdist`` tarballs generated under Windows.
|
||||
* Get rid of double scroll bar in printer profile editor.
|
||||
* Fixed tracking of current byte position in file being streamed from disk. Turns out that ``self._handle.tell`` lied to us thanks to line buffering.
|
||||
* Fixed select & print not working anymore for SD files thanks to a timing issue.
|
||||
* Fixed ``PrintFailed`` event payload (was still missing new folder relevant data).
|
||||
* Fixed premature parse stop on ``M114`` and ``M115`` responses with ``ok``-prefix.
|
||||
* Make sure `?l10n` request parameter gets also propagated to API calls as `X-Locale` header in case of locale sensitive API responses.
|
||||
* Fix language mixture due to cached template configs including localized strings; cache per locale.
|
||||
* Only insert divider in system menu after core commands if there are custom commands.
|
||||
* Fix update of webcam stream URL not being applied due to caching.
|
||||
* Fixed a rare race condition causing the new "The settings changed, reload?" popup to show up even when the settings change originated in the same client instance.
|
||||
* Fixed a bunch of missing translations.
|
||||
* Pinned Tornado version to 4.0.2. Former version requirement was able to pull in a beta version causing issues with websockets due to a bug in `permessage-deflate` handling. The Tornado requirement needs an update, but we'll leave it at 4.0.2 for 1.3.0 since we'll need to do some migration work for compatibility with anything newer. Potentially related to [#1523](https://github.com/foosel/OctoPrint/issues/1523).
|
||||
|
||||
### Changes from `maintenance` not yet released as part of a stable release
|
||||
|
||||
#### Bug fixes
|
||||
|
||||
* [#1567](https://github.com/foosel/OctoPrint/issues/1567) - Fix issue with restricted settings getting parsed to the wrong data structure in the frontend if loaded anonymously first.
|
||||
* [#1571](https://github.com/foosel/OctoPrint/issues/1571) - Fix parsing of port number from HTTP Host header for IPv6 addresses
|
||||
* Fix issue with settings restriction causing internal settings defaults to be changed.
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.0rc1...1.3.0rc2))
|
||||
|
||||
## 1.3.0rc1 (2016-10-19)
|
||||
|
||||
### New Features
|
||||
|
||||
* You can now create folders in the file list, upload files into said folders and thus better manage your projects' files.
|
||||
* New wizard dialog for system setups that can also be extended by plugins. Replaces the first run dialog for setting up access control and can also be triggered in other cases than only the first run, e.g. if plugins necessitate user input to function properly. Added wizards to help configuring the following components in OctoPrint on first run: access control, webcam URLs & ffmpeg path, server commands (restart, shutdown, reboot), printer profile. Also extended the bundled Cura plugin to add a wizard for its first setup to adjust path and import a slicing profile, and the bundled Software Update plugin to ask the user for details regarding the OctoPrint update configuration. Also see below.
|
||||
* New command line interface (CLI). Offers the same functionality as the old one plus:
|
||||
@@ -89,17 +274,27 @@
|
||||
* New features within the plugin system:
|
||||
* Plugins may now give hints in which order various hooks or mixin methods should be called by optionally providing an integer value that will be used for sorting the callbacks prior to execution.
|
||||
* Plugins may now define configuration overlays to be applied on top of the default configuration but before ``config.yaml``.
|
||||
* New mixin ``UiPlugin` for plugins that want to provide an alternative web interface delivered by the server.
|
||||
* New mixin `UiPlugin` for plugins that want to provide an alternative web interface delivered by the server.
|
||||
* New mixin ``WizardPlugin`` for plugins that want to provide wizard components to OctoPrint's new wizard dialog.
|
||||
* New hook ``octoprint.cli.commands`` for registering a command with the new OctoPrint CLI
|
||||
* New hook ``octoprint.comm.protocol.gcode.received`` for receiving messages from the printer
|
||||
* New hook ``octoprint.printer.factory`` for providing a custom factory to contruct the global ``PrinterInterface`` implementation.
|
||||
* New ``TemplatePlugin`` template type: ``wizard``
|
||||
* New Javascript client library for utilizing the server's API, can be reused by `UiPlugin`s.
|
||||
* OctoPrint will now track the current print head position on pause and cancel and provide it as new template variables ``pause_position``/``cancel_position`` for the relevant GCODE scripts. This will allow more intelligent pause codes that park the print head at a rest position during pause and move it back to the exact position it was before the pause on resume ([Example](https://gist.github.com/foosel/1c09e269b1c0bb7a471c20eef50c8d3e)). Note that this is NOT enabled by default and for now will necessitate adjusting the pause and resume GCODE scripts yourself since position tracking with multiple extruders or when printing from SD is currently not fool proof thanks to firmware limitations regarding reliable tracking of the various ``E`` values and the currently selected tool ``T``. In order to fully implement this feature, the following improvements were also done:
|
||||
* New ``PositionUpdated`` event when OctoPrint receives a response to an ``M114`` position query.
|
||||
* Extended ``PrintPaused`` and ``PrintCancelled`` events with position data from ``M114`` position query on print interruption/end.
|
||||
* Added (optional) firmware auto detection. If enabled (which it is by default), OctoPrint will now send an ``M115`` to the printer on initial connection in order to try to figure out what kind of firmware it is. For FIRMWARE_NAME values containing "repetier" (case insensitive), all Repetier-specific flags will be set on the comm layer. For FIRMWARE_NAME values containing "reprapfirmware" (also case insensitive), all RepRapFirmware-specific flags will be set on the comm layer. For now no other handling will be performed.
|
||||
* Added safe mode flag ``--safe`` and config setting ``startOnceInSafeMode`` that disables all third party plugins when active. The config setting will automatically be removed from `config.yaml` after the server has started through successfully.
|
||||
* Added ``octoprint config`` CLI that allows easier manipulation of config.yaml entries from the command line. Example: ``octoprint config set --bool server.startOnceInSafeMode true``
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#1048](https://github.com/foosel/OctoPrint/issues/1048) - Added "Last print time" to extended file information (see also [#1522](https://github.com/foosel/OctoPrint/pull/1522))
|
||||
* [#1422](https://github.com/foosel/OctoPrint/issues/1422) - Added option for post roll for timed timelapse to duplicate last frame instead of capturing new frames. That makes for a faster render at the cost of a still frame at the end of the rendered video. See also [#1553](https://github.com/foosel/OctoPrint/pull/1553).
|
||||
* [#1551](https://github.com/foosel/OctoPrint/issues/1551) - Allow to define a custom bounding box for valid printer head movements in the printer profile, to make print dimension check more flexible.
|
||||
* [#1583](https://github.com/foosel/OctoPrint/pull/1583) - Strip invalid `pip` arguments from `pip uninstall` commands, if provided by the user as additional pip arguments.
|
||||
* [#1593](https://github.com/foosel/OctoPrint/issues/1593) - Automatically migrate old manual system commands for restarting OctoPrint and rebooting or shutting down the server to the new system wide configuration settings. Make a backup copy of the old `config.yaml` before doing so in case a manual rollback is required.
|
||||
* New central configuration option for commands to restart OctoPrint and to restart and shut down the system OctoPrint is running on. This allows plugins (like the Software Update Plugin or the Plugin Manager) and core functionality to perform these common administrative tasks without the user needing to define everything redundantly.
|
||||
* `pip` helper now adjusts `pip install` parameters corresponding to detected `pip` version:
|
||||
* Removes `--process-dependency-links` when it's not needed
|
||||
@@ -129,6 +324,9 @@
|
||||
* Renamed ``GcodeFilesViewModel`` to ``FilesViewModel`` - plugin authors should accordingly update their dependencies from ``gcodeFilesViewModel`` to ``filesViewModel``. Using the old name still works, but will log a warning and stop working with 1.4.x.
|
||||
* Make sure ``volume.depth`` for circular beds is forced to ``volume.width`` in printer profiles
|
||||
* Support for `M116`
|
||||
* Support ``M114`` responses without whitespace between coordinates (protocol consistency - who needs it?).
|
||||
* `M600` is now marked as a long running command by default.
|
||||
* Don't focus files in the file list after deleting a file - made the list too jumpy.
|
||||
* Cura plugin: "Test" button to check if path to cura engine is valid.
|
||||
* Cura plugin: Wizard component for configuring the path to the CuraEngine binary and for importing the first slicing profile
|
||||
* GCODE viewer: Added Layer Up/Down buttons (see also [#1306] (https://github.com/foosel/OctoPrint/pull/1306))
|
||||
@@ -141,44 +339,67 @@
|
||||
* Plugin Manager: Track managable vs not managable plugins
|
||||
* Plugin Manager: Allow hiding plugins from Plugin Manager via ``config.yaml``.
|
||||
* Plugin Manager: Limit upload dialog for plugin archives to .zip, .tar.gz, .tgz and .tar extensions.
|
||||
* Plugin Manager: Allow closing of all notifications and close them automatically on detected server disconnect. No need to keep a "Restart needed" message around if a restart is in progress.
|
||||
* Software Update plugin: More verbose output for logged in administrators. Will now log the update commands and their output similar to the Plugin Manager install and uninstall dialog.
|
||||
* Software Update plugin: CLI for checking for and applying updates
|
||||
* Software Update plugin: Wizard component for configuring OctoPrint's update mechanism
|
||||
* Software Update plugin: "busy" spinner on check buttons while already checking for updates.
|
||||
* Software Update plugin: Prevent update notification when wizard is open.
|
||||
* Plugin Manager / Software Update plugin: The "There's a new version of pip" message during plugin installs and software updates is no longer displayed like an error.
|
||||
* Plugin Manager / Software Update plugin: The "busy" dialog can no longer be closed accidentally.
|
||||
* Timelapse: Better (& earlier) reporting to the user when something's up with the snapshot URL causing issues with capturing timelapse frames and hence making it impossible to render a timelapse movie on print completion.
|
||||
* Virtual printer: Usage screen for the ``!!DEBUG`` commands on ``!!DEBUG", ``!!DEBUG:help`` or ``!!DEBUG:?``
|
||||
* Virtual printer: Usage screen for the ``!!DEBUG`` commands on ``!!DEBUG``, ``!!DEBUG:help`` or ``!!DEBUG:?``
|
||||
* Updated frontend dependencies (possibly relevant for plugin authors):
|
||||
* Bootstrap to 2.3.2
|
||||
* JQuery to 2.2.4
|
||||
* Lodash to 3.10.1
|
||||
* SockJS to 1.1.1
|
||||
* Better error resilience against errors in UI components.
|
||||
* Various improvements in the GCODE interpreter which performs the GCODE analysis
|
||||
* Various adjustments towards Python 3 compatibility (still a work in progress though, see also [#1411](https://github.com/foosel/OctoPrint/pull/1411), [#1412](https://github.com/foosel/OctoPrint/pull/1412), [#1413](https://github.com/foosel/OctoPrint/pull/1413), [#1414](https://github.com/foosel/OctoPrint/pull/1414))
|
||||
* Various code refactorings
|
||||
* Various small UI improvements
|
||||
* Various documentation improvements
|
||||
|
||||
### Bug Fixes
|
||||
### Bug fixes
|
||||
|
||||
* [#1047](https://github.com/foosel/OctoPrint/issues/1047) - Fixed 90 degree webcam rotation for iOS Safari.
|
||||
* [#1148](https://github.com/foosel/OctoPrint/issues/1148) - Fixed retraction z hop setting for Z-triggered timelapses. Was not correctly propagated to the backend and hence not taking effect.
|
||||
* [#1567](https://github.com/foosel/OctoPrint/issues/1567) - Invalidate ``/api/settings`` cache on change of the user's login state (include user roles into ETag calculation).
|
||||
* [#1586](https://github.com/foosel/OctoPrint/issues/1586) - Fixed incompatibility of update script and command line helper with non-ASCII output from called commands.
|
||||
* [#1588](https://github.com/foosel/OctoPrint/issues/1588) - Fixed feedback controls again.
|
||||
* [#1599](https://github.com/foosel/OctoPrint/issues/1599) - Properly handle exceptions that arise within the update script during runtime.
|
||||
* It's not possible anymore to select files that are not machinecode files (e.g. GCODE) for printing on the file API.
|
||||
* Changes to a user's personal settings via the UI now propagate across sessions.
|
||||
* Improved compatibility of webcam rotation CSS across newer browsers (see also [#1436](https://github.com/foosel/OctoPrint/pull/1436))
|
||||
* Fix for system menu not getting properly reloaded after entries changed
|
||||
* Invalidate ``/api/settings`` cache on change of the currently enabled plugins (by including plugin names into ETag calculation) and/or on change of the current effective config.
|
||||
* Fix for `/api/settings` not being properly invalidated for plugin settings that do not have a representation in `config.yaml` but are only added at runtime (and hence are not captured by `config.effective`).
|
||||
* Invalidate ``/api/timelapse`` cache on change of the current timelapse configuration.
|
||||
* Fixed an issue causing the version number not to be properly extracted from ``sdist`` tarballs generated under Windows.
|
||||
* Get rid of double scroll bar in printer profile editor.
|
||||
* Fixed tracking of current byte position in file being streamed from disk. Turns out that ``self._handle.tell`` lied to us thanks to line buffering.
|
||||
* Fixed select & print not working anymore for SD files thanks to a timing issue.
|
||||
* Fixed ``PrintFailed`` event payload (was still missing new folder relevant data).
|
||||
* Fixed premature parse stop on ``M114`` and ``M115`` responses with ``ok``-prefix.
|
||||
* Make sure `?l10n` request parameter gets also propagated to API calls as `X-Locale` header in case of locale sensitive API responses.
|
||||
* Fix language mixture due to cached template configs including localized strings; cache per locale.
|
||||
* Only insert divider in system menu after core commands if there are custom commands.
|
||||
* Fix update of webcam stream URL not being applied due to caching.
|
||||
* Fixed a rare race condition causing the new "The settings changed, reload?" popup to show up even when the settings change originated in the same client instance.
|
||||
* Fixed a bunch of missing translations.
|
||||
* Pinned Tornado version to 4.0.2. Former version requirement was able to pull in a beta version causing issues with websockets due to a bug in `permessage-deflate` handling. The Tornado requirement needs an update, but we'll leave it at 4.0.2 for 1.3.0 since we'll need to do some migration work for compatibility with anything newer. Potentially related to [#1523](https://github.com/foosel/OctoPrint/issues/1523).
|
||||
* Fix a rare race condition in the command line helper and the update script that could cause the code to hang due to waiting on an event that would never be set.
|
||||
* Fix issue with handling new settings substructures when they are compared to existing settings data in order to find the structural diff.
|
||||
* Fix for the temperature graph not displaying the data history on site reload.
|
||||
|
||||
### Changes from `maintenance` not yet released as part of a stable release
|
||||
### More information
|
||||
|
||||
#### Improvements
|
||||
|
||||
* Allow arbitrary frame rates for creating timelapses. Before, the entered fps value was also directly used as frame rate for the actual video, which could cause problems with any frame rates not specified in the MPEG2 standard. Now OctoPrint will use a standard frame rate for the rendered video and render the timelapse stills into the finished movie with the configured frame rate.
|
||||
* Limit Cura profile importer to `.ini` files and clarified the supported versions
|
||||
* Add support for the `R` parameter for `M109` and `M190`
|
||||
|
||||
#### Bug fixes
|
||||
|
||||
* [#1541](https://github.com/foosel/OctoPrint/issues/1541) - Fix selecting the printer profile to use by default
|
||||
* [#1543](https://github.com/foosel/OctoPrint/issues/1543) - Fix target temperature propagation from communication layer
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.2.16...1.3.0rc1))
|
||||
* [Commits](https://github.com/foosel/OctoPrint/compare/1.2.18...1.3.0)
|
||||
* Release Candidates:
|
||||
* [1.3.0rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.0rc1)
|
||||
* [1.3.0rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.0rc2)
|
||||
* [1.3.0rc3](https://github.com/foosel/OctoPrint/releases/tag/1.3.0rc3)
|
||||
|
||||
## 1.2.18 (2016-11-30)
|
||||
|
||||
|
||||
+68
-27
@@ -12,6 +12,7 @@ or **[creating pull requests](#pull-requests)**.
|
||||
* [Where can I find which version and branch I'm on?](#where-can-i-find-which-version-and-branch-im-on)
|
||||
* [Where can I find those log files you keep talking about?](#where-can-i-find-those-log-files-you-keep-talking-about)
|
||||
* [Where can I find my browser's error console?](#where-can-i-find-my-browsers-error-console)
|
||||
* [Setting up a development environment](#setting-up-a-development-environment)
|
||||
* [Pull requests](#pull-requests)
|
||||
* [What do the branches mean?](#what-do-the-branches-mean)
|
||||
* [How OctoPrint is versioned](#how-octoprint-is-versioned)
|
||||
@@ -92,11 +93,15 @@ following section *completely* and also follow the instructions in the
|
||||
|
||||
2. Please make sure to **test out the current version** of OctoPrint to see
|
||||
whether the problem you are encountering still exists, and **test without
|
||||
any non-bundled plugins enabled** to make sure it's not a misbehaving
|
||||
plugin causing the issue at hand.
|
||||
any third-party plugins enabled** to make sure it's not a misbehaving
|
||||
plugin causing the issue at hand. For that please restart OctoPrint in
|
||||
**safe mode**, either by selecting "Restart OctoPrint in safe mode" from
|
||||
the "System" menu, or by starting OctoPrint from the command line with
|
||||
`octoprint serve --safe`. Then try to reproduce your issue. Find out
|
||||
more about safe mode in the [docs](http://docs.octoprint.org/en/master/features/safemode.html).
|
||||
|
||||
If you are feeling up to it you might also want to try the current development
|
||||
version of OctoPrint (if you aren't already). Refer to the [FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)
|
||||
You might also want to try the current development version of OctoPrint
|
||||
(if you aren't already). Refer to the [FAQ](https://github.com/foosel/OctoPrint/wiki/FAQ)
|
||||
for information on how to do this.
|
||||
|
||||
3. The problem still exists? Then please **look through the
|
||||
@@ -137,6 +142,12 @@ only provided here as some additional information for you), **even if only addin
|
||||
reproduce your issue in order to fix it and that is not possible if they
|
||||
don't know what you did to get it to happen in the first place.
|
||||
|
||||
Ideally provide exact steps to follow in order to reproduce your problem:
|
||||
|
||||
1. ...
|
||||
2. ...
|
||||
3. ...
|
||||
|
||||
If you encountered a problem with specific files of any sorts, make sure
|
||||
to also include a link to a file with which to reproduce the problem.]
|
||||
|
||||
@@ -144,10 +155,20 @@ only provided here as some additional information for you), **even if only addin
|
||||
|
||||
#### What happened instead?
|
||||
|
||||
#### Did the same happen when running OctoPrint in safe mode?
|
||||
|
||||
[Try to reproduce your problem in safe mode. You can find information
|
||||
on how to enable safe mode in the Contribution Guidelines.]
|
||||
|
||||
#### Branch & Commit or Version of OctoPrint
|
||||
|
||||
[Can be found in the lower left corner of the web interface. ALWAYS INCLUDE.]
|
||||
|
||||
#### Operating System running OctoPrint
|
||||
|
||||
[OctoPi, Linux, Windows, MacOS, something else? With version please,
|
||||
OctoPi's version can be found in /etc/octopi_version]
|
||||
|
||||
#### Printer model & used firmware incl. version
|
||||
|
||||
[If applicable, always include if unsure.]
|
||||
@@ -158,7 +179,8 @@ only provided here as some additional information for you), **even if only addin
|
||||
|
||||
#### Link to octoprint.log
|
||||
|
||||
[On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.]
|
||||
[On gist.github.com or pastebin.com. ALWAYS INCLUDE and never truncate.
|
||||
The Contribution Guidelines tell you where to find that.]
|
||||
|
||||
#### Link to contents of terminal tab or serial.log
|
||||
|
||||
@@ -173,16 +195,19 @@ only provided here as some additional information for you), **even if only addin
|
||||
#### Link to contents of Javascript console in the browser
|
||||
|
||||
[On gist.github.com or pastebin.com or alternatively a screenshot. If applicable -
|
||||
always include if unsure or reporting UI issues.]
|
||||
always include if unsure or reporting UI issues.
|
||||
|
||||
#### Screenshot(s) showing the problem:
|
||||
The Contribution Guidelines tell you where to find that.]
|
||||
|
||||
#### Screenshot(s)/video(s) showing the problem:
|
||||
|
||||
[If applicable. Always include if unsure or reporting UI issues.]
|
||||
|
||||
I have read the FAQ.
|
||||
|
||||
Copy-paste this template **completely**. Do not skip any lines or the bot
|
||||
*will* complain!
|
||||
Copy-paste this template **completely** (or use the version that gets pre-filled
|
||||
into the "new issue" form). Do not skip any lines or the bot *will* complain! Provide
|
||||
all requested information or your ticket will be closed.
|
||||
|
||||
### Where can I find which version and branch I'm on?
|
||||
|
||||
@@ -235,6 +260,10 @@ find information on how to do just that in the
|
||||
|
||||
See [How to open the Javascript Console in different browsers](https://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers)
|
||||
|
||||
## Setting up a development environment
|
||||
|
||||
See [the corresponding chapter in the documentation](http://docs.octoprint.org/en/master/development/index.html#setting-up-a-development-environment).
|
||||
|
||||
## Pull requests
|
||||
|
||||
1. If you want to add a new feature to OctoPrint, **please always first
|
||||
@@ -253,17 +282,18 @@ See [How to open the Javascript Console in different browsers](https://webmaster
|
||||
just cause unnecessary work and frustration for everyone or
|
||||
possibly get the PR rejected.
|
||||
3. Create your pull request **from a custom branch** on your end (e.g.
|
||||
`dev/myNewFeature`)[1] **against the `devel` branch**. Create **one pull request
|
||||
per feature/bug fix**. If your PR contains an important bug fix, we will
|
||||
make sure to backport it to the `maintenance` branch to also include it in
|
||||
the next release.
|
||||
4. Make sure there are **only relevant changes** included in your PR. No
|
||||
`dev/myNewFeature`)[1].
|
||||
4. Create your pull request **only against the `maintenance` or `devel` branch**:
|
||||
* if it's a bug fix for a bug in the current stable version: `maintenance` branch
|
||||
* otherwise: `devel` branch
|
||||
5. Create **one pull request per feature/bug fix**.
|
||||
6. Make sure there are **only relevant changes** included in your PR. No
|
||||
changes to unrelated files, no additional files that don't belong (e.g.
|
||||
commits of your full virtual environment). Make sure your PR consists
|
||||
**ideally of only one commit** (use git's rebase and squash functionality).
|
||||
5. Make sure you **follow the current coding style**. This means:
|
||||
7. Make sure you **follow the current coding style**. This means:
|
||||
* Tabs instead of spaces in the Python files[2]
|
||||
* Spaces instead of tabs in the Javascript sources
|
||||
* Spaces instead of tabs in the JavaScript sources
|
||||
* English language (code, variables, comments, ...)
|
||||
* Comments where necessary: Tell *why* the code does something like it does
|
||||
it, structure your code
|
||||
@@ -272,22 +302,22 @@ See [How to open the Javascript Console in different browsers](https://webmaster
|
||||
``.less`` files from which the CSS is compiled.
|
||||
* Make sure you do not add dead code (e.g. commented out left-overs
|
||||
from experiments).
|
||||
6. Ensure your changes **pass the existing unit tests**. PRs that break
|
||||
8. Ensure your changes **pass the existing unit tests**. PRs that break
|
||||
those cannot be accepted.
|
||||
7. **Test your changes thoroughly**. That also means testing with usage
|
||||
9. **Test your changes thoroughly**. That also means testing with usage
|
||||
scenarios you don't normally use, e.g. if you only use access control, test
|
||||
without and vice versa. If you only test with your printer, test with the
|
||||
virtual printer and vice versa. State in your pull request how you tested
|
||||
your changes. Ideally **add unit tests** - OctoPrint severely lacks in that
|
||||
department, but we are trying to change that, so any new code already covered
|
||||
with a test suite helps a lot!
|
||||
8. In your pull request's description, **state what your pull request does**,
|
||||
as in, what feature does it implement, what bug does it fix. The more
|
||||
thoroughly you explain your intent behind the PR here, the higher the
|
||||
chances it will get merged fast. There is a template provided below
|
||||
that can help you here.
|
||||
9. Don't forget to **add yourself to the [AUTHORS](./AUTHORS.md)
|
||||
file** :)
|
||||
10. In your pull request's description, **state what your pull request does**,
|
||||
as in, what feature does it implement, what bug does it fix. The more
|
||||
thoroughly you explain your intent behind the PR here, the higher the
|
||||
chances it will get merged fast. There is a template provided below
|
||||
that can help you here.
|
||||
11. Don't forget to **add yourself to the [AUTHORS](./AUTHORS.md)
|
||||
file** :)
|
||||
|
||||
Template to use for Pull Request descriptions:
|
||||
|
||||
@@ -315,7 +345,7 @@ There are three main branches in OctoPrint:
|
||||
add a commit after release to this branch - `<x>.<y>.<z>.post<commits since x.y.z>`
|
||||
(e.g. `1.2.9.post1`).
|
||||
* `maintenance`: Improvements and fixes of the current release that make up
|
||||
the next release go here. More or less continously updated. You can consider
|
||||
the next release go here. More or less continuously updated. You can consider
|
||||
this a preview of the next release version. It should be very stable at all
|
||||
times. Anything you spot in here helps tremendously with getting a rock solid
|
||||
next stable release, so if you want to help out development, running the
|
||||
@@ -335,10 +365,16 @@ There are three main branches in OctoPrint:
|
||||
the `maintenance` branch and are now being pushed on the "Maintenance"
|
||||
pre release channel for further testing. Version number follows the scheme
|
||||
`<x>.<y>.<z>rc<n>` (e.g. `1.2.9rc1`).
|
||||
* `staging/maintenance`: Any preparation for potential follow-up RCs takes place here.
|
||||
Version number follows the scheme `<x>.<y>.<z>rc<n+1>.dev<commits since increase of n>` (e.g.
|
||||
`1.2.9rc1.dev3`) for a current Maintenance RC of `<x>.<y>.<z>rc<n>`.
|
||||
* `rc/devel`: This branch is reserved for future releases that have graduated from
|
||||
the `devel` branch and are now being pushed on the "Devel" pre release channel
|
||||
for further testing. Version number follows the scheme `<x>.<y+1>.0rc<n>` (e.g. `1.3.0rc1`)
|
||||
for a current stable OctoPrint version of `<x>.<y>.<z>`.
|
||||
* `staging/devel`: Any preparation for potential follow-up Devel RCs takes place
|
||||
here. Version number follows the scheme `<x>.<y>.0rc<n+1>.dev<commits since increase of n>` (e.g.
|
||||
`1.3.0rc1.dev12`) for a current Devel RC of `<x>.<y>.0rc<n>`.
|
||||
|
||||
Additionally, from time to time you might see other branches pop up in the repository.
|
||||
Those usually have one of the following prefixes:
|
||||
@@ -350,7 +386,7 @@ Those usually have one of the following prefixes:
|
||||
* `dev/...` or `feature/...`: New functionality under development that is to be merged
|
||||
into the `devel` branch.
|
||||
|
||||
There is also the `gh-pages` branch, which holds OctoPrint's web page, and a couple of
|
||||
There is also the `gh-pages` branch, which holds OctoPrint's web page, and a few
|
||||
older development branches that are slowly being migrated or deleted.
|
||||
|
||||
## How OctoPrint is versioned
|
||||
@@ -391,6 +427,11 @@ the local version identifier to allow for an exact determination of the active c
|
||||
* 2016-09-09: New `rc/*` branches explained.
|
||||
* 2016-09-23: Some more work on "How to file a bug report" based on recent
|
||||
experiences
|
||||
* 2017-01-25: Fixed a typo
|
||||
* 2017-03-09: Allow PRs against `maintenance` branch for bugs in stable.
|
||||
* 2017-03-10: Reproduce bugs in safe mode to make sure they are really caused
|
||||
by OctoPrint itself and not a misbehaving plugin.
|
||||
* 2017-03-27: Added safe mode section to ticket template.
|
||||
|
||||
## Footnotes
|
||||
* [1] - If you are wondering why, the problem is that anything that you add
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# OctoPrint
|
||||
|
||||
OctoPrint provides a snappy web interface for controlling a 3D printer (RepRap, Ultimaker, ...). It is Free Software
|
||||
[](https://badge.fury.io/gh/foosel%2FOctoPrint)
|
||||
|
||||
OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software
|
||||
and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
Its website can be found at [octoprint.org](http://octoprint.org).
|
||||
@@ -33,7 +35,7 @@ If you think something is bad about OctoPrint or its documentation the way it is
|
||||
in any way to make it better instead of just complaining about it -- this is an Open Source Project
|
||||
after all :)
|
||||
|
||||
For information about how to go about contributions of any kind, please see the project's
|
||||
For information about how to go about submitting bug reports or pull requests, please see the project's
|
||||
[Contribution Guidelines](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## Installation
|
||||
@@ -41,7 +43,7 @@ For information about how to go about contributions of any kind, please see the
|
||||
Installation instructions for installing from source for different operating
|
||||
systems can be found [on the wiki](https://github.com/foosel/OctoPrint/wiki#assorted-guides).
|
||||
|
||||
If you want to run OctoPrint on a Raspberry Pi you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
||||
If you want to run OctoPrint on a Raspberry Pi, you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
||||
which is a custom SD card image that includes OctoPrint plus dependencies.
|
||||
|
||||
The generic steps that should basically be done regardless of operating system
|
||||
@@ -59,18 +61,18 @@ for details.
|
||||
|
||||
After installation, please make sure you follow the first-run wizard and set up
|
||||
access control as necessary. If you want to not only be notified about new
|
||||
releases but also be able to automatically upgrade to them from within
|
||||
releases, but also be able to automatically upgrade to them from within
|
||||
OctoPrint, take a look [at the documentation of the Software Update Plugin](https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update#making-octoprint-updateable-on-existing-installations)
|
||||
and at its settings.
|
||||
|
||||
## Dependencies
|
||||
|
||||
OctoPrint depends on a couple of python modules to do its job. Those are automatically installed when installing
|
||||
OctoPrint depends on a few python modules to do its job. Those are automatically installed when installing
|
||||
OctoPrint via `setup.py`:
|
||||
|
||||
python setup.py install
|
||||
|
||||
You should also do this every time after pulling from the repository, since the dependencies might have changed.
|
||||
You should do this every time after pulling from the repository, since the dependencies may have changed.
|
||||
|
||||
OctoPrint currently only supports Python 2.7.
|
||||
|
||||
@@ -81,41 +83,46 @@ Running the `setup.py` script via
|
||||
python setup.py install
|
||||
|
||||
installs the `octoprint` script in your Python installation's scripts folder
|
||||
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
||||
following usage examples assume that said `octoprint` script is on your `PATH`.
|
||||
(which, depending on whether you installed OctoPrint globally or into a virtual env, will be in your `PATH` or not). The
|
||||
following usage examples assume that the `octoprint` script is on your `PATH`.
|
||||
|
||||
You can start the server via
|
||||
|
||||
octoprint
|
||||
octoprint serve
|
||||
|
||||
By default it binds to all interfaces on port 5000 (so pointing your browser to `http://127.0.0.1:5000`
|
||||
will do the trick). If you want to change that, use the additional command line parameters `host` and `port`,
|
||||
which accept the host ip to bind to and the numeric port number respectively. If for example you want the server
|
||||
to only listen on the local interface on port 8080, the command line would be
|
||||
|
||||
octoprint --host=127.0.0.1 --port=8080
|
||||
octoprint serve --host=127.0.0.1 --port=8080
|
||||
|
||||
Alternatively, the host and port on which to bind can be defined via the configuration.
|
||||
Alternatively, the host and port on which to bind can be defined via the config file.
|
||||
|
||||
If you want to run OctoPrint as a daemon (only supported on Linux), use
|
||||
|
||||
octoprint --daemon {start|stop|restart} [--pid PIDFILE]
|
||||
octoprint daemon {start|stop|restart} [--pid PIDFILE]
|
||||
|
||||
If you do not supply a custom pidfile location via `--pid PIDFILE`, it will be created at `/tmp/octoprint.pid`.
|
||||
|
||||
You can also specify the configfile or the base directory (for basing off the `uploads`, `timelapse` and `logs` folders),
|
||||
You can also specify the config file or the base directory (for basing off the `uploads`, `timelapse` and `logs` folders),
|
||||
e.g.:
|
||||
|
||||
octoprint --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
octoprint serve --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
|
||||
See `octoprint --help` for further information.
|
||||
To start OctoPrint in safe mode - which disables all third party plugins that do not come bundled with OctoPrint - use
|
||||
the ``--safe`` flag:
|
||||
|
||||
OctoPrint also ships with a `run` script in its source directory. You can also invoke that to start up the server, it
|
||||
octoprint serve --safe
|
||||
|
||||
See `octoprint --help` for more information on the available command line parameters.
|
||||
|
||||
OctoPrint also ships with a `run` script in its source directory. You can invoke it to start the server. It
|
||||
takes the same command line arguments as the `octoprint` script.
|
||||
|
||||
## Configuration
|
||||
|
||||
If not specified via the commandline, the configfile `config.yaml` for OctoPrint is expected in the settings folder,
|
||||
If not specified via the command line, the config file `config.yaml` for OctoPrint is expected in the settings folder,
|
||||
which is located at `~/.octoprint` on Linux, at `%APPDATA%/OctoPrint` on Windows and
|
||||
at `~/Library/Application Support/OctoPrint` on MacOS.
|
||||
|
||||
|
||||
+13
-18
@@ -1,4 +1,4 @@
|
||||
# Supporters
|
||||
# Supporters
|
||||
|
||||
Development of this version of OctoPrint wouldn't have been possible without
|
||||
[financial support by the community](http://octoprint.org/support-octoprint/) -
|
||||
@@ -10,45 +10,42 @@ thanks to everyone who contributed!
|
||||
* Aleph Objects, Inc.
|
||||
* Andrew Moorby
|
||||
* Arnljot Arntsen
|
||||
* Aurelio Bernal
|
||||
* Bart Zudell
|
||||
* BEEVERYCREATIVE
|
||||
* Boris Hussein
|
||||
* Brad Jackson
|
||||
* Brad Mooneyham
|
||||
* Brent Fiegle
|
||||
* Brian E. Tyler
|
||||
* Charles Mitchell
|
||||
* Christopher Day
|
||||
* Chris Day
|
||||
* Christian Petropolis
|
||||
* COLLE+McVOY
|
||||
* CreativeTools
|
||||
* D Brian Kimmel
|
||||
* DeltaMaker 3D Printers
|
||||
* Doug Johnson
|
||||
* E3D BigBox
|
||||
* Erik de Bruijn
|
||||
* Ernesto Martinez
|
||||
* Exovite
|
||||
* F. Kunsmann
|
||||
* Frank Sander
|
||||
* Gary Deen
|
||||
* Gary N McKinney
|
||||
* George Robles
|
||||
* J. Eckert
|
||||
* Jason Galarneau
|
||||
* günter weber
|
||||
* Ivan Krasin
|
||||
* James Seigel
|
||||
* Jamie R McGuigan
|
||||
* Jeff Moe
|
||||
* Josh Daniels
|
||||
* Joshua David Gregory
|
||||
* Kaile Riser
|
||||
* Kale Stedman
|
||||
* Kazuhiro Ogura
|
||||
* Lamin Kivelä
|
||||
* M Khorakiwala
|
||||
* Makespace Madrid
|
||||
* Marcus Ackermann
|
||||
* Mark Qvist
|
||||
* Mark Walker
|
||||
* Masayoshi Mitsui
|
||||
* Michael Aumock
|
||||
* Michael McDargh Sr
|
||||
* Miles Flavel
|
||||
* Mohammed khorakiwala
|
||||
* Noe Ruiz
|
||||
* Patrick McGinnis
|
||||
* Peter Grace
|
||||
@@ -60,14 +57,12 @@ thanks to everyone who contributed!
|
||||
* Samer Najia
|
||||
* SD3D
|
||||
* SeeMeCNC
|
||||
* Shane Ekerbicer
|
||||
* Simon Hallam
|
||||
* Stefan Krister
|
||||
* Stephane Schittly
|
||||
* Steven Pearson
|
||||
* Sven Mueller
|
||||
* Terrance Shaw
|
||||
* Thomas Hatley
|
||||
* Timeshell.ca
|
||||
* Trent Shumay
|
||||
|
||||
and 989 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
and 1098 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
@@ -32,7 +32,9 @@
|
||||
|
||||
## Server
|
||||
|
||||
* [appdirs](http://github.com/ActiveState/appdirs): MIT
|
||||
* [Awesome-Slugify](https://pypi.python.org/pypi/awesome-slugify): GPLv3
|
||||
* [chainmap](https://bitbucket.org/jeunice/chainmap): Python
|
||||
* [Click](http://click.pocoo.org/): BSD
|
||||
* [feedparser](https://github.com/kurtmckee/feedparser): BSD
|
||||
* [Flask](http://flask.pocoo.org/): BSD
|
||||
@@ -41,6 +43,7 @@
|
||||
* [Flask-Login](https://github.com/maxcountryman/flask-login): MIT
|
||||
* [Flask-Markdown](http://github.com/dcolish/flask-markdown): BSD
|
||||
* [Flask-Principal](http://packages.python.org/Flask-Principal/): MIT
|
||||
* [future](https://python-future.org/): MIT
|
||||
* [netaddr](https://github.com/drkjam/netaddr/): BSD
|
||||
* [netifaces](https://bitbucket.org/al45tair/netifaces): MIT
|
||||
* [pkginfo](http://pypi.python.org/pypi/pkginfo/): Python
|
||||
@@ -51,7 +54,19 @@
|
||||
* [requests](http://python-requests.org/): Apache License 2.0
|
||||
* [rsa](http://stuvel.eu/rsa): Apache License 2.0
|
||||
* [sarge](http://sarge.readthedocs.org/): BSD
|
||||
* [scandir](https://github.com/benhoyt/scandir): BSD
|
||||
* [semantic_version](https://github.com/rbarrois/python-semanticversion): BSD
|
||||
* [SockJS-Tornado](http://github.com/mrjoes/sockjs-tornado/): MIT
|
||||
* [Tornado](http://www.tornadoweb.org/): Apache License 2.0
|
||||
* [watchdog](http://github.com/gorakhargosh/watchdog): Apache License 2.0
|
||||
* [websocket-client](https://github.com/liris/websocket-client): LGPLv3
|
||||
|
||||
## Development (testing, documentation generation, etc)
|
||||
|
||||
* [ddt](https://github.com/txels/ddt): MIT
|
||||
* [mock](https://github.com/testing-cabal/mock): BSD
|
||||
* [nose](http://pythonhosted.org/nose/): LGPL
|
||||
* [pypandoc](https://github.com/bebraw/pypandoc): MIT
|
||||
* [Sphinx](http://sphinx-doc.org/): BSD
|
||||
* [sphinxcontrib-httpdomain](https://bitbucket.org/birkenfeld/sphinx-contrib/src/default/httpdomain/): BSD
|
||||
* [sphinx_rtd_theme](https://github.com/snide/sphinx_rtd_theme/): BSD
|
||||
@@ -31,7 +31,7 @@ Printer State
|
||||
* - ``flags``
|
||||
- 1
|
||||
- Printer state flags
|
||||
- A couple of boolean printer state flags
|
||||
- A few boolean printer state flags
|
||||
* - ``flags.operational``
|
||||
- 1
|
||||
- Boolean
|
||||
@@ -286,9 +286,9 @@ Files
|
||||
- Type
|
||||
- Description
|
||||
* - ``hash``
|
||||
- 1
|
||||
- 0..1
|
||||
- String
|
||||
- MD5 hash of the file
|
||||
- MD5 hash of the file. Only available for ``local`` files.
|
||||
* - ``size``
|
||||
- 0..1
|
||||
- Number
|
||||
|
||||
+149
-2
@@ -16,9 +16,14 @@ Retrieve all files
|
||||
Retrieve information regarding all files currently available and regarding the disk space still available
|
||||
locally in the system.
|
||||
|
||||
By default only returns the files and folders in the root directory. If the query parameter ``recursive``
|
||||
is provided and set to ``true``, returns all files and folders.
|
||||
|
||||
Returns a :ref:`Retrieve response <sec-api-fileops-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**:
|
||||
**Example 1**:
|
||||
|
||||
Fetch only the files and folders from the root folder.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
@@ -35,6 +40,10 @@ Retrieve all files
|
||||
"files": [
|
||||
{
|
||||
"name": "whistle_v2.gcode",
|
||||
"path": "whistle_v2.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "...",
|
||||
"size": 1468987,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
@@ -60,15 +69,140 @@ Retrieve all files
|
||||
},
|
||||
{
|
||||
"name": "whistle_.gco",
|
||||
"path": "whistle_.gco",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"origin": "sdcard",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/sdcard/whistle_.gco"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "folderA",
|
||||
"path": "folderA",
|
||||
"type": "folder",
|
||||
"typePath": ["folder"],
|
||||
"children": [],
|
||||
"size": 1334
|
||||
}
|
||||
],
|
||||
"free": "3.2GB"
|
||||
}
|
||||
|
||||
**Example 2**
|
||||
|
||||
Recursively fetch all files and folders.
|
||||
|
||||
Fetch only the files and folders from the root folder.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/files?recursive=true HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"name": "whistle_v2.gcode",
|
||||
"path": "whistle_v2.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "...",
|
||||
"size": 1468987,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/whistle_v2.gcode",
|
||||
"download": "http://example.com/downloads/files/local/whistle_v2.gcode"
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"estimatedPrintTime": 1188,
|
||||
"filament": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
}
|
||||
},
|
||||
"print": {
|
||||
"failure": 4,
|
||||
"success": 23,
|
||||
"last": {
|
||||
"date": 1387144346,
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "whistle_.gco",
|
||||
"path": "whistle_.gco",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"origin": "sdcard",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/sdcard/whistle_.gco"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "folderA",
|
||||
"path": "folderA",
|
||||
"type": "folder",
|
||||
"typePath": ["folder"],
|
||||
"children": [
|
||||
{
|
||||
"name": "test.gcode",
|
||||
"path": "folderA/test.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "...",
|
||||
"size": 1234,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/folderA/test.gcode",
|
||||
"download": "http://example.com/downloads/files/local/folderA/test.gcode"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "subfolder",
|
||||
"path": "folderA/subfolder",
|
||||
"type": "folder",
|
||||
"typePath": ["folder"],
|
||||
"children": [
|
||||
{
|
||||
"name": "test.gcode",
|
||||
"path": "folderA/subfolder/test2.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "...",
|
||||
"size": 100,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/folderA/subfolder/test2.gcode",
|
||||
"download": "http://example.com/downloads/files/local/folderA/subfolder/test2.gcode"
|
||||
}
|
||||
},
|
||||
],
|
||||
"size": 100,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/folderA/subfolder",
|
||||
}
|
||||
],
|
||||
"size": 1334,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/folderA",
|
||||
}
|
||||
}
|
||||
],
|
||||
"free": "3.2GB"
|
||||
}
|
||||
|
||||
:param recursive: If set to ``true``, return all files and folders recursively. Otherwise only return items on same level.
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-fileops-retrievelocation:
|
||||
@@ -81,6 +215,9 @@ Retrieve files from specific location
|
||||
Retrieve information regarding the files currently available on the selected `location` and -- if targeting
|
||||
the ``local`` location -- regarding the disk space still available locally in the system.
|
||||
|
||||
By default only returns the files and folders in the root directory. If the query parameter ``recursive``
|
||||
is provided and set to ``true``, returns all files and folders.
|
||||
|
||||
Returns a :ref:`Retrieve response <sec-api-fileops-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**:
|
||||
@@ -100,6 +237,10 @@ Retrieve files from specific location
|
||||
"files": [
|
||||
{
|
||||
"name": "whistle_v2.gcode",
|
||||
"path": "whistle_v2.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"hash": "...",
|
||||
"size": 1468987,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
@@ -130,6 +271,7 @@ Retrieve files from specific location
|
||||
:param location: The origin location from which to retrieve the files. Currently only ``local`` and ``sdcard`` are
|
||||
supported, with ``local`` referring to files stored in OctoPrint's ``uploads`` folder and ``sdcard``
|
||||
referring to files stored on the printer's SD card (if available).
|
||||
:param recursive: If set to ``true``, return all files and folders recursively. Otherwise only return items on same level.
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If `location` is neither ``local`` nor ``sdcard``
|
||||
|
||||
@@ -196,6 +338,8 @@ Upload file or create folder
|
||||
"local": {
|
||||
"name": "whistle_v2.gcode",
|
||||
"path": "whistle_v2.gcode",
|
||||
"type": "machinecode",
|
||||
"typePath": ["machinecode", "gcode"],
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/whistle_v2.gcode",
|
||||
@@ -324,6 +468,9 @@ Retrieve a specific file's or folder's information
|
||||
|
||||
If the file is unknown, a :http:statuscode:`404` is returned.
|
||||
|
||||
If the targeted path is a folder, by default only its direct children will be returned. If ``recursive`` is
|
||||
provided and set to ``true``, all sub folders and their children will be returned too.
|
||||
|
||||
On success, a :http:statuscode:`200` is returned, with a :ref:`file information item <sec-api-datamodel-files-file>`
|
||||
as the response body.
|
||||
|
||||
@@ -368,7 +515,7 @@ Retrieve a specific file's or folder's information
|
||||
|
||||
:param location: The location of the file for which to retrieve the information, either ``local`` or ``sdcard``.
|
||||
:param filename: The filename of the file for which to retrieve the information
|
||||
:param children: Whether to include children of folders (true, default) or not (false)
|
||||
:param recursive: If set to ``true``, return all files and folders recursively. Otherwise only return items on same level.
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If ``target`` is neither ``local`` nor ``sdcard``, ``sdcard`` but SD card support is disabled or the
|
||||
requested file was not found
|
||||
|
||||
+113
-76
@@ -34,90 +34,92 @@ Retrieve all printer profiles
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
[
|
||||
{
|
||||
"id": "_default",
|
||||
"name": "Default",
|
||||
"color": "default",
|
||||
"model": "Generic RepRap Printer",
|
||||
"default": true,
|
||||
"current": true,
|
||||
"resource": "http://example.com/api/printerprofiles/_default",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
{
|
||||
"profiles": [
|
||||
{
|
||||
"id": "_default",
|
||||
"name": "Default",
|
||||
"color": "default",
|
||||
"model": "Generic RepRap Printer",
|
||||
"default": true,
|
||||
"current": true,
|
||||
"resource": "http://example.com/api/printerprofiles/_default",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
}
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "my_profile",
|
||||
"name": "My Profile",
|
||||
"color": "default",
|
||||
"model": "My Custom Printer",
|
||||
"default": false,
|
||||
"current": false,
|
||||
"resource": "http://example.com/api/printerprofiles/my_profile",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
{
|
||||
"id": "my_profile",
|
||||
"name": "My Profile",
|
||||
"color": "default",
|
||||
"model": "My Custom Printer",
|
||||
"default": false,
|
||||
"current": false,
|
||||
"resource": "http://example.com/api/printerprofiles/my_profile",
|
||||
"volume": {
|
||||
"formFactor": "rectangular",
|
||||
"origin": "lowerleft",
|
||||
"width": 200,
|
||||
"depth": 200,
|
||||
"height": 200
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
"heatedBed": true,
|
||||
"axes": {
|
||||
"x": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"y": {
|
||||
"speed": 6000,
|
||||
"inverted": false
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
}
|
||||
},
|
||||
"z": {
|
||||
"speed": 200,
|
||||
"inverted": false
|
||||
},
|
||||
"e": {
|
||||
"speed": 300,
|
||||
"inverted": false
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
"extruder": {
|
||||
"count": 1,
|
||||
"offsets": [
|
||||
{"x": 0.0, "y": 0.0}
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
.. _sec-api-printerprofiles-add:
|
||||
@@ -537,6 +539,41 @@ Profile
|
||||
- 0..1
|
||||
- ``float``
|
||||
- The height of the print volume
|
||||
* - ``volume.custom_box``
|
||||
- 0..1
|
||||
- ``boolean`` or ``object``
|
||||
- If the printer has a custom bounding box where the print head can be safely moved to, exceeding the defined print
|
||||
volume, that bounding box will be defined here. Otherwise (safe area == print volume) this value will be ``false``.
|
||||
* - ``volume.custom_box.min_x``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Minimum X coordinate defining the safe custom bounding box. Smaller value than the minimum X coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.max_x``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Maximum X coordinate defining the safe custom bounding box. Larger value than the maximum X coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.min_y``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Minimum Y coordinate defining the safe custom bounding box. Smaller value than the minimum Y coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.max_y``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Maximum Y coordinate defining the safe custom bounding box. Larger value than the maximum Y coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.min_z``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Minimum Z coordinate defining the safe custom bounding box. Smaller value than the minimum Z coordinate of the
|
||||
print volume.
|
||||
* - ``volume.custom_box.max_z``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- Maximum Z coordinate defining the safe custom bounding box. Larger value than the maximum Z coordinate of the
|
||||
print volume.
|
||||
* - ``heatedBed``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
|
||||
@@ -68,6 +68,23 @@ Save settings
|
||||
// ...
|
||||
}
|
||||
|
||||
.. _sec-api-settings-generateapikey:
|
||||
|
||||
Regenerate the system wide API key
|
||||
==================================
|
||||
|
||||
.. http:post:: /api/settings/apikey
|
||||
|
||||
Generates a new system wide API key.
|
||||
|
||||
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.
|
||||
|
||||
:status 200: No error
|
||||
:status 403: No admin rights
|
||||
|
||||
.. _sec-api-settings-datamodel:
|
||||
|
||||
Data model
|
||||
@@ -87,6 +104,9 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
|
||||
-
|
||||
* - ``api.key``
|
||||
- Only maps to ``api.key`` in ``config.yaml`` if request is sent with admin rights, set to ``n/a`` otherwise.
|
||||
Starting with OctoPrint 1.3.3 setting this field via :ref:`the API <sec-api-settings-save>` is not possible,
|
||||
only :ref:`regenerting it <sec-api-settings-generateapikey>` is supported. Setting a custom value is only
|
||||
possible through `config.yaml`.
|
||||
* - ``api.allowCrossOrigin``
|
||||
-
|
||||
* - ``appearance.name``
|
||||
@@ -133,6 +153,12 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
|
||||
-
|
||||
* - ``feature.modelSizeDetection``
|
||||
-
|
||||
* - ``feature.firmwareDetection``
|
||||
-
|
||||
* - ``feature.printCancelConfirmation``
|
||||
-
|
||||
* - ``feature.blockWhileDwelling``
|
||||
-
|
||||
* - ``folder.uploads``
|
||||
-
|
||||
* - ``folder.timelapse``
|
||||
|
||||
@@ -268,9 +268,14 @@ Slicer
|
||||
- ``string``
|
||||
- Identifier of the slicer
|
||||
* - ``displayName``
|
||||
- 0..1
|
||||
- 1
|
||||
- ``string``
|
||||
- Display name of the slicer
|
||||
* - ``sameDevice``
|
||||
- 1
|
||||
- ``boolean``
|
||||
- Whether the slicer runs on the same device as OctoPrint (``true``) and hence can't be used while printing,
|
||||
or not (``false``)
|
||||
* - ``default``
|
||||
- 1
|
||||
- ``boolean``
|
||||
|
||||
@@ -43,6 +43,13 @@ Installing pybonjour
|
||||
OctoPi versions 0.12.0 and later already come with pybonjour installed and ready to go,
|
||||
you don't need to perform these steps there.
|
||||
|
||||
.. note::
|
||||
|
||||
Currently there are no releases for pybonjour available on the Python Package Index PyPI. The latest pybonjour
|
||||
release is still available in the `Google Code Archive <https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pybonjour/pybonjour-1.1.1.tar.gz>`_.
|
||||
Since that URL is hilariously long though, a shortened version is provided with https://goo.gl/SxQZ06 and
|
||||
used in the installation instructions below.
|
||||
|
||||
In order for the Zeroconf discovery to work, the
|
||||
`pybonjour package <https://pypi.python.org/pypi/pybonjour>`_ needs to be available
|
||||
to the Python installation running OctoPrint.
|
||||
@@ -52,7 +59,7 @@ into some folder ``~/OctoPrint``. You executed ``python setup.py install`` withi
|
||||
virtualenv in the same folder called ``venv``. In order to install ``pybonjour``
|
||||
so it will be available to OctoPrint you'll need to do the following::
|
||||
|
||||
venv/bin/pip install pybonjour
|
||||
venv/bin/pip install https://goo.gl/SxQZ06
|
||||
|
||||
**Linux users:** You'll need to install an additional dependency for this to work, the
|
||||
libdnssd compatibility layer for libavahi. On Debian/Ubuntu that can be achieved with::
|
||||
@@ -71,7 +78,7 @@ The plugin supports the following configuration keys:
|
||||
optional, if not set the port OctoPrint itself was started under will be used
|
||||
* ``pathPrefix``: Path prefix OctoPrint is running under, optional, if not
|
||||
set ``/`` will be used
|
||||
* ``useSsl``: ``true``if OctoPrint should be called via HTTPS, ``false`` otherwise
|
||||
* ``useSsl``: ``true`` if OctoPrint should be called via HTTPS, ``false`` otherwise
|
||||
* ``httpUsername``: HTTP Basic Auth username OctoPrint is reachable with, optional
|
||||
* ``httpPassword``: HTTP Basic Auth password OctoPrint is reachable with, optional
|
||||
* ``upnpUuid``: uPNP UUID used for SSDP service announcements, usually you will
|
||||
|
||||
@@ -54,6 +54,12 @@ under Settings > Plugin Manager, or by directly editing ``config.yaml``:
|
||||
# Time to live for the repository cache
|
||||
repository_ttl: 1440
|
||||
|
||||
# The URL of the plugin notices feed to use
|
||||
notices: http://plugins.octoprint.org/notices.json
|
||||
|
||||
# Time to live for the notices feed cache
|
||||
notices_ttl: 360
|
||||
|
||||
# Additional arguments to use with pip. Defaults to unset,
|
||||
# you normally shouldn't need to modify this
|
||||
pip_args: --some --additional --pip --arguments
|
||||
@@ -76,6 +82,36 @@ under Settings > Plugin Manager, or by directly editing ``config.yaml``:
|
||||
- hidden
|
||||
- plugins
|
||||
|
||||
.. _sec-bundledplugins-pluginmanager-hooks:
|
||||
|
||||
Hooks
|
||||
-----
|
||||
|
||||
.. _sec-bundledplugins-pluginmanager-hooks-reconnect_hooks:
|
||||
|
||||
octoprint.plugin.pluginmanager.reconnect_hooks
|
||||
++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. py:function:: reconnect_hooks_hook(*args, **kwargs)
|
||||
|
||||
Returns additional hooks defined by the plugin for which the plugin manager
|
||||
should display the "You should reconnect to your printer" message on plugin
|
||||
install/uninstall/enabling/disabling.
|
||||
|
||||
Handlers should return a Python list containing the affected hook names.
|
||||
|
||||
**Example**
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def reconnect_hooks_hook(*args, **kwargs):
|
||||
return ["octoprint.plugin.exampleplugin.some_custom_hook",
|
||||
"octoprint.plugin.exampleplugin.some_other_custom_hook"]
|
||||
|
||||
__plugin_hooks__ = {
|
||||
"octoprint.plugin.pluginmanager.reconnect_hooks": reconnect_hooks_hook
|
||||
}
|
||||
|
||||
.. _sec-bundledplugins-pluginmanager-sourcecode:
|
||||
|
||||
Source Code
|
||||
|
||||
@@ -188,6 +188,16 @@ Version checks
|
||||
* ``repo``: (mandatory) Github repository to check
|
||||
* ``branch``: Branch of the Github repository to check, defaults to
|
||||
``master`` if not set.
|
||||
* ``current``: Current commit hash. Will be updated automatically.
|
||||
|
||||
* ``bitbucket_commit``: Checks against commits pushed to Bitbucket. Additional
|
||||
config parameters:
|
||||
|
||||
* ``user``: (mandatory) Bitbucket user the repository to check belongs to
|
||||
* ``repo``: (mandatory) Bitbucket repository to check
|
||||
* ``branch``: Branch of the Bitbucket repository to check, defaults to
|
||||
``master`` if not set.
|
||||
* ``current``: Current commit hash. Will be updated automatically.
|
||||
|
||||
* ``git_commit``: Checks a local git repository for new commits on its
|
||||
configured remote. Additional config parameters:
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ needs_sphinx = '1.3'
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['codeblockext', 'onlineinclude', 'sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinxcontrib.httpdomain',
|
||||
'sphinx.ext.napoleon']
|
||||
'sphinx.ext.napoleon', 'sphinxcontrib.mermaid']
|
||||
todo_include_todos = True
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
|
||||
@@ -519,6 +519,23 @@ Use the following settings to enable or disable OctoPrint features:
|
||||
# If ignoredIdenticalResends is true, how many consecutive identical resends to ignore
|
||||
identicalResendsCount: 7
|
||||
|
||||
# Whether to support F on its own as a valid GCODE command (true) or not (false)
|
||||
supportFAsCommand: false
|
||||
|
||||
# Whether to enable model size detection and warning (true) or not (false)
|
||||
modelSizeDetection: true
|
||||
|
||||
# Whether to attempt to auto detect the firmware of the printer and adjust settings
|
||||
# accordingly (true) or not and rely on manual configuration (false)
|
||||
firmwareDetection: true
|
||||
|
||||
# Whether to show a confirmation on print cancelling (true) or not (false)
|
||||
printCancelConfirmation: true
|
||||
|
||||
# Whether to block all sending to the printer while a G4 (dwell) command is active (true, repetier)
|
||||
# or not (false)
|
||||
blockWhileDwelling: false
|
||||
|
||||
.. _sec-configuration-config_yaml-folder:
|
||||
|
||||
Folder
|
||||
@@ -565,6 +582,45 @@ Use the following settings to set custom paths for folders used by OctoPrint:
|
||||
# Absolute path where to store (GCODE) scripts
|
||||
scripts: /path/to/scripts/folder
|
||||
|
||||
.. _sec-configuration-config_yaml-gcodeanalysis:
|
||||
|
||||
GCODE Analysis
|
||||
--------------
|
||||
|
||||
Settings pertaining to the server side GCODE analysis implementation.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Maximum number of extruders to support/to sanity check for
|
||||
maxExtruders: 10
|
||||
|
||||
# Pause between each processed GCODE line in normal priority mode, seconds
|
||||
throttle_normalprio: 0.01
|
||||
|
||||
# Pause between each processed GCODE line in high priority mode (e.g. on fresh
|
||||
# uploads), seconds
|
||||
throttle_highprio: 0.0
|
||||
|
||||
.. _sec-configuration-config_yaml-gcodeviewer:
|
||||
|
||||
GCODE Viewer
|
||||
------------
|
||||
|
||||
Settings pertaining to the built in GCODE Viewer.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Whether to enable the GCODE viewer in the UI
|
||||
enabled: true
|
||||
|
||||
# Maximum size a GCODE file may have on mobile devices to automatically be loaded
|
||||
# into the viewer, defaults to 2MB
|
||||
mobileSizeThreshold: 2097152
|
||||
|
||||
# Maximum size a GCODE file may have to automatically be loaded into the viewer,
|
||||
# defaults to 20MB
|
||||
sizeThreshold: 20971520
|
||||
|
||||
.. _sec-configuration-config_yaml-plugins:
|
||||
|
||||
Plugin settings
|
||||
@@ -679,8 +735,34 @@ Use the following settings to configure the serial connection to the printer:
|
||||
connection: 2
|
||||
|
||||
# Timeout during serial communication, in seconds.
|
||||
# Defaults to 5 sec
|
||||
communication: 5
|
||||
# Defaults to 30 sec
|
||||
communication: 30
|
||||
|
||||
# Timeout after which to query temperature when no target is set
|
||||
temperature: 5
|
||||
|
||||
# Timeout after which to query temperature when a target is set
|
||||
temperatureTargetSet: 2
|
||||
|
||||
# Timeout after which to query the SD status while SD printing
|
||||
sdStatus: 1
|
||||
|
||||
# Maximum number of consecutive communication timeouts after which the printer will be considered
|
||||
# dead and OctoPrint disconnects with an error.
|
||||
maxCommunicationTimeouts:
|
||||
|
||||
# max. timeouts when the printer is idle
|
||||
idle: 2
|
||||
|
||||
# max. timeouts when the printer is printing
|
||||
printing: 5
|
||||
|
||||
# max. timeouts when a long running command is active
|
||||
long: 5
|
||||
|
||||
# Maximum number of write attempts to serial during which nothing can be written before the communication
|
||||
# with the printer is considered dead and OctoPrint will disconnect with an error
|
||||
maxWritePasses:
|
||||
|
||||
# Use this to define additional patterns to consider for serial port listing. Must be a valid
|
||||
# "glob" pattern (see http://docs.python.org/2/library/glob.html). Defaults to not set.
|
||||
@@ -702,6 +784,7 @@ Use the following settings to configure the serial connection to the printer:
|
||||
- G32
|
||||
- M400
|
||||
- M226
|
||||
- M600
|
||||
|
||||
# Commands which need to always be send with a checksum. Defaults to only M110
|
||||
checksumRequiringCommands:
|
||||
@@ -746,10 +829,14 @@ Use the following settings to configure the server:
|
||||
# Use this option to define the port to which to bind the server, defaults to 5000
|
||||
port: 5000
|
||||
|
||||
# If this option is true, OctoPrint will show the First Run dialog and set it to false after that
|
||||
# completes
|
||||
# If this option is true, OctoPrint will show the First Run wizard and set the setting to
|
||||
# false after that completes
|
||||
firstRun: false
|
||||
|
||||
# If this option is true, OctoPrint will enable safe mode on the next server start and
|
||||
# reset the setting to false
|
||||
startOnceInSafeMode: false
|
||||
|
||||
# Secret key for encrypting cookies and such, randomly generated on first run
|
||||
secretKey: someSecretKey
|
||||
|
||||
@@ -856,8 +943,8 @@ Use the following settings to configure the server:
|
||||
* ``X-Scheme``: should contain your custom URL scheme to use (if different from ``http``), e.g. ``https``
|
||||
|
||||
If you use these headers OctoPrint will work both via the reverse proxy as well as when called directly. Take a look
|
||||
`into OctoPrint's wiki <https://github.com/foosel/OctoPrint/wiki/Reverse-proxy-configuration-examples>`_ for a couple
|
||||
of examples on how to configure this.
|
||||
`into OctoPrint's wiki <https://github.com/foosel/OctoPrint/wiki/Reverse-proxy-configuration-examples>`_ for some
|
||||
examples on how to configure this.
|
||||
|
||||
.. _sec-configuration-config_yaml-slicing:
|
||||
|
||||
@@ -944,10 +1031,12 @@ Use `Javascript regular expressions <https://developer.mozilla.org/en/docs/Web/J
|
||||
|
||||
# A list of filters to display in the terminal tab. Defaults to the filters shown below
|
||||
terminalFilters:
|
||||
- name: Suppress M105 requests/responses
|
||||
regex: '(Send: M105)|(Recv: ok T:)'
|
||||
- name: Suppress M27 requests/responses
|
||||
regex: '(Send: M27)|(Recv: SD printing byte)'
|
||||
- name: Suppress temperature messages
|
||||
regex: '(Send: (N\d+\s+)?M105)|(Recv: ok T:)'
|
||||
- name: Suppress SD status messages
|
||||
regex: '(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)'
|
||||
- name: Suppress wait responses
|
||||
regex: 'Recv: wait'
|
||||
|
||||
.. _sec-configuration-config_yaml-webcam:
|
||||
|
||||
@@ -981,22 +1070,42 @@ Use the following settings to configure webcam support:
|
||||
# Whether to include a "created with OctoPrint" watermark in the generated timelapse movies
|
||||
watermark: true
|
||||
|
||||
# Whether to flip the webcam horizontally
|
||||
flipH: false
|
||||
|
||||
# Whether to flip the webcam vertically
|
||||
flipV: false
|
||||
|
||||
# Whether to rotate the webcam 90° counter clockwise
|
||||
rotate90: false
|
||||
|
||||
# The default timelapse settings.
|
||||
timelapse:
|
||||
|
||||
# The timelapse type. Can be either "off", "zchange" or "timed". Defaults to "off"
|
||||
type: timed
|
||||
|
||||
# The framerate at which to render the movie
|
||||
fps: 25
|
||||
|
||||
# The number of seconds in the rendered video to add after a finished print. The exact way how the
|
||||
# additional images will be recorded depends on timelapse type. Timed timelapses continue to
|
||||
# record just like at the beginning, so the recording will continue another
|
||||
# fps * postRoll * interval seconds. Zchange timelapses will take one final picture and add it fps * postRoll
|
||||
postRoll: 0
|
||||
|
||||
# Additional options depending on the timelapse type. All timelapses take a postRoll and an fps setting.
|
||||
options:
|
||||
# The number of seconds in the rendered video to add after a finished print. The exact way how the
|
||||
# additional images will be recorded depends on timelapse type. Timed timelapses continue to
|
||||
# record just like at the beginning, so the recording will continue another
|
||||
# fps * postRoll * interval seconds. Zchange timelapses will take one final picture and add it fps * postRoll
|
||||
postRoll: 0
|
||||
|
||||
# The framerate at which to render the movie
|
||||
fps: 25
|
||||
|
||||
# Timed timelapses only: The interval which to leave between images in seconds
|
||||
interval: 2
|
||||
|
||||
# Timed timelapses only: Whether to capture the snapshots for the post roll (true) or just copy
|
||||
# the last captured snapshot from the print over and over again (false)
|
||||
capturePostRoll: true
|
||||
|
||||
# ZChange timelapses only: Z-hop height during retractions to ignore for capturing snapshots
|
||||
retractionZHop: 0.0
|
||||
|
||||
# After how many days unrendered timelapses will be deleted
|
||||
cleanTmpAfterDays: 7
|
||||
@@ -145,7 +145,6 @@ You'll need a user account with administrator privileges.
|
||||
cd OctoPrint
|
||||
virtualenv venv
|
||||
source venv/bin/activate
|
||||
pip install -U pyobjc
|
||||
pip install -e .[develop]
|
||||
|
||||
You can then start OctoPrint via ``~/devel/OctoPrint/venv/bin/octoprint`` or just ``octoprint`` if you activated the virtual
|
||||
@@ -167,7 +166,7 @@ IDE Setup
|
||||
PyCharm
|
||||
.......
|
||||
|
||||
- "File" > "Open ...", select OctoPrint checkout folder (e.g. ``~/devel/OctoPrint/venv`` or ``C:\Devel\OctoPrint``)
|
||||
- "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
|
||||
folder (e.g. ``~/devel/OctoPrint/venv`` or ``C:\Devel\OctoPrint\venv``)
|
||||
- Right click "src" in project tree, mark as source folder
|
||||
|
||||
+71
-7
@@ -152,7 +152,7 @@ File handling
|
||||
-------------
|
||||
|
||||
Upload
|
||||
A file has been uploaded.
|
||||
A file has been uploaded through the web interface.
|
||||
|
||||
Payload:
|
||||
* ``name``: the file's name
|
||||
@@ -165,19 +165,74 @@ Upload
|
||||
|
||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
||||
|
||||
FileAdded
|
||||
A file has been added to a storage.
|
||||
|
||||
Payload:
|
||||
* ``storage``: the storage's identifier
|
||||
* ``path``: the file's path within its storage location
|
||||
* ``name``: the file's name
|
||||
* ``type``: the file's type, a list of the path within the type hierarchy, e.g. ``["machinecode", "gcode"]`` or
|
||||
``["model", "stl"]``
|
||||
|
||||
.. note::
|
||||
|
||||
A copied file triggers this for its new path. A moved file first triggers ``FileRemoved`` for its original
|
||||
path and then ``FileAdded`` for the new one.
|
||||
|
||||
FileRemoved
|
||||
A file has been removed from a storage.
|
||||
|
||||
Payload:
|
||||
* ``storage``: the storage's identifier
|
||||
* ``path``: the file's path within its storage location
|
||||
* ``name``: the file's name
|
||||
* ``type``: the file's type, a list of the path within the type hierarchy, e.g. ``["machinecode", "gcode"]`` or
|
||||
``["model", "stl"]``
|
||||
|
||||
.. note::
|
||||
|
||||
A moved file first triggers ``FileRemoved`` for its original path and then ``FileAdded`` for the new one.
|
||||
|
||||
FolderAdded
|
||||
A folder has been added to a storage.
|
||||
|
||||
Payload:
|
||||
* ``storage``: the storage's identifier
|
||||
* ``path``: the folders's path within its storage location
|
||||
* ``name``: the folders's name
|
||||
|
||||
.. note::
|
||||
|
||||
A copied folder triggers this for its new path. A moved folder first triggers ``FolderRemoved`` for its original
|
||||
path and then ``FolderAdded`` for the new one.
|
||||
|
||||
FolderRemoved
|
||||
A folder has been removed from a storage.
|
||||
|
||||
Payload:
|
||||
* ``storage``: the storage's identifier
|
||||
* ``path``: the folders's path within its storage location
|
||||
* ``name``: the folders's name
|
||||
|
||||
.. note::
|
||||
|
||||
A moved folder first triggers ``FolderRemoved`` for its original path and then ``FolderAdded`` for the new one.
|
||||
|
||||
UpdatedFiles
|
||||
A file list was modified.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``type``: the type of file list that was modified. Currently only ``printables`` and ``gcode`` (DEPRECATED) are supported here.
|
||||
* ``type``: the type of file list that was modified. Only ``printables`` is supported here. See the deprecation
|
||||
note below.
|
||||
|
||||
.. note::
|
||||
.. deprecated:: 1.2.0
|
||||
|
||||
The ``gcode`` modification type has been superceeded by ``printables``. It is currently still available for
|
||||
reasons of backwards compatibility and will also be sent on modification of ``printables``. It will however
|
||||
be removed with 1.4.0.
|
||||
|
||||
The type ``gcode`` has been renamed to ``printables`` with the introduction of a new file management layer that
|
||||
supports STL files as first class citizens as well. For reasons of backwards compatibility the ``UpdatedFiles``
|
||||
event for printable files will be fired twice, once with ``type`` set to ``gcode``, once set to ``printables``.
|
||||
Support for the ``gcode`` type will be removed in the next release after version 1.2.0.
|
||||
|
||||
MetadataAnalysisStarted
|
||||
The metadata analysis of a file has started.
|
||||
@@ -422,6 +477,15 @@ PositionUpdate
|
||||
* ``t``: last tool selected *through OctoPrint*
|
||||
* ``f``: last feedrate for move commands ``G0``, ``G1`` or ``G28`` sent *through OctoPrint*
|
||||
|
||||
ToolChange
|
||||
A tool change command was sent to the printer. The payload contains the former current tool index and the
|
||||
new current tool index.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``old``: old tool index
|
||||
* ``new``: new tool index
|
||||
|
||||
Timelapses
|
||||
----------
|
||||
|
||||
|
||||
@@ -13,11 +13,19 @@ Unless :ref:`configured otherwise <sec-configuration-config_yaml-folder>`, OctoP
|
||||
the ``scripts/gcode`` folder in OctoPrint configuration directory (per default ``~/.octoprint`` on Linux, ``%APPDATA%\OctoPrint``
|
||||
on Windows and ``~/Library/Application Support/OctoPrint`` on MacOS).
|
||||
|
||||
These GCODE scripts are backed by the templating engine `Jinja2 <http://jinja.pocoo.org/>`_, allowing more than just
|
||||
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
|
||||
this end, OctoPrint injects a couple of variables into the :ref:`template rendering context <sec-features-gcode_scripts-context>`
|
||||
this end, OctoPrint injects some variables into the :ref:`template rendering context <sec-features-gcode_scripts-context>`
|
||||
as described below.
|
||||
|
||||
You can find the docs on the Jinja templating engine as used in OctoPrint at `jinja.octoprint.org <http://jinja.octoprint.org/templates.html>`_.
|
||||
|
||||
.. note::
|
||||
|
||||
Due to backwards compatibility issues with Jinja versions 2.9+, OctoPrint currently only supports Jinja 2.8. For this
|
||||
reason use the template documentation at `jinja.octoprint.org <http://jinja.octoprint.org/templates.html>`_ instead of the
|
||||
documentation of current stable Jinja versions.
|
||||
|
||||
.. _sec-features-gcode_scripts-predefined:
|
||||
|
||||
Predefined Scripts
|
||||
@@ -60,20 +68,35 @@ All GCODE scripts have access to the following template variables through the te
|
||||
|
||||
* ``printer_profile``: The currently selected Printer Profile, including
|
||||
information such as the extruder count, the build volume size, the filament diameter etc.
|
||||
* ``last_position``: Last position reported by the printer via `M114` (might be unset if no `M114` was sent so far!)
|
||||
* ``last_position``: Last position reported by the printer via `M114` (might be unset if no `M114` was sent so far!).
|
||||
Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and
|
||||
current tool ``t`` taken from commands sent through OctoPrint. All of these coordinates might be ``None`` if no
|
||||
position could be retrieved from the printer or the values could not be tracked (in case of ``f`` and ``t``)!
|
||||
* ``last_temperature``: Last actual and target temperature reported for all available tools and if available the
|
||||
heated bed. This is a dictionary of key-value pairs. The keys are the indices of the available tools (``0``, ``1``,
|
||||
...) and ``b`` for the heated bed. The values are a dictionary consisting of ``actual`` and ``target`` keys mapped
|
||||
to the corresponding temperature in degrees celsius. Note that not all tools your printer has must necessarily be
|
||||
present here, neither must the heated bed - it depends on whether OctoPrint has values for a tool or the bed. Also
|
||||
note that ``actual`` and ``target`` might be ``None``.
|
||||
* ``script``: An object wrapping the script's type (``gcode``) and name (e.g. ``afterPrintCancelled``) as ``script.type``
|
||||
and ``script.name`` respectively.
|
||||
|
||||
There are a couple of additional template variables available for the following specific scripts:
|
||||
There are a few additional template variables available for the following specific scripts:
|
||||
|
||||
* ``afterPrintPaused`` and ``beforePrintResumed``
|
||||
* ``pause_position``: Position reported by the printer via ``M114`` immediately before the print was paused. Consists
|
||||
of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and current tool
|
||||
``t`` taken from commands sent through OctoPrint.
|
||||
|
||||
* ``pause_position``: Position reported by the printer via ``M114`` immediately before the print was paused. See
|
||||
``last_position`` above for the structure to expect here.
|
||||
* ``pause_temperature``: Last known temperature values when the print was paused. See ``last_temperature`` above
|
||||
for the structure to expect here.
|
||||
|
||||
* ``afterPrintCancelled``
|
||||
|
||||
* ``cancel_position``: Position reported by the printer via ``M114`` immediately before the print was cancelled.
|
||||
Consists of ``x``, ``y``, ``z`` and ``e`` coordinates as received by the printer and tracked values for ``f`` and
|
||||
current tool ``t`` taken from commands sent through OctoPrint.
|
||||
See ``last_position`` above for the structure to expect here.
|
||||
* ``cancel_temperature``: Last known temperature values when the print was cancelled. See ``last_temperature`` above
|
||||
for the structure to expect here.
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
@@ -147,6 +170,7 @@ to 0 if a heated bed is configured.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Jinja Template Designer Documentation <http://jinja.pocoo.org/docs/dev/templates/>`_
|
||||
`Jinja Template Designer Documentation <http://jinja.octoprint.org/templates.html>`_
|
||||
Jinja's Template Designer Documentation describes the syntax and semantics of the template language used
|
||||
also by OctoPrint's GCODE scripts.
|
||||
also by OctoPrint's GCODE scripts. Linked here are the docs for Jinja 2.8.1, which OctoPrint still
|
||||
relies on for backwards compatibility reasons.
|
||||
@@ -16,3 +16,4 @@ Features
|
||||
gcode_scripts.rst
|
||||
action_commands.rst
|
||||
plugins.rst
|
||||
safemode.rst
|
||||
@@ -11,6 +11,16 @@ Right now plugins can be used to extend OctoPrint's web interface, to execute sp
|
||||
shutdown, to provide custom (API) endpoints or whole user interfaces with special functionality, to react to system
|
||||
events or progress reports or to add support for additional slicers. More plugin types are planned for the future.
|
||||
|
||||
.. note::
|
||||
|
||||
Since a plugin might not function properly and cause issues that are hard to diagnose or outright disrupt server
|
||||
functionality, you might want to be able to start OctoPrint without any third party plugins enabled. This is also
|
||||
very important when reporting bugs in OctoPrint, to ensure that what you are observing is actually a bug in
|
||||
OctoPrint and not in any of your installed third party plugins.
|
||||
|
||||
To do that, OctoPrint has a built-in safe mode that disables all plugins not shipped as part of OctoPrint. You can
|
||||
read more on how to enable that :ref:`here <sec-features-safemode>`.
|
||||
|
||||
.. _sec-features-plugins-available:
|
||||
|
||||
Finding Plugins
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
.. _sec-features-safemode:
|
||||
|
||||
*********
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
.. _sec-features-safemode-how:
|
||||
|
||||
How to start OctoPrint in safe mode
|
||||
===================================
|
||||
|
||||
There exist three ways to start OctoPrint in safe mode:
|
||||
|
||||
* since OctoPrint 1.3.2: by selecting "Restart OctoPrint in safe mode" from the "System" menu,
|
||||
if the "Restart OctoPrint" server command has been correctly configured (see :numref:`fig-features-safemode-systemmenu`).
|
||||
* by starting OctoPrint with the command line parameter ``--safe``, e.g. ``octoprint serve --safe``
|
||||
* by setting the option ``server.startOnceInSafeMode`` in :ref:`config.yaml <sec-configuration-config_yaml>`
|
||||
to ``true`` and restarting
|
||||
|
||||
The last two options will have OctoPrint enable safe mode only for the next server start - once you
|
||||
restart OctoPrint again, safe mode will be disabled again.
|
||||
|
||||
.. _fig-features-safemode-systemmenu:
|
||||
.. figure:: ../images/features-safemode-systemmenu.png
|
||||
:align: center
|
||||
:alt: "Restart OctoPrint in safe mode" in the "System" menu
|
||||
|
||||
"Restart OctoPrint in safe mode" in the "System" menu
|
||||
|
||||
.. _sec-features-safemode-differences:
|
||||
|
||||
Differences of safe mode vs normal operation mode
|
||||
=================================================
|
||||
|
||||
When OctoPrint is running in safe mode the following changes to its normal operation mode apply:
|
||||
|
||||
* 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).
|
||||
* 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's web interface will display a notification to remind you that it is running in
|
||||
safe mode.
|
||||
|
||||
.. _fig-features-safemode-notification:
|
||||
.. figure:: ../images/features-safemode-notification.png
|
||||
:align: center
|
||||
:alt: Safe mode notification
|
||||
|
||||
Safe mode notification
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
+106
-44
@@ -1,29 +1,45 @@
|
||||
.. sec-jsclientlib-base:
|
||||
.. _sec-jsclientlib-base:
|
||||
|
||||
:mod:`OctoPrint`
|
||||
----------------
|
||||
:mod:`OctoPrintClient`
|
||||
----------------------
|
||||
|
||||
.. js:data:: OctoPrint.options
|
||||
.. js:class:: OctoPrintClient([options])
|
||||
|
||||
The client library's options.
|
||||
Instantiates a new instance of the client library. Note that by default there's always an instance registered
|
||||
globally called ``OctoPrint``.
|
||||
|
||||
``OctoPrint.options.apikey``
|
||||
:param object options: An optional object of options to set :js:attr:`OctoPrintClient.options` to.
|
||||
|
||||
.. js:attribute:: OctoPrintClient.options
|
||||
|
||||
The client library instance's options. The following keys are currently supported:
|
||||
|
||||
``apikey``
|
||||
The API Key to use for requests against the OctoPrint API. Should usually be
|
||||
the anonymous UI API Key provided on the socket.
|
||||
|
||||
``OctoPrint.options.baseurl``
|
||||
``baseurl``
|
||||
The base URL of the OctoPrint API
|
||||
|
||||
``OctoPrint.options.locale``
|
||||
``locale``
|
||||
The locale to set in ``X-Locale`` headers on API requests. Useful for API
|
||||
endpoints that might return localized content.
|
||||
|
||||
.. js:data:: OctoPrint.plugins
|
||||
.. js:attribute:: OctoPrintClient.plugins
|
||||
|
||||
Registration of client library components provided by plugins.
|
||||
|
||||
OctoPrint plugins should always register their library exports
|
||||
in this object, using their plugin identifier as key.
|
||||
OctoPrint plugins should always register their client classes here using their plugin identifier as key via
|
||||
:js:func:`OctoPrintClient.registerPluginComponent`.
|
||||
|
||||
.. note::
|
||||
|
||||
The registration mechanism has changed slightly with OctoPrint 1.3.2 due to an otherwise unsolvable issue with
|
||||
allowing multiple clients to exist concurrently and still keeping the existing architecture intact.
|
||||
|
||||
The old mechanism works fine as long as you are only planning to offer your plugin client implementation on the
|
||||
default client instance ``OctoPrint``, however if you also want to support additional clients you'll need to
|
||||
use the implementation and registration approach as described below.
|
||||
|
||||
**Example:**
|
||||
|
||||
@@ -31,19 +47,26 @@
|
||||
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrint"], factory);
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(window.OctoPrint);
|
||||
factory(window.OctoPrintClient);
|
||||
}
|
||||
})(window || this, function(OctoPrint) {
|
||||
var exports = {};
|
||||
})(window || this, function(OctoPrintClient) {
|
||||
var MyPluginClient = function(base) {
|
||||
this.base = base;
|
||||
};
|
||||
|
||||
// fill exports
|
||||
MyPluginClient.prototype.someFunction = function() {
|
||||
// do something
|
||||
};
|
||||
|
||||
OctoPrint.plugins.myplugin = exports
|
||||
// further define API
|
||||
|
||||
OctoPrintClient.registerPluginComponent("myplugin", MyPluginClient);
|
||||
return MyPluginClient;
|
||||
});
|
||||
|
||||
.. js:function:: OctoPrint.getBaseUrl()
|
||||
.. js:function:: OctoPrintClient.getBaseUrl()
|
||||
|
||||
Returns the canonical base URL to use for OctoPrint's API. Uses the current value of
|
||||
:js:data:`OctoPrint.options.baseurl <OctoPrint.options>`. If that doesn't end in a ``/``,
|
||||
@@ -51,7 +74,7 @@
|
||||
|
||||
:returns string: The base url to use to access OctoPrint's API.
|
||||
|
||||
.. js:function:: OctoPrint.getRequestHeaders(additional)
|
||||
.. js:function:: OctoPrintClient.getRequestHeaders(additional)
|
||||
|
||||
Generates a dictionary of HTTP headers to use for API requests against OctoPrint with all
|
||||
necessary headers and any additionally provided ones.
|
||||
@@ -62,7 +85,7 @@
|
||||
:param object additional: Additional headers to add to the request.
|
||||
:returns object: HTTP headers to use for requests.
|
||||
|
||||
.. js:function:: OctoPrint.ajax(method, url, opts)
|
||||
.. js:function:: OctoPrintClient.ajax(method, url, opts)
|
||||
|
||||
Performs an AJAX request against the OctoPrint API, utilizing `jQuery's own ajax function <http://api.jquery.com/jquery.ajax/>`_.
|
||||
|
||||
@@ -87,7 +110,7 @@
|
||||
:param object opts: Additional options to use for the request, see above for details (optional)
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.ajaxWithData(method, url, data, opts)
|
||||
.. js:function:: OctoPrintClient.ajaxWithData(method, url, data, opts)
|
||||
|
||||
Performs an AJAX request against the OctoPrint API, including the provided ``data`` in the body of the request.
|
||||
|
||||
@@ -99,7 +122,7 @@
|
||||
:param object opts: Additonal options to use for the request (optional)
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.get(url, opts)
|
||||
.. js:function:: OctoPrintClient.get(url, opts)
|
||||
|
||||
Performs a ``GET`` request against ``url``.
|
||||
|
||||
@@ -116,7 +139,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.getWithQuery(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.getWithQuery(url, data, opts)
|
||||
|
||||
Performs a ``GET`` request against ``url`` using the provided ``data`` as URL query.
|
||||
|
||||
@@ -132,7 +155,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.post(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.post(url, data, opts)
|
||||
|
||||
Performs a ``POST`` request against ``url`` using the provided ``data`` as request body.
|
||||
|
||||
@@ -152,7 +175,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.postJson(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.postJson(url, data, opts)
|
||||
|
||||
Performs a ``POST`` request against ``url`` using the provided ``data`` object as request body
|
||||
after serializing it to JSON.
|
||||
@@ -172,33 +195,33 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.put(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.put(url, data, opts)
|
||||
|
||||
Performs ``PUT`` request against ``url`` using the provided ``data`` as request body.
|
||||
|
||||
See :js:func:`OctoPrint.post` for details.
|
||||
|
||||
.. js:function:: OctoPrint.putJson(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.putJson(url, data, opts)
|
||||
|
||||
Performs ``PUT`` request against ``url`` using the provided ``data`` as request body after
|
||||
serializing it to JSON.
|
||||
|
||||
See :js:func:`OctoPrint.postJson` for details.
|
||||
|
||||
.. js:function:: OctoPrint.patch(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.patch(url, data, opts)
|
||||
|
||||
Performs ``PATCH`` request against ``url`` using the provided ``data`` as request body.
|
||||
|
||||
See :js:func:`OctoPrint.post` for details.
|
||||
|
||||
.. js:function:: OctoPrint.patchJson(url, data, opts)
|
||||
.. js:function:: OctoPrintClient.patchJson(url, data, opts)
|
||||
|
||||
Performs ``PATCH`` request against ``url`` using the provided ``data`` as request body after
|
||||
serializing it to JSON.
|
||||
|
||||
See :js:func:`OctoPrint.postJson` for details.
|
||||
|
||||
.. js:function:: OctoPrint.delete(url, opts)
|
||||
.. js:function:: OctoPrintClient.delete(url, opts)
|
||||
|
||||
Performs a ``DELETE`` request against ``url``.
|
||||
|
||||
@@ -206,7 +229,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.download(url, opts)
|
||||
.. js:function:: OctoPrintClient.download(url, opts)
|
||||
|
||||
Downloads a file from ``url``, returning the response body as data type ``text``.
|
||||
|
||||
@@ -218,7 +241,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.upload(url, file, filename, additional)
|
||||
.. js:function:: OctoPrintClient.upload(url, file, filename, additional)
|
||||
|
||||
Uploads a ``file`` to ``url`` using a ``multipart/form-data`` ``POST`` request.
|
||||
|
||||
@@ -255,14 +278,18 @@
|
||||
|
||||
**Example:**
|
||||
|
||||
Uploading a file from a file input element, updating a label with the current upload progress.
|
||||
Uploading a file to ``some/path`` on the blueprint of plugin ``myplugin``, from a file input element,
|
||||
updating a label with the current upload progress.
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var fileInput = $("#my-file-input");
|
||||
var progressOutput = $("#progress-output");
|
||||
|
||||
OctoPrint.upload("/plugins/myplugin/some/path", fileInput, "myfilename.dat", {"somekey": "somevalue"})
|
||||
OctoPrint.upload(OctoPrint.getBlueprintUrl("myplugin") + "some/path",
|
||||
fileInput,
|
||||
"myfilename.dat",
|
||||
{"somekey": "somevalue"})
|
||||
.progress(function(data) {
|
||||
if (data.total) {
|
||||
var percentage = Math.round(data.loaded * 100 / data.total);
|
||||
@@ -277,12 +304,12 @@
|
||||
progressOutput.text("Uploaded!");
|
||||
});
|
||||
|
||||
:param string url: The URL to ``POST`` the upload to
|
||||
:param string url: URL to which to POST the upload, relative to base url or absolute
|
||||
:param object file: The file to object, see description for details
|
||||
:param string filename: An optional file name to use for the upload
|
||||
:param object additional: An optional object of additional key/value pairs to set on the uploaded form data
|
||||
|
||||
.. js:function:: OctoPrint.issueCommand(url, command, payload, opts)
|
||||
.. js:function:: OctoPrintClient.issueCommand(url, command, payload, opts)
|
||||
|
||||
Issues a command against an OctoPrint command API endpoint.
|
||||
|
||||
@@ -314,7 +341,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.getSimpleApiUrl(plugin)
|
||||
.. js:function:: OctoPrintClient.getSimpleApiUrl(plugin)
|
||||
|
||||
Returns the proper URL for the endpoint of a :class:`~octoprint.plugin.SimpleApiPlugin`, based on the
|
||||
plugin identifier.
|
||||
@@ -329,7 +356,7 @@
|
||||
:param string plugin: The identifier of the plugin for which to return the URL
|
||||
:returns string: The URL to use as endpoint
|
||||
|
||||
.. js:function:: OctoPrint.simpleApiGet(plugin, opts)
|
||||
.. js:function:: OctoPrintClient.simpleApiGet(plugin, opts)
|
||||
|
||||
Performs a ``GET`` request against the endpoint of a :class:`~octoprint.plugin.SimpleApiPlugin` with
|
||||
identifier ``plugin``.
|
||||
@@ -345,7 +372,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.simpleApiCommand(plugin, command, payload, opts)
|
||||
.. js:function:: OctoPrintClient.simpleApiCommand(plugin, command, payload, opts)
|
||||
|
||||
Performs the API command ``command`` against the endpoint of a :class:`~octoprint.plugin.SimpleApiPlugin` with
|
||||
identifier ``plugin``, including the optional ``payload``.
|
||||
@@ -366,7 +393,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.getBlueprintUrl(plugin)
|
||||
.. js:function:: OctoPrintClient.getBlueprintUrl(plugin)
|
||||
|
||||
Returns the proper base URL for blueprint endpoints of a :class:`~octoprint.plugin.BlueprintPlugin` with
|
||||
identifier ``plugin``.
|
||||
@@ -378,11 +405,15 @@
|
||||
// prints "plugin/myplugin/"
|
||||
console.log(OctoPrint.getBlueprintUrl("myplugin"));
|
||||
|
||||
.. js:function:: OctoPrint.createRejectedDeferred()
|
||||
.. js:function:: OctoPrintClient.createRejectedDeferred()
|
||||
|
||||
Static method.
|
||||
|
||||
Shortcut for creating a rejected `jQuery Deferred <http://api.jquery.com/category/deferred-object/>`_.
|
||||
|
||||
.. js:function:: OctoPrint.createCustomException(name)
|
||||
.. js:function:: OctoPrintClient.createCustomException(name)
|
||||
|
||||
Static method.
|
||||
|
||||
Creates a custom exception class. ``name`` may be either a function in which case it will be used
|
||||
as constructor for the new exception class, or a string, in which case a constructor with proper
|
||||
@@ -393,9 +424,40 @@
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
MyCustomException = OctoPrint.createCustomException("MyCustomException");
|
||||
MyCustomException = OctoPrintClient.createCustomException("MyCustomException");
|
||||
throw new MyCustomException("Something went horribly wrong!");
|
||||
|
||||
.. js:class:: OctoPrint.InvalidArgumentError
|
||||
.. js:function:: OctoPrintClient.registerPluginComponent(identifier, clientClass)
|
||||
|
||||
Static method.
|
||||
|
||||
Registers the plugin client component ``clientClass`` under the name ``identifier`` on the
|
||||
:js:attr:`OctoPrintClient.plugins` registry.
|
||||
|
||||
``clientClass`` must have a constructor that follows the signature ``ClientClass(base)`` and in which it sets
|
||||
the attribute ``base`` on the instance to:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var MyPluginClient = function(base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
Each :js:class:`OctoPrintClient` will create its own instance of registered plugin classes and make them available
|
||||
under :js:attr:`OctoPrintClient.plugins`. It will inject itself into those instances in order to allow plugin
|
||||
clients to access its functionality via ``this.base``:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
MyPluginClient.prototype.doSomething = function(data, opts) {
|
||||
return this.base.simpleApiCommand("myplugin", "doSomething", data, opts);
|
||||
};
|
||||
|
||||
:param string identifier: The identifier of the plugin for which ``clientClass`` is the client
|
||||
:param class clientClass: The client class to register. Constructor must follow the signature ``ClientClass(base)``
|
||||
where ``base`` will be assigned to the instance as ``this.base`` and be the :js:class:`OctoPrintClient`
|
||||
instance to use for API calls etc via ``this.base``.
|
||||
|
||||
.. js:class:: OctoPrintClient.InvalidArgumentError
|
||||
|
||||
Exception to use when functions are called with invalid arguments.
|
||||
@@ -1,9 +1,9 @@
|
||||
.. sec-jsclientlib-browser:
|
||||
.. _sec-jsclientlib-browser:
|
||||
|
||||
:mod:`OctoPrint.browser`
|
||||
------------------------
|
||||
:mod:`OctoPrintClient.browser`
|
||||
------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.browser.login(username, password, remember, opts)
|
||||
.. js:function:: OctoPrintClient.browser.login(username, password, remember, opts)
|
||||
|
||||
Logs the browser into OctoPrint, using the provided ``username`` and
|
||||
``password`` as credentials. If ``remember`` is set to ``true``, the session
|
||||
@@ -24,7 +24,7 @@
|
||||
:param object opts: Additional request options
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.browser.passiveLogin(opts)
|
||||
.. js:function:: OctoPrintClient.browser.passiveLogin(opts)
|
||||
|
||||
Tries to perform a passive login into OctoPrint, using existing session data
|
||||
stored in the browser's cookies.
|
||||
@@ -32,7 +32,7 @@
|
||||
:param object opts: Additional request options
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.browser.logout(opts)
|
||||
.. js:function:: OctoPrintClient.browser.logout(opts)
|
||||
|
||||
Logs the browser out of OctoPrint.
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.. sec-jsclientlib-connection:
|
||||
.. _sec-jsclientlib-connection:
|
||||
|
||||
:mod:`OctoPrint.connection`
|
||||
---------------------------
|
||||
:mod:`OctoPrintClient.connection`
|
||||
---------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.connection.getSettings(opts)
|
||||
.. js:function:: OctoPrintClient.connection.getSettings(opts)
|
||||
|
||||
Retrieves the available connection options for connection to a printer.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.connection.connect(data, opts)
|
||||
.. js:function:: OctoPrintClient.connection.connect(data, opts)
|
||||
|
||||
Connects to the printer, optionally using the provided connection ``data`` as parameters.
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.connection.disconnect(opts)
|
||||
.. js:function:: OctoPrintClient.connection.disconnect(opts)
|
||||
|
||||
Disconnects from the printer.
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.connection.fakeAck(opts)
|
||||
.. js:function:: OctoPrintClient.connection.fakeAck(opts)
|
||||
|
||||
Triggers a fake acknowledgement (``ok``) on the printer.
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
.. sec-jsclientlib-control:
|
||||
.. _sec-jsclientlib-control:
|
||||
|
||||
:mod:`OctoPrint.control`
|
||||
------------------------
|
||||
:mod:`OctoPrintClient.control`
|
||||
------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.control.getCustomControls(opts)
|
||||
.. js:function:: OctoPrintClient.control.getCustomControls(opts)
|
||||
|
||||
Retrieves the defined custom controls from the server.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.control.sendGcode(commands, opts)
|
||||
.. js:function:: OctoPrintClient.control.sendGcode(commands, opts)
|
||||
|
||||
Sends the provided ``commands`` to the printer.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.control.sendGcodeWithParameters(commands, parameters, opts)
|
||||
.. js:function:: OctoPrintClient.control.sendGcodeWithParameters(commands, parameters, opts)
|
||||
|
||||
Sends the provided ``commands`` to the printer, replacing contained placeholders with
|
||||
the provided ``parameters`` first.
|
||||
@@ -34,7 +34,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.control.sendGcodeScript(script, context, opts)
|
||||
.. js:function:: OctoPrintClient.control.sendGcodeScript(script, context, opts)
|
||||
|
||||
Sends the provided ``script`` to the printer, enhancing the template with the
|
||||
specified ``context``.
|
||||
@@ -44,7 +44,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.control.sendGcodeScriptWithParameters(script, context, parameters, opts)
|
||||
.. js:function:: OctoPrintClient.control.sendGcodeScriptWithParameters(script, context, parameters, opts)
|
||||
|
||||
Sends the provided ``script`` to the printer, enhancing the template with the
|
||||
specified ``context`` and ``parameters``.
|
||||
|
||||
+16
-16
@@ -1,9 +1,9 @@
|
||||
.. sec-jsclientlib-files:
|
||||
.. _sec-jsclientlib-files:
|
||||
|
||||
:mod:`OctoPrint.files`
|
||||
----------------------
|
||||
:mod:`OctoPrintClient.files`
|
||||
----------------------------
|
||||
|
||||
.. js:function:: OctoPrint.files.get(location, filename, opts)
|
||||
.. js:function:: OctoPrintClient.files.get(location, filename, opts)
|
||||
|
||||
Retrieves information about the file ``filename`` at ``location``.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.list(recursively, opts)
|
||||
.. js:function:: OctoPrintClient.files.list(recursively, opts)
|
||||
|
||||
Retrieves a list of all files from the server.
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.listForLocation(location, recursively, opts)
|
||||
.. js:function:: OctoPrintClient.files.listForLocation(location, recursively, opts)
|
||||
|
||||
Retrieves a list of all files stored at the specified ``location`` from the server.
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.select(location, path, print, opts)
|
||||
.. js:function:: OctoPrintClient.files.select(location, path, print, opts)
|
||||
|
||||
Selects a file at ``location`` named ``filename`` for printing. If ``print`` is supplied and
|
||||
truthy, also starts printing the file immediately.
|
||||
@@ -86,7 +86,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.slice(location, path, parameters, opts)
|
||||
.. js:function:: OctoPrintClient.files.slice(location, path, parameters, opts)
|
||||
|
||||
Slices a file at ``location`` called ``filename``, using the supplied slice command ``parameters``.
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.delete(location, path, opts)
|
||||
.. js:function:: OctoPrintClient.files.delete(location, path, opts)
|
||||
|
||||
Deletes the file or folder at ``location`` and ``path``.
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.copy(location, path, destination, opts)
|
||||
.. js:function:: OctoPrintClient.files.copy(location, path, destination, opts)
|
||||
|
||||
Copies file or folder ``path`` on ``location`` to new parent folder ``destination`` on ``location``.
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.move(location, filename, destination, opts)
|
||||
.. js:function:: OctoPrintClient.files.move(location, filename, destination, opts)
|
||||
|
||||
Moves file or folder ``path`` on ``location`` to new parent folder ``destination`` on ``location``.
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.createFolder(location, name, path, opts)
|
||||
.. js:function:: OctoPrintClient.files.createFolder(location, name, path, opts)
|
||||
|
||||
Creates a new folder ``name`` on ``location``. If ``path`` is provided and not empty the folder
|
||||
will be created as a new child of it.
|
||||
@@ -173,7 +173,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.upload(location, file, data)
|
||||
.. js:function:: OctoPrintClient.files.upload(location, file, data)
|
||||
|
||||
Uploads a ``file`` to the specified ``location``.
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
:param object or string file: The file to upload, see :js:func:`OctoPrint.upload` for more details
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.download(location, path, opts)
|
||||
.. js:function:: OctoPrintClient.files.download(location, path, opts)
|
||||
|
||||
Downloads the file at ``path`` in ``location``.
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.files.pathForEntry(entry)
|
||||
.. js:function:: OctoPrintClient.files.pathForEntry(entry)
|
||||
|
||||
Utility function to retrieve the path within its location for a given ``entry``.
|
||||
|
||||
@@ -242,7 +242,7 @@
|
||||
:param object entry: The entry object for which to retrieve the path
|
||||
:returns string: The path of the entry within its location
|
||||
|
||||
.. js:function:: OctoPrint.files.entryForPath(path, root)
|
||||
.. js:function:: OctoPrintClient.files.entryForPath(path, root)
|
||||
|
||||
Utility function to retrieve an entry by its ``path`` based on an entry tree provided by its
|
||||
``root``.
|
||||
|
||||
@@ -43,6 +43,41 @@ because the library depends on those to be available (as ``$`` and ``_``). You c
|
||||
Note that all components depend on the ``base`` component to be present, so if you are only including a select
|
||||
number of components, make sure to at the very least include that one to be able to utilize the client.
|
||||
|
||||
When you import the client library as described above, a global variable ``OctoPrint`` will become available, which is
|
||||
a prepared instance of the ``OctoPrintClient`` class the library assembles from registered components. You can directly
|
||||
used that singular ``OctoPrint`` instance if you only need to talk to one OctoPrint server:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
OctoPrint.options.baseurl = "http://example.com/octoprint/"
|
||||
OctoPrint.options.apikey = "apikey";
|
||||
|
||||
OctoPrint.files.list()
|
||||
.done(function(response) {
|
||||
// do something with the response
|
||||
});
|
||||
|
||||
If you want to access multiple servers, you should however instead instantiate your own clients. You can provide the
|
||||
connection options (``baseurl`` and ``apikey``) directly in the constructor or set them later:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
var client1 = new OctoPrintClient({baseurl: "http://example.com/octoprint1/", apikey: "apikey1"});
|
||||
|
||||
var client2 = new OctoPrintClient();
|
||||
client2.options.baseurl = "http://example.com/octoprint2/";
|
||||
client2.options.apikey = "apikey2";
|
||||
|
||||
client1.files.list()
|
||||
.done(function(response) {
|
||||
// do something with the response for server 1
|
||||
});
|
||||
|
||||
client2.files.list()
|
||||
.done(function(response) {
|
||||
// do something with the response for server 2
|
||||
});
|
||||
|
||||
.. seealso::
|
||||
|
||||
`OctoPrint-ForceLogin <https://github.com/OctoPrint/OctoPrint-ForceLogin>`_
|
||||
|
||||
+10
-10
@@ -1,9 +1,9 @@
|
||||
.. sec-jsclientlib-job:
|
||||
.. _sec-jsclientlib-job:
|
||||
|
||||
:mod:`OctoPrint.job`
|
||||
--------------------
|
||||
:mod:`OctoPrintClient.job`
|
||||
--------------------------
|
||||
|
||||
.. js:function:: OctoPrint.job.get(opts)
|
||||
.. js:function:: OctoPrintClient.job.get(opts)
|
||||
|
||||
Retrieves information about the current job.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.job.start(opts)
|
||||
.. js:function:: OctoPrintClient.job.start(opts)
|
||||
|
||||
Starts the current job.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.job.cancel(opts)
|
||||
.. js:function:: OctoPrintClient.job.cancel(opts)
|
||||
|
||||
Cancels the current job.
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.job.restart(opts)
|
||||
.. js:function:: OctoPrintClient.job.restart(opts)
|
||||
|
||||
Restarts the current job. This is equivalent to cancelling and immediately restarting
|
||||
the job.
|
||||
@@ -53,7 +53,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.job.pause(opts)
|
||||
.. js:function:: OctoPrintClient.job.pause(opts)
|
||||
|
||||
Pauses the current job if it's running, does nothing if it's already paused.
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.job.resume(opts)
|
||||
.. js:function:: OctoPrintClient.job.resume(opts)
|
||||
|
||||
Resumes the current job if it's currently pause, does nothing if it's running.
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.job.togglePause(opts)
|
||||
.. js:function:: OctoPrintClient.job.togglePause(opts)
|
||||
|
||||
Resumes a paused and pauses a running job.
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
.. sec-jsclientlib-languages:
|
||||
.. _sec-jsclientlib-languages:
|
||||
|
||||
:mod:`OctoPrint.languages`
|
||||
--------------------------
|
||||
:mod:`OctoPrintClient.languages`
|
||||
--------------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.languages.list(opts)
|
||||
.. js:function:: OctoPrintClient.languages.list(opts)
|
||||
|
||||
Retrieves a list of available language packs.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.languages.upload(file)
|
||||
.. js:function:: OctoPrintClient.languages.upload(file)
|
||||
|
||||
Uploads a language pack.
|
||||
|
||||
:param object or string file: The file to upload, see :js:func:`OctoPrint.upload` for more details
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.languages.delete(locale, pack, opts)
|
||||
.. js:function:: OctoPrintClient.languages.delete(locale, pack, opts)
|
||||
|
||||
Deletes the language pack ``pack`` for the specified locale ``locale``.
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
.. sec-jsclientlib-logs:
|
||||
.. _sec-jsclientlib-logs:
|
||||
|
||||
:mod:`OctoPrint.logs`
|
||||
---------------------
|
||||
:mod:`OctoPrintClient.logs`
|
||||
---------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.logs.list(opts)
|
||||
.. js:function:: OctoPrintClient.logs.list(opts)
|
||||
|
||||
Retrieves a list of log files.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.logs.delete(path, opts)
|
||||
.. js:function:: OctoPrintClient.logs.delete(path, opts)
|
||||
|
||||
Deletes the specified log ``path``.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.logs.download(path, opts)
|
||||
.. js:function:: OctoPrintClient.logs.download(path, opts)
|
||||
|
||||
Downloads the specified log ``file``.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.. sec-jsclientlib-printer:
|
||||
.. _sec-jsclientlib-printer:
|
||||
|
||||
:mod:`OctoPrint.printer`
|
||||
------------------------
|
||||
:mod:`OctoPrintClient.printer`
|
||||
------------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
.. js:function:: OctoPrint.printer.getFullState(flags, opts)
|
||||
.. js:function:: OctoPrintClient.printer.getFullState(flags, opts)
|
||||
|
||||
Retrieves the full printer state, including temperature information, sd state and general
|
||||
printer state.
|
||||
@@ -34,7 +34,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.getToolState(flags, opts)
|
||||
.. js:function:: OctoPrintClient.printer.getToolState(flags, opts)
|
||||
|
||||
Retrieves the current printer extruder state/temperature information, and optionally also the temperature
|
||||
history.
|
||||
@@ -52,7 +52,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.setToolTargetTemperatures(targets, opts)
|
||||
.. js:function:: OctoPrintClient.printer.setToolTargetTemperatures(targets, opts)
|
||||
|
||||
Sets the given temperatures on the printer's extruders.
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.setToolTemperatureOffsets(offsets, opts)
|
||||
.. js:function:: OctoPrintClient.printer.setToolTemperatureOffsets(offsets, opts)
|
||||
|
||||
Sets the given temperature offsets for the printer's extruders.
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.selectTool(tool, opts)
|
||||
.. js:function:: OctoPrintClient.printer.selectTool(tool, opts)
|
||||
|
||||
Selects the printer's current extruder.
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.extrude(amount, opts)
|
||||
.. js:function:: OctoPrintClient.printer.extrude(amount, opts)
|
||||
|
||||
Extrudes or retracts ``amount`` mm of filament on the currently selected extruder.
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.setFlowrate(factor, opts)
|
||||
.. js:function:: OctoPrintClient.printer.setFlowrate(factor, opts)
|
||||
|
||||
Sets the current flowrate multiplier.
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.getBedState(data, opts)
|
||||
.. js:function:: OctoPrintClient.printer.getBedState(data, opts)
|
||||
|
||||
Retrieves the current printer bed state/temperature information, and optionally also the temperature
|
||||
history.
|
||||
@@ -170,7 +170,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.setBedTargetTemperature(target, opts)
|
||||
.. js:function:: OctoPrintClient.printer.setBedTargetTemperature(target, opts)
|
||||
|
||||
Sets the given temperature on the printer's heated bed (if available).
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.setBedTemperatureOffset(offset, opts)
|
||||
.. js:function:: OctoPrintClient.printer.setBedTemperatureOffset(offset, opts)
|
||||
|
||||
Sets the given temperature offset for the printer's heated bed (if available).
|
||||
|
||||
@@ -210,7 +210,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.jog(amounts, opts)
|
||||
.. js:function:: OctoPrintClient.printer.jog(amounts, opts)
|
||||
|
||||
Jogs the specified axes by the specified ``amounts``.
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.home(axes, opts)
|
||||
.. js:function:: OctoPrintClient.printer.home(axes, opts)
|
||||
|
||||
Homes the specified ``axes``.
|
||||
|
||||
@@ -263,7 +263,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.setFeedrate(factor, opts)
|
||||
.. js:function:: OctoPrintClient.printer.setFeedrate(factor, opts)
|
||||
|
||||
Sets the feedrate multiplier to use.
|
||||
|
||||
@@ -275,7 +275,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.getSdState(opts)
|
||||
.. js:function:: OctoPrintClient.printer.getSdState(opts)
|
||||
|
||||
Retrieves the current ready state of the printer's SD card.
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.initSd(opts)
|
||||
.. js:function:: OctoPrintClient.printer.initSd(opts)
|
||||
|
||||
Instructs the printer to initialize its SD card (if present).
|
||||
|
||||
@@ -293,7 +293,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.refreshSd(opts)
|
||||
.. js:function:: OctoPrintClient.printer.refreshSd(opts)
|
||||
|
||||
Instructs the printer to refresh the list of files on the SD card (if present).
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printer.releaseSd(opts)
|
||||
.. js:function:: OctoPrintClient.printer.releaseSd(opts)
|
||||
|
||||
Instructs the printer to release its SD card (if present).
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
.. sec-jsclientlib-printerprofiles:
|
||||
.. _sec-jsclientlib-printerprofiles:
|
||||
|
||||
:mod:`OctoPrint.printerprofiles`
|
||||
--------------------------------
|
||||
:mod:`OctoPrintClient.printerprofiles`
|
||||
--------------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.printerprofiles.list(opts)
|
||||
.. js:function:: OctoPrintClient.printerprofiles.list(opts)
|
||||
|
||||
Retrieves a list of all configured printer profiles.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printerprofiles.get(id, opts)
|
||||
.. js:function:: OctoPrintClient.printerprofiles.get(id, opts)
|
||||
|
||||
:param string id: The identifier of the profile to retrieve
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printerprofiles.add(profile, additional, opts)
|
||||
.. js:function:: OctoPrintClient.printerprofiles.add(profile, additional, opts)
|
||||
|
||||
Adds a new profile to OctoPrint.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printerprofiles.update(id, profile, opts)
|
||||
.. js:function:: OctoPrintClient.printerprofiles.update(id, profile, opts)
|
||||
|
||||
Updates an existing profile in OctoPrint.
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.printerprofiles.delete(id, opts)
|
||||
.. js:function:: OctoPrintClient.printerprofiles.delete(id, opts)
|
||||
|
||||
Deletes a profile in OctoPrint.
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
.. sec-jsclientlib-settings:
|
||||
.. _sec-jsclientlib-settings:
|
||||
|
||||
:mod:`OctoPrint.settings`
|
||||
-------------------------
|
||||
:mod:`OctoPrintClient.settings`
|
||||
-------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.settings.get(opts)
|
||||
.. js:function:: OctoPrintClient.settings.get(opts)
|
||||
|
||||
Retrieves the current settings.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.settings.save(settings, opts)
|
||||
.. js:function:: OctoPrintClient.settings.save(settings, opts)
|
||||
|
||||
Saves the provided ``settings``.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.settings.getPluginSettings(plugin, opts)
|
||||
.. js:function:: OctoPrintClient.settings.getPluginSettings(plugin, opts)
|
||||
|
||||
Retrieves the settings of the specified ``plugin``.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.settings.savePluginSettings(plugin, settings, opts)
|
||||
.. js:function:: OctoPrintClient.settings.savePluginSettings(plugin, settings, opts)
|
||||
|
||||
Saves the ``settings`` for the specified ``plugin``.
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrintClient.settings.generateApiKey(opts)
|
||||
|
||||
Generate a new system wide API key.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ref:`Settings API <sec-api-settings>`
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
.. sec-jsclientlib-slicing:
|
||||
.. _sec-jsclientlib-slicing:
|
||||
|
||||
:mod:`OctoPrint.slicing`
|
||||
------------------------
|
||||
:mod:`OctoPrintClient.slicing`
|
||||
------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.slicing.listAllSlicersAndProfiles(opts)
|
||||
.. js:function:: OctoPrintClient.slicing.listAllSlicersAndProfiles(opts)
|
||||
|
||||
Retrieves a list of all slicers and their available slicing profiles.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.slicing.listProfilesForSlicer(slicer, opts)
|
||||
.. js:function:: OctoPrintClient.slicing.listProfilesForSlicer(slicer, opts)
|
||||
|
||||
Retrieves of all slicing profiles for the specified ``slicer``.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.slicing.getProfileForSlicer(slicer, profileId, opts)
|
||||
.. js:function:: OctoPrintClient.slicing.getProfileForSlicer(slicer, profileId, opts)
|
||||
|
||||
Retrieves the slicing profile with ``profileId`` for the specified ``slicer``.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.slicing.addProfileForSlicer(slicer, profileId, profile, opts)
|
||||
.. js:function:: OctoPrintClient.slicing.addProfileForSlicer(slicer, profileId, profile, opts)
|
||||
|
||||
Adds the profile with identifier ``profileId`` to the specified ``slicer``, using the provided ``profile`` data.
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.slicing.updateProfileForSlicer(slicer, profileId, profile, opts)
|
||||
.. js:function:: OctoPrintClient.slicing.updateProfileForSlicer(slicer, profileId, profile, opts)
|
||||
|
||||
Updates the profile ``profileId`` for ``slicer`` with the provided ``profile`` data.
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.slicing.deleteProfileForSlicer(slicer, profileId, opts)
|
||||
.. js:function:: OctoPrintClient.slicing.deleteProfileForSlicer(slicer, profileId, opts)
|
||||
|
||||
Deletes the profile ``profileId`` for ``slicer``.
|
||||
|
||||
|
||||
+15
-15
@@ -1,24 +1,24 @@
|
||||
.. sec-jsclientlib-socket:
|
||||
.. _sec-jsclientlib-socket:
|
||||
|
||||
:mod:`OctoPrint.socket`
|
||||
-----------------------
|
||||
:mod:`OctoPrintClient.socket`
|
||||
-----------------------------
|
||||
|
||||
.. js:data:: OctoPrint.socket.options
|
||||
.. js:attribute:: OctoPrintClient.socket.options
|
||||
|
||||
The socket client's options.
|
||||
|
||||
``OctoPrint.socket.options.timeouts``
|
||||
``OctoPrintClient.socket.options.timeouts``
|
||||
A list of consecutive timeouts after which to attempt reconnecting to a
|
||||
disconnected sockets, in seconds. Defaults to ``[1, 1, 2, 3, 5, 8, 13, 20, 40, 100]``.
|
||||
The default setting here makes the client slowly back off after the first couple of very
|
||||
fast connection attempts don't succeed, and give up after 10 tries.
|
||||
|
||||
``OctoPrint.socket.options.rateSlidingWindowSize``
|
||||
``OctoPrintClient.socket.options.rateSlidingWindowSize``
|
||||
Number of last rate measurements to take into account for timing analysis and
|
||||
communication throttling. See :ref:`Communication Throttling <sec-jsclient-socket-throttling>`
|
||||
below.
|
||||
|
||||
.. js:function:: OctoPrint.socket.connect(opts)
|
||||
.. js:function:: OctoPrintClient.socket.connect(opts)
|
||||
|
||||
Connects the socket client to OctoPrint's `SockJS <http://sockjs.org/>`_ socket.
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
|
||||
:param object opts: Additional options for the SockJS constructor.
|
||||
|
||||
.. js:function:: OctoPrint.socket.reconnect()
|
||||
.. js:function:: OctoPrintClient.socket.reconnect()
|
||||
|
||||
Reconnects the socket client. If the socket is currently connected it will be disconnected first.
|
||||
|
||||
.. js:function:: OctoPrint.socket.disconnect()
|
||||
.. js:function:: OctoPrintClient.socket.disconnect()
|
||||
|
||||
Disconnects the socket client.
|
||||
|
||||
.. js:function:: OctoPrint.socket.onMessage(message, handler)
|
||||
.. js:function:: OctoPrintClient.socket.onMessage(message, handler)
|
||||
|
||||
Registers the ``handler`` for messages of type ``message``.
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
:param string message: The type of message for which to register
|
||||
:param function handler: The handler function
|
||||
|
||||
.. js:function:: OctoPrint.socket.sendMessage(type, payload)
|
||||
.. js:function:: OctoPrintClient.socket.sendMessage(type, payload)
|
||||
|
||||
Sends a message of type ``type`` with the provided ``payload`` to the server.
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
:param string type: Type of message to send
|
||||
:param object payload: Payload to send
|
||||
|
||||
.. js:function:: OctoPrint.socket.onRateTooLow(measured, minimum)
|
||||
.. js:function:: OctoPrintClient.socket.onRateTooLow(measured, minimum)
|
||||
|
||||
Called by the socket client when the measured message round trip times have been lower than
|
||||
the current lower processing limit over the full sliding window, indicating that messages
|
||||
@@ -82,7 +82,7 @@
|
||||
:param Number measured: Maximal measured message round trip time
|
||||
:param Number minimum: Lower round trip time limit for keeping the rate
|
||||
|
||||
.. js:function:: OctoPrint.socket.onRateTooHigh(measured, maximum)
|
||||
.. js:function:: OctoPrintClient.socket.onRateTooHigh(measured, maximum)
|
||||
|
||||
Called by the socket client when the last measured round trip time was higher than the
|
||||
current upper procesisng limit, indicating that the messages are now processed slower than
|
||||
@@ -94,11 +94,11 @@
|
||||
:param Number measured: Measured message round trip time
|
||||
:param Number minimum: Upper round trip time limit for keeping the rate
|
||||
|
||||
.. js:function:: OctoPrint.socket.increaseRate()
|
||||
.. js:function:: OctoPrintClient.socket.increaseRate()
|
||||
|
||||
Instructs the server to increase the message rate by 500ms.
|
||||
|
||||
.. js:function:: OctoPrint.socket.decreaseRate()
|
||||
.. js:function:: OctoPrintClient.socket.decreaseRate()
|
||||
|
||||
Instructs the server to decrease the message rate by 500ms.
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
.. sec-jsclientlib-system:
|
||||
|
||||
:mod:`OctoPrint.system`
|
||||
-----------------------
|
||||
:mod:`OctoPrintClient.system`
|
||||
-----------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.system.getCommands(opts)
|
||||
.. js:function:: OctoPrintClient.system.getCommands(opts)
|
||||
|
||||
Retrieves a list of configured system commands for both ``core`` and ``custom`` sources.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.system.getCommandsForSource(source, opts)
|
||||
.. js:function:: OctoPrintClient.system.getCommandsForSource(source, opts)
|
||||
|
||||
Retrieves a list of system commands, limiting it to the specified ``source``, which might be
|
||||
either ``core`` or ``custom``.
|
||||
@@ -23,7 +23,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.system.executeCommand(source, action, opts)
|
||||
.. js:function:: OctoPrintClient.system.executeCommand(source, action, opts)
|
||||
|
||||
Executes command ``action`` on ``source``.
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.. sec-jsclientlib-timelapse:
|
||||
.. _sec-jsclientlib-timelapse:
|
||||
|
||||
:mod:`OctoPrint.timelapse`
|
||||
--------------------------
|
||||
:mod:`OctoPrintClient.timelapse`
|
||||
--------------------------------
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.get(unrendered, opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.get(unrendered, opts)
|
||||
|
||||
Get a list of all timelapses and the current timelapse config.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.list(opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.list(opts)
|
||||
|
||||
Get the lists of rendered and unrendered timelapses. The returned promis
|
||||
will be resolved with an object containing the properties ``rendered``
|
||||
@@ -23,21 +23,21 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.listRendered(opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.listRendered(opts)
|
||||
|
||||
Get the list of rendered timelapses.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.listUnrendered(opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.listUnrendered(opts)
|
||||
|
||||
Get the list of unrendered timelapses.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.download(filename, opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.download(filename, opts)
|
||||
|
||||
Download the rendered timelapse ``filename``.
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.delete(filename, opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.delete(filename, opts)
|
||||
|
||||
Delete the rendered timelapse ``filename``.
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.deleteUnrendered(name, opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.deleteUnrendered(name, opts)
|
||||
|
||||
Delete the unrendered timelapse ``name``.
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.renderUnrendered(name, opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.renderUnrendered(name, opts)
|
||||
|
||||
Render the unrendered timelapse ``name``.
|
||||
|
||||
@@ -69,14 +69,14 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.getConfig(opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.getConfig(opts)
|
||||
|
||||
Get the current timelapse configuration.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.timelapse.saveConfig(config, opts)
|
||||
.. js:function:: OctoPrintClient.timelapse.saveConfig(config, opts)
|
||||
|
||||
Save the timelapse configuration.
|
||||
|
||||
|
||||
+13
-13
@@ -1,7 +1,7 @@
|
||||
.. sec-jsclientlib-users:
|
||||
.. _sec-jsclientlib-users:
|
||||
|
||||
:mod:`OctoPrint.users`
|
||||
----------------------
|
||||
:mod:`OctoPrintClient.users`
|
||||
----------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
has admin rights *or* corresponds to the user to be modified. Some methods
|
||||
definitely require admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.users.list(opts)
|
||||
.. js:function:: OctoPrintClient.users.list(opts)
|
||||
|
||||
Get a list of all registered users.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.get(name, opts)
|
||||
.. js:function:: OctoPrintClient.users.get(name, opts)
|
||||
|
||||
Get information about a specific user.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.add(user, opts)
|
||||
.. js:function:: OctoPrintClient.users.add(user, opts)
|
||||
|
||||
Add a new user.
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.update(name, active, admin, opts)
|
||||
.. js:function:: OctoPrintClient.users.update(name, active, admin, opts)
|
||||
|
||||
Update an existing user.
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.delete(name, opts)
|
||||
.. js:function:: OctoPrintClient.users.delete(name, opts)
|
||||
|
||||
Delete an existing user.
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.changePassword(name, password, opts)
|
||||
.. js:function:: OctoPrintClient.users.changePassword(name, password, opts)
|
||||
|
||||
Change the password for a user.
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.generateApiKey(name, opts)
|
||||
.. js:function:: OctoPrintClient.users.generateApiKey(name, opts)
|
||||
|
||||
Generate a new API key for a user.
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.resetApiKey(name, opts)
|
||||
.. js:function:: OctoPrintClient.users.resetApiKey(name, opts)
|
||||
|
||||
Reset the API key for a user to being unset.
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.getSettings(name, opts)
|
||||
.. js:function:: OctoPrintClient.users.getSettings(name, opts)
|
||||
|
||||
Get the settings for a user.
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.users.saveSettings(name, settings, opts)
|
||||
.. js:function:: OctoPrintClient.users.saveSettings(name, settings, opts)
|
||||
|
||||
Save the settings for a user.
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
.. sec-jsclientlib-util:
|
||||
.. _sec-jsclientlib-util:
|
||||
|
||||
:mod:`OctoPrint.util`
|
||||
---------------------
|
||||
:mod:`OctoPrintClient.util`
|
||||
---------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.util.test(command, parameters, opts)
|
||||
.. js:function:: OctoPrintClient.util.test(command, parameters, opts)
|
||||
|
||||
Execute a :ref:`test command <sec-api-util-test>`.
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.util.testPath(path, additional, opts)
|
||||
.. js:function:: OctoPrintClient.util.testPath(path, additional, opts)
|
||||
|
||||
Test the provided ``path`` for existance. More test criteria supported by the :ref:`path test command <sec-api-util-test-path>`
|
||||
can be provided via the ``additional`` object.
|
||||
@@ -59,7 +59,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.util.testExecutable(path, opts)
|
||||
.. js:function:: OctoPrintClient.util.testExecutable(path, opts)
|
||||
|
||||
Shortcut to test if a provided ``path`` exists and is executable by OctoPrint.
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.util.testUrl(url, additional, opts)
|
||||
.. js:function:: OctoPrintClient.util.testUrl(url, additional, opts)
|
||||
|
||||
Test if a URL can be accessed. More test criteria supported by the :ref:`URL test command <sec-api-util-test-url>`
|
||||
can be provided via the ``additional`` object.
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
.. sec-jsclientlib-wizard:
|
||||
.. _sec-jsclientlib-wizard:
|
||||
|
||||
:mod:`OctoPrint.wizard`
|
||||
-----------------------
|
||||
:mod:`OctoPrintClient.wizard`
|
||||
-----------------------------
|
||||
|
||||
.. note::
|
||||
|
||||
All methods here require that the used API token or a the existing browser session
|
||||
has admin rights.
|
||||
|
||||
.. js:function:: OctoPrint.wizard.get(opts)
|
||||
.. js:function:: OctoPrintClient.wizard.get(opts)
|
||||
|
||||
Retrieve additional data about registered wizards.
|
||||
|
||||
:param object opts: Additional options for the request
|
||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||
|
||||
.. js:function:: OctoPrint.wizard.finish(handled, opts)
|
||||
.. js:function:: OctoPrintClient.wizard.finish(handled, opts)
|
||||
|
||||
Inform wizards that the wizard dialog has been finished.
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ development environment::
|
||||
$ virtualenv venv
|
||||
[...]
|
||||
$ source venv/bin/activate
|
||||
(venv) $ pip install -e[develop]
|
||||
(venv) $ pip install -e .[develop]
|
||||
[...]
|
||||
(venv) $ octoprint --help
|
||||
Usage: octoprint [OPTIONS] COMMAND [ARGS]...
|
||||
@@ -41,7 +41,15 @@ development environment::
|
||||
|
||||
[...]
|
||||
|
||||
We'll start at the most basic form a plugin can take - just a couple of simple lines of Python code:
|
||||
.. important::
|
||||
|
||||
This tutorial assumes you are running OctoPrint 1.3.0 and up. Please make sure your version of
|
||||
OctoPrint is up to date before proceeding. If you did a fresh checkout, that should already
|
||||
be the case but if not you might have to update first. You can check your version of OctoPrint
|
||||
by running ``octoprint --version`` or by taking a look into the lower left corner in OctoPrint's
|
||||
web interface.
|
||||
|
||||
We'll start at the most basic form a plugin can take - just a few simple lines of Python code:
|
||||
|
||||
.. code-block:: python
|
||||
:linenos:
|
||||
@@ -108,7 +116,7 @@ used :func:`~octoprint.plugin.StartupPlugin.on_startup` instead, in which case o
|
||||
up and ready to serve requests.
|
||||
|
||||
You'll also note that we are using ``self._logger`` for logging. Where did that one come from? OctoPrint's plugin system
|
||||
injects :ref:`a couple of useful objects <sec-plugins-mixins-injectedproperties>` into our plugin implementation classes,
|
||||
injects :ref:`a some useful objects <sec-plugins-mixins-injectedproperties>` into our plugin implementation classes,
|
||||
one of those being a fully instantiated `python logger <https://docs.python.org/2/library/logging.html>`_ ready to be
|
||||
used by your plugin. As you can see in the log output above, that logger uses the namespace ``octoprint.plugins.helloworld``
|
||||
for our little plugin here, or more generally ``octoprint.plugins.<plugin identifier>``.
|
||||
@@ -482,7 +490,7 @@ Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this:
|
||||
|
||||
OctoPrint injects the template variables that your plugin defines prefixed with ``plugin_<plugin identifier>_`` into
|
||||
the template renderer, so your ``url`` got turned into ``plugin_helloworld_url`` which you can now use as a simple
|
||||
`Jinja2 Variable <http://jinja.pocoo.org/docs/dev/templates/#variables>`_ in your plugin's template.
|
||||
`Jinja2 Variable <http://jinja.octoprint.org/templates.html#variables>`_ in your plugin's template.
|
||||
|
||||
Restart OctoPrint and shift-reload the page in your browser (to make sure you really get a fresh copy). The link should
|
||||
still work and point to the URL we defined as default.
|
||||
@@ -1070,8 +1078,14 @@ For some insight on how to create plugins that react to various events within Oc
|
||||
add support for a slicer, OctoPrint's own bundled `CuraEngine plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura>`_
|
||||
might give some hints. For extending OctoPrint's interface, the `NavbarTemp plugin <https://github.com/imrahil/OctoPrint-NavbarTemp>`_
|
||||
might show what's possible with a few lines of code already. Finally, just take a look at the
|
||||
`list of available plugins <https://github.com/foosel/OctoPrint/wiki#plugins>`_ on the OctoPrint wiki if you are
|
||||
looking for examples.
|
||||
`official Plugin Repository <http://plugins.octoprint.org>`_ if you are looking for examples.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Jinja Template Designer Documentation <http://jinja.octoprint.org/templates.html>`_
|
||||
Jinja's Template Designer Documentation describes the syntax and semantics of the template language used
|
||||
by OctoPrint's frontend. Linked here are the docs for Jinja 2.8.1, which OctoPrint still
|
||||
relies on for backwards compatibility reasons [#f3]_.
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
@@ -1084,3 +1098,7 @@ looking for examples.
|
||||
.. [#f2] Refer to the `LESS documentation <http://lesscss.org/#using-less>`_ on how to do that. If you are developing
|
||||
your plugin under Windows you might also want to give `WinLESS <http://winless.org/>`_ a look which will run
|
||||
in the background and keep your CSS files up to date with your various project's LESS files automatically.
|
||||
.. [#f3] Please always consult the Jinja documentation at `jinja.octoprint.org <http://jinja.octoprint.org>`_ instead of
|
||||
the current stable documentation available at Jinja's project page. The reason for that is that for backwards
|
||||
compatibility reasons OctoPrint currently sadly has to rely on an older version of Jinja. The documentation
|
||||
available at `jinja.octoprint.org <http://jinja.octoprint.org>`_ matches that older version.
|
||||
@@ -6,7 +6,7 @@ Helpers
|
||||
Helpers are methods that plugin can exposed to other plugins in order to make common functionality available on the
|
||||
system. They are registered with the OctoPrint plugin system through the use of the control property ``__plugin_helpers__``.
|
||||
|
||||
An example for providing a couple of helper functions to the system can be found in the
|
||||
An example for providing some helper functions to the system can be found in the
|
||||
`Discovery Plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Discovery>`_,
|
||||
which provides it's SSDP browsing and Zeroconf browsing and publishing functions as helper methods.
|
||||
|
||||
|
||||
+20
-1
@@ -396,7 +396,8 @@ This describes actually four hooks:
|
||||
|
||||
* ``queuing``: This phase is triggered just before the command is added to the send queue of the communication layer. This
|
||||
corresponds to the moment a command is being read from a file that is currently being printed. Handlers
|
||||
may suppress or change commands or their command type here.
|
||||
may suppress or change commands or their command type here. This is the only phase that supports multi command
|
||||
expansion by having the handler return a list, see below for details.
|
||||
* ``queued``: This phase is triggered just after the command was added to the send queue of the communication layer.
|
||||
No manipulation is possible here anymore (returned values will be ignored).
|
||||
* ``sending``: This phase is triggered just before the command is actually being sent to the printer. Right afterwards
|
||||
@@ -450,6 +451,24 @@ This describes actually four hooks:
|
||||
should use this option.
|
||||
* A 2-tuple consisting of a rewritten version of the ``cmd`` and the ``cmd_type``, e.g. ``return "M105", "temperature_poll"``.
|
||||
Handlers which wish to rewrite both the command and the command type should use this option.
|
||||
* A list of any of the above to allow for expanding one command into
|
||||
many. The following example shows how any queued command could be turned into a sequence of a temperature query,
|
||||
line number reset, display of the ``gcode`` on the printer's display and finally the actual command (this example
|
||||
does not make a lot of sense to be quite honest):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def rewrite_foo(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
|
||||
if gcode or not cmd.startswith("@foo"):
|
||||
return
|
||||
|
||||
return [("M105", "temperature_poll"),
|
||||
("M110",),
|
||||
"M117 echo foo: {}".format(cmd)]
|
||||
|
||||
|
||||
Note: Only one command of a given ``cmd_type`` (other than None) may be queued at a time. Trying to rewrite the ``cmd_type``
|
||||
to one already in the queue will give an error.
|
||||
|
||||
**Example**
|
||||
|
||||
|
||||
@@ -299,6 +299,130 @@ on your view model, taking a list of all bound view models:
|
||||
});
|
||||
})
|
||||
|
||||
.. _sec-plugins-viewmodels-livecycle:
|
||||
|
||||
Lifecycle diagrams
|
||||
------------------
|
||||
|
||||
.. _sec-plugins-viewmodels-startup:
|
||||
|
||||
Web interface startup
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mermaid::
|
||||
|
||||
sequenceDiagram
|
||||
participant Main
|
||||
participant onServerConnect
|
||||
participant fetchSettings
|
||||
participant bindViewModels
|
||||
participant DataUpdater
|
||||
participant LoginStateViewModel
|
||||
|
||||
Note right of DataUpdater: connectCallback = undefined
|
||||
|
||||
activate Main
|
||||
|
||||
Main->>+DataUpdater: connect
|
||||
Note right of DataUpdater: initialized = false
|
||||
DataUpdater-->>Main: ok
|
||||
deactivate Main
|
||||
DataUpdater->>DataUpdater: asynchronous connect to server...
|
||||
activate DataUpdater
|
||||
Note right of DataUpdater: store any callbacks instead of triggering (e.g. onServerConnect, fromHistoryData, fromCurrentData, ...)
|
||||
DataUpdater-X+Main: done
|
||||
deactivate DataUpdater
|
||||
deactivate DataUpdater
|
||||
|
||||
Main->>+DataUpdater: connectCallback = onServerConnect
|
||||
Note right of DataUpdater: connectCallback = onServerConnect
|
||||
DataUpdater-->>-Main: ok
|
||||
Main->>+onServerConnect: call
|
||||
onServerConnect->>+LoginStateViewModel: passiveLogin
|
||||
LoginStateViewModel-->>onServerConnect: ok
|
||||
onServerConnect-->>Main: ok
|
||||
deactivate onServerConnect
|
||||
deactivate Main
|
||||
|
||||
LoginStateViewModel->>+LoginStateViewModel: asynchronous passive login
|
||||
Note over Main,LoginStateViewModel: Session available!
|
||||
LoginStateViewModel-X+onServerConnect: done
|
||||
deactivate LoginStateViewModel
|
||||
deactivate LoginStateViewModel
|
||||
|
||||
onServerConnect->>+DataUpdater: initialized
|
||||
Note right of DataUpdater: initialized = true
|
||||
DataUpdater->DataUpdater: trigger stored callbacks
|
||||
DataUpdater-->>-onServerConnect: ok
|
||||
onServerConnect-X+Main: done
|
||||
deactivate onServerConnect
|
||||
|
||||
Main->>+fetchSettings: call
|
||||
Note right of fetchSettings: trigger onStartup
|
||||
|
||||
fetchSettings-->>Main: ok
|
||||
deactivate Main
|
||||
|
||||
fetchSettings->>+fetchSettings: asynchronous settings fetch
|
||||
fetchSettings->>+bindViewModels: call
|
||||
|
||||
loop for each view model
|
||||
bindViewModels->bindViewModels: trigger onBeforeBinding
|
||||
bindViewModels->bindViewModels: trigger onBoundTo
|
||||
bindViewModels->bindViewModels: trigger onAfterBinding
|
||||
end
|
||||
|
||||
bindViewModels->bindViewModels: trigger onAllBound
|
||||
opt User is logged in
|
||||
bindViewModels->>+LoginStateViewModel: onAllBound
|
||||
LoginStateViewModel->LoginStateViewModel: trigger onUserLoggedIn
|
||||
LoginStateViewModel-->>-bindViewModels: ok
|
||||
end
|
||||
bindViewModels->bindViewModels: trigger onStartupComplete
|
||||
bindViewModels-->>-fetchSettings: ok
|
||||
|
||||
deactivate fetchSettings
|
||||
deactivate fetchSettings
|
||||
|
||||
|
||||
.. _sec-plugins-viewmodels-reconnect:
|
||||
|
||||
Web interface reconnect
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mermaid::
|
||||
|
||||
sequenceDiagram
|
||||
participant onServerConnect
|
||||
participant DataUpdater
|
||||
participant LoginStateViewModel
|
||||
|
||||
activate DataUpdater
|
||||
DataUpdater->>DataUpdater: call connectCallback
|
||||
DataUpdater->>+onServerConnect: call
|
||||
onServerConnect-->>DataUpdater: ok
|
||||
deactivate DataUpdater
|
||||
|
||||
onServerConnect->>+LoginStateViewModel: passiveLogin
|
||||
LoginStateViewModel-->>onServerConnect: ok
|
||||
deactivate onServerConnect
|
||||
LoginStateViewModel->>+LoginStateViewModel: asynchronous passive login
|
||||
Note over onServerConnect,LoginStateViewModel: Session available!
|
||||
opt User is logged in
|
||||
LoginStateViewModel->LoginStateViewModel: trigger onUserLoggedIn
|
||||
end
|
||||
|
||||
activate onServerConnect
|
||||
LoginStateViewModel-XonServerConnect: done
|
||||
deactivate LoginStateViewModel
|
||||
deactivate LoginStateViewModel
|
||||
|
||||
onServerConnect->>+DataUpdater: initialized
|
||||
DataUpdater->DataUpdater: trigger stored callbacks
|
||||
DataUpdater-->>onServerConnect: ok
|
||||
deactivate DataUpdater
|
||||
deactivate onServerConnect
|
||||
|
||||
.. seealso::
|
||||
|
||||
`OctoPrint's core viewmodels <https://github.com/foosel/OctoPrint/tree/devel/src/octoprint/static/js/app/viewmodels>`_
|
||||
|
||||
@@ -7,41 +7,99 @@ __copyright__ = "Copyright (C) 2015 Gina Häußge - Released under terms of the
|
||||
|
||||
|
||||
import codecs
|
||||
import urllib2
|
||||
import requests
|
||||
from contextlib import closing
|
||||
|
||||
from sphinx.directives import LiteralInclude, dedent_lines
|
||||
from sphinx.directives.code import LiteralIncludeReader, LiteralInclude, dedent_lines, \
|
||||
nodes, set_source_info, parselinenos, logger, container_wrapper
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, List # NOQA
|
||||
|
||||
cache = dict()
|
||||
|
||||
class OnlineIncludeReader(LiteralIncludeReader):
|
||||
|
||||
def read_file(self, filename, location=None):
|
||||
# type: (unicode, Any) -> List[unicode]
|
||||
|
||||
global cache
|
||||
try:
|
||||
if filename in cache:
|
||||
lines = cache[filename]
|
||||
else:
|
||||
with closing(requests.get(filename, stream=True)) as r:
|
||||
r.encoding = self.encoding
|
||||
lines = r.text.splitlines(True)
|
||||
cache[filename] = lines
|
||||
|
||||
if 'tab-width' in self.options:
|
||||
lines = [line.expandtabs(self.options['tab-width']) for line in lines]
|
||||
|
||||
return lines
|
||||
except (IOError, OSError):
|
||||
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))
|
||||
|
||||
|
||||
class OnlineIncludeDirective(LiteralInclude):
|
||||
|
||||
def read_with_encoding(self, filename, document, codec_info, encoding):
|
||||
global cache
|
||||
def run(self):
|
||||
# type: () -> List[nodes.Node]
|
||||
document = self.state.document
|
||||
if not document.settings.file_insertion_enabled:
|
||||
return [document.reporter.warning('File insertion disabled',
|
||||
line=self.lineno)]
|
||||
env = document.settings.env
|
||||
|
||||
# convert options['diff'] to absolute path
|
||||
if 'diff' in self.options:
|
||||
_, path = env.relfn2path(self.options['diff'])
|
||||
self.options['diff'] = path
|
||||
|
||||
f = None
|
||||
try:
|
||||
if not self.arguments[0] in cache:
|
||||
f = codecs.StreamReaderWriter(urllib2.urlopen(self.arguments[0]), codec_info[2],
|
||||
codec_info[3], 'strict')
|
||||
lines = f.readlines()
|
||||
cache[self.arguments[0]] = lines
|
||||
else:
|
||||
lines = cache[self.arguments[0]]
|
||||
location = self.state_machine.get_source_and_line(self.lineno)
|
||||
url = self.arguments[0]
|
||||
|
||||
reader = OnlineIncludeReader(url, self.options, env.config)
|
||||
text, lines = reader.read(location=location)
|
||||
|
||||
retnode = nodes.literal_block(text, text, source=url)
|
||||
set_source_info(self, retnode)
|
||||
if self.options.get('diff'): # if diff is set, set udiff
|
||||
retnode['language'] = 'udiff'
|
||||
elif 'language' in self.options:
|
||||
retnode['language'] = self.options['language']
|
||||
retnode['linenos'] = ('linenos' in self.options or
|
||||
'lineno-start' in self.options or
|
||||
'lineno-match' in self.options)
|
||||
retnode['classes'] += self.options.get('class', [])
|
||||
extra_args = retnode['highlight_args'] = {}
|
||||
if 'emphasize-lines' in self.options:
|
||||
hl_lines = parselinenos(self.options['emphasize-lines'], lines)
|
||||
if any(i >= lines for i in hl_lines):
|
||||
logger.warning('line number spec is out of range(1-%d): %r' %
|
||||
(lines, self.options['emphasize-lines']),
|
||||
location=location)
|
||||
extra_args['hl_lines'] = [x + 1 for x in hl_lines if x < lines]
|
||||
extra_args['linenostart'] = reader.lineno_start
|
||||
|
||||
if 'caption' in self.options:
|
||||
caption = self.options['caption'] or self.arguments[0]
|
||||
retnode = container_wrapper(self, retnode, caption)
|
||||
|
||||
# retnode will be note_implicit_target that is linked from caption and numref.
|
||||
# when options['name'] is provided, it should be primary ID.
|
||||
self.add_name(retnode)
|
||||
|
||||
return [retnode]
|
||||
except Exception as exc:
|
||||
return [document.reporter.warning(str(exc), line=self.lineno)]
|
||||
|
||||
lines = dedent_lines(lines, self.options.get('dedent'))
|
||||
return lines
|
||||
except (IOError, OSError, urllib2.URLError):
|
||||
return [document.reporter.warning(
|
||||
'Include file %r not found or reading it failed' % self.arguments[0],
|
||||
line=self.lineno)]
|
||||
except UnicodeError:
|
||||
return [document.reporter.warning(
|
||||
'Encoding %r used for reading included file %r seems to '
|
||||
'be wrong, try giving an :encoding: option' %
|
||||
(encoding, self.arguments[0]))]
|
||||
finally:
|
||||
if f is not None:
|
||||
f.close()
|
||||
|
||||
def visit_onlineinclude(translator, node):
|
||||
translator.visit_literal_block(node)
|
||||
@@ -53,4 +111,4 @@ def setup(app):
|
||||
app.add_directive("onlineinclude", OnlineIncludeDirective)
|
||||
|
||||
handler = (visit_onlineinclude, depart_onlineinclude)
|
||||
app.add_node(OnlineIncludeDirective, html=handler, latex=handler, text=handler)
|
||||
app.add_node(OnlineIncludeDirective, html=handler, latex=handler, text=handler)
|
||||
+10
-9
@@ -13,7 +13,7 @@
|
||||
# /etc/default/octoprint.
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Sami Olmari
|
||||
# Author: Sami Olmari & Gina Häußge
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DESC="OctoPrint Daemon"
|
||||
@@ -21,9 +21,14 @@ NAME="OctoPrint"
|
||||
PKGNAME=octoprint
|
||||
PIDFILE=/var/run/$PKGNAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$PKGNAME
|
||||
DEFAULTS=/etc/default/$PKGNAME
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
|
||||
[ -r $DEFAULTS ] && . $DEFAULTS
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# Exit if the DAEMON is not set
|
||||
if [ -z "$DAEMON" ]
|
||||
@@ -38,10 +43,6 @@ fi
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -z "$START" -o "$START" != "yes" ]
|
||||
then
|
||||
log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
|
||||
@@ -55,12 +56,12 @@ then
|
||||
fi
|
||||
|
||||
COMMAND_ARGS=
|
||||
if [ -z "$BASEDIR" ]
|
||||
if [ -n "$BASEDIR" ]
|
||||
then
|
||||
COMMAND_ARGS="--basedir $BASEDIR $COMMAND_ARGS"
|
||||
fi
|
||||
|
||||
if [ -z "$CONFIGFILE" ]
|
||||
if [ -n "$CONFIGFILE" ]
|
||||
then
|
||||
COMMAND_ARGS="--config $CONFIGFILE $COMMAND_ARGS"
|
||||
fi
|
||||
@@ -91,7 +92,7 @@ do_start()
|
||||
if [ $RETVAL != 0 ]; then
|
||||
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \
|
||||
--exec $DAEMON --chuid $OCTOPRINT_USER --user $OCTOPRINT_USER --umask $UMASK --nicelevel=$NICELEVEL \
|
||||
-- $COMMAND_ARGS serve $DAEMON_ARGS
|
||||
-- serve $COMMAND_ARGS $DAEMON_ARGS
|
||||
RETVAL="$?"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ description-file = README.md
|
||||
|
||||
[versioneer]
|
||||
VCS = git
|
||||
style = pep440-post
|
||||
style = pep440-tag
|
||||
versionfile_source = src/octoprint/_version.py
|
||||
versionfile_build = octoprint/_version.py
|
||||
tag_prefix =
|
||||
|
||||
@@ -15,6 +15,9 @@ import octoprint_setuptools
|
||||
# Requirements for our application
|
||||
INSTALL_REQUIRES = [
|
||||
"flask>=0.9,<0.11",
|
||||
"Jinja2>=2.8,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
|
||||
# guarantee backwards compatibility for plugins and such with that
|
||||
# version, hence we need to pin to a lower version for now. See #1697
|
||||
"werkzeug>=0.8.3,<0.9",
|
||||
"tornado==4.0.2", # pinned for now, we need to migrate to a newer tornado, but due
|
||||
# to some voodoo needed to get large streamed uploads and downloads
|
||||
@@ -43,9 +46,15 @@ INSTALL_REQUIRES = [
|
||||
"feedparser>=5.2.1,<5.3",
|
||||
"chainmap>=1.0.2,<1.1",
|
||||
"future>=0.15,<0.16",
|
||||
"scandir>=1.3,<1.4"
|
||||
"scandir>=1.3,<1.4",
|
||||
"websocket-client>=0.40,<0.41",
|
||||
"python-dateutil>=2.6,<2.7",
|
||||
"wrapt>=1.10.10,<1.11"
|
||||
]
|
||||
|
||||
if sys.platform == "darwin":
|
||||
INSTALL_REQUIRES.append("appdirs>=1.4.0")
|
||||
|
||||
# Additional requirements for optional install options
|
||||
EXTRA_REQUIRES = dict(
|
||||
# Dependencies for developing OctoPrint
|
||||
@@ -56,9 +65,10 @@ EXTRA_REQUIRES = dict(
|
||||
"ddt",
|
||||
|
||||
# Documentation dependencies
|
||||
"sphinx>=1.3,<1.4",
|
||||
"sphinx>=1.6,<1.7",
|
||||
"sphinxcontrib-httpdomain",
|
||||
"sphinx_rtd_theme",
|
||||
"sphinxcontrib-mermaid",
|
||||
"sphinx_bootstrap_theme",
|
||||
|
||||
# PyPi upload related
|
||||
"pypandoc"
|
||||
|
||||
@@ -58,7 +58,8 @@ class FatalStartupError(BaseException):
|
||||
def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
||||
logging_config=None, debug=False, verbosity=0, uncaught_logger=None,
|
||||
uncaught_handler=None, safe_mode=False, after_preinit_logging=None,
|
||||
after_settings=None, after_logging=None, after_safe_mode=None):
|
||||
after_settings=None, after_logging=None, after_safe_mode=None,
|
||||
after_plugin_manager=None):
|
||||
kwargs = dict()
|
||||
|
||||
logger, recorder = preinit_logging(debug, verbosity, uncaught_logger, uncaught_handler)
|
||||
@@ -94,6 +95,11 @@ def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
||||
after_safe_mode(**kwargs)
|
||||
|
||||
plugin_manager = init_pluginsystem(settings, safe_mode=safe_mode)
|
||||
kwargs["plugin_manager"] = plugin_manager
|
||||
|
||||
if callable(after_plugin_manager):
|
||||
after_plugin_manager(**kwargs)
|
||||
|
||||
return settings, logger, safe_mode, plugin_manager
|
||||
|
||||
|
||||
@@ -176,7 +182,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
||||
"stream": "ext://sys.stdout"
|
||||
},
|
||||
"file": {
|
||||
"class": "octoprint.logging.handlers.CleaningTimedRotatingFileHandler",
|
||||
"class": "octoprint.logging.handlers.OctoPrintLogHandler",
|
||||
"level": "DEBUG",
|
||||
"formatter": "simple",
|
||||
"when": "D",
|
||||
@@ -221,6 +227,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
||||
if verbosity > 2:
|
||||
default_config["root"]["level"] = "DEBUG"
|
||||
|
||||
config = default_config
|
||||
if use_logging_file:
|
||||
# further logging configuration from file...
|
||||
if logging_file is None:
|
||||
@@ -233,9 +240,8 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
||||
config_from_file = yaml.safe_load(f)
|
||||
|
||||
# we merge that with the default config
|
||||
config = dict_merge(default_config, config_from_file)
|
||||
else:
|
||||
config = default_config
|
||||
if config_from_file is not None and isinstance(config_from_file, dict):
|
||||
config = dict_merge(default_config, config_from_file)
|
||||
|
||||
# configure logging globally
|
||||
return set_logging_config(config, debug, verbosity, uncaught_logger, uncaught_handler)
|
||||
|
||||
@@ -7,6 +7,7 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
||||
|
||||
import click
|
||||
import octoprint
|
||||
import sys
|
||||
|
||||
#~~ click context
|
||||
|
||||
@@ -47,15 +48,25 @@ def hidden_option(*param_decls, **attrs):
|
||||
return f
|
||||
return decorator
|
||||
|
||||
#~~ helper for settings context options
|
||||
#~~ helper for setting context options
|
||||
|
||||
def set_ctx_obj_option(ctx, param, value):
|
||||
"""Helper for setting eager options on the context."""
|
||||
if ctx.obj is None:
|
||||
ctx.obj = OctoPrintContext()
|
||||
|
||||
if hasattr(ctx.obj, param.name):
|
||||
if value != param.default:
|
||||
setattr(ctx.obj, param.name, value)
|
||||
elif param.default is not None:
|
||||
setattr(ctx.obj, param.name, param.default)
|
||||
|
||||
#~~ helper for retrieving context options
|
||||
|
||||
def get_ctx_obj_option(ctx, key, default, include_parents=True):
|
||||
if include_parents and hasattr(ctx, "parent") and ctx.parent:
|
||||
fallback = get_ctx_obj_option(ctx.parent, key, default)
|
||||
else:
|
||||
fallback = default
|
||||
return getattr(ctx.obj, key, fallback)
|
||||
|
||||
#~~ helper for setting a lot of bulk options
|
||||
|
||||
@@ -105,13 +116,13 @@ def standard_options(hidden=False):
|
||||
#~~ helper for settings legacy options we still have to support on "octoprint"
|
||||
|
||||
legacy_options = bulk_options([
|
||||
hidden_option("--host", type=click.STRING),
|
||||
hidden_option("--port", type=click.INT),
|
||||
hidden_option("--logging", type=click.Path()),
|
||||
hidden_option("--debug", "-d", is_flag=True),
|
||||
hidden_option("--daemon", type=click.Choice(["start", "stop", "restart"])),
|
||||
hidden_option("--pid", type=click.Path(), default="/tmp/octoprint.pid"),
|
||||
hidden_option("--iknowwhatimdoing", "allow_root", is_flag=True),
|
||||
hidden_option("--host", type=click.STRING, callback=set_ctx_obj_option),
|
||||
hidden_option("--port", type=click.INT, callback=set_ctx_obj_option),
|
||||
hidden_option("--logging", type=click.Path(), callback=set_ctx_obj_option),
|
||||
hidden_option("--debug", "-d", is_flag=True, callback=set_ctx_obj_option),
|
||||
hidden_option("--daemon", type=click.Choice(["start", "stop", "restart"]), callback=set_ctx_obj_option),
|
||||
hidden_option("--pid", type=click.Path(), default="/tmp/octoprint.pid", callback=set_ctx_obj_option),
|
||||
hidden_option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option),
|
||||
])
|
||||
"""Legacy options available directly on the "octoprint" command in earlier versions.
|
||||
Kept available for reasons of backwards compatibility, but hidden from the
|
||||
@@ -129,9 +140,9 @@ from .config import config_commands
|
||||
sources=[server_commands, plugin_commands, dev_commands, client_commands, config_commands])
|
||||
@standard_options()
|
||||
@legacy_options
|
||||
@click.version_option(version=octoprint.__version__)
|
||||
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
|
||||
@click.pass_context
|
||||
def octo(ctx, debug, host, port, logging, daemon, pid, allow_root):
|
||||
def octo(ctx, **kwargs):
|
||||
|
||||
if ctx.invoked_subcommand is None:
|
||||
# We have to support calling the octoprint command without any
|
||||
@@ -140,16 +151,23 @@ def octo(ctx, debug, host, port, logging, daemon, pid, allow_root):
|
||||
# But better print a message to inform people that they should
|
||||
# use the sub commands instead.
|
||||
|
||||
def get_value(key):
|
||||
return get_ctx_obj_option(ctx, key, kwargs.get(key))
|
||||
daemon = get_value("daemon")
|
||||
|
||||
if daemon:
|
||||
click.echo("Daemon operation via \"octoprint --daemon "
|
||||
"start|stop|restart\" is deprecated, please use "
|
||||
"\"octoprint daemon start|stop|restart\" from now on")
|
||||
|
||||
from octoprint.cli.server import daemon_command
|
||||
ctx.invoke(daemon_command, debug=debug, pid=pid, daemon=daemon, allow_root=allow_root)
|
||||
if sys.platform == "win32" or sys.platform == "darwin":
|
||||
click.echo("Sorry, daemon mode is not supported under your operating system right now")
|
||||
else:
|
||||
from octoprint.cli.server import daemon_command
|
||||
ctx.invoke(daemon_command, command=daemon, **kwargs)
|
||||
else:
|
||||
click.echo("Starting the server via \"octoprint\" is deprecated, "
|
||||
"please use \"octoprint serve\" from now on.")
|
||||
|
||||
from octoprint.cli.server import serve_command
|
||||
ctx.invoke(serve_command, debug=debug, host=host, port=port, logging=logging, allow_root=allow_root)
|
||||
ctx.invoke(serve_command, **kwargs)
|
||||
+61
-27
@@ -9,7 +9,7 @@ import json
|
||||
|
||||
import octoprint_client
|
||||
|
||||
from octoprint.cli import pass_octoprint_ctx, bulk_options, standard_options
|
||||
from octoprint.cli import get_ctx_obj_option
|
||||
from octoprint import init_settings, FatalStartupError
|
||||
|
||||
|
||||
@@ -29,19 +29,37 @@ def client_commands():
|
||||
|
||||
|
||||
@client_commands.group("client", context_settings=dict(ignore_unknown_options=True))
|
||||
@click.option("--apikey", "-a", type=click.STRING)
|
||||
@click.option("--host", "-h", type=click.STRING)
|
||||
@click.option("--port", "-p", type=click.INT)
|
||||
@click.option("--httpuser", type=click.STRING)
|
||||
@click.option("--httppass", type=click.STRING)
|
||||
@click.option("--https", is_flag=True)
|
||||
@click.option("--prefix", type=click.STRING)
|
||||
@pass_octoprint_ctx
|
||||
@click.pass_context
|
||||
def client(ctx, obj, host, port, httpuser, httppass, https, prefix):
|
||||
def client(ctx, apikey, host, port, httpuser, httppass, https, prefix):
|
||||
"""Basic API client."""
|
||||
try:
|
||||
obj.settings = init_settings(obj.basedir, obj.configfile)
|
||||
octoprint_client.init_client(obj.settings, https=https, httpuser=httpuser, httppass=httppass, host=host, port=port, prefix=prefix)
|
||||
if not host or not port or not apikey:
|
||||
settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None))
|
||||
|
||||
if not host:
|
||||
host = settings.get(["server", "host"])
|
||||
host = host if host != "0.0.0.0" else "127.0.0.1"
|
||||
if not port:
|
||||
port = settings.getInt(["server", "port"])
|
||||
|
||||
if not apikey:
|
||||
apikey = settings.get(["api", "key"])
|
||||
|
||||
baseurl = octoprint_client.build_base_url(https=https,
|
||||
httpuser=httpuser,
|
||||
httppass=httppass,
|
||||
host=host,
|
||||
port=port,
|
||||
prefix=prefix)
|
||||
|
||||
ctx.obj.client = octoprint_client.Client(baseurl, apikey)
|
||||
except FatalStartupError as e:
|
||||
click.echo(e.message, err=True)
|
||||
click.echo("There was a fatal error initializing the client.", err=True)
|
||||
@@ -61,27 +79,33 @@ def log_response(response, status_code=True, body=True, headers=False):
|
||||
|
||||
@client.command("get")
|
||||
@click.argument("path")
|
||||
def get(path):
|
||||
@click.option("--timeout", type=float, default=None)
|
||||
@click.pass_context
|
||||
def get(ctx, path, timeout):
|
||||
"""Performs a GET request against the specified server path."""
|
||||
r = octoprint_client.get(path)
|
||||
r = ctx.obj.client.get(path, timeout=timeout)
|
||||
log_response(r)
|
||||
|
||||
|
||||
@client.command("post_json")
|
||||
@click.argument("path")
|
||||
@click.argument("data", type=JsonStringParamType())
|
||||
def post_json(path, data):
|
||||
@click.option("--timeout", type=float, default=None)
|
||||
@click.pass_context
|
||||
def post_json(ctx, path, data, timeout):
|
||||
"""POSTs JSON data to the specified server path."""
|
||||
r = octoprint_client.post_json(path, data)
|
||||
r = ctx.obj.client.post_json(path, data, timeout=timeout)
|
||||
log_response(r)
|
||||
|
||||
|
||||
@client.command("patch_json")
|
||||
@click.argument("path")
|
||||
@click.argument("data", type=JsonStringParamType())
|
||||
def patch_json(path, data):
|
||||
@click.option("--timeout", type=float, default=None, help="Request timeout in seconds")
|
||||
@click.pass_context
|
||||
def patch_json(ctx, path, data, timeout):
|
||||
"""PATCHes JSON data to the specified server path."""
|
||||
r = octoprint_client.patch(path, data, encoding="json")
|
||||
r = ctx.obj.client.patch(path, data, encoding="json", timeout=timeout)
|
||||
log_response(r)
|
||||
|
||||
|
||||
@@ -90,8 +114,10 @@ def patch_json(path, data):
|
||||
@click.argument("file_path", type=click.Path(exists=True, dir_okay=False, resolve_path=True))
|
||||
@click.option("--json", is_flag=True)
|
||||
@click.option("--yaml", is_flag=True)
|
||||
def post_from_file(path, file_path, json_flag, yaml_flag):
|
||||
"""POSTs JSON data to the specified server path."""
|
||||
@click.option("--timeout", type=float, default=None, help="Request timeout in seconds")
|
||||
@click.pass_context
|
||||
def post_from_file(ctx, path, file_path, json_flag, yaml_flag, timeout):
|
||||
"""POSTs JSON data to the specified server path, taking the data from the specified file."""
|
||||
if json_flag or yaml_flag:
|
||||
if json_flag:
|
||||
with open(file_path, "rb") as fp:
|
||||
@@ -101,12 +127,12 @@ def post_from_file(path, file_path, json_flag, yaml_flag):
|
||||
with open(file_path, "rb") as fp:
|
||||
data = yaml.safe_load(fp)
|
||||
|
||||
r = octoprint_client.post_json(path, data)
|
||||
r = ctx.obj.client.post_json(path, data, timeout=timeout)
|
||||
else:
|
||||
with open(file_path, "rb") as fp:
|
||||
data = fp.read()
|
||||
|
||||
r = octoprint_client.post(path, data)
|
||||
r = ctx.obj.client.post(path, data, timeout=timeout)
|
||||
|
||||
log_response(r)
|
||||
|
||||
@@ -118,13 +144,15 @@ def post_from_file(path, file_path, json_flag, yaml_flag):
|
||||
@click.option("--int", "-i", "int_params", multiple=True, nargs=2, type=click.Tuple([unicode, int]))
|
||||
@click.option("--float", "-f", "float_params", multiple=True, nargs=2, type=click.Tuple([unicode, float]))
|
||||
@click.option("--bool", "-b", "bool_params", multiple=True, nargs=2, type=click.Tuple([unicode, bool]))
|
||||
def command(path, command, str_params, int_params, float_params, bool_params):
|
||||
@click.option("--timeout", type=float, default=None, help="Request timeout in seconds")
|
||||
@click.pass_context
|
||||
def command(ctx, path, command, str_params, int_params, float_params, bool_params, timeout):
|
||||
"""Sends a JSON command to the specified server path."""
|
||||
data = dict()
|
||||
params = str_params + int_params + float_params + bool_params
|
||||
for param in params:
|
||||
data[param[0]] = param[1]
|
||||
r = octoprint_client.post_command(path, command, additional=data)
|
||||
r = ctx.obj.client.post_command(path, command, additional=data, timeout=timeout)
|
||||
log_response(r, body=False)
|
||||
|
||||
|
||||
@@ -134,26 +162,32 @@ def command(path, command, str_params, int_params, float_params, bool_params):
|
||||
@click.option("--parameter", "-P", "params", multiple=True, nargs=2, type=click.Tuple([unicode, unicode]))
|
||||
@click.option("--file-name", type=click.STRING)
|
||||
@click.option("--content-type", type=click.STRING)
|
||||
def upload(path, file_path, params, file_name, content_type):
|
||||
@click.option("--timeout", type=float, default=None, help="Request timeout in seconds")
|
||||
@click.pass_context
|
||||
def upload(ctx, path, file_path, params, file_name, content_type, timeout):
|
||||
"""Uploads the specified file to the specified server path."""
|
||||
data = dict()
|
||||
for param in params:
|
||||
data[param[0]] = param[1]
|
||||
|
||||
r = octoprint_client.upload(path, file_path, additional=data, file_name=file_name, content_type=content_type)
|
||||
r = ctx.obj.client.upload(path, file_path,
|
||||
additional=data, file_name=file_name, content_type=content_type, timeout=timeout)
|
||||
log_response(r)
|
||||
|
||||
|
||||
@client.command("delete")
|
||||
@click.argument("path")
|
||||
def delete(path):
|
||||
@click.option("--timeout", type=float, default=None, help="Request timeout in seconds")
|
||||
@click.pass_context
|
||||
def delete(ctx, path, timeout):
|
||||
"""Sends a DELETE request to the specified server path."""
|
||||
r = octoprint_client.delete(path)
|
||||
r = ctx.obj.client.delete(path, timeout=timeout)
|
||||
log_response(r)
|
||||
|
||||
|
||||
@client.command("listen")
|
||||
def listen():
|
||||
@click.pass_context
|
||||
def listen(ctx):
|
||||
def on_connect(ws):
|
||||
click.echo(">>> Connected!")
|
||||
|
||||
@@ -169,11 +203,11 @@ def listen():
|
||||
def on_message(ws, message_type, message_payload):
|
||||
click.echo("Message: {}, Payload: {}".format(message_type, json.dumps(message_payload)))
|
||||
|
||||
socket = octoprint_client.connect_socket(on_connect=on_connect,
|
||||
on_close=on_close,
|
||||
on_error=on_error,
|
||||
on_heartbeat=on_heartbeat,
|
||||
on_message=on_message)
|
||||
socket = ctx.obj.client.create_socket(on_connect=on_connect,
|
||||
on_close=on_close,
|
||||
on_error=on_error,
|
||||
on_heartbeat=on_heartbeat,
|
||||
on_message=on_message)
|
||||
|
||||
click.echo(">>> Waiting for client to exit")
|
||||
try:
|
||||
|
||||
+21
-24
@@ -9,7 +9,7 @@ import click
|
||||
import logging
|
||||
|
||||
from octoprint import init_settings, FatalStartupError
|
||||
from octoprint.cli import pass_octoprint_ctx, standard_options, bulk_options
|
||||
from octoprint.cli import pass_octoprint_ctx, standard_options, bulk_options, get_ctx_obj_option
|
||||
|
||||
import yaml
|
||||
import json
|
||||
@@ -46,13 +46,12 @@ def config_commands():
|
||||
pass
|
||||
|
||||
@config_commands.group(name="config")
|
||||
@pass_octoprint_ctx
|
||||
@click.pass_context
|
||||
def config(ctx, obj):
|
||||
def config(ctx):
|
||||
"""Basic config manipulation."""
|
||||
logging.basicConfig(level=logging.DEBUG if obj.verbosity > 0 else logging.WARN)
|
||||
logging.basicConfig(level=logging.DEBUG if get_ctx_obj_option(ctx, "verbosity", 0) > 0 else logging.WARN)
|
||||
try:
|
||||
obj.settings = init_settings(obj.basedir, obj.configfile)
|
||||
ctx.obj.settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None))
|
||||
except FatalStartupError as e:
|
||||
click.echo(e.message, err=True)
|
||||
click.echo("There was a fatal error initializing the client.", err=True)
|
||||
@@ -73,7 +72,7 @@ def config(ctx, obj):
|
||||
help="Parse value from json")
|
||||
@pass_octoprint_ctx
|
||||
@click.pass_context
|
||||
def set_command(ctx, obj, path, value, as_bool, as_float, as_int, as_json):
|
||||
def set_command(ctx, path, value, as_bool, as_float, as_int, as_json):
|
||||
"""Sets a config path to the provided value."""
|
||||
if as_json:
|
||||
try:
|
||||
@@ -90,16 +89,16 @@ def set_command(ctx, obj, path, value, as_bool, as_float, as_int, as_json):
|
||||
elif as_int:
|
||||
data_type = int
|
||||
|
||||
_set_helper(obj.settings, path, value, data_type=data_type)
|
||||
_set_helper(ctx.obj.settings, path, value, data_type=data_type)
|
||||
|
||||
|
||||
@config.command(name="remove")
|
||||
@standard_options(hidden=True)
|
||||
@click.argument("path", type=click.STRING)
|
||||
@pass_octoprint_ctx
|
||||
def remove_command(obj, path):
|
||||
@click.pass_context
|
||||
def remove_command(ctx, path):
|
||||
"""Removes a config path."""
|
||||
_set_helper(obj.settings, path, None)
|
||||
_set_helper(ctx.obj.settings, path, None)
|
||||
|
||||
|
||||
@config.command(name="append_value")
|
||||
@@ -107,9 +106,8 @@ def remove_command(obj, path):
|
||||
@click.argument("path", type=click.STRING)
|
||||
@click.argument("value", type=click.STRING)
|
||||
@click.option("--json", "as_json", is_flag=True)
|
||||
@pass_octoprint_ctx
|
||||
@click.pass_context
|
||||
def append_value_command(ctx, obj, path, value, as_json=False):
|
||||
def append_value_command(ctx, path, value, as_json=False):
|
||||
"""Appends value to list behind config path."""
|
||||
path = _to_settings_path(path)
|
||||
|
||||
@@ -120,7 +118,7 @@ def append_value_command(ctx, obj, path, value, as_json=False):
|
||||
click.echo(e.message, err=True)
|
||||
ctx.exit(-1)
|
||||
|
||||
current = obj.settings.get(path)
|
||||
current = ctx.obj.settings.get(path)
|
||||
if current is None:
|
||||
current = []
|
||||
if not isinstance(current, list):
|
||||
@@ -128,7 +126,7 @@ def append_value_command(ctx, obj, path, value, as_json=False):
|
||||
ctx.exit(-1)
|
||||
|
||||
current.append(value)
|
||||
_set_helper(obj.settings, path, current)
|
||||
_set_helper(ctx.obj.settings, path, current)
|
||||
|
||||
|
||||
@config.command(name="insert_value")
|
||||
@@ -137,9 +135,8 @@ def append_value_command(ctx, obj, path, value, as_json=False):
|
||||
@click.argument("index", type=click.INT)
|
||||
@click.argument("value", type=click.STRING)
|
||||
@click.option("--json", "as_json", is_flag=True)
|
||||
@pass_octoprint_ctx
|
||||
@click.pass_context
|
||||
def insert_value_command(ctx, obj, path, index, value, as_json=False):
|
||||
def insert_value_command(ctx, path, index, value, as_json=False):
|
||||
"""Inserts value at index of list behind config key."""
|
||||
path = _to_settings_path(path)
|
||||
|
||||
@@ -150,7 +147,7 @@ def insert_value_command(ctx, obj, path, index, value, as_json=False):
|
||||
click.echo(e.message, err=True)
|
||||
ctx.exit(-1)
|
||||
|
||||
current = obj.settings.get(path)
|
||||
current = ctx.obj.settings.get(path)
|
||||
if current is None:
|
||||
current = []
|
||||
if not isinstance(current, list):
|
||||
@@ -158,7 +155,7 @@ def insert_value_command(ctx, obj, path, index, value, as_json=False):
|
||||
ctx.exit(-1)
|
||||
|
||||
current.insert(index, value)
|
||||
_set_helper(obj.settings, path, current)
|
||||
_set_helper(ctx.obj.settings, path, current)
|
||||
|
||||
|
||||
@config.command(name="remove_value")
|
||||
@@ -168,7 +165,7 @@ def insert_value_command(ctx, obj, path, index, value, as_json=False):
|
||||
@click.option("--json", "as_json", is_flag=True)
|
||||
@pass_octoprint_ctx
|
||||
@click.pass_context
|
||||
def remove_value_command(ctx, obj, path, value, as_json=False):
|
||||
def remove_value_command(ctx, path, value, as_json=False):
|
||||
"""Removes value from list at config path."""
|
||||
path = _to_settings_path(path)
|
||||
|
||||
@@ -179,7 +176,7 @@ def remove_value_command(ctx, obj, path, value, as_json=False):
|
||||
click.echo(e.message, err=True)
|
||||
ctx.exit(-1)
|
||||
|
||||
current = obj.settings.get(path)
|
||||
current = ctx.obj.settings.get(path)
|
||||
if current is None:
|
||||
current = []
|
||||
if not isinstance(current, list):
|
||||
@@ -191,7 +188,7 @@ def remove_value_command(ctx, obj, path, value, as_json=False):
|
||||
ctx.exit()
|
||||
|
||||
current.remove(value)
|
||||
_set_helper(obj.settings, path, current)
|
||||
_set_helper(ctx.obj.settings, path, current)
|
||||
|
||||
|
||||
@config.command(name="get")
|
||||
@@ -203,11 +200,11 @@ def remove_value_command(ctx, obj, path, value, as_json=False):
|
||||
@click.option("--raw", "as_raw", is_flag=True,
|
||||
help="Output value as raw string representation")
|
||||
@standard_options(hidden=True)
|
||||
@pass_octoprint_ctx
|
||||
def get_command(obj, path, as_json=False, as_yaml=False, as_raw=False):
|
||||
@click.pass_context
|
||||
def get_command(ctx, path, as_json=False, as_yaml=False, as_raw=False):
|
||||
"""Retrieves value from config path."""
|
||||
path = _to_settings_path(path)
|
||||
value = obj.settings.get(path, merged=True)
|
||||
value = ctx.obj.settings.get(path, merged=True)
|
||||
|
||||
if as_json:
|
||||
output = json.dumps(value)
|
||||
|
||||
@@ -8,6 +8,8 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
||||
|
||||
import click
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
class OctoPrintDevelCommands(click.MultiCommand):
|
||||
"""
|
||||
Custom `click.MultiCommand <http://click.pocoo.org/5/api/#click.MultiCommand>`_
|
||||
@@ -204,7 +206,7 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
||||
click.echo("This doesn't look like an OctoPrint plugin folder")
|
||||
sys.exit(1)
|
||||
|
||||
self.command_caller.call([sys.executable, "setup.py", "develop"], cwd=path)
|
||||
self.command_caller.call([sys.executable, "-m", "pip", "install", "-e", "."], cwd=path)
|
||||
|
||||
return command
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
||||
import click
|
||||
import logging
|
||||
|
||||
from octoprint.cli import pass_octoprint_ctx, OctoPrintContext
|
||||
from octoprint.cli import pass_octoprint_ctx, OctoPrintContext, get_ctx_obj_option
|
||||
|
||||
#~~ "octoprint plugin:command" commands
|
||||
|
||||
@@ -50,8 +50,8 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
||||
# context (basedir and configfile)
|
||||
from octoprint import init_settings, init_pluginsystem, FatalStartupError
|
||||
try:
|
||||
self.settings = init_settings(ctx.obj.basedir, ctx.obj.configfile)
|
||||
self.plugin_manager = init_pluginsystem(self.settings, safe_mode=ctx.obj.safe_mode)
|
||||
self.settings = init_settings(get_ctx_obj_option(ctx, "basedir", None), get_ctx_obj_option(ctx, "configfile", None))
|
||||
self.plugin_manager = init_pluginsystem(self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False))
|
||||
except FatalStartupError as e:
|
||||
click.echo(e.message, err=True)
|
||||
click.echo("There was a fatal error initializing the settings or the plugin system.", err=True)
|
||||
|
||||
+126
-64
@@ -9,7 +9,7 @@ import click
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from octoprint.cli import pass_octoprint_ctx, bulk_options, standard_options
|
||||
from octoprint.cli import bulk_options, standard_options, set_ctx_obj_option, get_ctx_obj_option
|
||||
|
||||
def run_server(basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode, octoprint_daemon=None):
|
||||
"""Initializes the environment and starts up the server."""
|
||||
@@ -17,20 +17,24 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
from octoprint import init_platform, __display_version__, FatalStartupError
|
||||
|
||||
def log_startup(recorder=None, safe_mode=None, **kwargs):
|
||||
from octoprint.logging import get_divider_line
|
||||
|
||||
logger = logging.getLogger("octoprint.server")
|
||||
|
||||
logger.info(get_divider_line("*"))
|
||||
logger.info("Starting OctoPrint {}".format(__display_version__))
|
||||
if safe_mode:
|
||||
logger.info("Starting in SAFE MODE. Third party plugins will be disabled!")
|
||||
|
||||
if recorder and len(recorder):
|
||||
logger.info("--- Logged during platform initialization: ---")
|
||||
logger.info(get_divider_line("-", "Logged during platform initialization:"))
|
||||
|
||||
from octoprint.logging.handlers import CombinedLogHandler
|
||||
handler = CombinedLogHandler(*logging.getLogger().handlers)
|
||||
recorder.setTarget(handler)
|
||||
recorder.flush()
|
||||
|
||||
logger.info("----------------------------------------------")
|
||||
logger.info(get_divider_line("-"))
|
||||
|
||||
from octoprint import urllib3_ssl
|
||||
if not urllib3_ssl:
|
||||
@@ -41,6 +45,30 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
"update to a Python version >= 2.7.9 or alternatively "
|
||||
"install PyOpenSSL plus its dependencies. For details see "
|
||||
"https://urllib3.readthedocs.org/en/latest/security.html#openssl-pyopenssl")
|
||||
logger.info(get_divider_line("*"))
|
||||
|
||||
def log_register_rollover(safe_mode=None, plugin_manager=None, **kwargs):
|
||||
from octoprint.logging import get_handler, log_to_handler, get_divider_line
|
||||
from octoprint.logging.handlers import OctoPrintLogHandler
|
||||
|
||||
def rollover_callback():
|
||||
handler = get_handler("file")
|
||||
if handler is None:
|
||||
return
|
||||
|
||||
logger = logging.getLogger("octoprint.server")
|
||||
|
||||
def _log(message, level=logging.INFO):
|
||||
log_to_handler(logger, handler, level, message)
|
||||
|
||||
_log(get_divider_line("-", "Log roll over detected"))
|
||||
_log("OctoPrint {}".format(__display_version__))
|
||||
if safe_mode:
|
||||
_log("SAFE MODE is active. Third party plugins are disabled!")
|
||||
plugin_manager.log_all_plugins(only_to_handler=handler)
|
||||
_log(get_divider_line("-"))
|
||||
|
||||
OctoPrintLogHandler.registerRolloverCallback(rollover_callback)
|
||||
|
||||
try:
|
||||
settings, _, safe_mode, plugin_manager = init_platform(basedir,
|
||||
@@ -50,7 +78,8 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
verbosity=verbosity,
|
||||
uncaught_logger=__name__,
|
||||
safe_mode=safe_mode,
|
||||
after_safe_mode=log_startup)
|
||||
after_safe_mode=log_startup,
|
||||
after_plugin_manager=log_register_rollover)
|
||||
except FatalStartupError as e:
|
||||
click.echo(e.message, err=True)
|
||||
click.echo("There was a fatal error starting up OctoPrint.", err=True)
|
||||
@@ -69,92 +98,125 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
#~~ server options
|
||||
|
||||
server_options = bulk_options([
|
||||
click.option("--host", type=click.STRING,
|
||||
click.option("--host", type=click.STRING, callback=set_ctx_obj_option,
|
||||
help="Specify the host on which to bind the server."),
|
||||
click.option("--port", type=click.INT,
|
||||
click.option("--port", type=click.INT, callback=set_ctx_obj_option,
|
||||
help="Specify the port on which to bind the server."),
|
||||
click.option("--logging", type=click.Path(),
|
||||
click.option("--logging", type=click.Path(), callback=set_ctx_obj_option,
|
||||
help="Specify the config file to use for configuring logging."),
|
||||
click.option("--iknowwhatimdoing", "allow_root", is_flag=True,
|
||||
click.option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option,
|
||||
help="Allow OctoPrint to run as user root."),
|
||||
click.option("--debug", is_flag=True, help="Enable debug mode.")
|
||||
click.option("--debug", is_flag=True, callback=set_ctx_obj_option,
|
||||
help="Enable debug mode.")
|
||||
])
|
||||
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``,
|
||||
``--logging``, ``--iknowwhatimdoing`` and ``--debug``."""
|
||||
|
||||
daemon_options = bulk_options([
|
||||
click.option("--pid", type=click.Path(), default="/tmp/octoprint.pid", callback=set_ctx_obj_option,
|
||||
help="Pidfile to use for daemonizing.")
|
||||
])
|
||||
"""Decorator to add the options for the daemon subcommand: ``--pid``."""
|
||||
|
||||
#~~ "octoprint serve" and "octoprint daemon" commands
|
||||
|
||||
@click.group()
|
||||
@pass_octoprint_ctx
|
||||
def server_commands(obj):
|
||||
def server_commands():
|
||||
pass
|
||||
|
||||
|
||||
@server_commands.command(name="serve")
|
||||
@server_options
|
||||
@standard_options(hidden=True)
|
||||
@pass_octoprint_ctx
|
||||
def serve_command(obj, host, port, logging, allow_root, debug):
|
||||
@click.pass_context
|
||||
def serve_command(ctx, **kwargs):
|
||||
"""Starts the OctoPrint server."""
|
||||
run_server(obj.basedir, obj.configfile, host, port, debug,
|
||||
allow_root, logging, obj.verbosity, obj.safe_mode)
|
||||
|
||||
def get_value(key):
|
||||
return get_ctx_obj_option(ctx, key, kwargs.get(key))
|
||||
|
||||
host = get_value("host")
|
||||
port = get_value("port")
|
||||
logging = get_value("logging")
|
||||
allow_root = get_value("allow_root")
|
||||
debug = get_value("debug")
|
||||
|
||||
basedir = get_value("basedir")
|
||||
configfile = get_value("configfile")
|
||||
verbosity = get_value("verbosity")
|
||||
safe_mode = get_value("safe_mode")
|
||||
|
||||
run_server(basedir, configfile, host, port, debug,
|
||||
allow_root, logging, verbosity, safe_mode)
|
||||
|
||||
|
||||
@server_commands.command(name="daemon")
|
||||
@click.option("--pid", type=click.Path(), default="/tmp/octoprint.pid",
|
||||
help="Pidfile to use for daemonizing.")
|
||||
@server_options
|
||||
@standard_options(hidden=True)
|
||||
@click.argument("command", type=click.Choice(["start", "stop", "restart", "status"]),
|
||||
metavar="start|stop|restart|status")
|
||||
@pass_octoprint_ctx
|
||||
def daemon_command(octoprint_ctx, pid, host, port, logging, allow_root, debug, command):
|
||||
"""
|
||||
Starts, stops or restarts in daemon mode.
|
||||
if sys.platform != "win32" and sys.platform != "darwin":
|
||||
# we do not support daemon mode under windows or macosx
|
||||
|
||||
Please note that daemon mode is only supported under Linux right now.
|
||||
"""
|
||||
if sys.platform == "darwin" or sys.platform == "win32":
|
||||
click.echo("Sorry, daemon mode is only supported under Linux right now",
|
||||
file=sys.stderr)
|
||||
sys.exit(2)
|
||||
@server_commands.command(name="daemon")
|
||||
@server_options
|
||||
@daemon_options
|
||||
@standard_options(hidden=True)
|
||||
@click.argument("command", type=click.Choice(["start", "stop", "restart", "status"]),
|
||||
metavar="start|stop|restart|status")
|
||||
@click.pass_context
|
||||
def daemon_command(ctx, command, **kwargs):
|
||||
"""
|
||||
Starts, stops or restarts in daemon mode.
|
||||
|
||||
if pid is None:
|
||||
click.echo("No path to a pidfile set",
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Please note that daemon mode is only supported under Linux right now.
|
||||
"""
|
||||
|
||||
from octoprint.daemon import Daemon
|
||||
class OctoPrintDaemon(Daemon):
|
||||
def __init__(self, pidfile, basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode):
|
||||
Daemon.__init__(self, pidfile)
|
||||
def get_value(key):
|
||||
return get_ctx_obj_option(ctx, key, kwargs.get(key))
|
||||
|
||||
self._basedir = basedir
|
||||
self._configfile = configfile
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._debug = debug
|
||||
self._allow_root = allow_root
|
||||
self._logging_config = logging_config
|
||||
self._verbosity = verbosity
|
||||
self._safe_mode = safe_mode
|
||||
host = get_value("host")
|
||||
port = get_value("port")
|
||||
logging = get_value("logging")
|
||||
allow_root = get_value("allow_root")
|
||||
debug = get_value("debug")
|
||||
pid = get_value("pid")
|
||||
|
||||
def run(self):
|
||||
run_server(self._basedir, self._configfile, self._host, self._port, self._debug,
|
||||
self._allow_root, self._logging_config, self._verbosity, self._safe_mode,
|
||||
octoprint_daemon=self)
|
||||
basedir = get_value("basedir")
|
||||
configfile = get_value("configfile")
|
||||
verbosity = get_value("verbosity")
|
||||
safe_mode = get_value("safe_mode")
|
||||
|
||||
octoprint_daemon = OctoPrintDaemon(pid, octoprint_ctx.basedir, octoprint_ctx.configfile,
|
||||
host, port, debug, allow_root, logging, octoprint_ctx.verbosity,
|
||||
octoprint_ctx.safe_mode)
|
||||
if pid is None:
|
||||
click.echo("No path to a pidfile set",
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if command == "start":
|
||||
octoprint_daemon.start()
|
||||
elif command == "stop":
|
||||
octoprint_daemon.stop()
|
||||
elif command == "restart":
|
||||
octoprint_daemon.restart()
|
||||
elif command == "status":
|
||||
octoprint_daemon.status()
|
||||
from octoprint.daemon import Daemon
|
||||
class OctoPrintDaemon(Daemon):
|
||||
def __init__(self, pidfile, basedir, configfile, host, port, debug, allow_root, logging_config, verbosity, safe_mode):
|
||||
Daemon.__init__(self, pidfile)
|
||||
|
||||
self._basedir = basedir
|
||||
self._configfile = configfile
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._debug = debug
|
||||
self._allow_root = allow_root
|
||||
self._logging_config = logging_config
|
||||
self._verbosity = verbosity
|
||||
self._safe_mode = safe_mode
|
||||
|
||||
def run(self):
|
||||
run_server(self._basedir, self._configfile, self._host, self._port, self._debug,
|
||||
self._allow_root, self._logging_config, self._verbosity, self._safe_mode,
|
||||
octoprint_daemon=self)
|
||||
|
||||
octoprint_daemon = OctoPrintDaemon(pid, basedir, configfile, host, port, debug, allow_root, logging, verbosity,
|
||||
safe_mode)
|
||||
|
||||
if command == "start":
|
||||
octoprint_daemon.start()
|
||||
elif command == "stop":
|
||||
octoprint_daemon.stop()
|
||||
elif command == "restart":
|
||||
octoprint_daemon.restart()
|
||||
elif command == "status":
|
||||
octoprint_daemon.status()
|
||||
|
||||
|
||||
+34
-18
@@ -53,6 +53,11 @@ class Events(object):
|
||||
METADATA_ANALYSIS_FINISHED = "MetadataAnalysisFinished"
|
||||
METADATA_STATISTICS_UPDATED = "MetadataStatisticsUpdated"
|
||||
|
||||
FILE_ADDED = "FileAdded",
|
||||
FILE_REMOVED = "FileRemoved",
|
||||
FOLDER_ADDED = "FolderAdded",
|
||||
FOLDER_REMOVED = "FolderRemoved",
|
||||
|
||||
# SD Upload
|
||||
TRANSFER_STARTED = "TransferStarted"
|
||||
TRANSFER_DONE = "TransferDone"
|
||||
@@ -79,6 +84,7 @@ class Events(object):
|
||||
EJECT = "Eject"
|
||||
E_STOP = "EStop"
|
||||
POSITION_UPDATE = "PositionUpdate"
|
||||
TOOL_CHANGE = "ToolChange"
|
||||
REGISTERED_MESSAGE_RECEIVED = "RegisteredMessageReceived"
|
||||
|
||||
# Timelapse
|
||||
@@ -332,24 +338,34 @@ class CommandTrigger(GenericEventListener):
|
||||
self._executeGcodeCommand(command, debug=debug)
|
||||
|
||||
def _executeSystemCommand(self, command, debug=False):
|
||||
def commandExecutioner(command):
|
||||
def commandExecutioner(cmd):
|
||||
if debug:
|
||||
self._logger.info("Executing system command: %s" % command)
|
||||
self._logger.info("Executing system command: {}".format(cmd))
|
||||
else:
|
||||
self._logger.info("Executing a system command")
|
||||
# we run this with shell=True since we have to trust whatever
|
||||
# our admin configured as command and since we want to allow
|
||||
# shell-alike handling here...
|
||||
subprocess.Popen(command, shell=True)
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
|
||||
try:
|
||||
if isinstance(command, (list, tuple, set)):
|
||||
for c in command:
|
||||
commandExecutioner(c)
|
||||
else:
|
||||
commandExecutioner(command)
|
||||
except subprocess.CalledProcessError as e:
|
||||
self._logger.warn("Command failed with return code %i: %s" % (e.returncode, str(e)))
|
||||
except:
|
||||
self._logger.exception("Command failed")
|
||||
def process():
|
||||
try:
|
||||
if isinstance(command, (list, tuple, set)):
|
||||
for c in command:
|
||||
commandExecutioner(c)
|
||||
else:
|
||||
commandExecutioner(command)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if debug:
|
||||
self._logger.warn("Command failed with return code {}: {}".format(e.returncode, str(e)))
|
||||
else:
|
||||
self._logger.warn("Command failed with return code {}, enable debug logging on target 'octoprint.events' for details".format(e.returncode))
|
||||
except:
|
||||
self._logger.exception("Command failed")
|
||||
|
||||
t = threading.Thread(target=process)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
def _executeGcodeCommand(self, command, debug=False):
|
||||
commands = [command]
|
||||
@@ -361,7 +377,7 @@ class CommandTrigger(GenericEventListener):
|
||||
|
||||
def _processCommand(self, command, payload):
|
||||
"""
|
||||
Performs string substitutions in the command string based on a couple of current parameters.
|
||||
Performs string substitutions in the command string based on a few current parameters.
|
||||
|
||||
The following substitutions are currently supported:
|
||||
|
||||
@@ -397,7 +413,7 @@ class CommandTrigger(GenericEventListener):
|
||||
|
||||
currentData = self._printer.get_current_data()
|
||||
|
||||
if "currentZ" in currentData.keys() and currentData["currentZ"] is not None:
|
||||
if "currentZ" in currentData and currentData["currentZ"] is not None:
|
||||
params["__currentZ"] = str(currentData["currentZ"])
|
||||
|
||||
if "job" in currentData and "file" in currentData["job"] and "name" in currentData["job"]["file"] \
|
||||
@@ -405,9 +421,9 @@ class CommandTrigger(GenericEventListener):
|
||||
params["__filename"] = currentData["job"]["file"]["name"]
|
||||
params["__filepath"] = currentData["job"]["file"]["path"]
|
||||
params["__fileorigin"] = currentData["job"]["file"]["origin"]
|
||||
if "progress" in currentData.keys() and currentData["progress"] is not None \
|
||||
and "completion" in currentData["progress"].keys() and currentData["progress"]["completion"] is not None:
|
||||
params["__progress"] = str(round(currentData["progress"]["completion"] * 100))
|
||||
if "progress" in currentData and currentData["progress"] is not None \
|
||||
and "completion" in currentData["progress"] and currentData["progress"]["completion"] is not None:
|
||||
params["__progress"] = str(round(currentData["progress"]["completion"]))
|
||||
|
||||
# now add the payload keys as well
|
||||
if isinstance(payload, dict):
|
||||
|
||||
@@ -20,6 +20,8 @@ from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
ContentTypeMapping = namedtuple("ContentTypeMapping", "extensions, content_type")
|
||||
ContentTypeDetector = namedtuple("ContentTypeDetector", "extensions, detector")
|
||||
|
||||
@@ -205,17 +207,26 @@ class FileManager(object):
|
||||
# callback was not registered
|
||||
pass
|
||||
|
||||
def _determine_analysis_backlog(self, storage_type, storage_manager):
|
||||
def _determine_analysis_backlog(self, storage_type, storage_manager, root=None, high_priority=False):
|
||||
counter = 0
|
||||
for entry, path, printer_profile in storage_manager.analysis_backlog:
|
||||
|
||||
backlog_generator = storage_manager.analysis_backlog
|
||||
if root is not None:
|
||||
backlog_generator = storage_manager.analysis_backlog_for_path(path=root)
|
||||
|
||||
for entry, path, printer_profile in backlog_generator:
|
||||
file_type = get_file_type(path)[-1]
|
||||
file_name = storage_manager.split_path(path)
|
||||
|
||||
# we'll use the default printer profile for the backlog since we don't know better
|
||||
queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default())
|
||||
if self._analysis_queue.enqueue(queue_entry, high_priority=False):
|
||||
if self._analysis_queue.enqueue(queue_entry, high_priority=high_priority):
|
||||
counter += 1
|
||||
self._logger.info("Added {counter} items from storage type \"{storage_type}\" to analysis queue".format(**locals()))
|
||||
|
||||
if root:
|
||||
self._logger.info("Added {counter} items from storage type \"{storage_type}\" and root \"{root}\" to analysis queue".format(**locals()))
|
||||
else:
|
||||
self._logger.info("Added {counter} items from storage type \"{storage_type}\" to analysis queue".format(**locals()))
|
||||
|
||||
def add_storage(self, storage_type, storage_manager):
|
||||
self._storage_managers[storage_type] = storage_manager
|
||||
@@ -396,50 +407,132 @@ class FileManager(object):
|
||||
|
||||
if hook_file_object is not None:
|
||||
file_object = hook_file_object
|
||||
file_path = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||
absolute_path = self._storage(destination).path_on_disk(file_path)
|
||||
_, file_name = self._storage(destination).split_path(file_path)
|
||||
|
||||
queue_entry = self._analysis_queue_entry(destination, path)
|
||||
self._analysis_queue.dequeue(queue_entry)
|
||||
|
||||
path_in_storage = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||
|
||||
if analysis is None:
|
||||
file_type = get_file_type(absolute_path)
|
||||
if file_type:
|
||||
queue_entry = QueueEntry(file_name, file_path, file_type[-1], destination, absolute_path, printer_profile)
|
||||
queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile)
|
||||
if queue_entry:
|
||||
self._analysis_queue.enqueue(queue_entry, high_priority=True)
|
||||
else:
|
||||
self._add_analysis_result(destination, path, analysis)
|
||||
|
||||
_, name = self._storage(destination).split_path(path_in_storage)
|
||||
eventManager().fire(Events.FILE_ADDED, dict(storage=destination,
|
||||
path=path_in_storage,
|
||||
name=name,
|
||||
type=get_file_type(name)))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
return file_path
|
||||
return path_in_storage
|
||||
|
||||
def remove_file(self, destination, path):
|
||||
queue_entry = self._analysis_queue_entry(destination, path)
|
||||
self._analysis_queue.dequeue(queue_entry)
|
||||
self._storage(destination).remove_file(path)
|
||||
|
||||
_, name = self._storage(destination).split_path(path)
|
||||
eventManager().fire(Events.FILE_REMOVED, dict(storage=destination,
|
||||
path=path,
|
||||
name=name,
|
||||
type=get_file_type(name)))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
|
||||
def copy_file(self, destination, source, dst):
|
||||
self._storage(destination).copy_file(source, dst)
|
||||
path_in_storage = self._storage(destination).copy_file(source, dst)
|
||||
if not self.has_analysis(destination, path_in_storage):
|
||||
queue_entry = self._analysis_queue_entry(destination, path_in_storage)
|
||||
if queue_entry:
|
||||
self._analysis_queue.enqueue(queue_entry)
|
||||
|
||||
_, name = self._storage(destination).split_path(path_in_storage)
|
||||
eventManager().fire(Events.FILE_ADDED, dict(storage=destination,
|
||||
path=path_in_storage,
|
||||
name=name,
|
||||
type=get_file_type(name)))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
|
||||
def move_file(self, destination, source, dst):
|
||||
self._storage(destination).move_file(source, dst)
|
||||
queue_entry = self._analysis_queue_entry(destination, source)
|
||||
self._analysis_queue.dequeue(queue_entry)
|
||||
path = self._storage(destination).move_file(source, dst)
|
||||
if not self.has_analysis(destination, path):
|
||||
queue_entry = self._analysis_queue_entry(destination, path)
|
||||
if queue_entry:
|
||||
self._analysis_queue.enqueue(queue_entry)
|
||||
|
||||
source_path_in_storage = self._storage(destination).path_in_storage(source)
|
||||
_, source_name = self._storage(destination).split_path(source_path_in_storage)
|
||||
dst_path_in_storage = self._storage(destination).path_in_storage(dst)
|
||||
_, dst_name = self._storage(destination).split_path(dst_path_in_storage)
|
||||
|
||||
eventManager().fire(Events.FILE_REMOVED, dict(storage=destination,
|
||||
path=source_path_in_storage,
|
||||
name=source_name,
|
||||
type=get_file_type(source_name)))
|
||||
eventManager().fire(Events.FILE_ADDED, dict(storage=destination,
|
||||
path=dst_path_in_storage,
|
||||
name=dst_name,
|
||||
type=get_file_type(dst_name)))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
|
||||
def add_folder(self, destination, path, ignore_existing=True):
|
||||
folder_path = self._storage(destination).add_folder(path, ignore_existing=ignore_existing)
|
||||
path_in_storage = self._storage(destination).add_folder(path, ignore_existing=ignore_existing)
|
||||
|
||||
_, name = self._storage(destination).split_path(path_in_storage)
|
||||
eventManager().fire(Events.FOLDER_ADDED, dict(storage=destination,
|
||||
path=path_in_storage,
|
||||
name=name))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
return folder_path
|
||||
return path_in_storage
|
||||
|
||||
def remove_folder(self, destination, path, recursive=True):
|
||||
self._analysis_queue.dequeue_folder(destination, path)
|
||||
self._analysis_queue.pause()
|
||||
self._storage(destination).remove_folder(path, recursive=recursive)
|
||||
self._analysis_queue.resume()
|
||||
|
||||
_, name = self._storage(destination).split_path(path)
|
||||
eventManager().fire(Events.FOLDER_REMOVED, dict(storage=destination,
|
||||
path=path,
|
||||
name=name))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
|
||||
def copy_folder(self, destination, source, dst):
|
||||
self._storage(destination).copy_folder(source, dst)
|
||||
path_in_storage = self._storage(destination).copy_folder(source, dst)
|
||||
self._determine_analysis_backlog(destination, self._storage(destination), root=dst)
|
||||
|
||||
_, name = self._storage(destination).split_path(path_in_storage)
|
||||
eventManager().fire(Events.FOLDER_ADDED, dict(storage=destination,
|
||||
path=path_in_storage,
|
||||
name=name))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
|
||||
def move_folder(self, destination, source, dst):
|
||||
self._analysis_queue.dequeue_folder(destination, source)
|
||||
self._analysis_queue.pause()
|
||||
self._storage(destination).move_folder(source, dst)
|
||||
self._determine_analysis_backlog(destination, self._storage(destination), root=dst)
|
||||
self._analysis_queue.resume()
|
||||
|
||||
source_path_in_storage = self._storage(destination).path_in_storage(source)
|
||||
_, source_name = self._storage(destination).split_path(source_path_in_storage)
|
||||
dst_path_in_storage = self._storage(destination).path_in_storage(destination)
|
||||
_, dst_name = self._storage(destination).split_path(dst_path_in_storage)
|
||||
|
||||
eventManager().fire(Events.FOLDER_REMOVED, dict(storage=destination,
|
||||
path=source_path_in_storage,
|
||||
name=source_name))
|
||||
eventManager().fire(Events.FOLDER_ADDED, dict(storage=destination,
|
||||
path=dst_path_in_storage,
|
||||
name=dst_name))
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
|
||||
def has_analysis(self, destination, path):
|
||||
return self._storage(destination).has_analysis(path)
|
||||
|
||||
def get_metadata(self, destination, path):
|
||||
return self._storage(destination).get_metadata(path)
|
||||
|
||||
@@ -542,3 +635,15 @@ class FileManager(object):
|
||||
def _on_analysis_finished(self, entry, result):
|
||||
self._add_analysis_result(entry.location, entry.path, result)
|
||||
|
||||
def _analysis_queue_entry(self, destination, path, printer_profile=None):
|
||||
if printer_profile is None:
|
||||
printer_profile = self._printer_profile_manager.get_current_or_default()
|
||||
|
||||
absolute_path = self._storage(destination).path_on_disk(path)
|
||||
_, file_name = self._storage(destination).split_path(path)
|
||||
file_type = get_file_type(absolute_path)
|
||||
|
||||
if file_type:
|
||||
return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile)
|
||||
else:
|
||||
return None
|
||||
@@ -17,8 +17,7 @@ import collections
|
||||
import time
|
||||
|
||||
from octoprint.events import Events, eventManager
|
||||
|
||||
import octoprint.util.gcodeInterpreter as gcodeInterpreter
|
||||
from octoprint.settings import settings
|
||||
|
||||
|
||||
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile")):
|
||||
@@ -40,6 +39,12 @@ class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, locatio
|
||||
return "{location}:{path}".format(location=self.location, path=self.path)
|
||||
|
||||
|
||||
class AnalysisAborted(Exception):
|
||||
def __init__(self, reenqueue=True, *args, **kwargs):
|
||||
Exception.__init__(self, *args, **kwargs)
|
||||
self.reenqueue = reenqueue
|
||||
|
||||
|
||||
class AnalysisQueue(object):
|
||||
"""
|
||||
OctoPrint's :class:`AnalysisQueue` can manage various :class:`AbstractAnalysisQueue` implementations, mapped
|
||||
@@ -77,6 +82,16 @@ class AnalysisQueue(object):
|
||||
self._queues[entry.type].enqueue(entry, high_priority=high_priority)
|
||||
return True
|
||||
|
||||
def dequeue(self, entry):
|
||||
if not entry.type in self._queues:
|
||||
return False
|
||||
|
||||
self._queues[entry.type].dequeue(entry.location, entry.path)
|
||||
|
||||
def dequeue_folder(self, destination, path):
|
||||
for queue in self._queues.values():
|
||||
queue.dequeue_folder(destination, path)
|
||||
|
||||
def pause(self):
|
||||
for queue in self._queues.values():
|
||||
queue.pause()
|
||||
@@ -112,8 +127,10 @@ class AbstractAnalysisQueue(object):
|
||||
.. automethod:: _do_abort
|
||||
"""
|
||||
|
||||
LOW_PRIO = 0
|
||||
HIGH_PRIO = 100
|
||||
LOW_PRIO = 100
|
||||
LOW_PRIO_ABORTED = 75
|
||||
HIGH_PRIO = 50
|
||||
HIGH_PRIO_ABORTED = 0
|
||||
|
||||
def __init__(self, finished_callback):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
@@ -123,11 +140,15 @@ class AbstractAnalysisQueue(object):
|
||||
self._active = threading.Event()
|
||||
self._active.set()
|
||||
|
||||
self._done = threading.Event()
|
||||
self._done.clear()
|
||||
|
||||
self._currentFile = None
|
||||
self._currentProgress = None
|
||||
|
||||
self._queue = queue.PriorityQueue()
|
||||
self._current = None
|
||||
self._current_highprio = False
|
||||
|
||||
self._worker = threading.Thread(target=self._work)
|
||||
self._worker.daemon = True
|
||||
@@ -153,7 +174,24 @@ class AbstractAnalysisQueue(object):
|
||||
self._logger.debug("Adding entry {entry} to analysis queue with low priority".format(entry=entry))
|
||||
prio = self.__class__.LOW_PRIO
|
||||
|
||||
self._queue.put((prio, entry))
|
||||
self._queue.put((prio, entry, high_priority))
|
||||
if high_priority and self._current is not None and not self._current_highprio:
|
||||
self._logger.debug("Aborting current analysis in favor of high priority one")
|
||||
self._do_abort()
|
||||
|
||||
def dequeue(self, location, path):
|
||||
if self._current is not None and self._current.location == location \
|
||||
and self._current.path == path:
|
||||
self._do_abort(reenqueue=False)
|
||||
self._done.wait()
|
||||
self._done.clear()
|
||||
|
||||
def dequeue_folder(self, location, path):
|
||||
if self._current is not None and self._current.location == location \
|
||||
and self._current.path.startswith(path + "/"):
|
||||
self._do_abort(reenqueue=False)
|
||||
self._done.wait()
|
||||
self._done.clear()
|
||||
|
||||
def pause(self):
|
||||
"""
|
||||
@@ -175,24 +213,23 @@ class AbstractAnalysisQueue(object):
|
||||
self._active.set()
|
||||
|
||||
def _work(self):
|
||||
aborted = None
|
||||
while True:
|
||||
if aborted is not None:
|
||||
entry = aborted
|
||||
aborted = None
|
||||
self._logger.debug("Got an aborted analysis job for entry {entry}, processing this instead of first item in queue".format(**locals()))
|
||||
else:
|
||||
(priority, entry) = self._queue.get()
|
||||
self._logger.debug("Processing entry {entry} from queue (priority {priority})".format(**locals()))
|
||||
|
||||
(priority, entry, high_priority) = self._queue.get()
|
||||
self._logger.debug("Processing entry {} from queue (priority {})".format(entry, priority))
|
||||
self._active.wait()
|
||||
|
||||
try:
|
||||
self._analyze(entry, high_priority=(priority == self.__class__.HIGH_PRIO))
|
||||
self._analyze(entry, high_priority=high_priority)
|
||||
self._queue.task_done()
|
||||
except gcodeInterpreter.AnalysisAborted:
|
||||
aborted = entry
|
||||
self._logger.debug("Running analysis of entry {entry} aborted".format(**locals()))
|
||||
self._done.set()
|
||||
except AnalysisAborted as ex:
|
||||
if ex.reenqueue:
|
||||
self._queue.put((self.__class__.HIGH_PRIO_ABORTED if high_priority else self.__class__.LOW_PRIO_ABORTED,
|
||||
entry,
|
||||
high_priority))
|
||||
self._logger.debug("Running analysis of entry {} aborted".format(entry))
|
||||
self._queue.task_done()
|
||||
self._done.set()
|
||||
else:
|
||||
time.sleep(1.0)
|
||||
|
||||
@@ -202,10 +239,12 @@ class AbstractAnalysisQueue(object):
|
||||
return
|
||||
|
||||
self._current = entry
|
||||
self._current_highprio = high_priority
|
||||
self._current_progress = 0
|
||||
|
||||
try:
|
||||
self._logger.info("Starting analysis of {entry}".format(**locals()))
|
||||
start_time = time.time()
|
||||
self._logger.info("Starting analysis of {}".format(entry))
|
||||
eventManager().fire(Events.METADATA_ANALYSIS_STARTED, {"name": entry.name,
|
||||
"path": entry.path,
|
||||
"origin": entry.location,
|
||||
@@ -217,7 +256,7 @@ class AbstractAnalysisQueue(object):
|
||||
result = self._do_analysis(high_priority=high_priority)
|
||||
except TypeError:
|
||||
result = self._do_analysis()
|
||||
self._logger.debug("Analysis of entry {entry} finished, notifying callback".format(**locals()))
|
||||
self._logger.info("Analysis of entry {} finished, needed {:.2f}s".format(entry, time.time() - start_time))
|
||||
self._finished_callback(self._current, result)
|
||||
finally:
|
||||
self._current = None
|
||||
@@ -237,7 +276,7 @@ class AbstractAnalysisQueue(object):
|
||||
"""
|
||||
return None
|
||||
|
||||
def _do_abort(self):
|
||||
def _do_abort(self, reenqueue=True):
|
||||
"""
|
||||
Aborts analysis of the current entry. Needs to be overridden by sub classes.
|
||||
"""
|
||||
@@ -264,34 +303,95 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
||||
* The extruded volume in cm³
|
||||
"""
|
||||
|
||||
def __init__(self, finished_callback):
|
||||
AbstractAnalysisQueue.__init__(self, finished_callback)
|
||||
|
||||
self._aborted = False
|
||||
self._reenqueue = False
|
||||
|
||||
def _do_analysis(self, high_priority=False):
|
||||
import sarge
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
try:
|
||||
def throttle():
|
||||
throttle = settings().getFloat(["gcodeAnalysis", "throttle_highprio"]) if high_priority \
|
||||
else settings().getFloat(["gcodeAnalysis", "throttle_normalprio"])
|
||||
throttle_lines = settings().getInt(["gcodeAnalysis", "throttle_lines"])
|
||||
max_extruders = settings().getInt(["gcodeAnalysis", "maxExtruders"])
|
||||
g90_extruder = settings().getBoolean(["feature", "g90InfluencesExtruder"])
|
||||
speedx = self._current.printer_profile["axes"]["x"]["speed"]
|
||||
speedy = self._current.printer_profile["axes"]["y"]["speed"]
|
||||
offsets = self._current.printer_profile["extruder"]["offsets"]
|
||||
|
||||
interpreter = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "util", "gcodeInterpreter.py"))
|
||||
command = [sys.executable, interpreter, "--speed-x={}".format(speedx), "--speed-y={}".format(speedy),
|
||||
"--max-t={}".format(max_extruders), "--throttle={}".format(throttle),
|
||||
"--throttle-lines={}".format(throttle_lines)]
|
||||
for offset in offsets[1:]:
|
||||
command += ["--offset", str(offset[0]), str(offset[1])]
|
||||
if g90_extruder:
|
||||
command += ["--g90-extruder"]
|
||||
command.append(self._current.absolute_path)
|
||||
|
||||
self._logger.info("Invoking analysis command: {}".format(" ".join(command)))
|
||||
|
||||
self._aborted = False
|
||||
p = sarge.run(command, async=True, stdout=sarge.Capture())
|
||||
|
||||
while len(p.commands) == 0:
|
||||
# somewhat ugly... we can't use wait_events because
|
||||
# the events might not be all set if an exception
|
||||
# by sarge is triggered within the async process
|
||||
# thread
|
||||
time.sleep(0.01)
|
||||
|
||||
throttle_callback = throttle
|
||||
if high_priority:
|
||||
throttle_callback = None
|
||||
# by now we should have a command, let's wait for its
|
||||
# process to have been prepared
|
||||
p.commands[0].process_ready.wait()
|
||||
|
||||
self._gcode = gcodeInterpreter.gcode()
|
||||
self._gcode.load(self._current.absolute_path, self._current.printer_profile, throttle=throttle_callback)
|
||||
if not p.commands[0].process:
|
||||
# the process might have been set to None in case of any exception
|
||||
raise RuntimeError(u"Error while trying to run command {}".format(" ".join(command)))
|
||||
|
||||
try:
|
||||
# let's wait for stuff to finish
|
||||
while p.returncode is None:
|
||||
if self._aborted:
|
||||
# oh, we shall abort, let's do so!
|
||||
p.commands[0].terminate()
|
||||
raise AnalysisAborted(reenqueue=self._reenqueue)
|
||||
|
||||
# else continue
|
||||
p.commands[0].poll()
|
||||
finally:
|
||||
p.close()
|
||||
|
||||
output = p.stdout.text
|
||||
self._logger.debug("Got output: {!r}".format(output))
|
||||
|
||||
if not "RESULTS:" in output:
|
||||
raise RuntimeError("No analysis result found")
|
||||
|
||||
_, output = output.split("RESULTS:")
|
||||
analysis = yaml.safe_load(output)
|
||||
|
||||
result = dict()
|
||||
result["printingArea"] = self._gcode.printing_area
|
||||
result["dimensions"] = self._gcode.dimensions
|
||||
if self._gcode.totalMoveTimeMinute:
|
||||
result["estimatedPrintTime"] = self._gcode.totalMoveTimeMinute * 60
|
||||
if self._gcode.extrusionAmount:
|
||||
result["printingArea"] = analysis["printing_area"]
|
||||
result["dimensions"] = analysis["dimensions"]
|
||||
if analysis["total_time"]:
|
||||
result["estimatedPrintTime"] = analysis["total_time"] * 60
|
||||
if analysis["extrusion_length"]:
|
||||
result["filament"] = dict()
|
||||
for i in range(len(self._gcode.extrusionAmount)):
|
||||
for i in range(len(analysis["extrusion_length"])):
|
||||
result["filament"]["tool%d" % i] = {
|
||||
"length": self._gcode.extrusionAmount[i],
|
||||
"volume": self._gcode.extrusionVolume[i]
|
||||
"length": analysis["extrusion_length"][i],
|
||||
"volume": analysis["extrusion_volume"][i]
|
||||
}
|
||||
return result
|
||||
finally:
|
||||
self._gcode = None
|
||||
|
||||
def _do_abort(self):
|
||||
if self._gcode:
|
||||
self._gcode.abort()
|
||||
def _do_abort(self, reenqueue=True):
|
||||
self._aborted = True
|
||||
self._reenqueue = reenqueue
|
||||
@@ -20,6 +20,8 @@ from octoprint.util import atomic_write
|
||||
from contextlib import contextmanager
|
||||
from copy import deepcopy
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
import octoprint.filemanager
|
||||
|
||||
from octoprint.util import is_hidden_path
|
||||
@@ -29,7 +31,6 @@ class StorageInterface(object):
|
||||
Interface of storage adapters for OctoPrint.
|
||||
"""
|
||||
|
||||
|
||||
@property
|
||||
def analysis_backlog(self):
|
||||
"""
|
||||
@@ -44,6 +45,11 @@ class StorageInterface(object):
|
||||
return
|
||||
yield
|
||||
|
||||
def analysis_backlog_for_path(self, path=None):
|
||||
# empty generator pattern, yield is intentionally unreachable
|
||||
return
|
||||
yield
|
||||
|
||||
def last_modified(self, path=None, recursive=False):
|
||||
"""
|
||||
Get the last modification date of the specified ``path`` or ``path``'s subtree.
|
||||
@@ -150,7 +156,9 @@ class StorageInterface(object):
|
||||
|
||||
def add_folder(self, path, ignore_existing=True):
|
||||
"""
|
||||
Adds a folder as ``path``. The ``path`` will be sanitized.
|
||||
Adds a folder as ``path``
|
||||
|
||||
The ``path`` will be sanitized.
|
||||
|
||||
:param string path: the path of the new folder
|
||||
:param bool ignore_existing: if set to True, no error will be raised if the folder to be added already exists
|
||||
@@ -160,7 +168,7 @@ class StorageInterface(object):
|
||||
|
||||
def remove_folder(self, path, recursive=True):
|
||||
"""
|
||||
Removes the folder at ``path``.
|
||||
Removes the folder at ``path``
|
||||
|
||||
:param string path: the path of the folder to remove
|
||||
:param bool recursive: if set to True, contained folders and files will also be removed, otherwise and error will
|
||||
@@ -174,6 +182,8 @@ class StorageInterface(object):
|
||||
|
||||
:param string source: path to the source folder
|
||||
:param string destination: path to destination
|
||||
|
||||
:return: the path in the storage to the copy of the folder
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -183,6 +193,8 @@ class StorageInterface(object):
|
||||
|
||||
:param string source: path to the source folder
|
||||
:param string destination: path to destination
|
||||
|
||||
:return: the new path in the storage to the folder
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -203,7 +215,9 @@ class StorageInterface(object):
|
||||
|
||||
def remove_file(self, path):
|
||||
"""
|
||||
Removes the file at ``path``. Will also take care of deleting the corresponding entries
|
||||
Removes the file at ``path``
|
||||
|
||||
Will also take care of deleting the corresponding entries
|
||||
in the metadata and deleting all links pointing to the file.
|
||||
|
||||
:param string path: path of the file to remove
|
||||
@@ -216,6 +230,8 @@ class StorageInterface(object):
|
||||
|
||||
:param string source: path to the source file
|
||||
:param string destination: path to destination
|
||||
|
||||
:return: the path in the storage to the copy of the file
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -225,6 +241,16 @@ class StorageInterface(object):
|
||||
|
||||
:param string source: path to the source file
|
||||
:param string destination: path to destination
|
||||
|
||||
:return: the new path in the storage to the file
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def has_analysis(self, path):
|
||||
"""
|
||||
Returns whether the file at path has been analysed yet
|
||||
|
||||
:param path: virtual path to the file for which to retrieve the metadata
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -462,7 +488,13 @@ class LocalFileStorage(StorageInterface):
|
||||
|
||||
@property
|
||||
def analysis_backlog(self):
|
||||
for entry in self._analysis_backlog_generator():
|
||||
return self.analysis_backlog_for_path()
|
||||
|
||||
def analysis_backlog_for_path(self, path=None):
|
||||
if path:
|
||||
path = self.sanitize_path(path)
|
||||
|
||||
for entry in self._analysis_backlog_generator(path):
|
||||
yield entry
|
||||
|
||||
def _analysis_backlog_generator(self, path=None):
|
||||
@@ -473,10 +505,10 @@ class LocalFileStorage(StorageInterface):
|
||||
if not metadata:
|
||||
metadata = dict()
|
||||
for entry in scandir(path):
|
||||
if is_hidden_path(entry.name) or not octoprint.filemanager.valid_file_type(entry.name):
|
||||
if is_hidden_path(entry.name):
|
||||
continue
|
||||
|
||||
if entry.is_file():
|
||||
if entry.is_file() and octoprint.filemanager.valid_file_type(entry.name):
|
||||
if not entry.name in metadata or not isinstance(metadata[entry.name], dict) or not "analysis" in metadata[entry.name]:
|
||||
printer_profile_rels = self.get_link(entry.path, "printerprofile")
|
||||
if printer_profile_rels:
|
||||
@@ -511,7 +543,7 @@ class LocalFileStorage(StorageInterface):
|
||||
filepath = self.sanitize_path(filepath)
|
||||
path = self.sanitize_path(path)
|
||||
|
||||
return filepath.startswith(path)
|
||||
return filepath == path or filepath.startswith(path + os.sep)
|
||||
|
||||
def file_exists(self, path):
|
||||
path, name = self.sanitize(path)
|
||||
@@ -604,6 +636,8 @@ class LocalFileStorage(StorageInterface):
|
||||
except Exception as e:
|
||||
raise StorageError("Could not copy %s in %s to %s in %s" % (source_data["name"], source_data["path"], destination_data["name"], destination_data["path"]), cause=e)
|
||||
|
||||
return self.path_in_storage(destination_data["fullpath"])
|
||||
|
||||
def move_folder(self, source, destination):
|
||||
source_data, destination_data = self._get_source_destination_data(source, destination)
|
||||
|
||||
@@ -614,6 +648,8 @@ class LocalFileStorage(StorageInterface):
|
||||
|
||||
self._delete_metadata(source_data["fullpath"])
|
||||
|
||||
return self.path_in_storage(destination_data["fullpath"])
|
||||
|
||||
def add_file(self, path, file_object, printer_profile=None, links=None, allow_overwrite=False):
|
||||
path, name = self.sanitize(path)
|
||||
if not octoprint.filemanager.valid_file_type(name):
|
||||
@@ -635,16 +671,9 @@ class LocalFileStorage(StorageInterface):
|
||||
# save the file's hash to the metadata of the folder
|
||||
file_hash = self._create_hash(file_path)
|
||||
metadata = self._get_metadata_entry(path, name, default=dict())
|
||||
metadata_dirty = False
|
||||
if not "hash" in metadata or metadata["hash"] != file_hash:
|
||||
metadata["hash"] = file_hash
|
||||
metadata_dirty = True
|
||||
if "analysis" in metadata:
|
||||
del metadata["analysis"]
|
||||
metadata_dirty = True
|
||||
|
||||
if metadata_dirty:
|
||||
self._update_metadata_entry(path, name, metadata)
|
||||
# hash changed -> throw away old metadata
|
||||
self._update_metadata_entry(path, name, dict(hash=file_hash))
|
||||
|
||||
# process any links that were also provided for adding to the file
|
||||
if not links:
|
||||
@@ -687,6 +716,8 @@ class LocalFileStorage(StorageInterface):
|
||||
self._copy_metadata_entry(source_data["path"], source_data["name"],
|
||||
destination_data["path"], destination_data["name"])
|
||||
|
||||
return self.path_in_storage(destination_data["fullpath"])
|
||||
|
||||
def move_file(self, source, destination, allow_overwrite=False):
|
||||
source_data, destination_data = self._get_source_destination_data(source, destination)
|
||||
|
||||
@@ -699,6 +730,12 @@ class LocalFileStorage(StorageInterface):
|
||||
destination_data["path"], destination_data["name"],
|
||||
delete_source=True)
|
||||
|
||||
return self.path_in_storage(destination_data["fullpath"])
|
||||
|
||||
def has_analysis(self, path):
|
||||
metadata = self.get_metadata(path)
|
||||
return "analysis" in metadata
|
||||
|
||||
def get_metadata(self, path):
|
||||
path, name = self.sanitize(path)
|
||||
return self._get_metadata_entry(path, name)
|
||||
@@ -946,7 +983,15 @@ class LocalFileStorage(StorageInterface):
|
||||
continue
|
||||
|
||||
printer_profile = history_entry["printerProfile"]
|
||||
if not printer_profile:
|
||||
continue
|
||||
|
||||
print_time = history_entry["printTime"]
|
||||
try:
|
||||
print_time = float(print_time)
|
||||
except:
|
||||
self._logger.warn("Invalid print time value found in print history for {} in {}/.metadata.yaml: {!r}".format(name, path, print_time))
|
||||
continue
|
||||
|
||||
if not printer_profile in former_print_times:
|
||||
former_print_times[printer_profile] = []
|
||||
@@ -1123,11 +1168,16 @@ class LocalFileStorage(StorageInterface):
|
||||
# no hidden files and folders
|
||||
continue
|
||||
|
||||
entry_name = entry.name
|
||||
entry_path = entry.path
|
||||
entry_is_file = entry.is_file()
|
||||
entry_is_dir = entry.is_dir()
|
||||
entry_stat = entry.stat()
|
||||
try:
|
||||
entry_name = entry.name
|
||||
entry_path = entry.path
|
||||
entry_is_file = entry.is_file()
|
||||
entry_is_dir = entry.is_dir()
|
||||
entry_stat = entry.stat()
|
||||
except:
|
||||
# error while trying to fetch file metadata, that might be thanks to file already having
|
||||
# been moved or deleted - ignore it and continue
|
||||
continue
|
||||
|
||||
try:
|
||||
new_entry_name, new_entry_path = self._sanitize_entry(entry_name, path, entry_path)
|
||||
|
||||
@@ -1,4 +1,137 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
from . import handlers
|
||||
from octoprint.logging import handlers
|
||||
|
||||
def log_to_handler(logger, handler, level, msg, exc_info=None, extra=None, *args):
|
||||
"""
|
||||
Logs to the provided handler only.
|
||||
|
||||
Arguments:
|
||||
logger: logger to log to
|
||||
handler: handler to restrict logging to
|
||||
level: level to log at
|
||||
msg: message to log
|
||||
exc_info: optional exception info
|
||||
extra: optional extra data
|
||||
*args: log args
|
||||
"""
|
||||
from logging import _srcfile
|
||||
import sys
|
||||
|
||||
# this is just the same as logging.Logger._log
|
||||
|
||||
if _srcfile:
|
||||
# IronPython doesn't track Python frames, so findCaller raises an
|
||||
# exception on some versions of IronPython. We trap it here so that
|
||||
# IronPython can use logging.
|
||||
try:
|
||||
fn, lno, func = logger.findCaller()
|
||||
except ValueError:
|
||||
fn, lno, func = "(unknown file)", 0, "(unknown function)"
|
||||
else:
|
||||
fn, lno, func = "(unknown file)", 0, "(unknown function)"
|
||||
if exc_info:
|
||||
if not isinstance(exc_info, tuple):
|
||||
exc_info = sys.exc_info()
|
||||
|
||||
record = logger.makeRecord(logger.name, level, fn, lno, msg, args, exc_info, func, extra)
|
||||
|
||||
# and this is a mixture of logging.Logger.handle and logging.Logger.callHandlers
|
||||
|
||||
if (not logger.disabled) and logger.filter(record):
|
||||
if record.levelno >= handler.level:
|
||||
handler.handle(record)
|
||||
|
||||
|
||||
def get_handler(name, logger=None):
|
||||
"""
|
||||
Retrieves the handler named ``name``.
|
||||
|
||||
If optional ``logger`` is provided, search will be
|
||||
limited to that logger, otherwise the root logger will be
|
||||
searched.
|
||||
|
||||
Arguments:
|
||||
name: the name of the handler to look for
|
||||
logger: (optional) the logger to search in, root logger if not provided
|
||||
|
||||
Returns:
|
||||
the handler if it could be found, None otherwise
|
||||
"""
|
||||
import logging
|
||||
|
||||
if logger is None:
|
||||
logger = logging.getLogger()
|
||||
|
||||
for handler in logger.handlers:
|
||||
if handler.get_name() == name:
|
||||
return handler
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_divider_line(c, message=None, length=78, indent=3):
|
||||
"""
|
||||
Generate a divider line for logging, optionally with included message.
|
||||
|
||||
Examples:
|
||||
|
||||
>>> get_divider_line("-")
|
||||
'------------------------------------------------------------------------------'
|
||||
>>> get_divider_line("=", length=10)
|
||||
'=========='
|
||||
>>> get_divider_line("-", message="Hi", length=10)
|
||||
'--- Hi ---'
|
||||
>>> get_divider_line("-", message="A slightly longer text")
|
||||
'--- A slightly longer text ---------------------------------------------------'
|
||||
>>> get_divider_line("-", message="A slightly longer text", indent=5)
|
||||
'----- A slightly longer text -------------------------------------------------'
|
||||
>>> get_divider_line("-", message="Hello World!", length=10)
|
||||
'--- Hello World!'
|
||||
>>> get_divider_line(None)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AssertionError: c is not text
|
||||
>>> get_divider_line("´`")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AssertionError: c is not a single character
|
||||
>>> get_divider_line("-", message=3)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AssertionError: message is not text
|
||||
>>> get_divider_line("-", length="hello")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AssertionError: length is not an int
|
||||
>>> get_divider_line("-", indent="hi")
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AssertionError: indent is not an int
|
||||
|
||||
Arguments:
|
||||
c: character to use for the line
|
||||
message: message to print in the line
|
||||
length: length of the line
|
||||
indent: indentation of message in line
|
||||
|
||||
Returns:
|
||||
formatted divider line
|
||||
"""
|
||||
|
||||
assert isinstance(c, (str, unicode, bytes)), "c is not text"
|
||||
assert len(c) == 1, "c is not a single character"
|
||||
assert isinstance(length, int), "length is not an int"
|
||||
assert isinstance(indent, int), "indent is not an int"
|
||||
|
||||
if message is None:
|
||||
return c * length
|
||||
|
||||
assert isinstance(message, (str, unicode, bytes)), "message is not text"
|
||||
|
||||
space = length - 2 * (indent + 1)
|
||||
if space >= len(message):
|
||||
return c * indent + " " + message + " " + c * (length - indent - 2 - len(message))
|
||||
else:
|
||||
return c * indent + " " + message
|
||||
@@ -17,6 +17,21 @@ class CleaningTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler
|
||||
os.remove(s)
|
||||
|
||||
|
||||
class OctoPrintLogHandler(CleaningTimedRotatingFileHandler):
|
||||
rollover_callbacks = []
|
||||
|
||||
@classmethod
|
||||
def registerRolloverCallback(cls, callback, *args, **kwargs):
|
||||
cls.rollover_callbacks.append((callback, args, kwargs))
|
||||
|
||||
def doRollover(self):
|
||||
CleaningTimedRotatingFileHandler.doRollover(self)
|
||||
|
||||
for rcb in self.__class__.rollover_callbacks:
|
||||
callback, args, kwargs = rcb
|
||||
callback(*args, **kwargs)
|
||||
|
||||
|
||||
class SerialLogHandler(logging.handlers.RotatingFileHandler):
|
||||
|
||||
_do_rollover = False
|
||||
|
||||
@@ -45,7 +45,8 @@ def _validate_plugin(phase, plugin_info):
|
||||
return True
|
||||
|
||||
def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_entry_points=None, plugin_disabled_list=None,
|
||||
plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None, plugin_validators=None):
|
||||
plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None, plugin_validators=None,
|
||||
plugin_checked_module_dependencies=None):
|
||||
"""
|
||||
Factory method for initially constructing and consecutively retrieving the :class:`~octoprint.plugin.core.PluginManager`
|
||||
singleton.
|
||||
@@ -71,6 +72,8 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
plugin_obsolete_hooks (list): A list of hooks that have been declared obsolete. Plugins implementing them will
|
||||
not be enabled since they might depend on functionality that is no longer available.
|
||||
plugin_validators (list): A list of additional plugin validators through which to process each plugin.
|
||||
plugin_checked_module_dependencies (dict): A dictionary of package name-version-pairs for which to enable
|
||||
dependency checking during plugin loading.
|
||||
|
||||
Returns:
|
||||
PluginManager: A fully initialized :class:`~octoprint.plugin.core.PluginManager` instance to be used for plugin
|
||||
@@ -104,7 +107,8 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
UiPlugin]
|
||||
|
||||
if plugin_restart_needing_hooks is None:
|
||||
plugin_restart_needing_hooks = ["octoprint.server.http"]
|
||||
plugin_restart_needing_hooks = ["octoprint.server.http.*",
|
||||
"octoprint.printer.factory"]
|
||||
|
||||
if plugin_obsolete_hooks is None:
|
||||
plugin_obsolete_hooks = ["octoprint.comm.protocol.gcode"]
|
||||
@@ -113,6 +117,9 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
plugin_validators = [_validate_plugin]
|
||||
else:
|
||||
plugin_validators.append(_validate_plugin)
|
||||
if plugin_checked_module_dependencies is None:
|
||||
from octoprint import __version__ as octoprint_version
|
||||
plugin_checked_module_dependencies = dict(octoprint=octoprint_version)
|
||||
|
||||
_instance = PluginManager(plugin_folders,
|
||||
plugin_types,
|
||||
@@ -121,7 +128,8 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
plugin_disabled_list=plugin_disabled_list,
|
||||
plugin_restart_needing_hooks=plugin_restart_needing_hooks,
|
||||
plugin_obsolete_hooks=plugin_obsolete_hooks,
|
||||
plugin_validators=plugin_validators)
|
||||
plugin_validators=plugin_validators,
|
||||
plugin_checked_module_dependencies=plugin_checked_module_dependencies)
|
||||
else:
|
||||
raise ValueError("Plugin Manager not initialized yet")
|
||||
return _instance
|
||||
@@ -239,7 +247,7 @@ class PluginSettings(object):
|
||||
"""
|
||||
The :class:`PluginSettings` class is the interface for plugins to their own or globally defined settings.
|
||||
|
||||
It provides a couple of convenience methods for directly accessing plugin settings via the regular
|
||||
It provides some convenience methods for directly accessing plugin settings via the regular
|
||||
:class:`octoprint.settings.Settings` interfaces as well as means to access plugin specific folder locations.
|
||||
|
||||
All getter and setter methods will ensure that plugin settings are stored in their correct location within the
|
||||
@@ -263,13 +271,17 @@ class PluginSettings(object):
|
||||
:returns: The retrieved settings value.
|
||||
:rtype: object
|
||||
|
||||
.. method:: get_int(path)
|
||||
.. method:: get_int(path, min=None, max=None)
|
||||
|
||||
Like :func:`get` but tries to convert the retrieved value to ``int``.
|
||||
Like :func:`get` but tries to convert the retrieved value to ``int``. If ``min`` is provided and the retrieved
|
||||
value is less than it, it will be returned instead of the value. Likewise for ``max`` - it will be returned if
|
||||
the value is greater than it.
|
||||
|
||||
.. method:: get_float(path)
|
||||
.. method:: get_float(path, min=None, max=None)
|
||||
|
||||
Like :func:`get` but tries to convert the retrieved value to ``float``.
|
||||
Like :func:`get` but tries to convert the retrieved value to ``float``. If ``min`` is provided and the retrieved
|
||||
value is less than it, it will be returned instead of the value. Likewise for ``max`` - it will be returned if
|
||||
the value is greater than it.
|
||||
|
||||
.. method:: get_boolean(path)
|
||||
|
||||
@@ -285,13 +297,19 @@ class PluginSettings(object):
|
||||
:param boolean force: If set to True, the modified configuration will even be written back to disk if
|
||||
the value didn't change.
|
||||
|
||||
.. method:: set_int(path, value, force=False)
|
||||
.. method:: set_int(path, value, force=False, min=None, max=None)
|
||||
|
||||
Like :func:`set` but ensures the value is an ``int`` through attempted conversion before setting it.
|
||||
If ``min`` and/or ``max`` are provided, it will also be ensured that the value is greater than or equal
|
||||
to ``min`` and less than or equal to ``max``. If that is not the case, the limit value (``min`` if less than
|
||||
that, ``max`` if greater than that) will be set instead.
|
||||
|
||||
.. method:: set_float(path, value, force=False)
|
||||
.. method:: set_float(path, value, force=False, min=None, max=None)
|
||||
|
||||
Like :func:`set` but ensures the value is an ``float`` through attempted conversion before setting it.
|
||||
If ``min`` and/or ``max`` are provided, it will also be ensured that the value is greater than or equal
|
||||
to ``min`` and less than or equal to ``max``. If that is not the case, the limit value (``min`` if less than
|
||||
that, ``max`` if greater than that) will be set instead.
|
||||
|
||||
.. method:: set_boolean(path, value, force=False)
|
||||
|
||||
|
||||
+153
-43
@@ -31,6 +31,7 @@ import os
|
||||
import imp
|
||||
from collections import defaultdict, namedtuple, OrderedDict
|
||||
import logging
|
||||
import fnmatch
|
||||
|
||||
import pkg_resources
|
||||
import pkginfo
|
||||
@@ -40,6 +41,8 @@ try:
|
||||
except ImportError:
|
||||
from scandir import scandir
|
||||
|
||||
from octoprint.util.version import version_matches_spec
|
||||
|
||||
EntryPointOrigin = namedtuple("EntryPointOrigin", "type, entry_point, module_name, package_name, package_version")
|
||||
FolderOrigin = namedtuple("FolderOrigin", "type, folder")
|
||||
|
||||
@@ -71,6 +74,9 @@ class PluginInfo(object):
|
||||
attr_description = '__plugin_description__'
|
||||
""" Module attribute from which to retrieve the plugin's description. """
|
||||
|
||||
attr_disabling_discouraged = '__plugin_disabling_discouraged__'
|
||||
""" Module attribute from which to retrieve the reason why disabling the plugin is discouraged. Only effective if ``self.bundled`` is True. """
|
||||
|
||||
attr_version = '__plugin_version__'
|
||||
""" Module attribute from which to retrieve the plugin's version. """
|
||||
|
||||
@@ -294,6 +300,19 @@ class PluginInfo(object):
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_description, default=self._description)
|
||||
|
||||
@property
|
||||
def disabling_discouraged(self):
|
||||
"""
|
||||
Reason why disabling of this plugin is discouraged. Only evaluated for bundled plugins! Will be taken from
|
||||
the disabling_discouraged attribute of the plugin module as defined in :attr:`attr_disabling_discouraged` if
|
||||
available. False if unset or plugin not bundled.
|
||||
|
||||
Returns:
|
||||
str or None: Reason why disabling this plugin is discouraged (only for bundled plugins)
|
||||
"""
|
||||
return self._get_instance_attribute(self.__class__.attr_disabling_discouraged, default=False) if self.bundled \
|
||||
else False
|
||||
|
||||
@property
|
||||
def version(self):
|
||||
"""
|
||||
@@ -447,7 +466,7 @@ class PluginManager(object):
|
||||
|
||||
def __init__(self, plugin_folders, plugin_types, plugin_entry_points, logging_prefix=None,
|
||||
plugin_disabled_list=None, plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None,
|
||||
plugin_validators=None):
|
||||
plugin_validators=None, plugin_checked_module_dependencies=None):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
if logging_prefix is None:
|
||||
@@ -468,6 +487,7 @@ class PluginManager(object):
|
||||
self.plugin_restart_needing_hooks = plugin_restart_needing_hooks
|
||||
self.plugin_obsolete_hooks = plugin_obsolete_hooks
|
||||
self.plugin_validators = plugin_validators
|
||||
self.plugin_dependency_checks = plugin_checked_module_dependencies
|
||||
self.logging_prefix = logging_prefix
|
||||
|
||||
self.enabled_plugins = dict()
|
||||
@@ -555,6 +575,10 @@ class PluginManager(object):
|
||||
key = entry.name
|
||||
elif entry.is_file() and entry.name.endswith(".py"):
|
||||
key = entry.name[:-3] # strip off the .py extension
|
||||
if key.startswith("__"):
|
||||
# might be an __init__.py in our plugins folder, or something else we don't want
|
||||
# to handle
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
|
||||
@@ -598,6 +622,20 @@ class PluginManager(object):
|
||||
module_name = entry_point.module_name
|
||||
version = entry_point.dist.version
|
||||
|
||||
if self.plugin_dependency_checks:
|
||||
requires = entry_point.dist.requires()
|
||||
missing_requirements = []
|
||||
for require in requires:
|
||||
if require.key in self.plugin_dependency_checks:
|
||||
available_version = self.plugin_dependency_checks[require.key]
|
||||
spec = str(require.specifier)
|
||||
if not version_matches_spec(available_version, spec, package=require.key, base=True):
|
||||
missing_requirements.append("{}{}".format(require.key, spec))
|
||||
|
||||
if missing_requirements:
|
||||
self.logger.warn("Plugin \"{}\" is missing requirements, skipping it: {}".format(key, ", ".join(missing_requirements)))
|
||||
continue
|
||||
|
||||
if key in existing or key in result or (ignore_uninstalled and key in self.marked_plugins["uninstalled"]):
|
||||
# plugin is already defined or marked as uninstalled, ignore it
|
||||
continue
|
||||
@@ -640,7 +678,8 @@ class PluginManager(object):
|
||||
|
||||
return result
|
||||
|
||||
def _import_plugin_from_module(self, key, folder=None, module_name=None, name=None, version=None, summary=None, author=None, url=None, license=None):
|
||||
def _import_plugin_from_module(self, key, folder=None, module_name=None, name=None, version=None, summary=None,
|
||||
author=None, url=None, license=None):
|
||||
# TODO error handling
|
||||
try:
|
||||
if folder:
|
||||
@@ -926,45 +965,107 @@ class PluginManager(object):
|
||||
return plugin.needs_restart or self.has_restart_needing_implementation(plugin) or self.has_restart_needing_hooks(plugin)
|
||||
|
||||
def has_restart_needing_implementation(self, plugin):
|
||||
if not plugin.implementation:
|
||||
return False
|
||||
|
||||
return isinstance(plugin.implementation, RestartNeedingPlugin)
|
||||
return self.has_any_of_mixins(plugin, RestartNeedingPlugin)
|
||||
|
||||
def has_restart_needing_hooks(self, plugin):
|
||||
if not plugin.hooks:
|
||||
return False
|
||||
|
||||
hooks = plugin.hooks.keys()
|
||||
for hook in hooks:
|
||||
if self.is_restart_needing_hook(hook):
|
||||
return True
|
||||
return False
|
||||
return self.has_any_of_hooks(plugin, self.plugin_restart_needing_hooks)
|
||||
|
||||
def has_obsolete_hooks(self, plugin):
|
||||
if not plugin.hooks:
|
||||
return False
|
||||
|
||||
hooks = plugin.hooks.keys()
|
||||
for hook in hooks:
|
||||
if self.is_obsolete_hook(hook):
|
||||
return True
|
||||
return False
|
||||
return self.has_any_of_hooks(plugin, self.plugin_obsolete_hooks)
|
||||
|
||||
def is_restart_needing_hook(self, hook):
|
||||
if self.plugin_restart_needing_hooks is None:
|
||||
return False
|
||||
|
||||
for h in self.plugin_restart_needing_hooks:
|
||||
if hook.startswith(h):
|
||||
return True
|
||||
|
||||
return False
|
||||
return self.hook_matches_hooks(hook, self.plugin_restart_needing_hooks)
|
||||
|
||||
def is_obsolete_hook(self, hook):
|
||||
if self.plugin_obsolete_hooks is None:
|
||||
return self.hook_matches_hooks(hook, self.plugin_obsolete_hooks)
|
||||
|
||||
@staticmethod
|
||||
def has_any_of_hooks(plugin, *hooks):
|
||||
"""
|
||||
Tests if the ``plugin`` contains any of the provided ``hooks``.
|
||||
|
||||
Uses :func:`octoprint.plugin.core.PluginManager.hook_matches_hooks`.
|
||||
|
||||
Args:
|
||||
plugin: plugin to test hooks for
|
||||
*hooks: hooks to test against
|
||||
|
||||
Returns:
|
||||
(bool): True if any of the plugin's hooks match the provided hooks,
|
||||
False otherwise.
|
||||
"""
|
||||
|
||||
if hooks and len(hooks) == 1 and isinstance(hooks[0], (list, tuple)):
|
||||
hooks = hooks[0]
|
||||
|
||||
hooks = filter(lambda hook: hook is not None, hooks)
|
||||
if not hooks:
|
||||
return False
|
||||
return hook in self.plugin_obsolete_hooks
|
||||
if not plugin or not plugin.hooks:
|
||||
return False
|
||||
|
||||
plugin_hooks = plugin.hooks.keys()
|
||||
|
||||
return any(map(lambda hook: PluginManager.hook_matches_hooks(hook, *hooks),
|
||||
plugin_hooks))
|
||||
|
||||
@staticmethod
|
||||
def hook_matches_hooks(hook, *hooks):
|
||||
"""
|
||||
Tests if ``hook`` matches any of the provided ``hooks`` to test for.
|
||||
|
||||
``hook`` is expected to be an exact hook name.
|
||||
|
||||
``hooks`` is expected to be a list containing one or more hook names or
|
||||
patterns. That can be either an exact hook name or an
|
||||
:func:`fnmatch.fnmatch` pattern.
|
||||
|
||||
Args:
|
||||
hook: the hook to test
|
||||
hooks: the hook name patterns to test against
|
||||
|
||||
Returns:
|
||||
(bool): True if the ``hook`` matches any of the ``hooks``, False otherwise.
|
||||
|
||||
"""
|
||||
|
||||
if hooks and len(hooks) == 1 and isinstance(hooks[0], (list, tuple)):
|
||||
hooks = hooks[0]
|
||||
|
||||
hooks = filter(lambda hook: hook is not None, hooks)
|
||||
if not hooks:
|
||||
return False
|
||||
if not hook:
|
||||
return False
|
||||
|
||||
return any(map(lambda h: fnmatch.fnmatch(hook, h),
|
||||
hooks))
|
||||
|
||||
@staticmethod
|
||||
def has_any_of_mixins(plugin, *mixins):
|
||||
"""
|
||||
Tests if the ``plugin`` has an implementation implementing any
|
||||
of the provided ``mixins``.
|
||||
|
||||
Args:
|
||||
plugin: plugin for which to check the implementation
|
||||
*mixins: mixins to test against
|
||||
|
||||
Returns:
|
||||
(bool): True if the plugin's implementation implements any of the
|
||||
provided mixins, False otherwise.
|
||||
"""
|
||||
|
||||
if mixins and len(mixins) == 1 and isinstance(mixins[0], (list, tuple)):
|
||||
mixins = mixins[0]
|
||||
|
||||
mixins = filter(lambda mixin: mixin is not None, mixins)
|
||||
if not mixins:
|
||||
return False
|
||||
if not plugin or not plugin.implementation:
|
||||
return False
|
||||
|
||||
return isinstance(plugin.implementation, tuple(mixins))
|
||||
|
||||
def initialize_implementations(self, additional_injects=None, additional_inject_factories=None, additional_pre_inits=None, additional_post_inits=None):
|
||||
for name, plugin in self.enabled_plugins.items():
|
||||
@@ -1062,21 +1163,30 @@ class PluginManager(object):
|
||||
return True
|
||||
|
||||
|
||||
def log_all_plugins(self, show_bundled=True, bundled_str=(" (bundled)", ""), show_location=True, location_str=" = {location}", show_enabled=True, enabled_str=(" ", "!")):
|
||||
def log_all_plugins(self, show_bundled=True, bundled_str=(" (bundled)", ""), show_location=True,
|
||||
location_str=" = {location}", show_enabled=True, enabled_str=(" ", "!"),
|
||||
only_to_handler=None):
|
||||
all_plugins = self.enabled_plugins.values() + self.disabled_plugins.values()
|
||||
|
||||
def _log(message, level=logging.INFO):
|
||||
if only_to_handler is not None:
|
||||
import octoprint.logging
|
||||
octoprint.logging.log_to_handler(self.logger, only_to_handler, level, message, [])
|
||||
else:
|
||||
self.logger.log(level, message)
|
||||
|
||||
if len(all_plugins) <= 0:
|
||||
self.logger.info("No plugins available")
|
||||
_log("No plugins available")
|
||||
else:
|
||||
self.logger.info("{count} plugin(s) registered with the system:\n{plugins}".format(count=len(all_plugins), plugins="\n".join(
|
||||
map(lambda x: "| " + x.long_str(show_bundled=show_bundled,
|
||||
bundled_strs=bundled_str,
|
||||
show_location=show_location,
|
||||
location_str=location_str,
|
||||
show_enabled=show_enabled,
|
||||
enabled_strs=enabled_str),
|
||||
sorted(self.plugins.values(), key=lambda x: str(x).lower()))
|
||||
)))
|
||||
formatted_plugins = "\n".join(map(lambda x: "| " + x.long_str(show_bundled=show_bundled,
|
||||
bundled_strs=bundled_str,
|
||||
show_location=show_location,
|
||||
location_str=location_str,
|
||||
show_enabled=show_enabled,
|
||||
enabled_strs=enabled_str),
|
||||
sorted(self.plugins.values(), key=lambda x: str(x).lower())))
|
||||
_log("{count} plugin(s) registered with the system:\n{plugins}".format(count=len(all_plugins),
|
||||
plugins=formatted_plugins))
|
||||
|
||||
def get_plugin(self, identifier, require_enabled=True):
|
||||
"""
|
||||
|
||||
@@ -23,6 +23,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
from .core import (Plugin, RestartNeedingPlugin, SortablePlugin)
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
class OctoPrintPlugin(Plugin):
|
||||
"""
|
||||
@@ -531,7 +532,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
provided request by calling :meth:`~octoprint.plugin.UiPlugin.will_handle_ui` with the Flask
|
||||
`Request <http://flask.pocoo.org/docs/0.10/api/#flask.Request>`_ object as
|
||||
parameter. If you plugin returns `True` here, OctoPrint will next call
|
||||
:meth:`~octoprint.plugin.UiPlugin.on_ui_render` with a couple of parameters like
|
||||
:meth:`~octoprint.plugin.UiPlugin.on_ui_render` with a few parameters like
|
||||
- again - the Flask Request object and the render keyword arguments as
|
||||
used by the default OctoPrint web interface. For more information see below.
|
||||
|
||||
@@ -582,7 +583,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
it only gets re-rendered if the request demands that (by having no-cache headers set) or if
|
||||
the cache gets invalidated otherwise.
|
||||
|
||||
In order to be able to do that, the ``UiPlugin`` offers overriding a couple of cache specific
|
||||
In order to be able to do that, the ``UiPlugin`` offers overriding some cache specific
|
||||
methods used for figuring out the source files whose modification time to use for cache invalidation
|
||||
as well as override possibilities for ETag and LastModified calculation. Additionally there are
|
||||
methods to allow persisting call parameters to allow for preemptively caching your UI during
|
||||
@@ -742,10 +743,25 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
OctoPrint's version, current ``UI_API_KEY``, tracked file paths and ``LastModified`` value).
|
||||
|
||||
Returns:
|
||||
basestring: An alternatively calculated ETag value. Ignored if ``None`` is returned (default).
|
||||
str: An alternatively calculated ETag value. Ignored if ``None`` is returned (default).
|
||||
"""
|
||||
return None
|
||||
|
||||
def get_ui_additional_etag(self, default_additional):
|
||||
"""
|
||||
Allows to provide a list of additional fields to use for ETag generation.
|
||||
|
||||
By default the same list will be returned that is also used in the stock UI (and injected
|
||||
via the parameter ``default_additional``).
|
||||
|
||||
Arguments:
|
||||
default_additional (list): The list of default fields added to the ETag of the default UI
|
||||
|
||||
Returns:
|
||||
(list): A list of additional fields for the ETag generation, or None
|
||||
"""
|
||||
return default_additional
|
||||
|
||||
def get_ui_custom_lastmodified(self):
|
||||
"""
|
||||
Allows to calculate the LastModified differently than using the most recent modification
|
||||
@@ -806,6 +822,25 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
|
||||
"""
|
||||
return False
|
||||
|
||||
def get_ui_custom_template_filter(self, default_template_filter):
|
||||
"""
|
||||
Allows to specify a custom template filter to use for filtering the template contained in the
|
||||
``render_kwargs`` provided to the templating sub system.
|
||||
|
||||
Only relevant for UiPlugins that actually utilize the stock templates of OctoPrint.
|
||||
|
||||
By default simply returns the provided ``default_template_filter``.
|
||||
|
||||
Arguments:
|
||||
default_template_filter (callable): The default template filter used by the default UI
|
||||
|
||||
Returns:
|
||||
(callable) A filter function accepting the ``template_type`` and ``template_key`` of a template
|
||||
and returning ``True`` to keep it and ``False`` to filter it out. If ``None`` is returned, no
|
||||
filtering will take place.
|
||||
"""
|
||||
return default_template_filter
|
||||
|
||||
class WizardPlugin(OctoPrintPlugin, ReloadNeedingPlugin):
|
||||
"""
|
||||
The ``WizardPlugin`` mixin allows plugins to report to OctoPrint whether
|
||||
@@ -1004,7 +1039,7 @@ class SimpleApiPlugin(OctoPrintPlugin):
|
||||
mixin offers.
|
||||
|
||||
Use this mixin if all you need to do is return some kind of dynamic data to your plugin from the backend
|
||||
and/or want to react to simple commands which boil down to a type of command and a couple of flat parameters
|
||||
and/or want to react to simple commands which boil down to a type of command and a few flat parameters
|
||||
supplied with it.
|
||||
|
||||
The simple API constructed by OctoPrint for you will be made available under ``/api/plugin/<plugin identifier>/``.
|
||||
@@ -1343,6 +1378,14 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
Of course, you are always free to completely override both :func:`on_settings_load` and :func:`on_settings_save` if the
|
||||
default implementations do not fit your requirements.
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
Make sure to protect sensitive information stored by your plugin that only logged in administrators (or users)
|
||||
should have access to via :meth:`~octoprint.plugin.SettingsPlugin.get_settings_restricted_paths`. OctoPrint will
|
||||
return its settings on the REST API even to anonymous clients, but will filter out fields it know are restricted,
|
||||
therefore you **must** make sure that you specify sensitive information accordingly to limit access as required!
|
||||
|
||||
.. attribute:: _settings
|
||||
|
||||
The :class:`~octoprint.plugin.PluginSettings` instance to use for accessing the plugin's settings. Injected by
|
||||
@@ -1514,8 +1557,8 @@ class SettingsPlugin(OctoPrintPlugin):
|
||||
field="field"),
|
||||
path=dict(to=dict(never=dict(return="return"))))
|
||||
|
||||
def get_settings_restricted_path(self):
|
||||
return dict(admin=[["some", "admin_only", "path], ["another", "admin_only", "path"],
|
||||
def get_settings_restricted_paths(self):
|
||||
return dict(admin=[["some", "admin_only", "path"], ["another", "admin_only", "path"],],
|
||||
user=[["some", "user_only", "path"],],
|
||||
never=[["path", "to", "never", "return"],])
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# make our plugins testable
|
||||
@@ -18,6 +18,8 @@ import threading
|
||||
import feedparser
|
||||
import flask
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from octoprint.server import admin_permission
|
||||
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
|
||||
from flask.ext.babel import gettext
|
||||
@@ -39,40 +41,75 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
# StartupPlugin
|
||||
|
||||
def on_after_startup(self):
|
||||
self._fetch_all_channels()
|
||||
# decouple channel fetching from server startup
|
||||
def fetch_data():
|
||||
self._fetch_all_channels()
|
||||
|
||||
thread = threading.Thread(target=fetch_data)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
# SettingsPlugin
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(channels=dict(_important=dict(name="Important OctoPrint Announcements",
|
||||
priority=1,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/important.xml"),
|
||||
_news=dict(name="OctoPrint News",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/news.xml"),
|
||||
_releases=dict(name="OctoPrint Release Announcements",
|
||||
settings = dict(channels=dict(_important=dict(name="Important Announcements",
|
||||
description="Important announcements about OctoPrint.",
|
||||
priority=1,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/important.xml"),
|
||||
_releases=dict(name="Release Announcements",
|
||||
description="Announcements of new releases and release candidates of OctoPrint.",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/releases.xml"),
|
||||
_blog=dict(name="On the OctoBlog",
|
||||
description="Development news, community spotlights, OctoPrint On Air episodes and more from the official OctoBlog.",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/releases.xml"),
|
||||
_spotlight=dict(name="OctoPrint Community Spotlights",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/spotlight.xml"),
|
||||
_octopi=dict(name="OctoPi Announcements",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/octopi.xml"),
|
||||
_plugins=dict(name="New Plugins in the Repository",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://plugins.octoprint.org/feed.xml")),
|
||||
enabled_channels=[],
|
||||
forced_channels=["_important"],
|
||||
ttl=6*60,
|
||||
display_limit=3,
|
||||
summary_limit=300)
|
||||
url="http://octoprint.org/feeds/octoblog.xml"),
|
||||
_plugins=dict(name="New Plugins in the Repository",
|
||||
description="Announcements of new plugins released on the official Plugin Repository.",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://plugins.octoprint.org/feed.xml"),
|
||||
_octopi=dict(name="OctoPi News",
|
||||
description="News around OctoPi, the Raspberry Pi image including OctoPrint.",
|
||||
priority=2,
|
||||
type="rss",
|
||||
url="http://octoprint.org/feeds/octopi.xml")),
|
||||
enabled_channels=[],
|
||||
forced_channels=["_important"],
|
||||
channel_order=["_important", "_releases", "_blog", "_plugins", "_octopi"],
|
||||
ttl=6*60,
|
||||
display_limit=3,
|
||||
summary_limit=300)
|
||||
settings["enabled_channels"] = settings["channels"].keys()
|
||||
return settings
|
||||
|
||||
def get_settings_version(self):
|
||||
return 1
|
||||
|
||||
def on_settings_migrate(self, target, current):
|
||||
if current is None:
|
||||
# first version had different default feeds and only _important enabled by default
|
||||
channels = self._settings.get(["channels"])
|
||||
if "_news" in channels:
|
||||
del channels["_news"]
|
||||
if "_spotlight" in channels:
|
||||
del channels["_spotlight"]
|
||||
self._settings.set(["channels"], channels)
|
||||
|
||||
enabled = self._settings.get(["enabled_channels"])
|
||||
add_blog = False
|
||||
if "_news" in enabled:
|
||||
add_blog = True
|
||||
enabled.remove("_news")
|
||||
if "_spotlight" in enabled:
|
||||
add_blog = True
|
||||
enabled.remove("_spotlight")
|
||||
if add_blog and not "_blog" in enabled:
|
||||
enabled.append("_blog")
|
||||
self._settings.set(["enabled_channels"], enabled)
|
||||
|
||||
# AssetPlugin
|
||||
|
||||
@@ -97,7 +134,7 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
def get_channel_data(self):
|
||||
from octoprint.settings import valid_boolean_trues
|
||||
|
||||
result = dict()
|
||||
result = []
|
||||
|
||||
force = flask.request.values.get("force", "false") in valid_boolean_trues
|
||||
|
||||
@@ -118,15 +155,17 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
last = entries[0]["published"]
|
||||
self._mark_read_until(key, last)
|
||||
|
||||
result[key] = dict(channel=data["name"],
|
||||
result.append(dict(key=key,
|
||||
channel=data["name"],
|
||||
url=data["url"],
|
||||
description=data.get("description", ""),
|
||||
priority=data.get("priority", 2),
|
||||
enabled=key in enabled or key in forced,
|
||||
forced=key in forced,
|
||||
data=entries,
|
||||
unread=unread)
|
||||
unread=unread))
|
||||
|
||||
return flask.jsonify(result)
|
||||
return flask.jsonify(channels=result)
|
||||
|
||||
def etag():
|
||||
import hashlib
|
||||
@@ -141,11 +180,11 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
|
||||
return hash.hexdigest()
|
||||
|
||||
def condition():
|
||||
return check_etag(etag())
|
||||
def condition(lm, etag):
|
||||
return check_etag(etag)
|
||||
|
||||
return with_revalidation_checking(etag_factory=lambda *args, **kwargs: etag(),
|
||||
condition=lambda *args, **kwargs: condition(),
|
||||
condition=lambda lm, etag: condition(lm, etag),
|
||||
unless=lambda: force)(view)()
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/channels/<channel>", methods=["POST"])
|
||||
@@ -208,9 +247,13 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
with self._cached_channel_configs_mutex:
|
||||
if self._cached_channel_configs is None or force:
|
||||
configs = self._settings.get(["channels"], merged=True)
|
||||
result = dict()
|
||||
for key, config in configs.items():
|
||||
if "url" not in config or "name" not in config:
|
||||
order = self._settings.get(["channel_order"])
|
||||
all_keys = order + [key for key in sorted(configs.keys()) if not key in order]
|
||||
|
||||
result = OrderedDict()
|
||||
for key in all_keys:
|
||||
config = configs.get(key)
|
||||
if config is None or "url" not in config or "name" not in config:
|
||||
# strip invalid entries
|
||||
continue
|
||||
result[self._slugify(key)] = config
|
||||
@@ -287,7 +330,8 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
url = config["url"]
|
||||
try:
|
||||
start = time.time()
|
||||
r = requests.get(url)
|
||||
r = requests.get(url, timeout=30)
|
||||
r.raise_for_status()
|
||||
self._logger.info(u"Loaded channel {} from {} in {:.2}s".format(key, config["url"], time.time() - start))
|
||||
except Exception as e:
|
||||
self._logger.exception(
|
||||
@@ -322,7 +366,7 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
|
||||
return dict(title=entry["title"],
|
||||
title_without_tags=_strip_tags(entry["title"]),
|
||||
summary=entry["summary"],
|
||||
summary=_lazy_images(entry["summary"]),
|
||||
summary_without_images=_strip_images(entry["summary"]),
|
||||
published=published,
|
||||
link=entry["link"],
|
||||
@@ -337,8 +381,57 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
||||
|
||||
_image_tag_re = re.compile(r'<img.*?/?>')
|
||||
def _strip_images(text):
|
||||
"""
|
||||
>>> _strip_images(u"<a href='test.html'>I'm a link</a> and this is an image: <img src='foo.jpg' alt='foo'>")
|
||||
u"<a href='test.html'>I'm a link</a> and this is an image: "
|
||||
>>> _strip_images(u"One <img src=\\"one.jpg\\"> and two <img src='two.jpg' > and three <img src=three.jpg> and four <img src=\\"four.png\\" alt=\\"four\\">")
|
||||
u'One and two and three and four '
|
||||
>>> _strip_images(u"No images here")
|
||||
u'No images here'
|
||||
"""
|
||||
return _image_tag_re.sub('', text)
|
||||
|
||||
def _replace_images(text, callback):
|
||||
"""
|
||||
>>> callback = lambda img: "foobar"
|
||||
>>> _replace_images(u"<a href='test.html'>I'm a link</a> and this is an image: <img src='foo.jpg' alt='foo'>", callback)
|
||||
u"<a href='test.html'>I'm a link</a> and this is an image: foobar"
|
||||
>>> _replace_images(u"One <img src=\\"one.jpg\\"> and two <img src='two.jpg' > and three <img src=three.jpg> and four <img src=\\"four.png\\" alt=\\"four\\">", callback)
|
||||
u'One foobar and two foobar and three foobar and four foobar'
|
||||
"""
|
||||
result = text
|
||||
for match in _image_tag_re.finditer(text):
|
||||
tag = match.group(0)
|
||||
replaced = callback(tag)
|
||||
result = result.replace(tag, replaced)
|
||||
return result
|
||||
|
||||
_image_src_re = re.compile(r'src=(?P<quote>[\'"]*)(?P<src>.*?)(?P=quote)(?=\s+|>)')
|
||||
def _lazy_images(text, placeholder=None):
|
||||
"""
|
||||
>>> _lazy_images(u"<a href='test.html'>I'm a link</a> and this is an image: <img src='foo.jpg' alt='foo'>")
|
||||
u'<a href=\\'test.html\\'>I\\'m a link</a> and this is an image: <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-src=\\'foo.jpg\\' alt=\\'foo\\'>'
|
||||
>>> _lazy_images(u"<a href='test.html'>I'm a link</a> and this is an image: <img src='foo.jpg' alt='foo'>", placeholder="ph.png")
|
||||
u'<a href=\\'test.html\\'>I\\'m a link</a> and this is an image: <img src="ph.png" data-src=\\'foo.jpg\\' alt=\\'foo\\'>'
|
||||
>>> _lazy_images(u"One <img src=\\"one.jpg\\"> and two <img src='two.jpg' > and three <img src=three.jpg> and four <img src=\\"four.png\\" alt=\\"four\\">", placeholder="ph.png")
|
||||
u'One <img src="ph.png" data-src="one.jpg"> and two <img src="ph.png" data-src=\\'two.jpg\\' > and three <img src="ph.png" data-src=three.jpg> and four <img src="ph.png" data-src="four.png" alt="four">'
|
||||
>>> _lazy_images(u"No images here")
|
||||
u'No images here'
|
||||
"""
|
||||
if placeholder is None:
|
||||
# 1px transparent gif
|
||||
placeholder = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
||||
|
||||
def callback(img_tag):
|
||||
match = _image_src_re.search(img_tag)
|
||||
if match is not None:
|
||||
src = match.group("src")
|
||||
quote = match.group("quote")
|
||||
quoted_src = quote + src + quote
|
||||
img_tag = img_tag.replace(match.group(0), 'src="{}" data-src={}'.format(placeholder, quoted_src))
|
||||
return img_tag
|
||||
|
||||
return _replace_images(text, callback)
|
||||
|
||||
def _strip_tags(text):
|
||||
"""
|
||||
@@ -374,4 +467,9 @@ def _strip_tags(text):
|
||||
|
||||
|
||||
__plugin_name__ = "Announcement Plugin"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_description__ = "Announcements all around OctoPrint"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin you might miss important announcements "
|
||||
"regarding security or other critical issues concerning OctoPrint.")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = AnnouncementPlugin()
|
||||
@@ -1 +1 @@
|
||||
table td.settings_plugin_announcements_channels_name,table th.settings_plugin_announcements_channels_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_announcements_channels_actions,table th.settings_plugin_announcements_channels_actions{text-align:center;width:80px}table td.settings_plugin_announcements_channels_actions a,table th.settings_plugin_announcements_channels_actions a{text-decoration:none;color:#000}table td.settings_plugin_announcements_channels_actions a.disabled,table th.settings_plugin_announcements_channels_actions a.disabled{color:#ccc;cursor:default}#plugin_announcements_dialog .unread{font-weight:700}#plugin_announcements_dialog article{padding-right:20px}#plugin_announcements_dialog article.read{opacity:.5}#plugin_announcements_dialog article.read:hover{opacity:1}#plugin_announcements_dialog article .actions{background-color:#f5f5f5;border-radius:2px;padding:2px 5px;margin-top:5px}#plugin_announcements_dialog article .actions .markread{float:right}#plugin_announcements_dialog article .actions a{color:#000}
|
||||
table td.settings_plugin_announcements_channels_name,table th.settings_plugin_announcements_channels_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_announcements_channels_actions,table th.settings_plugin_announcements_channels_actions{text-align:center;width:80px}table td.settings_plugin_announcements_channels_actions a,table th.settings_plugin_announcements_channels_actions a{text-decoration:none;color:#000}table td.settings_plugin_announcements_channels_actions a.disabled,table th.settings_plugin_announcements_channels_actions a.disabled{color:#ccc;cursor:default}#plugin_announcements_dialog .unread{font-weight:700}#plugin_announcements_dialog article{padding-right:20px}#plugin_announcements_dialog article.read{opacity:.5}#plugin_announcements_dialog article.read:hover{opacity:1}#plugin_announcements_dialog article .actions{background-color:#f5f5f5;border-radius:2px;padding:2px 5px;margin-top:5px}#plugin_announcements_dialog article .actions .markread{float:right}#plugin_announcements_dialog article .actions a{color:#000}#plugin_announcements_dialog .modal-footer .configurelink{float:left}
|
||||
@@ -40,7 +40,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.toggleButtonCss = function(data) {
|
||||
var icon = data.enabled ? "icon-circle" : "icon-circle-blank";
|
||||
var icon = data.enabled ? "fa fa-circle" : "fa fa-circle-o";
|
||||
var disabled = (self.enableToggle(data)) ? "" : " disabled";
|
||||
|
||||
return icon + disabled;
|
||||
@@ -120,12 +120,13 @@ $(function() {
|
||||
};
|
||||
|
||||
self.fromResponse = function(data) {
|
||||
if (!self.loginState.isAdmin()) return;
|
||||
|
||||
var currentTab = $("li.active a", self.announcementDialogTabs).attr("href");
|
||||
|
||||
var unread = 0;
|
||||
var channels = [];
|
||||
_.each(data, function(value, key) {
|
||||
value.key = key;
|
||||
_.each(data.channels, function(value) {
|
||||
value.last = value.data.length ? value.data[0].published : undefined;
|
||||
value.count = value.data.length;
|
||||
unread += value.unread;
|
||||
@@ -140,6 +141,11 @@ $(function() {
|
||||
};
|
||||
|
||||
self.showAnnouncementDialog = function(channel) {
|
||||
if (!self.loginState.isAdmin()) return;
|
||||
|
||||
// lazy load images that still need lazy-loading
|
||||
$("#plugin_announcements_dialog_content article img").lazyload();
|
||||
|
||||
self.announcementDialogContent.scrollTop(0);
|
||||
|
||||
if (!self.announcementDialog.hasClass("in")) {
|
||||
@@ -172,6 +178,8 @@ $(function() {
|
||||
};
|
||||
|
||||
self.displayAnnouncements = function(channels) {
|
||||
if (!self.loginState.isAdmin()) return;
|
||||
|
||||
var displayLimit = self.settings.settings.plugins.announcements.display_limit();
|
||||
var maxLength = self.settings.settings.plugins.announcements.summary_limit();
|
||||
|
||||
@@ -222,7 +230,7 @@ $(function() {
|
||||
}
|
||||
var rest = newItems.length - displayedItems.length;
|
||||
|
||||
var text = "<ul>";
|
||||
var text = "<ul style='margin-top: 10px; margin-bottom: 10px'>";
|
||||
_.each(displayedItems, function(item) {
|
||||
var limitedSummary = stripParagraphs(item.summary_without_images.trim());
|
||||
if (limitedSummary.length > maxLength) {
|
||||
@@ -239,6 +247,8 @@ $(function() {
|
||||
text += gettext(_.sprintf("... and %(rest)d more.", {rest: rest}));
|
||||
}
|
||||
|
||||
text += "<small>" + gettext("You can edit your announcement subscriptions under Settings > Announcements.") + "</small>";
|
||||
|
||||
var options = {
|
||||
title: channel,
|
||||
text: text,
|
||||
@@ -248,22 +258,22 @@ $(function() {
|
||||
buttons: [{
|
||||
text: gettext("Later"),
|
||||
click: function(notice) {
|
||||
self.hiddenChannels.push(key);
|
||||
notice.remove();
|
||||
self.hiddenChannels.push(key);
|
||||
}
|
||||
}, {
|
||||
text: gettext("Mark read"),
|
||||
click: function(notice) {
|
||||
self.markRead(key, value.last);
|
||||
notice.remove();
|
||||
self.markRead(key, value.last);
|
||||
}
|
||||
}, {
|
||||
text: gettext("Read..."),
|
||||
addClass: "btn-primary",
|
||||
click: function(notice) {
|
||||
notice.remove();
|
||||
self.showAnnouncementDialog(key);
|
||||
self.markRead(key, value.last);
|
||||
notice.remove();
|
||||
}
|
||||
}]
|
||||
},
|
||||
@@ -284,10 +294,25 @@ $(function() {
|
||||
});
|
||||
};
|
||||
|
||||
self.hideAnnouncements = function() {
|
||||
_.each(self.channelNotifications, function(notification, key) {
|
||||
notification.remove();
|
||||
});
|
||||
self.channelNotifications = {};
|
||||
};
|
||||
|
||||
self.configureAnnouncements = function() {
|
||||
self.settings.show("settings_plugin_announcements");
|
||||
};
|
||||
|
||||
self.onUserLoggedIn = function() {
|
||||
self.retrieveData();
|
||||
};
|
||||
|
||||
self.onUserLoggedOut = function() {
|
||||
self.hideAnnouncements();
|
||||
};
|
||||
|
||||
self.onStartup = function() {
|
||||
self.announcementDialog = $("#plugin_announcements_dialog");
|
||||
self.announcementDialogContent = $("#plugin_announcements_dialog_content");
|
||||
|
||||
@@ -53,4 +53,10 @@ table {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
.configurelink {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
<!-- ko foreach: {data: channels.items, afterAdd: setupTabLink} -->
|
||||
<!-- ko if: $data.enabled || $data.forced -->
|
||||
<li>
|
||||
<a data-toggle="tab" target="_blank" data-bind="text: $data.channel + ' (' + $data.unread + '/' + $data.count + ')', attr: {href: '#plugin_announcements_dialog_channel_' + $data.key}, css: {unread: $data.unread}"></a>
|
||||
<a data-toggle="tab" target="_blank" data-bind="text: $data.channel, attr: {href: '#plugin_announcements_dialog_channel_' + $data.key, title: $data.description}, css: {unread: $data.unread}"></a>
|
||||
</li>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="content" data-bind="html: $data.summary"></div>
|
||||
<div class="actions">
|
||||
<span class="articlelink"><small><a data-bind="text: $data.link, attr: {href: $data.link}" target="_blank" rel="noreferrer noopener"></a></small></span>
|
||||
<span class="markread"><small><a href="javascript:void(0)" data-bind="click: function() { $root.markRead($parent.key, $data.published) }"><i class="icon-eye-open"></i> {{ _('Mark as last read') }}</a></small></span>
|
||||
<span class="markread"><small><a href="javascript:void(0)" data-bind="click: function() { $root.markRead($parent.key, $data.published) }"><i class="fa fa-eye"></i> {{ _('Mark as last read') }}</a></small></span>
|
||||
</div>
|
||||
</article>
|
||||
<!-- /ko -->
|
||||
@@ -40,6 +40,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-block" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
||||
<button class="btn configurelink" data-bind="click: configureAnnouncements"><i class="fa fa-wrench"></i></button>
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Close') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,3 +1,3 @@
|
||||
<a id="navbar_show_announcements" class="pull-right" href="javascript:void(0)" data-bind="click: function() { showAnnouncementDialog(); }" title="{{ _('Announcements') }}">
|
||||
<i data-bind="css: {'icon-bell': !unread(), 'icon-bell-alt': unread()}"></i>
|
||||
<i class="fa" data-bind="css: {'fa-bell-o': !unread(), 'fa-bell': unread()}"></i>
|
||||
</a>
|
||||
@@ -10,7 +10,8 @@
|
||||
<tbody data-bind="foreach: channels.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_plugin_announcements_channels_name">
|
||||
<div data-bind="text: channel, css: {muted: !enabled}"></div>
|
||||
<div data-bind="css: {muted: !enabled}"><strong data-bind="text: channel"></strong></div>
|
||||
<div data-bind="text: description, css: {muted: !enabled}"></div>
|
||||
<div><small class="muted" data-bind="text: url"> </small></div>
|
||||
</td>
|
||||
<td class="settings_plugin_announcements_channels_actions">
|
||||
@@ -31,4 +32,4 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-block" data-bind="click: $root.refreshAnnouncements"><i class="icon-refresh"></i> {{ _('Refresh Announcements') }}</button>
|
||||
<button class="btn btn-block" data-bind="click: $root.refreshAnnouncements"><i class="fa fa-refresh"></i> {{ _('Refresh Announcements') }}</button>
|
||||
@@ -49,9 +49,12 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
#~~ AssetPlugin API
|
||||
|
||||
def get_assets(self):
|
||||
return dict(
|
||||
js=["js/corewizard.js"]
|
||||
)
|
||||
if self.is_wizard_required():
|
||||
return dict(
|
||||
js=["js/corewizard.js"]
|
||||
)
|
||||
else:
|
||||
return dict()
|
||||
|
||||
#~~ WizardPlugin API
|
||||
|
||||
@@ -74,7 +77,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
return self._user_manager.enabled and not self._user_manager.hasBeenCustomized()
|
||||
|
||||
def _get_acl_wizard_details(self):
|
||||
return dict()
|
||||
return dict(required=self._is_acl_wizard_required())
|
||||
|
||||
def _get_acl_wizard_name(self):
|
||||
return gettext("Access Control")
|
||||
@@ -119,7 +122,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
return not (webcam_snapshot_url and webcam_stream_url and ffmpeg_path)
|
||||
|
||||
def _get_webcam_wizard_details(self):
|
||||
return dict()
|
||||
return dict(required=self._is_webcam_wizard_required())
|
||||
|
||||
def _get_webcam_wizard_name(self):
|
||||
return gettext("Webcam & Timelapse")
|
||||
@@ -134,7 +137,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
return not (system_shutdown_command and system_restart_command and server_restart_command)
|
||||
|
||||
def _get_servercommands_wizard_details(self):
|
||||
return dict()
|
||||
return dict(required=self._is_servercommands_wizard_required())
|
||||
|
||||
def _get_servercommands_wizard_name(self):
|
||||
return gettext("Server Commands")
|
||||
@@ -145,7 +148,7 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
return self._printer_profile_manager.is_default_unmodified() and self._printer_profile_manager.profile_count == 1
|
||||
|
||||
def _get_printerprofile_wizard_details(self):
|
||||
return dict()
|
||||
return dict(required=self._is_printerprofile_wizard_required())
|
||||
|
||||
def _get_printerprofile_wizard_name(self):
|
||||
return gettext("Default Printer Profile")
|
||||
@@ -172,5 +175,9 @@ class CoreWizardPlugin(octoprint.plugin.AssetPlugin,
|
||||
|
||||
|
||||
__plugin_name__ = "Core Wizard"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_description__ = "Provides wizard dialogs for core components and functionality"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to perform "
|
||||
"setup steps that might be required after an update.")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = CoreWizardPlugin()
|
||||
@@ -11,6 +11,8 @@ $(function() {
|
||||
self.setup = ko.observable(false);
|
||||
self.decision = ko.observable();
|
||||
|
||||
self.required = false;
|
||||
|
||||
self.passwordMismatch = ko.pureComputed(function() {
|
||||
return self.password() != self.confirmedPassword();
|
||||
});
|
||||
@@ -72,6 +74,8 @@ $(function() {
|
||||
};
|
||||
|
||||
self.onBeforeWizardTabChange = function(next, current) {
|
||||
if (!self.required) return true;
|
||||
|
||||
if (!current || !_.startsWith(current, "wizard_plugin_corewizard_acl_") || self.setup()) {
|
||||
return true;
|
||||
}
|
||||
@@ -82,7 +86,13 @@ $(function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
self.onWizardDetails = function(response) {
|
||||
self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.acl && response.corewizard.details.acl.required;
|
||||
};
|
||||
|
||||
self.onWizardFinish = function() {
|
||||
if (!self.required) return;
|
||||
|
||||
if (!self.decision()) {
|
||||
return "reload";
|
||||
}
|
||||
@@ -94,7 +104,14 @@ $(function() {
|
||||
|
||||
self.settingsViewModel = parameters[0];
|
||||
|
||||
self.required = false;
|
||||
|
||||
self.onWizardDetails = function(response) {
|
||||
self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.webcam && response.corewizard.details.webcam.required;
|
||||
};
|
||||
|
||||
self.onWizardFinish = function() {
|
||||
if (!self.required) return;
|
||||
if (self.settingsViewModel.webcam_streamUrl()
|
||||
|| (self.settingsViewModel.webcam_snapshotUrl() && self.settingsViewModel.webcam_ffmpegPath())) {
|
||||
return "reload";
|
||||
@@ -113,18 +130,29 @@ $(function() {
|
||||
|
||||
self.printerProfiles = parameters[0];
|
||||
|
||||
self.required = false;
|
||||
|
||||
self.editor = self.printerProfiles.createProfileEditor();
|
||||
self.editorLoaded = ko.observable(false);
|
||||
|
||||
self.onStartup = function() {
|
||||
self.onWizardDetails = function(response) {
|
||||
self.required = response && response.corewizard && response.corewizard.details && response.corewizard.details.printerprofile && response.corewizard.details.printerprofile.required;
|
||||
if (!self.required) return;
|
||||
|
||||
OctoPrint.printerprofiles.get("_default")
|
||||
.done(function(data) {
|
||||
self.editor.fromProfileData(data);
|
||||
self.editorLoaded(true);
|
||||
})
|
||||
.fail(function() {
|
||||
self.editor.fromProfileData();
|
||||
self.editorLoaded(true);
|
||||
});
|
||||
};
|
||||
|
||||
self.onWizardFinish = function() {
|
||||
if (!self.required) return;
|
||||
|
||||
OctoPrint.printerprofiles.update("_default", self.editor.toProfileData())
|
||||
.done(function() {
|
||||
self.printerProfiles.requestData();
|
||||
|
||||
@@ -17,6 +17,7 @@ import octoprint.slicing
|
||||
import octoprint.settings
|
||||
|
||||
from octoprint.util.paths import normalize as normalize_path
|
||||
from octoprint.util import to_unicode
|
||||
|
||||
from .profile import Profile
|
||||
from .profile import GcodeFlavors
|
||||
@@ -236,7 +237,8 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
|
||||
self._save_profile(path, new_profile, allow_overwrite=allow_overwrite)
|
||||
|
||||
def do_slice(self, model_path, printer_profile, machinecode_path=None, profile_path=None, position=None, on_progress=None, on_progress_args=None, on_progress_kwargs=None):
|
||||
def do_slice(self, model_path, printer_profile, machinecode_path=None, profile_path=None, position=None,
|
||||
on_progress=None, on_progress_args=None, on_progress_kwargs=None):
|
||||
try:
|
||||
with self._job_mutex:
|
||||
if not profile_path:
|
||||
@@ -246,11 +248,11 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
machinecode_path = path + ".gco"
|
||||
|
||||
if position and isinstance(position, dict) and "x" in position and "y" in position:
|
||||
posX = position["x"]
|
||||
posY = position["y"]
|
||||
pos_x = position["x"]
|
||||
pos_y = position["y"]
|
||||
else:
|
||||
posX = None
|
||||
posY = None
|
||||
pos_x = None
|
||||
pos_y = None
|
||||
|
||||
if on_progress:
|
||||
if not on_progress_args:
|
||||
@@ -258,7 +260,10 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
if not on_progress_kwargs:
|
||||
on_progress_kwargs = dict()
|
||||
|
||||
self._cura_logger.info(u"### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||
self._cura_logger.info(u"### Slicing {} to {} using profile stored at {}"
|
||||
.format(to_unicode(model_path, errors="replace"),
|
||||
to_unicode(machinecode_path, errors="replace"),
|
||||
to_unicode(profile_path, errors="replace")))
|
||||
|
||||
executable = normalize_path(self._settings.get(["cura_engine"]))
|
||||
if not executable:
|
||||
@@ -266,7 +271,24 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
|
||||
working_dir = os.path.dirname(executable)
|
||||
|
||||
engine_settings = self._convert_to_engine(profile_path, printer_profile, posX, posY)
|
||||
slicing_profile = Profile(self._load_profile(profile_path), printer_profile, pos_x, pos_y)
|
||||
|
||||
# NOTE: We can assume an extruder count of 1 here since the only way we currently
|
||||
# support dual extrusion in this implementation is by using the second extruder for support (which
|
||||
# the engine conversion will automatically detect and adapt accordingly).
|
||||
#
|
||||
# We currently do only support STL files as sliceables, which by default can only contain one mesh,
|
||||
# so no risk of having to slice multi-objects at the moment, which would necessitate a full analysis
|
||||
# of the objects to slice to determine amount of needed extruders to use here. If we ever decide to
|
||||
# also support dual extrusion slicing (including composition from multiple STLs or support for OBJ or
|
||||
# AMF files and the like), this code needs to be adapted!
|
||||
#
|
||||
# The extruder count is needed to decide which start/end gcode will be used from the Cura profile.
|
||||
# Stock Cura implementation counts the number of objects in the scene for this (and also takes a look
|
||||
# at the support usage, like the engine conversion here does). We only ever have one object.
|
||||
engine_settings = self._convert_to_engine(profile_path, printer_profile,
|
||||
pos_x=pos_x, pos_y=pos_y,
|
||||
used_extruders=1)
|
||||
|
||||
# Start building the argument list for the CuraEngine command execution
|
||||
args = [executable, '-v', '-p']
|
||||
@@ -276,7 +298,9 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
args += ["-s", "%s=%s" % (k, str(v))]
|
||||
args += ["-o", machinecode_path, model_path]
|
||||
|
||||
self._logger.info(u"Running %r in %s" % (" ".join(args), working_dir))
|
||||
self._logger.info(u"Running {!r} in {}".format(u" ".join(map(lambda x: to_unicode(x, errors="replace"),
|
||||
args)),
|
||||
working_dir))
|
||||
|
||||
import sarge
|
||||
p = sarge.run(args, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
|
||||
@@ -297,7 +321,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
p.commands[0].poll()
|
||||
continue
|
||||
|
||||
line = octoprint.util.to_unicode(line, errors="replace")
|
||||
line = to_unicode(line, errors="replace")
|
||||
self._cura_logger.debug(line.strip())
|
||||
|
||||
if on_progress is not None:
|
||||
@@ -375,11 +399,11 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
if not tool_key in analysis["filament"]:
|
||||
analysis["filament"][tool_key] = dict()
|
||||
|
||||
if profile.get_float("filament_diameter") != None:
|
||||
if profile.get("gcode_flavor") == GcodeFlavors.ULTIGCODE or profile.get("gcode_flavor") == GcodeFlavors.REPRAP_VOLUME:
|
||||
analysis["filament"][tool_key] = _get_usage_from_volume(filament, profile.get_float("filament_diameter"))
|
||||
if slicing_profile.get_float("filament_diameter") is not None:
|
||||
if slicing_profile.get("gcode_flavor") == GcodeFlavors.ULTIGCODE or slicing_profile.get("gcode_flavor") == GcodeFlavors.REPRAP_VOLUME:
|
||||
analysis["filament"][tool_key] = _get_usage_from_volume(filament, slicing_profile.get_float("filament_diameter"))
|
||||
else:
|
||||
analysis["filament"][tool_key] = _get_usage_from_length(filament, profile.get_float("filament_diameter"))
|
||||
analysis["filament"][tool_key] = _get_usage_from_length(filament, slicing_profile.get_float("filament_diameter"))
|
||||
|
||||
except:
|
||||
pass
|
||||
@@ -420,7 +444,8 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
command = self._slicing_commands[machinecode_path]
|
||||
if command is not None:
|
||||
command.terminate()
|
||||
self._logger.info(u"Cancelled slicing of %s" % machinecode_path)
|
||||
self._logger.info(u"Cancelled slicing of {}"
|
||||
.format(to_unicode(machinecode_path, errors="replace")))
|
||||
|
||||
def _load_profile(self, path):
|
||||
import yaml
|
||||
@@ -442,9 +467,9 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
with octoprint.util.atomic_write(path, "wb", max_permissions=0o666) as f:
|
||||
yaml.safe_dump(profile, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
|
||||
def _convert_to_engine(self, profile_path, printer_profile, posX, posY):
|
||||
profile = Profile(self._load_profile(profile_path), printer_profile, posX, posY)
|
||||
return profile.convert_to_engine()
|
||||
def _convert_to_engine(self, profile_path, printer_profile, pos_x=None, pos_y=None, used_extruders=1):
|
||||
profile = Profile(self._load_profile(profile_path), printer_profile, pos_x, pos_y)
|
||||
return profile.convert_to_engine(used_extruders=used_extruders)
|
||||
|
||||
def _sanitize_name(name):
|
||||
if name is None:
|
||||
@@ -488,7 +513,7 @@ def _get_usage_from_length(filament_length, filament_diameter):
|
||||
|
||||
__plugin_name__ = "CuraEngine (<= 15.04)"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_url__ = "https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura"
|
||||
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/cura.html"
|
||||
__plugin_description__ = "Adds support for slicing via CuraEngine versions up to and including version 15.04 from within OctoPrint"
|
||||
__plugin_license__ = "AGPLv3"
|
||||
__plugin_implementation__ = CuraPlugin()
|
||||
|
||||
@@ -7,7 +7,9 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from builtins import range
|
||||
from past.builtins import basestring
|
||||
|
||||
class SupportLocationTypes(object):
|
||||
NONE = "none"
|
||||
@@ -63,12 +65,14 @@ defaults = dict(
|
||||
solid_top=True,
|
||||
solid_bottom=True,
|
||||
fill_overlap=15,
|
||||
perimeter_before_infill=False,
|
||||
|
||||
# speeds
|
||||
print_speed=50.0,
|
||||
travel_speed=150.0,
|
||||
bottom_layer_speed=20.0,
|
||||
infill_speed=0.0,
|
||||
solidarea_speed=0.0,
|
||||
outer_shell_speed=0.0,
|
||||
inner_shell_speed=0.0,
|
||||
|
||||
@@ -117,8 +121,11 @@ defaults = dict(
|
||||
raft_base_linewidth=1.0,
|
||||
raft_interface_thickness=0.27,
|
||||
raft_interface_linewidth=0.4,
|
||||
raft_airgap_all=0.0,
|
||||
raft_airgap=0.22,
|
||||
raft_surface_layers=2,
|
||||
raft_surface_thickness=0.27,
|
||||
raft_surface_linewidth=0.4,
|
||||
|
||||
# repairing
|
||||
fix_horrible_union_all_type_a=True,
|
||||
@@ -597,8 +604,8 @@ class Profile(object):
|
||||
diameters = self._get("filament_diameter")
|
||||
if not match.group(1):
|
||||
return diameters[0]
|
||||
index = int(match.group(1))
|
||||
if index >= len(diameters):
|
||||
index = int(match.group(1)) - 1
|
||||
if index >= len(diameters) or index < 0:
|
||||
return 0.0
|
||||
return diameters[index]
|
||||
|
||||
@@ -610,8 +617,8 @@ class Profile(object):
|
||||
temperatures = self._get("print_temperature")
|
||||
if not match.group(1):
|
||||
return temperatures[0]
|
||||
index = int(match.group(1))
|
||||
if index >= len(temperatures):
|
||||
index = int(match.group(1)) - 1
|
||||
if index >= len(temperatures) or index < 0:
|
||||
return 0.0
|
||||
return temperatures[index]
|
||||
|
||||
@@ -669,9 +676,7 @@ class Profile(object):
|
||||
return default
|
||||
return int(value * 1000)
|
||||
|
||||
def get_gcode_template(self, key):
|
||||
extruder_count = self.get_int("extruder_amount")
|
||||
|
||||
def get_gcode_template(self, key, extruder_count=1):
|
||||
if key in self._profile:
|
||||
gcode = self._profile[key]
|
||||
else:
|
||||
@@ -731,7 +736,7 @@ class Profile(object):
|
||||
|
||||
return pre + str(f)
|
||||
|
||||
def get_gcode(self, key):
|
||||
def get_gcode(self, key, extruder_count=1):
|
||||
prefix = ""
|
||||
postfix = ""
|
||||
|
||||
@@ -741,11 +746,11 @@ class Profile(object):
|
||||
return ""
|
||||
|
||||
if key == "start_gcode":
|
||||
contents = self.get_gcode_template("start_gcode")
|
||||
contents = self.get_gcode_template("start_gcode", extruder_count=extruder_count)
|
||||
prefix += self.get_start_gcode_prefix(contents)
|
||||
|
||||
else:
|
||||
contents = self.get_gcode_template(key)
|
||||
contents = self.get_gcode_template(key, extruder_count=extruder_count)
|
||||
|
||||
return unicode(prefix + re.sub("(.)\{([^\}]*)\}", self.replaceTagMatch, contents).rstrip() + '\n' + postfix).strip().encode('utf-8') + '\n'
|
||||
|
||||
@@ -754,9 +759,13 @@ class Profile(object):
|
||||
|
||||
prefix = ""
|
||||
|
||||
gcode_parameter_key = "S"
|
||||
if self.get("gcode_flavor") == GcodeFlavors.MACH3:
|
||||
gcode_parameter_key = "P"
|
||||
|
||||
e_steps = self.get_float("steps_per_e")
|
||||
if e_steps > 0:
|
||||
prefix += "M92 E{e_steps}\n" % (e_steps)
|
||||
prefix += "M92 E{e_steps}\n".format(e_steps=e_steps)
|
||||
temp = self.get_float("print_temperature")
|
||||
|
||||
bed_temp = 0
|
||||
@@ -765,30 +774,30 @@ class Profile(object):
|
||||
include_bed_temp = bed_temp > 0 and not "{print_bed_temperature}" in Profile.regex_strip_comments.sub("", contents)
|
||||
|
||||
if include_bed_temp:
|
||||
prefix += "M140 S{bed_temp}\n".format(bed_temp=bed_temp)
|
||||
prefix += "M140 {param}{bed_temp}\n".format(param=gcode_parameter_key, bed_temp=bed_temp)
|
||||
|
||||
if temp > 0 and not "{print_temperature}" in Profile.regex_strip_comments.sub("", contents):
|
||||
if extruder_count > 0:
|
||||
def temp_line(temp, extruder, template):
|
||||
def temp_line(temp, extruder, param, template):
|
||||
t = temp
|
||||
if extruder > 0:
|
||||
print_temp = self.get_float("print_temperature%d" % (extruder + 1))
|
||||
if print_temp > 0:
|
||||
t = print_temp
|
||||
return template.format(extruder=extruder, temp=t)
|
||||
return template.format(extruder=extruder, temp=t, param=param)
|
||||
|
||||
prefix_preheat = ""
|
||||
prefix_waitheat = ""
|
||||
for n in range(0, extruder_count):
|
||||
if n > 0:
|
||||
prefix_preheat += temp_line(temp, n, "M104 T{extruder} S{temp}\n")
|
||||
prefix_waitheat += temp_line(temp, n, "M109 T{extruder} S{temp}\n")
|
||||
prefix_preheat += temp_line(temp, n, gcode_parameter_key, "M104 T{extruder} {param}{temp}\n")
|
||||
prefix_waitheat += temp_line(temp, n, gcode_parameter_key, "M109 T{extruder} {param}{temp}\n")
|
||||
prefix += prefix_preheat + prefix_waitheat + "T0\n"
|
||||
else:
|
||||
prefix += "M109 S{temp}\n".format(temp=temp)
|
||||
prefix += "M109 {param}{temp}\n".format(param=gcode_parameter_key, temp=temp)
|
||||
|
||||
if include_bed_temp:
|
||||
prefix += "M190 S{bed_temp}\n".format(bed_temp=bed_temp)
|
||||
prefix += "M190 {param}{bed_temp}\n".format(param=gcode_parameter_key, bed_temp=bed_temp)
|
||||
|
||||
return prefix
|
||||
|
||||
@@ -822,7 +831,7 @@ class Profile(object):
|
||||
if layer_height == 0.0:
|
||||
return 1
|
||||
import math
|
||||
return int(math.ceil(solid_thickness / (layer_height - 0.0001)))
|
||||
return int(math.ceil((solid_thickness - 0.0001) / layer_height))
|
||||
|
||||
def calculate_minimal_extruder_count(self):
|
||||
extruder_count = self.get("extruder_amount")
|
||||
@@ -852,13 +861,14 @@ class Profile(object):
|
||||
|
||||
return int(self.get_float("machine_depth") / 2.0) if not self.get_boolean("machine_center_is_zero") else 0.0
|
||||
|
||||
def convert_to_engine(self):
|
||||
def convert_to_engine(self, used_extruders=1):
|
||||
|
||||
edge_width, line_count = self.calculate_edge_width_and_line_count()
|
||||
solid_layer_count = self.calculate_solid_layer_count()
|
||||
|
||||
extruder_count = self.get_int("extruder_amount")
|
||||
minimal_extruder_count = self.calculate_minimal_extruder_count()
|
||||
actual_extruder_count = max(minimal_extruder_count, used_extruders)
|
||||
|
||||
settings = {
|
||||
"layerThickness": self.get_microns("layer_height"),
|
||||
@@ -871,12 +881,14 @@ class Profile(object):
|
||||
"downSkinCount": solid_layer_count if self.get_boolean("solid_bottom") else 0,
|
||||
"upSkinCount": solid_layer_count if self.get_boolean("solid_top") else 0,
|
||||
"infillOverlap": self.get_int("fill_overlap"),
|
||||
"perimeterBeforeInfill": 1 if self.get_boolean("perimeter_before_infill") else 0,
|
||||
"initialSpeedupLayers": int(4),
|
||||
"initialLayerSpeed": self.get_int("bottom_layer_speed"),
|
||||
"printSpeed": self.get_int("print_speed"),
|
||||
"infillSpeed": self.get_int("infill_speed") if self.get_int("infill_speed") > 0 else self.get_int("print_speed"),
|
||||
"inset0Speed": self.get_int("outer_shell_speed") if self.get_int("outer_shell_speed") > 0 else self.get_int("print_speed"),
|
||||
"insetXSpeed": self.get_int("inner_shell_speed") if self.get_int("inner_shell_speed") > 0 else self.get_int("print_speed"),
|
||||
"skinSpeed": self.get_int("solidarea_speed") if self.get_int("solidarea_speed") > 0 > 0 else self.get_int("print_speed"),
|
||||
"moveSpeed": self.get_int("travel_speed"),
|
||||
"fanSpeedMin": self.get_int("fan_speed") if self.get_boolean("fan_enabled") else 0,
|
||||
"fanSpeedMax": self.get_int("fan_speed_max") if self.get_boolean("fan_enabled") else 0,
|
||||
@@ -892,22 +904,23 @@ class Profile(object):
|
||||
"retractionAmountExtruderSwitch": self.get_microns("retraction_dual_amount"),
|
||||
"retractionZHop": self.get_microns("retraction_hop"),
|
||||
"minimalExtrusionBeforeRetraction": self.get_microns("retraction_minimal_extrusion"),
|
||||
"enableCombing": 1 if self.get("retraction_combing") == RetractionCombingTypes.ALL else (2 if self.get("retraction_combing") == RetractionCombingTypes.NO_SKIN else 0),
|
||||
"multiVolumeOverlap": self.get_microns("overlap_dual"),
|
||||
"objectSink": max(0, self.get_microns("object_sink")),
|
||||
"minimalLayerTime": self.get_int("cool_min_layer_time"),
|
||||
"minimalFeedrate": self.get_int("cool_min_feedrate"),
|
||||
"coolHeadLift": 1 if self.get_boolean("cool_head_lift") else 0,
|
||||
|
||||
"enableCombing": 1 if self.get("retraction_combing") == RetractionCombingTypes.ALL else (2 if self.get("retraction_combing") == RetractionCombingTypes.NO_SKIN else 0),
|
||||
|
||||
# model positioning
|
||||
"posx": self.get_pos_x() * 1000, # in microns
|
||||
"posy": self.get_pos_y() * 1000, # in microns
|
||||
|
||||
# gcodes
|
||||
"startCode": self.get_gcode("start_gcode"),
|
||||
"endCode": self.get_gcode("end_gcode"),
|
||||
"preSwitchExtruderCode": self.get_gcode("preSwitchExtruder_gcode"),
|
||||
"postSwitchExtruderCode": self.get_gcode("postSwitchExtruder_gcode"),
|
||||
"startCode": self.get_gcode("start_gcode", extruder_count=actual_extruder_count),
|
||||
"endCode": self.get_gcode("end_gcode", extruder_count=actual_extruder_count),
|
||||
"preSwitchExtruderCode": self.get_gcode("preSwitchExtruder_gcode", extruder_count=actual_extruder_count),
|
||||
"postSwitchExtruderCode": self.get_gcode("postSwitchExtruder_gcode", extruder_count=actual_extruder_count),
|
||||
|
||||
# fixing
|
||||
"fixHorrible": 0,
|
||||
@@ -952,12 +965,13 @@ class Profile(object):
|
||||
settings["raftInterfaceThickness"] = self.get_microns("raft_interface_thickness")
|
||||
settings["raftInterfaceLinewidth"] = self.get_microns("raft_interface_linewidth")
|
||||
settings["raftInterfaceLineSpacing"] = self.get_microns("raft_interface_linewidth") * 2
|
||||
settings["raftAirGapLayer0"] = self.get_microns("raft_airgap")
|
||||
settings["raftAirGapLayer0"] = self.get_microns("raft_airgap") + self.get_microns("raft_airgap_all")
|
||||
settings["raftAirGap"] = self.get_microns("raft_airgap_all")
|
||||
settings["raftBaseSpeed"] = self.get_int("bottom_layer_speed")
|
||||
settings["raftFanSpeed"] = 100
|
||||
settings["raftSurfaceThickness"] = settings["raftInterfaceThickness"]
|
||||
settings["raftSurfaceLinewidth"] = int(edge_width * 1000)
|
||||
settings["raftSurfaceLineSpacing"] = int(edge_width * 1000 * 0.9)
|
||||
settings["raftFanSpeed"] = 0
|
||||
settings["raftSurfaceThickness"] = self.get_microns("raft_surface_thickness")
|
||||
settings["raftSurfaceLinewidth"] = self.get_microns("raft_surface_linewidth")
|
||||
settings["raftSurfaceLineSpacing"] = self.get_microns("raft_surface_linewidth")
|
||||
settings["raftSurfaceLayers"] = self.get_int("raft_surface_layers")
|
||||
settings["raftSurfaceSpeed"] = self.get_int("bottom_layer_speed")
|
||||
|
||||
|
||||
@@ -25,11 +25,35 @@ $(function() {
|
||||
self.profileAllowOverwrite = ko.observable(true);
|
||||
self.profileMakeDefault = ko.observable(false);
|
||||
|
||||
// make sure to update form data if any of the metadata changes
|
||||
self.profileName.subscribe(function() { self.copyProfileMetadata(); });
|
||||
self.profileDisplayName.subscribe(function() {
|
||||
if (self.profileDisplayName()) {
|
||||
self.placeholderName(self._sanitize(self.profileDisplayName()).toLowerCase());
|
||||
}
|
||||
self.copyProfileMetadata();
|
||||
});
|
||||
self.profileDescription.subscribe(function() { self.copyProfileMetadata(); });
|
||||
self.profileAllowOverwrite.subscribe(function() { self.copyProfileMetadata(); });
|
||||
self.profileMakeDefault.subscribe(function() { self.copyProfileMetadata(); });
|
||||
|
||||
self.unconfiguredCuraEngine = ko.observable();
|
||||
self.unconfiguredSlicingProfile = ko.observable();
|
||||
|
||||
self.uploadDialog = $("#settings_plugin_cura_import");
|
||||
self.uploadElement = $("#settings-cura-import");
|
||||
self.uploadButton = $("#settings-cura-import-start");
|
||||
self.uploadData = ko.observable(undefined);
|
||||
self.uploadBusy = ko.observable(false);
|
||||
|
||||
self.uploadEnabled = ko.pureComputed(function() {
|
||||
return self.fieldsEnabled();
|
||||
});
|
||||
self.fieldsEnabled = ko.pureComputed(function() {
|
||||
return self.uploadData() && !self.uploadBusy()
|
||||
&& (self.profileName() || self.placeholderName())
|
||||
&& (self.profileDisplayName() || self.placeholderDisplayName())
|
||||
&& (self.profileDescription() || self.placeholderDescription());
|
||||
});
|
||||
|
||||
self.profiles = new ItemListHelper(
|
||||
"plugin_cura_profiles",
|
||||
@@ -66,6 +90,53 @@ $(function() {
|
||||
return name.replace(/[^a-zA-Z0-9\-_\.\(\) ]/g, "").replace(/ /g, "_");
|
||||
};
|
||||
|
||||
self.performUpload = function() {
|
||||
if (self.uploadData()) {
|
||||
self.uploadData().submit();
|
||||
}
|
||||
};
|
||||
|
||||
self.copyProfileMetadata = function(form) {
|
||||
form = form || (self.uploadData() ? self.uploadData().formData : {});
|
||||
|
||||
if (self.profileName() !== undefined) {
|
||||
form["name"] = self.profileName();
|
||||
} else if (self.placeholderName() !== undefined) {
|
||||
form["name"] = self.placeholderName();
|
||||
}
|
||||
|
||||
if (self.profileDisplayName() !== undefined) {
|
||||
form["displayName"] = self.profileDisplayName();
|
||||
} else if (self.placeholderDisplayName() !== undefined) {
|
||||
form["displayName"] = self.placeholderDisplayName();
|
||||
}
|
||||
|
||||
if (self.profileDescription() !== undefined) {
|
||||
form["description"] = self.profileDescription();
|
||||
} else if (self.placeholderDescription() !== undefined) {
|
||||
form["description"] = self.placeholderDescription();
|
||||
}
|
||||
|
||||
if (self.profileMakeDefault()) {
|
||||
form["default"] = true;
|
||||
}
|
||||
|
||||
return form;
|
||||
};
|
||||
|
||||
self.clearUpload = function() {
|
||||
self.uploadData(undefined);
|
||||
self.fileName(undefined);
|
||||
self.placeholderName(undefined);
|
||||
self.placeholderDisplayName(undefined);
|
||||
self.placeholderDescription(undefined);
|
||||
self.profileName(undefined);
|
||||
self.profileDisplayName(undefined);
|
||||
self.profileDescription(undefined);
|
||||
self.profileAllowOverwrite(true);
|
||||
self.profileMakeDefault(false);
|
||||
};
|
||||
|
||||
self.uploadElement.fileupload({
|
||||
dataType: "json",
|
||||
maxNumberOfFiles: 1,
|
||||
@@ -73,6 +144,11 @@ $(function() {
|
||||
headers: OctoPrint.getRequestHeaders(),
|
||||
add: function(e, data) {
|
||||
if (data.files.length == 0) {
|
||||
// no files? ignore
|
||||
return false;
|
||||
}
|
||||
if (self.uploadData()) {
|
||||
// data already defined? ignore (should never happen)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,41 +159,22 @@ $(function() {
|
||||
self.placeholderDisplayName(name);
|
||||
self.placeholderDescription("Imported from " + self.fileName() + " on " + formatDate(new Date().getTime() / 1000));
|
||||
|
||||
self.uploadButton.unbind("click");
|
||||
self.uploadButton.on("click", function() {
|
||||
var form = {
|
||||
allowOverwrite: self.profileAllowOverwrite()
|
||||
};
|
||||
var form = {
|
||||
allowOverwrite: self.profileAllowOverwrite()
|
||||
};
|
||||
data.formData = self.copyProfileMetadata(form);
|
||||
|
||||
if (self.profileName() !== undefined) {
|
||||
form["name"] = self.profileName();
|
||||
}
|
||||
if (self.profileDisplayName() !== undefined) {
|
||||
form["displayName"] = self.profileDisplayName();
|
||||
}
|
||||
if (self.profileDescription() !== undefined) {
|
||||
form["description"] = self.profileDescription();
|
||||
}
|
||||
if (self.profileMakeDefault()) {
|
||||
form["default"] = true;
|
||||
}
|
||||
|
||||
data.formData = form;
|
||||
data.submit();
|
||||
});
|
||||
self.uploadData(data);
|
||||
},
|
||||
submit: function(e, data) {
|
||||
self.copyProfileMetadata();
|
||||
self.uploadBusy(true);
|
||||
},
|
||||
done: function(e, data) {
|
||||
self.fileName(undefined);
|
||||
self.placeholderName(undefined);
|
||||
self.placeholderDisplayName(undefined);
|
||||
self.placeholderDescription(undefined);
|
||||
self.profileName(undefined);
|
||||
self.profileDisplayName(undefined);
|
||||
self.profileDescription(undefined);
|
||||
self.profileAllowOverwrite(true);
|
||||
self.profileMakeDefault(false);
|
||||
self.uploadBusy(false);
|
||||
self.clearUpload();
|
||||
|
||||
$("#settings_plugin_cura_import").modal("hide");
|
||||
self.uploadDialog.modal("hide");
|
||||
self.requestData();
|
||||
self.slicingViewModel.requestData();
|
||||
}
|
||||
@@ -160,12 +217,9 @@ $(function() {
|
||||
});
|
||||
};
|
||||
|
||||
self.showImportProfileDialog = function(makeDefault) {
|
||||
if (makeDefault == undefined) {
|
||||
makeDefault = _.filter(self.profiles.items(), function(profile) { profile.isdefault() }).length == 0;
|
||||
}
|
||||
self.profileMakeDefault(makeDefault);
|
||||
$("#settings_plugin_cura_import").modal("show");
|
||||
self.showImportProfileDialog = function() {
|
||||
self.clearUpload();
|
||||
self.uploadDialog.modal("show");
|
||||
};
|
||||
|
||||
self.testEnginePath = function() {
|
||||
@@ -207,7 +261,18 @@ $(function() {
|
||||
|
||||
self.onBeforeBinding = function () {
|
||||
self.settings = self.settingsViewModel.settings;
|
||||
//self.requestData();
|
||||
};
|
||||
|
||||
self.onAllBound = function() {
|
||||
self.uploadDialog.on("hidden", function(event) {
|
||||
if (event.target.id == "settings_plugin_cura_import") {
|
||||
self.clearUpload();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.onSettingsShown = function() {
|
||||
self.requestData();
|
||||
};
|
||||
|
||||
self.onSettingsHidden = function() {
|
||||
|
||||
@@ -20,31 +20,31 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Identifier') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: profileName, attr: {placeholder: placeholderName}">
|
||||
<input type="text" class="input-block-level" data-bind="value: profileName, attr: {placeholder: placeholderName}, enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Name') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: profileDisplayName, attr: {placeholder: placeholderDisplayName}">
|
||||
<input type="text" class="input-block-level" data-bind="value: profileDisplayName, valueUpdate: 'afterkeydown', attr: {placeholder: placeholderDisplayName}, enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Description') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: profileDescription, attr: {placeholder: placeholderDescription}">
|
||||
<input type="text" class="input-block-level" data-bind="value: profileDescription, attr: {placeholder: placeholderDescription}, enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<label class="checkbox" data-bind="enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
<input type="checkbox" data-bind="checked: profileMakeDefault"> {{ _('Make default profile') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<label class="checkbox" data-bind="enable: fieldsEnabled, css: {disabled: !fieldsEnabled()}">
|
||||
<input type="checkbox" data-bind="checked: profileAllowOverwrite"> {{ _('Overwrite existing file') }}
|
||||
</label>
|
||||
</div>
|
||||
@@ -59,6 +59,6 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Abort') }}</button>
|
||||
<button class="btn btn-primary" id="settings-cura-import-start">{{ _('Confirm') }}</button>
|
||||
<button class="btn btn-primary" data-bind="click: performUpload, enable: uploadEnabled, css: {disabled: !uploadEnabled()}" id="settings-cura-import-start"><i class="fa fa-spinner fa-spin" data-bind="visible: uploadBusy"></i> {{ _('Confirm') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -12,10 +12,10 @@
|
||||
</thead>
|
||||
<tbody data-bind="foreach: profiles.paginatedItems">
|
||||
<tr data-bind="attr: {title: description}">
|
||||
<td class="settings_plugin_cura_profiles_key"><span class="icon-star" data-bind="invisible: !isdefault()"></span> <span data-bind="text: key"></span></td>
|
||||
<td class="settings_plugin_cura_profiles_key"><span class="fa fa-star" data-bind="invisible: !isdefault()"></span> <span data-bind="text: key"></span></td>
|
||||
<td class="settings_plugin_cura_profiles_name" data-bind="text: name"></td>
|
||||
<td class="settings_plugin_cura_profiles_actions">
|
||||
<a href="#" class="icon-star" title="{{ _('Make default') }}" data-bind="enable: !isdefault(), css: {disabled: isdefault()}, click: function() { if (!$data.isdefault()) { $root.makeProfileDefault($data); } }"></a> | <a href="#" class="icon-trash" title="{{ _('Delete Profile') }}" data-bind="enable: !isdefault(), css: {disabled: isdefault()}, click: function() { if (!$data.isdefault()) { $root.removeProfile($data); } }"></a>
|
||||
<a href="#" class="fa fa-star" title="{{ _('Make default') }}" data-bind="enable: !isdefault(), css: {disabled: isdefault()}, click: function() { if (!$data.isdefault()) { $root.makeProfileDefault($data); } }"></a> | <a href="#" class="fa fa-trash-o" title="{{ _('Delete Profile') }}" data-bind="enable: !isdefault(), css: {disabled: isdefault()}, click: function() { if (!$data.isdefault()) { $root.removeProfile($data); } }"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -12,6 +12,7 @@ The SSDP/UPNP implementations has been largely inspired by https://gist.github.c
|
||||
import logging
|
||||
import os
|
||||
import flask
|
||||
from flask.ext.babel import gettext
|
||||
from builtins import range
|
||||
|
||||
import octoprint.plugin
|
||||
@@ -25,8 +26,10 @@ except:
|
||||
|
||||
__plugin_name__ = "Discovery"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_url__ = "https://github.com/foosel/OctoPrint/wiki/Plugin:-Discovery"
|
||||
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/discovery.html"
|
||||
__plugin_description__ = "Makes the OctoPrint instance discoverable via Bonjour/Avahi/Zeroconf and uPnP"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin your OctoPrint instance will no longer be "
|
||||
"discoverable on the network via Bonjour and uPnP.")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
|
||||
def __plugin_load__():
|
||||
|
||||
@@ -5,6 +5,7 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from past.builtins import basestring
|
||||
|
||||
import octoprint.plugin
|
||||
import octoprint.plugin.core
|
||||
@@ -13,9 +14,11 @@ from octoprint.settings import valid_boolean_trues
|
||||
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
|
||||
from octoprint.server import admin_permission, VERSION
|
||||
from octoprint.util.pip import LocalPipCaller, UnknownPip
|
||||
from octoprint.util.version import parse_version, version_matches_any_spec
|
||||
|
||||
from flask import jsonify, make_response
|
||||
from flask.ext.babel import gettext
|
||||
from collections import OrderedDict
|
||||
|
||||
import logging
|
||||
import sarge
|
||||
@@ -24,6 +27,10 @@ import requests
|
||||
import re
|
||||
import os
|
||||
import pkg_resources
|
||||
import copy
|
||||
import dateutil.parser
|
||||
import time
|
||||
import threading
|
||||
|
||||
class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
@@ -34,7 +41,14 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
ARCHIVE_EXTENSIONS = (".zip", ".tar.gz", ".tgz", ".tar")
|
||||
|
||||
pip_inapplicable_arguments = dict(uninstall=["--user"])
|
||||
OPERATING_SYSTEMS = dict(windows=["win32"],
|
||||
linux=lambda x: x.startswith("linux"),
|
||||
macos=["darwin"],
|
||||
freebsd=lambda x: x.startswith("freebsd"))
|
||||
|
||||
PIP_INAPPLICABLE_ARGUMENTS = dict(uninstall=["--user"])
|
||||
|
||||
RECONNECT_HOOKS = ["octoprint.comm.protocol.*",]
|
||||
|
||||
def __init__(self):
|
||||
self._pending_enable = set()
|
||||
@@ -49,12 +63,19 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._repository_cache_path = None
|
||||
self._repository_cache_ttl = 0
|
||||
|
||||
self._notices = dict()
|
||||
self._notices_available = False
|
||||
self._notices_cache_path = None
|
||||
self._notices_cache_ttl = 0
|
||||
|
||||
self._console_logger = None
|
||||
|
||||
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._pip_caller = LocalPipCaller(force_user=self._settings.get_boolean(["pip_force_user"]))
|
||||
self._pip_caller.on_log_call = self._log_call
|
||||
@@ -69,7 +90,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
##~~ StartupPlugin
|
||||
|
||||
def on_startup(self, host, port):
|
||||
def on_after_startup(self):
|
||||
from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
|
||||
console_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="console"), when="D", backupCount=3)
|
||||
console_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
|
||||
@@ -79,7 +100,14 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._console_logger.setLevel(logging.DEBUG)
|
||||
self._console_logger.propagate = False
|
||||
|
||||
self._repository_available = self._fetch_repository_from_disk()
|
||||
# decouple repository fetching from server startup
|
||||
def fetch_data():
|
||||
self._repository_available = self._fetch_repository_from_disk()
|
||||
self._notices_available = self._fetch_notices_from_disk()
|
||||
|
||||
thread = threading.Thread(target=fetch_data)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
##~~ SettingsPlugin
|
||||
|
||||
@@ -87,6 +115,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return dict(
|
||||
repository="http://plugins.octoprint.org/plugins.json",
|
||||
repository_ttl=24*60,
|
||||
notices="http://plugins.octoprint.org/notices.json",
|
||||
notices_ttl=6*60,
|
||||
pip_args=None,
|
||||
pip_force_user=False,
|
||||
dependency_links=False,
|
||||
@@ -97,6 +127,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
||||
|
||||
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"])
|
||||
|
||||
##~~ AssetPlugin
|
||||
@@ -188,6 +219,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
if refresh_repository:
|
||||
self._repository_available = self._refresh_repository()
|
||||
|
||||
refresh_notices = request.values.get("refresh_notices", "false") in valid_boolean_trues
|
||||
if refresh_notices:
|
||||
self._notices_available = self._refresh_notices()
|
||||
|
||||
def view():
|
||||
return jsonify(plugins=self._get_plugins(),
|
||||
repository=dict(
|
||||
@@ -213,6 +248,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
hash.update(repr(self._get_plugins()))
|
||||
hash.update(str(self._repository_available))
|
||||
hash.update(repr(self._repository_plugins))
|
||||
hash.update(str(self._notices_available))
|
||||
hash.update(repr(self._notices))
|
||||
hash.update(repr(safe_mode))
|
||||
return hash.hexdigest()
|
||||
|
||||
@@ -221,7 +258,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)(view)()
|
||||
unless=lambda: refresh_repository or refresh_notices)(view)()
|
||||
|
||||
def on_api_command(self, command, data):
|
||||
if not admin_permission.can():
|
||||
@@ -236,7 +273,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
plugin_name = data["plugin"] if "plugin" in data else None
|
||||
return self.command_install(url=url,
|
||||
force="force" in data and data["force"] in valid_boolean_trues,
|
||||
dependency_links="dependency_links" in data and data["dependency_links"] in valid_boolean_trues,
|
||||
dependency_links="dependency_links" in data
|
||||
and data["dependency_links"] in valid_boolean_trues,
|
||||
reinstall=plugin_name)
|
||||
|
||||
elif command == "uninstall":
|
||||
@@ -257,37 +295,84 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
def command_install(self, url=None, path=None, force=False, reinstall=None, dependency_links=False):
|
||||
if url is not None:
|
||||
pip_args = ["install", sarge.shell_quote(url)]
|
||||
source = url
|
||||
source_type = "url"
|
||||
already_installed_check = lambda line: url in line
|
||||
|
||||
elif path is not None:
|
||||
pip_args = ["install", sarge.shell_quote(path)]
|
||||
path = os.path.abspath(path)
|
||||
path_url = "file://" + path
|
||||
if os.sep != "/":
|
||||
# windows gets special handling
|
||||
path = path.replace(os.sep, "/").lower()
|
||||
path_url = "file:///" + path
|
||||
|
||||
source = path
|
||||
source_type = "path"
|
||||
already_installed_check = lambda line: path_url in line.lower() # lower case in case of windows
|
||||
|
||||
else:
|
||||
raise ValueError("Either URL or path must be provided")
|
||||
|
||||
self._logger.info("Installing plugin from {}".format(source))
|
||||
pip_args = ["install", sarge.shell_quote(source)]
|
||||
|
||||
if dependency_links or self._settings.get_boolean(["dependency_links"]):
|
||||
pip_args.append("--process-dependency-links")
|
||||
|
||||
all_plugins_before = self._plugin_manager.find_plugins()
|
||||
all_plugins_before = self._plugin_manager.find_plugins(existing=dict())
|
||||
|
||||
already_installed_string = "Requirement already satisfied (use --upgrade to upgrade)"
|
||||
success_string = "Successfully installed"
|
||||
failure_string = "Could not install"
|
||||
|
||||
try:
|
||||
returncode, stdout, stderr = self._call_pip(pip_args)
|
||||
|
||||
# pip's output for a package that is already installed looks something like any of these:
|
||||
#
|
||||
# Requirement already satisfied (use --upgrade to upgrade): OctoPrint-Plugin==1.0 from \
|
||||
# https://example.com/foobar.zip in <lib>
|
||||
# Requirement already satisfied (use --upgrade to upgrade): OctoPrint-Plugin in <lib>
|
||||
# Requirement already satisfied (use --upgrade to upgrade): OctoPrint-Plugin==1.0 from \
|
||||
# file:///tmp/foobar.zip in <lib>
|
||||
# Requirement already satisfied (use --upgrade to upgrade): OctoPrint-Plugin==1.0 from \
|
||||
# file:///C:/Temp/foobar.zip in <lib>
|
||||
#
|
||||
# If we detect any of these matching what we just tried to install, we'll need to trigger a second
|
||||
# install with reinstall flags.
|
||||
|
||||
if not force and any(map(lambda x: x.strip().startswith(already_installed_string) and already_installed_check(x),
|
||||
stdout)):
|
||||
self._logger.info("Plugin to be installed from {} was already installed, forcing a reinstall".format(source))
|
||||
self._log_message("Looks like the plugin was already installed. Forcing a reinstall.")
|
||||
force = True
|
||||
except:
|
||||
self._logger.exception("Could not install plugin from %s" % url)
|
||||
return make_response("Could not install plugin from URL, see the log for more details", 500)
|
||||
else:
|
||||
if force:
|
||||
# We don't use --upgrade here because that will also happily update all our dependencies - we'd rather
|
||||
# do that in a controlled manner
|
||||
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]
|
||||
try:
|
||||
returncode, stdout, stderr = self._call_pip(pip_args)
|
||||
except:
|
||||
self._logger.exception("Could not install plugin from %s" % url)
|
||||
return make_response("Could not install plugin from URL, see the log for more details", 500)
|
||||
self._logger.exception("Could not install plugin from {}".format(source))
|
||||
return make_response("Could not install plugin from source {}, see the log for more details"
|
||||
.format(source), 500)
|
||||
|
||||
try:
|
||||
result_line = filter(lambda x: x.startswith(success_string) or x.startswith(failure_string), stdout)[-1]
|
||||
result_line = filter(lambda x: x.startswith(success_string) or x.startswith(failure_string),
|
||||
stdout)[-1]
|
||||
except IndexError:
|
||||
result = dict(result=False, reason="Could not parse output from pip")
|
||||
self._logger.error("Installing the plugin from {} failed, could not parse output from pip. "
|
||||
"See plugin_pluginmanager_console.log for generated output".format(source))
|
||||
result = dict(result=False,
|
||||
source=source,
|
||||
source_type=source_type,
|
||||
reason="Could not parse output from pip, see plugin_pluginmanager_console.log "
|
||||
"for generated output")
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
@@ -300,8 +385,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
# Successfully installed OctoPrint-Plugin Dependency-One Dependency-Two
|
||||
# Cleaning up...
|
||||
#
|
||||
# So we'll need to fetch the "Successfully installed" line, strip the "Successfully" part, then split by whitespace
|
||||
# and strip to get all installed packages.
|
||||
# So we'll need to fetch the "Successfully installed" line, strip the "Successfully" part, then split
|
||||
# by whitespace and strip to get all installed packages.
|
||||
#
|
||||
# We then need to iterate over all known plugins and see if either the package name or the package name plus
|
||||
# version number matches one of our installed packages. If it does, that's our installed plugin.
|
||||
@@ -313,58 +398,57 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
result_line = result_line.strip()
|
||||
if not result_line.startswith(success_string):
|
||||
result = dict(result=False, reason="Pip did not report successful installation")
|
||||
self._logger.error("Installing the plugin from {} failed, pip did not report successful installation"
|
||||
.format(source))
|
||||
result = dict(result=False,
|
||||
source=source,
|
||||
source_type=source_type,
|
||||
reason="Pip did not report successful installation")
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
installed = map(lambda x: x.strip(), result_line[len(success_string):].split(" "))
|
||||
all_plugins_after = self._plugin_manager.find_plugins(existing=dict(), ignore_uninstalled=False)
|
||||
|
||||
for key, plugin in all_plugins_after.items():
|
||||
if plugin.origin is None or plugin.origin.type != "entry_point":
|
||||
continue
|
||||
|
||||
package_name = plugin.origin.package_name
|
||||
package_version = plugin.origin.package_version
|
||||
versioned_package = "{package_name}-{package_version}".format(**locals())
|
||||
|
||||
if package_name in installed or versioned_package in installed:
|
||||
# exact match, we are done here
|
||||
new_plugin_key = key
|
||||
new_plugin = plugin
|
||||
break
|
||||
|
||||
else:
|
||||
# it might still be a version that got stripped by python's package resources, e.g. 1.4.5a0 => 1.4.5a
|
||||
found = False
|
||||
|
||||
for inst in installed:
|
||||
if inst.startswith(versioned_package):
|
||||
found = True
|
||||
break
|
||||
|
||||
if found:
|
||||
new_plugin_key = key
|
||||
new_plugin = plugin
|
||||
break
|
||||
else:
|
||||
self._logger.warn("The plugin was installed successfully, but couldn't be found afterwards to initialize properly during runtime. Please restart OctoPrint.")
|
||||
result = dict(result=True, url=url, needs_restart=True, needs_refresh=True, was_reinstalled=False, plugin="unknown")
|
||||
new_plugin = self._find_installed_plugin(installed, plugins=all_plugins_after)
|
||||
if new_plugin is None:
|
||||
self._logger.warn("The plugin was installed successfully, but couldn't be found afterwards to "
|
||||
"initialize properly during runtime. Please restart OctoPrint.")
|
||||
result = dict(result=True,
|
||||
source=source,
|
||||
source_type=source_type,
|
||||
needs_restart=True,
|
||||
needs_refresh=True,
|
||||
needs_reconnect=True,
|
||||
was_reinstalled=False,
|
||||
plugin="unknown")
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
self._plugin_manager.reload_plugins()
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(new_plugin) or new_plugin_key in all_plugins_before or reinstall is not None
|
||||
needs_refresh = new_plugin.implementation and isinstance(new_plugin.implementation, octoprint.plugin.ReloadNeedingPlugin)
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(new_plugin) \
|
||||
or new_plugin.key in all_plugins_before \
|
||||
or reinstall is not None
|
||||
needs_refresh = new_plugin.implementation \
|
||||
and isinstance(new_plugin.implementation, octoprint.plugin.ReloadNeedingPlugin)
|
||||
needs_reconnect = self._plugin_manager.has_any_of_hooks(new_plugin, self._reconnect_hooks) and self._printer.is_operational()
|
||||
|
||||
is_reinstall = self._plugin_manager.is_plugin_marked(new_plugin_key, "uninstalled")
|
||||
self._plugin_manager.mark_plugin(new_plugin_key,
|
||||
is_reinstall = self._plugin_manager.is_plugin_marked(new_plugin.key, "uninstalled")
|
||||
self._plugin_manager.mark_plugin(new_plugin.key,
|
||||
uninstalled=False,
|
||||
installed=not is_reinstall and needs_restart)
|
||||
|
||||
self._plugin_manager.log_all_plugins()
|
||||
|
||||
result = dict(result=True, url=url, needs_restart=needs_restart, needs_refresh=needs_refresh, was_reinstalled=new_plugin_key in all_plugins_before or reinstall is not None, plugin=self._to_external_representation(new_plugin))
|
||||
self._logger.info("The plugin was installed successfully: {}, version {}".format(new_plugin.name, new_plugin.version))
|
||||
result = dict(result=True,
|
||||
source=source,
|
||||
source_type=source_type,
|
||||
needs_restart=needs_restart,
|
||||
needs_refresh=needs_refresh,
|
||||
needs_reconnect=needs_reconnect,
|
||||
was_reinstalled=new_plugin.key in all_plugins_before or reinstall is not None,
|
||||
plugin=self._to_external_plugin(new_plugin))
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
@@ -419,6 +503,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin)
|
||||
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()
|
||||
|
||||
was_pending_install = self._plugin_manager.is_plugin_marked(plugin.key, "installed")
|
||||
self._plugin_manager.mark_plugin(plugin.key,
|
||||
@@ -444,7 +529,11 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
self._plugin_manager.reload_plugins()
|
||||
|
||||
result = dict(result=True, needs_restart=needs_restart, needs_refresh=needs_refresh, plugin=self._to_external_representation(plugin))
|
||||
result = dict(result=True,
|
||||
needs_restart=needs_restart,
|
||||
needs_refresh=needs_refresh,
|
||||
needs_reconnect=needs_reconnect,
|
||||
plugin=self._to_external_plugin(plugin))
|
||||
self._send_result_notification("uninstall", result)
|
||||
return jsonify(result)
|
||||
|
||||
@@ -454,11 +543,13 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin)
|
||||
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()
|
||||
|
||||
pending = ((command == "disable" and plugin.key in self._pending_enable) or (command == "enable" and plugin.key in self._pending_disable))
|
||||
safe_mode_victim = getattr(plugin, "safe_mode_victim", False)
|
||||
needs_restart_api = (needs_restart or safe_mode_victim) and not pending
|
||||
needs_refresh_api = needs_refresh and not pending
|
||||
needs_reconnect_api = needs_reconnect and not pending
|
||||
|
||||
try:
|
||||
if command == "disable":
|
||||
@@ -469,13 +560,51 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._logger.exception(u"Problem toggling enabled state of {name}: {reason}".format(name=plugin.key, reason=e.reason))
|
||||
result = dict(result=False, reason=e.reason)
|
||||
except octoprint.plugin.core.PluginNeedsRestart:
|
||||
result = dict(result=True, needs_restart=True, needs_refresh=True, plugin=self._to_external_representation(plugin))
|
||||
result = dict(result=True,
|
||||
needs_restart=True,
|
||||
needs_refresh=True,
|
||||
needs_reconnect=True,
|
||||
plugin=self._to_external_plugin(plugin))
|
||||
else:
|
||||
result = dict(result=True, needs_restart=needs_restart_api, needs_refresh=needs_refresh_api, plugin=self._to_external_representation(plugin))
|
||||
result = dict(result=True,
|
||||
needs_restart=needs_restart_api,
|
||||
needs_refresh=needs_refresh_api,
|
||||
needs_reconnect=needs_reconnect_api,
|
||||
plugin=self._to_external_plugin(plugin))
|
||||
|
||||
self._send_result_notification(command, result)
|
||||
return jsonify(result)
|
||||
|
||||
def _find_installed_plugin(self, packages, plugins=None):
|
||||
if plugins is None:
|
||||
plugins = self._plugin_manager.find_plugins(existing=dict(), ignore_uninstalled=False)
|
||||
|
||||
for key, plugin in plugins.items():
|
||||
if plugin.origin is None or plugin.origin.type != "entry_point":
|
||||
continue
|
||||
|
||||
package_name = plugin.origin.package_name
|
||||
package_version = plugin.origin.package_version
|
||||
versioned_package = "{package_name}-{package_version}".format(**locals())
|
||||
|
||||
if package_name in packages or versioned_package in packages:
|
||||
# exact match, we are done here
|
||||
return plugin
|
||||
|
||||
else:
|
||||
# it might still be a version that got stripped by python's package resources, e.g. 1.4.5a0 => 1.4.5a
|
||||
found = False
|
||||
|
||||
for inst in packages:
|
||||
if inst.startswith(versioned_package):
|
||||
found = True
|
||||
break
|
||||
|
||||
if found:
|
||||
return plugin
|
||||
|
||||
return None
|
||||
|
||||
def _send_result_notification(self, action, result):
|
||||
notification = dict(type="result", action=action)
|
||||
notification.update(result)
|
||||
@@ -492,7 +621,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
if additional_args is not None:
|
||||
|
||||
inapplicable_arguments = self.__class__.pip_inapplicable_arguments.get(args[0], list())
|
||||
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)
|
||||
|
||||
@@ -568,10 +697,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return self._refresh_repository(repo_data=repo_data)
|
||||
|
||||
def _fetch_repository_from_url(self):
|
||||
import requests
|
||||
repository_url = self._settings.get(["repository"])
|
||||
try:
|
||||
r = requests.get(repository_url)
|
||||
r = requests.get(repository_url, timeout=30)
|
||||
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)))
|
||||
@@ -595,10 +724,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return False
|
||||
|
||||
current_os = self._get_os()
|
||||
octoprint_version = self._get_octoprint_version(base=True)
|
||||
parsed_octoprint_version = self._get_octoprint_version()
|
||||
|
||||
def map_repository_entry(entry):
|
||||
result = dict(entry)
|
||||
result = copy.deepcopy(entry)
|
||||
|
||||
if not "follow_dependency_links" in result:
|
||||
result["follow_dependency_links"] = False
|
||||
@@ -609,10 +738,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
)
|
||||
|
||||
if "compatibility" in entry:
|
||||
if "octoprint" in entry["compatibility"] and entry["compatibility"]["octoprint"] is not None and len(entry["compatibility"]["octoprint"]):
|
||||
result["is_compatible"]["octoprint"] = self._is_octoprint_compatible(octoprint_version, entry["compatibility"]["octoprint"])
|
||||
if "octoprint" in entry["compatibility"] and entry["compatibility"]["octoprint"] is not None and isinstance(entry["compatibility"]["octoprint"], (list, tuple)) and len(entry["compatibility"]["octoprint"]):
|
||||
result["is_compatible"]["octoprint"] = self._is_octoprint_compatible(parsed_octoprint_version, entry["compatibility"]["octoprint"])
|
||||
|
||||
if "os" in entry["compatibility"] and entry["compatibility"]["os"] is not None and len(entry["compatibility"]["os"]):
|
||||
if "os" in entry["compatibility"] and entry["compatibility"]["os"] is not None and isinstance(entry["compatibility"]["os"], (list, tuple)) and len(entry["compatibility"]["os"]):
|
||||
result["is_compatible"]["os"] = self._is_os_compatible(current_os, entry["compatibility"]["os"])
|
||||
|
||||
return result
|
||||
@@ -620,81 +749,160 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._repository_plugins = map(map_repository_entry, repo_data)
|
||||
return True
|
||||
|
||||
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:
|
||||
try:
|
||||
import json
|
||||
with open(self._notices_cache_path) as f:
|
||||
notice_data = json.load(f)
|
||||
self._logger.info("Loaded notices from disk, was still valid")
|
||||
except:
|
||||
self._logger.exception("Error while loading notices from {}".format(self._notices_cache_path))
|
||||
|
||||
return self._refresh_notices(notice_data=notice_data)
|
||||
|
||||
def _fetch_notices_from_url(self):
|
||||
notices_url = self._settings.get(["notices"])
|
||||
try:
|
||||
r = requests.get(notices_url, timeout=30)
|
||||
r.raise_for_status()
|
||||
self._logger.info("Loaded plugin notices data from {}".format(notices_url))
|
||||
except Exception as e:
|
||||
self._logger.exception("Could not fetch notices from {notices_url}: {message}".format(notices_url=notices_url, message=str(e)))
|
||||
return None
|
||||
|
||||
notice_data = r.json()
|
||||
|
||||
try:
|
||||
import json
|
||||
with octoprint.util.atomic_write(self._notices_cache_path, "wb") as f:
|
||||
json.dump(notice_data, f)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while saving notices to {}: {}".format(self._notices_cache_path, str(e)))
|
||||
return notice_data
|
||||
|
||||
def _refresh_notices(self, notice_data=None):
|
||||
if notice_data is None:
|
||||
notice_data = self._fetch_notices_from_url()
|
||||
if notice_data is None:
|
||||
return False
|
||||
|
||||
notices = dict()
|
||||
for notice in notice_data:
|
||||
if not "plugin" in notice or not "text" in notice or not "date" in notice:
|
||||
continue
|
||||
|
||||
key = notice["plugin"]
|
||||
|
||||
try:
|
||||
parsed_date = dateutil.parser.parse(notice["date"])
|
||||
notice["timestamp"] = parsed_date.timetuple()
|
||||
except Exception as e:
|
||||
self._logger.warn("Error while parsing date {!r} for plugin notice "
|
||||
"of plugin {}, ignoring notice: {}".format(notice["date"], key, str(e)))
|
||||
continue
|
||||
|
||||
if not key in notices:
|
||||
notices[key] = []
|
||||
notices[key].append(notice)
|
||||
|
||||
self._notices = notices
|
||||
return True
|
||||
|
||||
def _is_octoprint_compatible(self, octoprint_version, compatibility_entries):
|
||||
"""
|
||||
Tests if the current ``octoprint_version`` is compatible to any of the provided ``compatibility_entries``.
|
||||
"""
|
||||
|
||||
for octo_compat in compatibility_entries:
|
||||
if not any(octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")):
|
||||
octo_compat = ">={}".format(octo_compat)
|
||||
spec_matcher = ("<", "<=", "!=", "==", ">=", ">", "~=", "===")
|
||||
specs = map(lambda x: x if any(x.startswith(c) for c in spec_matcher) else ">={}".format(x),
|
||||
compatibility_entries)
|
||||
|
||||
s = next(pkg_resources.parse_requirements("OctoPrint" + octo_compat))
|
||||
if octoprint_version in s:
|
||||
break
|
||||
else:
|
||||
return False
|
||||
try:
|
||||
return version_matches_any_spec(octoprint_version, specs, package="OctoPrint", base=True)
|
||||
except:
|
||||
self._logger.exception("Something is wrong with these compatibility specs: {!r}".format(specs))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def _is_os_compatible(self, current_os, compatibility_entries):
|
||||
@staticmethod
|
||||
def _is_os_compatible(current_os, compatibility_entries):
|
||||
"""
|
||||
Tests if the ``current_os`` matches any of the provided ``compatibility_entries``.
|
||||
Tests if the ``current_os`` or ``sys.platform`` are blacklisted or whitelisted in ``compatibility_entries``
|
||||
"""
|
||||
return current_os in compatibility_entries
|
||||
if len(compatibility_entries) == 0:
|
||||
# shortcut - no compatibility info means we are compatible
|
||||
return True
|
||||
|
||||
def _get_os(self):
|
||||
if sys.platform == "win32":
|
||||
return "windows"
|
||||
elif sys.platform == "linux2":
|
||||
return "linux"
|
||||
elif sys.platform == "darwin":
|
||||
return "macos"
|
||||
negative_entries = map(lambda x: x[1:], filter(lambda x: x.startswith("!"), compatibility_entries))
|
||||
positive_entries = filter(lambda x: not x.startswith("!"), compatibility_entries)
|
||||
|
||||
negative_match = False
|
||||
if negative_entries:
|
||||
# check if we are blacklisted
|
||||
negative_match = current_os in negative_entries or any(map(lambda x: sys.platform.startswith(x), negative_entries))
|
||||
|
||||
positive_match = True
|
||||
if positive_entries:
|
||||
# check if we are whitelisted
|
||||
positive_match = current_os in positive_entries or any(map(lambda x: sys.platform.startswith(x), positive_entries))
|
||||
|
||||
return positive_match and not negative_match
|
||||
|
||||
@classmethod
|
||||
def _get_os(cls):
|
||||
for identifier, platforms in cls.OPERATING_SYSTEMS.items():
|
||||
if (callable(platforms) and platforms(sys.platform)) or (isinstance(platforms, list) and sys.platform in platforms):
|
||||
return identifier
|
||||
else:
|
||||
return "unknown"
|
||||
return "unmapped"
|
||||
|
||||
def _get_octoprint_version_string(self):
|
||||
return VERSION
|
||||
|
||||
def _get_octoprint_version(self, base=False):
|
||||
octoprint_version_string = self._get_octoprint_version_string()
|
||||
|
||||
if "-" in octoprint_version_string:
|
||||
octoprint_version_string = octoprint_version_string[:octoprint_version_string.find("-")]
|
||||
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version_string)
|
||||
if base:
|
||||
if isinstance(octoprint_version, tuple):
|
||||
# old setuptools
|
||||
base_version = []
|
||||
for part in octoprint_version:
|
||||
if part.startswith("*"):
|
||||
break
|
||||
base_version.append(part)
|
||||
base_version.append("*final")
|
||||
octoprint_version = tuple(base_version)
|
||||
else:
|
||||
# new setuptools
|
||||
octoprint_version = pkg_resources.parse_version(octoprint_version.base_version)
|
||||
@staticmethod
|
||||
def _get_octoprint_version_string():
|
||||
from octoprint import __version__ as octoprint_version
|
||||
return octoprint_version
|
||||
|
||||
@staticmethod
|
||||
def _get_octoprint_version(base=False):
|
||||
return parse_version(PluginManagerPlugin._get_octoprint_version_string(), base=base)
|
||||
|
||||
@property
|
||||
def _reconnect_hooks(self):
|
||||
reconnect_hooks = self.__class__.RECONNECT_HOOKS
|
||||
|
||||
reconnect_hook_provider_hooks = self._plugin_manager.get_hooks("octoprint.plugin.pluginmanager.reconnect_hooks")
|
||||
for name, hook in reconnect_hook_provider_hooks.items():
|
||||
try:
|
||||
result = hook()
|
||||
if isinstance(result, (list, tuple)):
|
||||
reconnect_hooks.extend(filter(lambda x: isinstance(x, basestring), result))
|
||||
except:
|
||||
self._logger.exception("Error while retrieving additional hooks for which a "
|
||||
"reconnect is required from plugin {name}".format(**locals()))
|
||||
|
||||
return reconnect_hooks
|
||||
|
||||
def _get_plugins(self):
|
||||
plugins = self._plugin_manager.plugins
|
||||
|
||||
hidden = self._settings.get(["hidden"])
|
||||
result = []
|
||||
for name, plugin in plugins.items():
|
||||
if name in hidden:
|
||||
for key, plugin in plugins.items():
|
||||
if key in hidden:
|
||||
continue
|
||||
result.append(self._to_external_representation(plugin))
|
||||
result.append(self._to_external_plugin(plugin))
|
||||
|
||||
return result
|
||||
|
||||
def _to_external_representation(self, plugin):
|
||||
def _to_external_plugin(self, plugin):
|
||||
return dict(
|
||||
key=plugin.key,
|
||||
name=plugin.name,
|
||||
description=plugin.description,
|
||||
disabling_discouraged=gettext(plugin.disabling_discouraged) if plugin.disabling_discouraged else False,
|
||||
author=plugin.author,
|
||||
version=plugin.version,
|
||||
url=plugin.url,
|
||||
@@ -708,12 +916,45 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
pending_disable=((plugin.enabled or getattr(plugin, "safe_mode_enabled", False)) and plugin.key in self._pending_disable),
|
||||
pending_install=(self._plugin_manager.is_plugin_marked(plugin.key, "installed")),
|
||||
pending_uninstall=(self._plugin_manager.is_plugin_marked(plugin.key, "uninstalled")),
|
||||
origin=plugin.origin.type
|
||||
origin=plugin.origin.type,
|
||||
notifications = self._get_notifications(plugin)
|
||||
)
|
||||
|
||||
def _get_notifications(self, plugin):
|
||||
key = plugin.key
|
||||
if not plugin.enabled:
|
||||
return
|
||||
|
||||
if key not in self._notices:
|
||||
return
|
||||
|
||||
octoprint_version = self._get_octoprint_version(base=True)
|
||||
plugin_notifications = self._notices.get(key, [])
|
||||
|
||||
def filter_relevant(notification):
|
||||
return "text" in notification and "date" in notification and \
|
||||
("versions" not in notification or plugin.version in notification["versions"]) and \
|
||||
("octoversions" not in notification or self._is_octoprint_compatible(octoprint_version, notification["octoversions"]))
|
||||
|
||||
def map_notification(notification):
|
||||
return self._to_external_notification(key, notification)
|
||||
|
||||
return filter(lambda x: x is not None,
|
||||
map(map_notification,
|
||||
filter(filter_relevant,
|
||||
plugin_notifications)))
|
||||
|
||||
def _to_external_notification(self, key, notification):
|
||||
return dict(key=key,
|
||||
date=time.mktime(notification["timestamp"]),
|
||||
text=notification["text"],
|
||||
link=notification.get("link"),
|
||||
versions=notification.get("versions", []),
|
||||
important=notification.get("important", False))
|
||||
|
||||
__plugin_name__ = "Plugin Manager"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_url__ = "https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager"
|
||||
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html"
|
||||
__plugin_description__ = "Allows installing and managing OctoPrint plugins"
|
||||
__plugin_license__ = "AGPLv3"
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
table th.settings_plugin_plugin_manager_plugins_name,table td.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table th.settings_plugin_plugin_manager_plugins_actions,table td.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table th.settings_plugin_plugin_manager_plugins_actions a,table td.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table th.settings_plugin_plugin_manager_plugins_actions a.disabled,table td.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog .slimScrollDiv{margin-bottom:20px}#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;padding-right:10px;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_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_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{overflow:hidden;width:auto;height:300px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px;padding-right:10px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:bold}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
|
||||
table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog .slimScrollDiv{margin-bottom:20px}#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_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_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{overflow:hidden;width:auto;height:300px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px 10px 5px 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}
|
||||
@@ -1,68 +1,84 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrint"], factory);
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(window.OctoPrint);
|
||||
factory(global.OctoPrintClient);
|
||||
}
|
||||
})(window || this, function(OctoPrint) {
|
||||
var exports = {};
|
||||
|
||||
exports.get = function(refresh, opts) {
|
||||
return OctoPrint.get(OctoPrint.getSimpleApiUrl("pluginmanager") + ((refresh) ? "?refresh_repository=true" : ""), opts);
|
||||
})(this, function(OctoPrintClient) {
|
||||
var OctoPrintPluginManagerClient = function(base) {
|
||||
this.base = base;
|
||||
};
|
||||
|
||||
exports.getWithRefresh = function(opts) {
|
||||
return exports.get(true, opts);
|
||||
OctoPrintPluginManagerClient.prototype.get = function(refresh, opts) {
|
||||
var refresh_repo, refresh_notices;
|
||||
if (_.isPlainObject(refresh)) {
|
||||
refresh_repo = refresh.repo || false;
|
||||
refresh_notices = refresh.notices || false;
|
||||
} else {
|
||||
refresh_repo = refresh;
|
||||
refresh_notices = false;
|
||||
}
|
||||
|
||||
var query = [];
|
||||
if (refresh_repo) query.push("refresh_repository=true");
|
||||
if (refresh_notices) query.push("refresh_notices=true");
|
||||
|
||||
return this.base.get(this.base.getSimpleApiUrl("pluginmanager") + ((query.length) ? "?" + query.join("&") : ""), opts);
|
||||
};
|
||||
|
||||
exports.getWithoutRefresh = function(opts) {
|
||||
return exports.get(false, opts);
|
||||
OctoPrintPluginManagerClient.prototype.getWithRefresh = function(opts) {
|
||||
return this.get(true, opts);
|
||||
};
|
||||
|
||||
exports.install = function(pluginUrl, dependencyLinks, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.getWithoutRefresh = function(opts) {
|
||||
return this.get(false, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.install = function(pluginUrl, dependencyLinks, opts) {
|
||||
var data = {
|
||||
url: pluginUrl,
|
||||
dependency_links: !!dependencyLinks
|
||||
};
|
||||
return OctoPrint.simpleApiCommand("pluginmanager", "install", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
|
||||
};
|
||||
|
||||
exports.reinstall = function(plugin, pluginUrl, dependencyLinks, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.reinstall = function(plugin, pluginUrl, dependencyLinks, opts) {
|
||||
var data = {
|
||||
url: pluginUrl,
|
||||
dependency_links: !!dependencyLinks,
|
||||
reinstall: plugin,
|
||||
force: true
|
||||
};
|
||||
return OctoPrint.simpleApiCommand("pluginmanager", "install", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
|
||||
};
|
||||
|
||||
exports.uninstall = function(plugin, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
|
||||
var data = {
|
||||
plugin: plugin
|
||||
};
|
||||
return OctoPrint.simpleApiCommand("pluginmanager", "uninstall", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
|
||||
};
|
||||
|
||||
exports.enable = function(plugin, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
|
||||
var data = {
|
||||
plugin: plugin
|
||||
};
|
||||
return OctoPrint.simpleApiCommand("pluginmanager", "enable", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "enable", data, opts);
|
||||
};
|
||||
|
||||
exports.disable = function(plugin, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.disable = function(plugin, opts) {
|
||||
var data = {
|
||||
plugin: plugin
|
||||
};
|
||||
return OctoPrint.simpleApiCommand("pluginmanager", "disable", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "disable", data, opts);
|
||||
};
|
||||
|
||||
exports.upload = function(file) {
|
||||
return OctoPrint.upload(OctoPrint.getBlueprintUrl("pluginmanager") + "upload_archive", file);
|
||||
OctoPrintPluginManagerClient.prototype.upload = function(file) {
|
||||
return this.base.upload(this.base.getBlueprintUrl("pluginmanager") + "upload_archive", file);
|
||||
};
|
||||
|
||||
OctoPrint.plugins.pluginmanager = exports;
|
||||
OctoPrintClient.registerPluginComponent("pluginmanager", OctoPrintPluginManagerClient);
|
||||
return OctoPrintPluginManagerClient;
|
||||
});
|
||||
|
||||
$(function() {
|
||||
@@ -76,6 +92,8 @@ $(function() {
|
||||
|
||||
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();
|
||||
|
||||
@@ -182,6 +200,20 @@ $(function() {
|
||||
});
|
||||
|
||||
self.notifications = [];
|
||||
self.noticeNotifications = [];
|
||||
self.hiddenNoticeNotifications = {};
|
||||
self.noticeCount = ko.observable(0);
|
||||
|
||||
self.noticeCountText = ko.pureComputed(function() {
|
||||
var count = self.noticeCount();
|
||||
if (count == 0) {
|
||||
return gettext("There are no plugin notices. Great!");
|
||||
} else if (count == 1) {
|
||||
return gettext("There is a plugin notice for one of your installed plugins.");
|
||||
} else {
|
||||
return _.sprintf(gettext("There are %(count)d plugin notices for one or more of your installed plugins."), {count: count});
|
||||
}
|
||||
});
|
||||
|
||||
self.enableManagement = ko.pureComputed(function() {
|
||||
return !self.printerState.isPrinting();
|
||||
@@ -247,7 +279,13 @@ $(function() {
|
||||
});
|
||||
},
|
||||
done: function(e, data) {
|
||||
self._markDone();
|
||||
var response = data.result;
|
||||
if (response.result) {
|
||||
self._markDone();
|
||||
} else {
|
||||
self._markDone(response.reason);
|
||||
}
|
||||
|
||||
self.uploadButton.unbind("click");
|
||||
self.uploadFilename(undefined);
|
||||
},
|
||||
@@ -258,7 +296,7 @@ $(function() {
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
self._markDone();
|
||||
self._markDone("Could not install plugin, unknown error.");
|
||||
self.uploadButton.unbind("click");
|
||||
self.uploadFilename(undefined);
|
||||
}
|
||||
@@ -277,19 +315,36 @@ $(function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
self.fromResponse = function(data) {
|
||||
self._fromPluginsResponse(data.plugins);
|
||||
self._fromRepositoryResponse(data.repository);
|
||||
self._fromPipResponse(data.pip);
|
||||
self.fromResponse = function(data, options) {
|
||||
self._fromPluginsResponse(data.plugins, options);
|
||||
self._fromRepositoryResponse(data.repository, options);
|
||||
self._fromPipResponse(data.pip, options);
|
||||
|
||||
self.safeMode(data.safe_mode || false);
|
||||
};
|
||||
|
||||
self._fromPluginsResponse = function(data) {
|
||||
self._fromPluginsResponse = function(data, options) {
|
||||
var evalNotices = options.eval_notices || false;
|
||||
var ignoreNoticeHidden = options.ignore_notice_hidden || false;
|
||||
var ignoreNoticeIgnored = options.ignore_notice_ignored || false;
|
||||
|
||||
if (evalNotices) self._removeAllNoticeNotifications();
|
||||
|
||||
var installedPlugins = [];
|
||||
var noticeCount = 0;
|
||||
_.each(data, function(plugin) {
|
||||
installedPlugins.push(plugin.key);
|
||||
|
||||
if (evalNotices && plugin.notifications && plugin.notifications.length) {
|
||||
_.each(plugin.notifications, function(notification) {
|
||||
noticeCount++;
|
||||
if (!ignoreNoticeIgnored && self._isNoticeNotificationIgnored(plugin.key, notification.date)) return;
|
||||
if (!ignoreNoticeHidden && self._isNoticeNotificationHidden(plugin.key, notification.date)) return;
|
||||
self._showPluginNotification(plugin, notification);
|
||||
});
|
||||
}
|
||||
});
|
||||
if (evalNotices) self.noticeCount(noticeCount);
|
||||
self.installedPlugins(installedPlugins);
|
||||
self.plugins.updateItems(data);
|
||||
};
|
||||
@@ -321,13 +376,28 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.requestData = function(includeRepo) {
|
||||
self.requestData = function(options) {
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
OctoPrint.plugins.pluginmanager.get(includeRepo)
|
||||
.done(self.fromResponse);
|
||||
if (!_.isPlainObject(options)) {
|
||||
options = {
|
||||
refresh_repo: options,
|
||||
refresh_notices: false,
|
||||
eval_notices: false
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
options.refresh_repo = options.refresh_repo || 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})
|
||||
.done(function(data) {
|
||||
self.fromResponse(data, options);
|
||||
});
|
||||
};
|
||||
|
||||
self.togglePlugin = function(data) {
|
||||
@@ -341,7 +411,9 @@ $(function() {
|
||||
|
||||
if (data.key == "pluginmanager") return;
|
||||
|
||||
var onSuccess = self.requestData,
|
||||
var onSuccess = function() {
|
||||
self.requestData();
|
||||
},
|
||||
onError = function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
@@ -357,9 +429,26 @@ $(function() {
|
||||
.done(onSuccess)
|
||||
.fail(onError);
|
||||
} else {
|
||||
OctoPrint.plugins.pluginmanager.disable(data.key)
|
||||
.done(onSuccess)
|
||||
.fail(onError);
|
||||
var perform = function() {
|
||||
OctoPrint.plugins.pluginmanager.disable(data.key)
|
||||
.done(onSuccess)
|
||||
.fail(onError);
|
||||
};
|
||||
|
||||
if (data.disabling_discouraged) {
|
||||
var message = _.sprintf(gettext("You are about to disable \"%(name)s\"."), {name: data.name})
|
||||
+ "</p><p>" + data.disabling_discouraged;
|
||||
showConfirmationDialog({
|
||||
title: gettext("This is not recommended"),
|
||||
message: message,
|
||||
question: gettext("Do you still want to disable it?"),
|
||||
cancel: gettext("Keep enabled"),
|
||||
proceed: gettext("Disable anyway"),
|
||||
onproceed: perform
|
||||
})
|
||||
} else {
|
||||
perform();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -415,32 +504,33 @@ $(function() {
|
||||
}
|
||||
self._markWorking(workTitle, workText);
|
||||
|
||||
var onSuccess = function() {
|
||||
var onSuccess = function(response) {
|
||||
if (response.result) {
|
||||
self._markDone();
|
||||
} else {
|
||||
self._markDone(response.reason)
|
||||
}
|
||||
self.requestData();
|
||||
self.installUrl("");
|
||||
},
|
||||
onError = function() {
|
||||
self._markDone("Could not install plugin, unknown error, please consult octoprint.log for details");
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
},
|
||||
onAlways = function() {
|
||||
self._markDone();
|
||||
};
|
||||
|
||||
if (reinstall) {
|
||||
OctoPrint.plugins.pluginmanager.reinstall(reinstall, url, followDependencyLinks)
|
||||
.done(onSuccess)
|
||||
.fail(onError)
|
||||
.always(onAlways);
|
||||
.fail(onError);
|
||||
} else {
|
||||
OctoPrint.plugins.pluginmanager.install(url, followDependencyLinks)
|
||||
.done(onSuccess)
|
||||
.fail(onError)
|
||||
.always(onAlways);
|
||||
.fail(onError);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -459,7 +549,9 @@ $(function() {
|
||||
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name}));
|
||||
|
||||
OctoPrint.plugins.pluginmanager.uninstall(data.key)
|
||||
.done(self.requestData)
|
||||
.done(function() {
|
||||
self.requestData();
|
||||
})
|
||||
.fail(function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
@@ -477,8 +569,23 @@ $(function() {
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
self.requestData({refresh_repo: true});
|
||||
};
|
||||
|
||||
self.requestData(true);
|
||||
self.refreshNotices = function() {
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.requestData({refresh_notices: true, eval_notices: true, ignore_notice_hidden: true, ignore_notice_ignored: true});
|
||||
};
|
||||
|
||||
self.reshowNotices = function() {
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.requestData({eval_notices: true, ignore_notice_hidden: true, ignore_notice_ignored: true});
|
||||
};
|
||||
|
||||
self.showPluginSettings = function() {
|
||||
@@ -499,6 +606,18 @@ $(function() {
|
||||
repositoryTtl = null;
|
||||
}
|
||||
|
||||
var notices = self.config_noticesUrl();
|
||||
if (notices != undefined && notices.trim() == "") {
|
||||
notices = null;
|
||||
}
|
||||
|
||||
var noticesTtl;
|
||||
try {
|
||||
noticesTtl = parseInt(self.config_noticesTtl());
|
||||
} catch (ex) {
|
||||
noticesTtl = null;
|
||||
}
|
||||
|
||||
var pipArgs = self.config_pipAdditionalArgs();
|
||||
if (pipArgs != undefined && pipArgs.trim() == "") {
|
||||
pipArgs = null;
|
||||
@@ -509,6 +628,8 @@ $(function() {
|
||||
pluginmanager: {
|
||||
repository: repository,
|
||||
repository_ttl: repositoryTtl,
|
||||
notices: notices,
|
||||
notices_ttl: noticesTtl,
|
||||
pip_args: pipArgs,
|
||||
pip_force_user: self.config_pipForceUser()
|
||||
}
|
||||
@@ -517,13 +638,15 @@ $(function() {
|
||||
self.settingsViewModel.saveData(data, function() {
|
||||
self.configurationDialog.modal("hide");
|
||||
self._copyConfig();
|
||||
self.refreshRepository();
|
||||
self.requestData({refresh_repo: true, refresh_notices: true, eval_notices: true});
|
||||
});
|
||||
};
|
||||
|
||||
self._copyConfig = function() {
|
||||
self.config_repositoryUrl(self.settingsViewModel.settings.plugins.pluginmanager.repository());
|
||||
self.config_repositoryTtl(self.settingsViewModel.settings.plugins.pluginmanager.repository_ttl());
|
||||
self.config_noticesUrl(self.settingsViewModel.settings.plugins.pluginmanager.notices());
|
||||
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());
|
||||
};
|
||||
@@ -537,10 +660,10 @@ $(function() {
|
||||
};
|
||||
|
||||
self.installButtonText = function(data) {
|
||||
return self.isCompatible(data) ? (self.installed(data) ? gettext("Reinstall") : gettext("Install")) : gettext("Incompatible");
|
||||
return self.isCompatible(data) ? (self.installed(data) ? gettext("Reinstall") : gettext("Install")) : (data.disabled ? gettext("Disabled") : gettext("Incompatible"));
|
||||
};
|
||||
|
||||
self._displayNotification = function(response, titleSuccess, textSuccess, textRestart, textReload, titleError, textError) {
|
||||
self._displayNotification = function(response, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError) {
|
||||
var notification;
|
||||
|
||||
var beforeClose = function(notification) {
|
||||
@@ -562,17 +685,21 @@ $(function() {
|
||||
hide: false
|
||||
};
|
||||
|
||||
var restartClicked = false;
|
||||
if (self.restartCommandSpec) {
|
||||
options.confirm = {
|
||||
confirm: true,
|
||||
buttons: [{
|
||||
text: gettext("Restart now"),
|
||||
click: function () {
|
||||
click: function (notice) {
|
||||
if (restartClicked) return;
|
||||
restartClicked = true;
|
||||
showConfirmationDialog({
|
||||
message: gettext("This will restart your OctoPrint server."),
|
||||
onproceed: function() {
|
||||
OctoPrint.system.executeCommand("core", "restart")
|
||||
.done(function() {
|
||||
notice.remove();
|
||||
new PNotify({
|
||||
title: gettext("Restart in progress"),
|
||||
text: gettext("The server is now being restarted in the background")
|
||||
@@ -584,6 +711,9 @@ $(function() {
|
||||
text: gettext("Trying to restart the server produced an error, please check octoprint.log for details. You'll have to restart manually.")
|
||||
})
|
||||
});
|
||||
},
|
||||
onclose: function() {
|
||||
restartClicked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -593,6 +723,7 @@ $(function() {
|
||||
|
||||
notification = PNotify.singleButtonNotify(options);
|
||||
} else if (response.needs_refresh) {
|
||||
var refreshClicked = false;
|
||||
notification = PNotify.singleButtonNotify({
|
||||
title: titleSuccess,
|
||||
text: textReload,
|
||||
@@ -601,6 +732,8 @@ $(function() {
|
||||
buttons: [{
|
||||
text: gettext("Reload now"),
|
||||
click: function () {
|
||||
if (refreshClicked) return;
|
||||
refreshClicked = true;
|
||||
location.reload(true);
|
||||
}
|
||||
}]
|
||||
@@ -614,6 +747,15 @@ $(function() {
|
||||
},
|
||||
hide: false
|
||||
})
|
||||
} else if (response.needs_reconnect) {
|
||||
notification = new PNotify({
|
||||
title: titleSuccess,
|
||||
text: textReconnect,
|
||||
callbacks: {
|
||||
before_close: beforeClose
|
||||
},
|
||||
hide: false
|
||||
})
|
||||
} else {
|
||||
notification = new PNotify({
|
||||
title: titleSuccess,
|
||||
@@ -651,9 +793,14 @@ $(function() {
|
||||
self.workingDialog.modal({keyboard: false, backdrop: "static", show: true});
|
||||
};
|
||||
|
||||
self._markDone = function() {
|
||||
self._markDone = function(error) {
|
||||
self.working(false);
|
||||
self.loglines.push({line: gettext("Done!"), stream: "message"});
|
||||
if (error) {
|
||||
self.loglines.push({line: gettext("Error!"), stream: "error"});
|
||||
self.loglines.push({line: error, stream: "error"})
|
||||
} else {
|
||||
self.loglines.push({line: gettext("Done!"), stream: "message"});
|
||||
}
|
||||
self._scrollWorkingOutputToEnd();
|
||||
};
|
||||
|
||||
@@ -667,7 +814,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.toggleButtonCss = function(data) {
|
||||
var icon = self._getToggleCommand(data) == "enable" ? "icon-circle-blank" : "icon-circle";
|
||||
var icon = self._getToggleCommand(data) == "enable" ? "fa fa-circle-o" : "fa fa-circle";
|
||||
var disabled = (self.enableToggle(data)) ? "" : " disabled";
|
||||
|
||||
return icon + disabled;
|
||||
@@ -686,13 +833,184 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self.showPluginNotifications = function(plugin) {
|
||||
if (!plugin.notifications || plugin.notifications.length == 0) return;
|
||||
|
||||
self._removeAllNoticeNotificationsForPlugin(plugin.key);
|
||||
_.each(plugin.notifications, function(notification) {
|
||||
self._showPluginNotification(plugin, notification);
|
||||
});
|
||||
};
|
||||
|
||||
self.showPluginNotificationsLinkText = function(plugins) {
|
||||
if (!plugins.notifications || plugins.notifications.length == 0) return;
|
||||
|
||||
var count = plugins.notifications.length;
|
||||
var importantCount = _.filter(plugins.notifications, function(notification) { return notification.important }).length;
|
||||
if (count > 1) {
|
||||
if (importantCount) {
|
||||
return _.sprintf(gettext("There are %(count)d notices (%(important)d marked as important) available regarding this plugin - click to show!"), {count: count, important: importantCount});
|
||||
} else {
|
||||
return _.sprintf(gettext("There are %(count)d notices available regarding this plugin - click to show!"), {count: count});
|
||||
}
|
||||
} else {
|
||||
if (importantCount) {
|
||||
return gettext("There is an important notice available regarding this plugin - click to show!");
|
||||
} else {
|
||||
return gettext("There is a notice available regarding this plugin - click to show!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self._showPluginNotification = function(plugin, notification) {
|
||||
var name = plugin.name;
|
||||
var version = plugin.version;
|
||||
|
||||
var important = notification.important;
|
||||
var link = notification.link;
|
||||
|
||||
var title;
|
||||
if (important) {
|
||||
title = _.sprintf(gettext("Important notice regarding plugin \"%(name)s\""), {name: name});
|
||||
} else {
|
||||
title = _.sprintf(gettext("Notice regarding plugin \"%(name)s\""), {name: 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>";
|
||||
} else {
|
||||
text += "<small>" + gettext("Affected versions: all") + "</small>";
|
||||
}
|
||||
|
||||
text += "<p>" + notification.text + "</p>";
|
||||
if (link) {
|
||||
text += "<p><a href='" + link + "' target='_blank'>" + gettext("Read more...") + "</a></p>";
|
||||
}
|
||||
|
||||
var beforeClose = function(notification) {
|
||||
if (!self.noticeNotifications[plugin.key]) return;
|
||||
self.noticeNotifications[plugin.key] = _.without(self.noticeNotifications[plugin.key], notification);
|
||||
};
|
||||
|
||||
var options = {
|
||||
title: title,
|
||||
text: text,
|
||||
type: (important) ? "error" : "notice",
|
||||
before_close: beforeClose,
|
||||
hide: false,
|
||||
confirm: {
|
||||
confirm: true,
|
||||
buttons: [{
|
||||
text: gettext("Later"),
|
||||
click: function(notice) {
|
||||
self._hideNoticeNotification(plugin.key, notification.date);
|
||||
notice.remove();
|
||||
notice.get().trigger("pnotify.cancel", notice);
|
||||
}
|
||||
}, {
|
||||
text: gettext("Mark read"),
|
||||
click: function(notice) {
|
||||
self._ignoreNoticeNotification(plugin.key, notification.date);
|
||||
notice.remove();
|
||||
notice.get().trigger("pnotify.cancel", notice);
|
||||
}
|
||||
}]
|
||||
},
|
||||
buttons: {
|
||||
sticker: false,
|
||||
closer: false
|
||||
}
|
||||
};
|
||||
|
||||
if (!self.noticeNotifications[plugin.key]) {
|
||||
self.noticeNotifications[plugin.key] = [];
|
||||
}
|
||||
self.noticeNotifications[plugin.key].push(new PNotify(options));
|
||||
};
|
||||
|
||||
self._removeAllNoticeNotifications = function() {
|
||||
_.each(_.keys(self.noticeNotifications), function(key) {
|
||||
self._removeAllNoticeNotificationsForPlugin(key);
|
||||
});
|
||||
};
|
||||
|
||||
self._removeAllNoticeNotificationsForPlugin = function(key) {
|
||||
if (!self.noticeNotifications[key] || !self.noticeNotifications[key].length) return;
|
||||
_.each(self.noticeNotifications[key], function(notification) {
|
||||
notification.remove();
|
||||
});
|
||||
};
|
||||
|
||||
self._hideNoticeNotification = function(key, date) {
|
||||
if (!self.hiddenNoticeNotifications[key]) {
|
||||
self.hiddenNoticeNotifications[key] = [];
|
||||
}
|
||||
if (!_.contains(self.hiddenNoticeNotifications[key], date)) {
|
||||
self.hiddenNoticeNotifications[key].push(date);
|
||||
}
|
||||
};
|
||||
|
||||
self._isNoticeNotificationHidden = function(key, date) {
|
||||
if (!self.hiddenNoticeNotifications[key]) return false;
|
||||
return _.any(_.map(self.hiddenNoticeNotifications[key], function(d) { return date == d; }));
|
||||
};
|
||||
|
||||
var noticeLocalStorageKey = "plugin.pluginmanager.seen_notices";
|
||||
self._ignoreNoticeNotification = function(key, date) {
|
||||
if (!Modernizr.localstorage)
|
||||
return false;
|
||||
if (!self.loginState.isAdmin())
|
||||
return false;
|
||||
|
||||
var currentString = localStorage[noticeLocalStorageKey];
|
||||
var current;
|
||||
if (currentString === undefined) {
|
||||
current = {};
|
||||
} else {
|
||||
current = JSON.parse(currentString);
|
||||
}
|
||||
if (!current[self.loginState.username()]) {
|
||||
current[self.loginState.username()] = {};
|
||||
}
|
||||
if (!current[self.loginState.username()][key]) {
|
||||
current[self.loginState.username()][key] = [];
|
||||
}
|
||||
|
||||
if (!_.contains(current[self.loginState.username()][key], date)) {
|
||||
current[self.loginState.username()][key].push(date);
|
||||
localStorage[noticeLocalStorageKey] = JSON.stringify(current);
|
||||
}
|
||||
};
|
||||
|
||||
self._isNoticeNotificationIgnored = function(key, date) {
|
||||
if (!Modernizr.localstorage)
|
||||
return false;
|
||||
|
||||
if (localStorage[noticeLocalStorageKey] == undefined)
|
||||
return false;
|
||||
|
||||
var knownData = JSON.parse(localStorage[noticeLocalStorageKey]);
|
||||
|
||||
if (!self.loginState.isAdmin())
|
||||
return true;
|
||||
|
||||
var userData = knownData[self.loginState.username()];
|
||||
if (userData === undefined)
|
||||
return false;
|
||||
|
||||
return userData[key] && _.contains(userData[key], date);
|
||||
};
|
||||
|
||||
self.onBeforeBinding = function() {
|
||||
self.settings = self.settingsViewModel.settings;
|
||||
};
|
||||
|
||||
self.onUserLoggedIn = function(user) {
|
||||
if (user.admin) {
|
||||
self.requestData();
|
||||
self.requestData({eval_notices: true});
|
||||
} else {
|
||||
self.onUserLoggedOut();
|
||||
}
|
||||
@@ -751,7 +1069,7 @@ $(function() {
|
||||
});
|
||||
self._scrollWorkingOutputToEnd();
|
||||
} else if (messageType == "result") {
|
||||
var titleSuccess, textSuccess, textRestart, textReload, titleError, textError;
|
||||
var titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError;
|
||||
var action = data.action;
|
||||
|
||||
var name = "Unknown";
|
||||
@@ -771,35 +1089,58 @@ $(function() {
|
||||
textSuccess = gettext("A plugin was installed successfully, however it was impossible to detect which one. Please Restart OctoPrint to make sure everything will be registered properly");
|
||||
textRestart = textSuccess;
|
||||
textReload = textSuccess;
|
||||
textReconnect = textSuccess;
|
||||
} else if (data.was_reinstalled) {
|
||||
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" reinstalled"), {name: name});
|
||||
textSuccess = gettext("The plugin was reinstalled successfully");
|
||||
textRestart = gettext("The plugin was reinstalled successfully, however a restart of OctoPrint is needed for that to take effect.");
|
||||
textReload = gettext("The plugin was reinstalled successfully, however a reload of the page is needed for that to take effect.");
|
||||
textReconnect = gettext("The plugin was reinstalled successfully, however a reconnect to the printer is needed for that to take effect.");
|
||||
} else {
|
||||
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" installed"), {name: name});
|
||||
textSuccess = gettext("The plugin was installed successfully");
|
||||
textRestart = gettext("The plugin was installed successfully, however a restart of OctoPrint is needed for that to take effect.");
|
||||
textReload = gettext("The plugin was installed successfully, however a reload of the page is needed for that to take effect.");
|
||||
textReconnect = gettext("The plugin was installed successfully, however a reconnect to the printer is needed for that to take effect.");
|
||||
}
|
||||
|
||||
titleError = gettext("Something went wrong");
|
||||
var url = "unknown";
|
||||
if (data.hasOwnProperty("url")) {
|
||||
url = data.url;
|
||||
var source = "unknown";
|
||||
if (data.hasOwnProperty("source")) {
|
||||
source = data.source;
|
||||
}
|
||||
var sourceType = "unknown";
|
||||
if (data.hasOwnProperty("source_type")) {
|
||||
sourceType = data.source_type;
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty("reason")) {
|
||||
if (data.was_reinstalled) {
|
||||
textError = _.sprintf(gettext("Reinstalling the plugin from URL \"%(url)s\" failed: %(reason)s"), {reason: data.reason, url: url});
|
||||
if (sourceType == "path") {
|
||||
textError = _.sprintf(gettext("Reinstalling the plugin from file failed: %(reason)s"), {reason: data.reason});
|
||||
} else {
|
||||
textError = _.sprintf(gettext("Reinstalling the plugin from \"%(source)s\" failed: %(reason)s"), {reason: data.reason, source: source});
|
||||
}
|
||||
} else {
|
||||
textError = _.sprintf(gettext("Installing the plugin from URL \"%(url)s\" failed: %(reason)s"), {reason: data.reason, url: url});
|
||||
if (sourceType == "path") {
|
||||
textError = _.sprintf(gettext("Installing the plugin from file failed: %(reason)s"), {reason: data.reason});
|
||||
} else {
|
||||
textError = _.sprintf(gettext("Installing the plugin from \"%(source)s\" failed: %(reason)s"), {reason: data.reason, source: source});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (data.was_reinstalled) {
|
||||
textError = _.sprintf(gettext("Reinstalling the plugin from URL \"%(url)s\" failed, please see the log for details."), {url: url});
|
||||
if (sourceType == "path") {
|
||||
textError = gettext("Reinstalling the plugin from file failed, please see the log for details.");
|
||||
} else {
|
||||
textError = _.sprintf(gettext("Reinstalling the plugin from \"%(source)s\" failed, please see the log for details."), {source: source});
|
||||
}
|
||||
} else {
|
||||
textError = _.sprintf(gettext("Installing the plugin from URL \"%(url)s\" failed, please see the log for details."), {url: url});
|
||||
if (sourceType == "path") {
|
||||
textError = gettext("Installing the plugin from file failed, please see the log for details.");
|
||||
} else {
|
||||
textError = _.sprintf(gettext("Installing the plugin from \"%(source)s\" failed, please see the log for details."), {source: source});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -812,6 +1153,7 @@ $(function() {
|
||||
textSuccess = gettext("The plugin was uninstalled successfully");
|
||||
textRestart = gettext("The plugin was uninstalled successfully, however a restart of OctoPrint is needed for that to take effect.");
|
||||
textReload = gettext("The plugin was uninstalled successfully, however a reload of the page is needed for that to take effect.");
|
||||
textReconnect = gettext("The plugin was uninstalled successfully, however a reconnect to the printer is needed for that to take effect.");
|
||||
|
||||
titleError = gettext("Something went wrong");
|
||||
if (data.hasOwnProperty("reason")) {
|
||||
@@ -829,6 +1171,7 @@ $(function() {
|
||||
textSuccess = gettext("The plugin was enabled successfully.");
|
||||
textRestart = gettext("The plugin was enabled successfully, however a restart of OctoPrint is needed for that to take effect.");
|
||||
textReload = gettext("The plugin was enabled successfully, however a reload of the page is needed for that to take effect.");
|
||||
textReconnect = gettext("The plugin was enabled successfully, however a reconnect to the printer is needed for that to take effect.");
|
||||
|
||||
titleError = gettext("Something went wrong");
|
||||
if (data.hasOwnProperty("reason")) {
|
||||
@@ -846,6 +1189,7 @@ $(function() {
|
||||
textSuccess = gettext("The plugin was disabled successfully.");
|
||||
textRestart = gettext("The plugin was disabled successfully, however a restart of OctoPrint is needed for that to take effect.");
|
||||
textReload = gettext("The plugin was disabled successfully, however a reload of the page is needed for that to take effect.");
|
||||
textReconnect = gettext("The plugin was disabled successfully, however a reconnect to the printer is needed for that to take effect.");
|
||||
|
||||
titleError = gettext("Something went wrong");
|
||||
if (data.hasOwnProperty("reason")) {
|
||||
@@ -858,7 +1202,7 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
self._displayNotification(data, titleSuccess, textSuccess, textRestart, textReload, titleError, textError);
|
||||
self._displayNotification(data, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError);
|
||||
self.requestData();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -89,6 +89,11 @@ table {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.error {
|
||||
font-weight: bold;
|
||||
color: #990000;
|
||||
}
|
||||
|
||||
.stdout {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
{{ pluginmanager_safemode() }}
|
||||
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="icon-wrench"></i></button>
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Installed Plugins') }}</h3>
|
||||
@@ -40,17 +40,18 @@
|
||||
<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="icon-th-large" data-bind="visible: bundled"></i> <i class="icon-lock" title="{{ _('Cannot be uninstalled through OctoPrint') }}" data-bind="visible: !managable"></i> <i title="{{ _('Restart of OctoPrint needed for changes to take effect') }}" class="icon-refresh" data-bind="visible: pending_enable || pending_disable || pending_install || pending_uninstall"></i> <i title="{{ _('Pending install') }}" class="icon-plus" data-bind="visible: pending_install"></i> <i title="{{ _('Pending uninstall') }}" class="icon-minus" data-bind="visible: pending_uninstall"></i> <i title="{{ _('Disabled due to safe mode') }}" class="icon-medkit" data-bind="visible: safe_mode_victim"></i></div>
|
||||
<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></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="icon-home"></i> <a data-bind="attr: {href: url}" target="_blank" rel="noreferrer noopener">{{ _('Homepage') }}</a></small>
|
||||
<small data-bind="visible: license"><i class="icon-legal"></i> <span data-bind="text: license"></span></small>
|
||||
<small data-bind="visible: author"><i class="icon-user"></i> <span data-bind="text: author"></span></small>
|
||||
<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="icon-trash" title="{{ _('Uninstall Plugin') }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
|
||||
<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>
|
||||
@@ -72,8 +73,8 @@
|
||||
<div class="muted" data-bind="visible: pipAvailable()">
|
||||
<div>
|
||||
<small>
|
||||
<a href="#" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="toggle-arrow icon-caret-right"></i> Using pip of "<span data-bind="text: pipPython"></span>", Version <span data-bind="text: pipVersion"></span>
|
||||
<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>
|
||||
@@ -86,12 +87,28 @@
|
||||
</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 id="settings_plugin_pluginmanager_workingdialog" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<h3 data-bind="text: workingTitle"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre id="settings_plugin_pluginmanager_workingdialog_output" class="terminal pre-scrollable" style="height: 170px" data-bind="foreach: loglines"><span data-bind="text: line, css: {stdout: stream == 'stdout', stderr: stream == 'stderr', call: stream == 'call', message: stream == 'message'}"></span><br></pre>
|
||||
<pre id="settings_plugin_pluginmanager_workingdialog_output" class="pre-scrollable pre-output" style="height: 170px" data-bind="foreach: loglines"><span data-bind="text: line, css: {stdout: stream == 'stdout', stderr: stream == 'stderr', call: stream == 'call', message: stream == 'message', error: stream == 'error'}"></span></pre>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" data-bind="enable: !$root.working()" aria-hidden="true">{{ _('Close') }}</button>
|
||||
@@ -111,16 +128,16 @@
|
||||
{{ _('... from the <a href="%(url)s" target="_blank">Plugin Repository</a>', url='http://plugins.octoprint.org') }}
|
||||
<div class="dropdown pull-right">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<span class="icon-wrench"></span>
|
||||
<span class="fa fa-wrench"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.changeSorting('title'); }"><i class="icon-ok" data-bind="style: {visibility: repositoryplugins.currentSorting() == 'title' ? 'visible' : 'hidden'}"></i> {{ _('Sort by title') }} ({{ _('ascending') }})</a></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.changeSorting('published'); }"><i class="icon-ok" data-bind="style: {visibility: repositoryplugins.currentSorting() == 'published' ? 'visible' : 'hidden'}"></i> {{ _('Sort by publication date') }} ({{ _('descending') }})</a></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.changeSorting('title'); }"><i class="fa fa-check" data-bind="style: {visibility: repositoryplugins.currentSorting() == 'title' ? 'visible' : 'hidden'}"></i> {{ _('Sort by title') }} ({{ _('ascending') }})</a></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.changeSorting('published'); }"><i class="fa fa-check" data-bind="style: {visibility: repositoryplugins.currentSorting() == 'published' ? 'visible' : 'hidden'}"></i> {{ _('Sort by publication date') }} ({{ _('descending') }})</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.toggleFilter('filter_installed'); }"><i class="icon-ok" data-bind="style: {visibility: _.contains(repositoryplugins.currentFilters(), 'filter_installed') ? 'visible' : 'hidden'}"></i> {{ _('Only show uninstalled plugins') }}</a></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.toggleFilter('filter_incompatible'); }"><i class="icon-ok" data-bind="style: {visibility: _.contains(repositoryplugins.currentFilters(), 'filter_incompatible') ? 'visible' : 'hidden'}"></i> {{ _('Only show compatible plugins') }}</a></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.toggleFilter('filter_installed'); }"><i class="fa fa-check" data-bind="style: {visibility: _.contains(repositoryplugins.currentFilters(), 'filter_installed') ? 'visible' : 'hidden'}"></i> {{ _('Only show uninstalled plugins') }}</a></li>
|
||||
<li><a href="#" data-bind="click: function() { repositoryplugins.toggleFilter('filter_incompatible'); }"><i class="fa fa-check" data-bind="style: {visibility: _.contains(repositoryplugins.currentFilters(), 'filter_incompatible') ? 'visible' : 'hidden'}"></i> {{ _('Only show compatible plugins') }}</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#" data-bind="click: function() { refreshRepository(); }"><i class="icon-refresh"></i> {{ _('Refresh list from repository') }}</a></li>
|
||||
<li><a href="#" data-bind="click: function() { refreshRepository(); }"><i class="fa fa-refresh"></i> {{ _('Refresh list from repository') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</h4>
|
||||
@@ -137,15 +154,16 @@
|
||||
<div><span data-bind="text: title"></span></div>
|
||||
<div><small class="muted" data-bind="text: description"> </small></div>
|
||||
<div>
|
||||
<small data-bind="visible: page"><i class="icon-info"></i> <a data-bind="attr: {href: page}" target="_blank">{{ _('Details') }}</a></small>
|
||||
<small data-bind="visible: homepage"><i class="icon-home"></i> <a data-bind="attr: {href: homepage}" target="_blank">{{ _('Homepage') }}</a></small>
|
||||
<small data-bind="visible: license"><i class="icon-legal"></i> <span data-bind="text: license"></span></small>
|
||||
<small data-bind="visible: author"><i class="icon-user"></i> <span data-bind="text: author"></span></small>
|
||||
<small data-bind="visible: page"><i class="fa fa-info"></i> <a data-bind="attr: {href: page}" target="_blank">{{ _('Details') }}</a></small>
|
||||
<small data-bind="visible: homepage"><i class="fa fa-home"></i> <a data-bind="attr: {href: homepage}" target="_blank">{{ _('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>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<button class="btn btn-primary btn-block" data-bind="enable: $root.enableRepoInstall($data), css: {disabled: !$root.enableRepoInstall($data)}, click: function() { if ($root.enableRepoInstall($data)) { $root.installFromRepository($data); } else { return false; } }"><i class="icon-add"></i> <span data-bind="text: $root.installButtonText($data)"></span></button>
|
||||
<button class="btn btn-primary btn-block" data-bind="enable: $root.enableRepoInstall($data), css: {disabled: !$root.enableRepoInstall($data)}, click: function() { if ($root.enableRepoInstall($data)) { $root.installFromRepository($data); } else { return false; } }"><i class="fa fa-add"></i> <span data-bind="text: $root.installButtonText($data)"></span></button>
|
||||
<div data-bind="visible: $data.disabled !== undefined" style="text-align: center"><small><a data-bind="attr: {href: page}" target="_blank">{{ _('"Why?"') }}</a></small></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -191,7 +209,7 @@
|
||||
</form>
|
||||
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
@@ -237,6 +255,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<legend>{{ _('Notices configuration') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('URL of the Notices source to use. You should normally not have to change this.') }}">
|
||||
<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.') }}">
|
||||
<label class="control-label">{{ _('Notices cache TTL') }}</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-mini" data-bind="value: config_noticesTtl">
|
||||
<span class="add-on">min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<legend>{{ _('pip configuration') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('Additional arguments for the pip command. You should normally not have to change this.') }}">
|
||||
|
||||
@@ -18,10 +18,11 @@ import hashlib
|
||||
|
||||
from . import version_checks, updaters, exceptions, util, cli
|
||||
|
||||
from flask.ext.babel import gettext
|
||||
|
||||
from octoprint.server.util.flask import restricted_access, with_revalidation_checking, check_etag
|
||||
from octoprint.server import admin_permission, VERSION, REVISION, BRANCH
|
||||
from octoprint.util import dict_merge
|
||||
from octoprint.util import dict_merge, to_unicode
|
||||
import octoprint.settings
|
||||
|
||||
|
||||
@@ -34,16 +35,22 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.WizardPlugin):
|
||||
|
||||
COMMIT_TRACKING_TYPES = ("github_commit", "bitbucket_commit")
|
||||
|
||||
def __init__(self):
|
||||
self._update_in_progress = False
|
||||
self._configured_checks_mutex = threading.Lock()
|
||||
self._configured_checks = None
|
||||
self._refresh_configured_checks = False
|
||||
|
||||
self._get_versions_mutex = threading.Lock()
|
||||
|
||||
self._version_cache = dict()
|
||||
self._version_cache_ttl = 0
|
||||
self._version_cache_path = None
|
||||
self._version_cache_dirty = False
|
||||
self._version_cache_timestamp = None
|
||||
|
||||
self._console_logger = None
|
||||
|
||||
@@ -70,24 +77,68 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._console_logger.setLevel(logging.DEBUG)
|
||||
self._console_logger.propagate = False
|
||||
|
||||
def on_after_startup(self):
|
||||
# refresh cache now if necessary so it's faster once the user connects to the instance - but decouple it from
|
||||
# the server startup
|
||||
def fetch_data():
|
||||
self.get_current_versions()
|
||||
|
||||
thread = threading.Thread(target=fetch_data)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def _get_configured_checks(self):
|
||||
with self._configured_checks_mutex:
|
||||
if self._refresh_configured_checks or self._configured_checks is None:
|
||||
self._refresh_configured_checks = False
|
||||
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)
|
||||
effective_configs = dict()
|
||||
|
||||
for name, hook in update_check_hooks.items():
|
||||
try:
|
||||
hook_checks = hook()
|
||||
except:
|
||||
self._logger.exception("Error while retrieving update information from plugin {name}".format(**locals()))
|
||||
else:
|
||||
for key, data in hook_checks.items():
|
||||
for key, default_config in hook_checks.items():
|
||||
if key in effective_configs or key == "octoprint":
|
||||
if key == name:
|
||||
self._logger.warn("Software update hook {} provides check for itself but that was already registered by {} - overwriting that third party registration now!".format(name, check_providers.get(key, "unknown hook")))
|
||||
else:
|
||||
self._logger.warn("Software update hook {} tried to overwrite config for check {} but that was already configured elsewhere".format(name, key))
|
||||
continue
|
||||
|
||||
check_providers[key] = name
|
||||
|
||||
yaml_config = dict()
|
||||
effective_config = default_config
|
||||
if key in self._configured_checks:
|
||||
data = dict_merge(data, self._configured_checks[key])
|
||||
self._configured_checks[key] = data
|
||||
yaml_config = self._configured_checks[key]
|
||||
effective_config = dict_merge(default_config, yaml_config)
|
||||
|
||||
# Make sure there's nothing persisted in that check that shouldn't be persisted
|
||||
#
|
||||
# This used to be part of the settings migration (version 2) due to a bug - it can't
|
||||
# stay there though since it interferes with manual entries to the checks not
|
||||
# originating from within a plugin. Hence we do that step now here.
|
||||
if "type" not in effective_config or effective_config["type"] not in self.COMMIT_TRACKING_TYPES:
|
||||
deletables = ["current", "displayVersion"]
|
||||
else:
|
||||
deletables = []
|
||||
self._clean_settings_check(key, yaml_config, default_config, delete=deletables, save=False)
|
||||
|
||||
if effective_config:
|
||||
effective_configs[key] = effective_config
|
||||
else:
|
||||
self._logger.warn("Update for {} is empty or None, ignoring it".format(key))
|
||||
|
||||
# finally set all our internal representations to our processed results
|
||||
for key, config in effective_configs.items():
|
||||
self._configured_checks[key] = config
|
||||
|
||||
self._settings.set(["check_providers"], check_providers)
|
||||
self._settings.save()
|
||||
|
||||
@@ -112,6 +163,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
try:
|
||||
with open(self._version_cache_path) as f:
|
||||
data = yaml.safe_load(f)
|
||||
timestamp = os.stat(self._version_cache_path).st_mtime
|
||||
except:
|
||||
self._logger.exception("Error while loading version cache from disk")
|
||||
else:
|
||||
@@ -134,6 +186,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
self._version_cache = data
|
||||
self._version_cache_dirty = False
|
||||
self._version_cache_timestamp = timestamp
|
||||
self._logger.info("Loaded version cache from disk")
|
||||
except:
|
||||
self._logger.exception("Error parsing in version cache data")
|
||||
@@ -150,6 +203,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
yaml.safe_dump(self._version_cache, stream=file_obj, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
|
||||
self._version_cache_dirty = False
|
||||
self._version_cache_timestamp = time.time()
|
||||
self._logger.info("Saved version cache to disk")
|
||||
|
||||
#~~ SettingsPlugin API
|
||||
@@ -164,15 +218,21 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
"repo": "OctoPrint",
|
||||
"update_script": "{{python}} \"{update_script}\" --branch={{branch}} --force={{force}} \"{{folder}}\" {{target}}".format(update_script=update_script),
|
||||
"restart": "octoprint",
|
||||
"stable_branch": dict(branch="master", name="Stable"),
|
||||
"prerelease_branches": [dict(branch="rc/maintenance", name="Maintenance RCs"),
|
||||
dict(branch="rc/devel", name="Devel RCs")]
|
||||
"stable_branch": dict(branch="master", commitish=["master"], name="Stable"),
|
||||
"prerelease_branches": [dict(branch="rc/maintenance",
|
||||
commitish=["rc/maintenance"], # maintenance RCs
|
||||
name="Maintenance RCs"),
|
||||
dict(branch="rc/devel",
|
||||
commitish=["rc/maintenance", "rc/devel"], # devel & maintenance RCs
|
||||
name="Devel RCs")]
|
||||
},
|
||||
},
|
||||
"pip_command": None,
|
||||
"check_providers": {},
|
||||
|
||||
"cache_ttl": 24 * 60,
|
||||
|
||||
"notify_users": True
|
||||
}
|
||||
|
||||
def on_settings_load(self):
|
||||
@@ -220,7 +280,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
def on_settings_save(self, data):
|
||||
for key in self.get_settings_defaults():
|
||||
if key in ("checks", "cache_ttl", "octoprint_checkout_folder", "octoprint_type", "octoprint_release_channel"):
|
||||
if key in ("checks", "cache_ttl", "notify_user", "octoprint_checkout_folder", "octoprint_type", "octoprint_release_channel"):
|
||||
continue
|
||||
if key in data:
|
||||
self._settings.set([key], data[key])
|
||||
@@ -229,6 +289,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._settings.set_int(["cache_ttl"], data["cache_ttl"])
|
||||
self._version_cache_ttl = self._settings.get_int(["cache_ttl"]) * 60
|
||||
|
||||
if "notify_users" in data:
|
||||
self._settings.set_boolean(["notify_users"], data["notify_users"])
|
||||
|
||||
checks = self._get_configured_checks()
|
||||
if "octoprint" in checks:
|
||||
check = checks["octoprint"]
|
||||
@@ -287,11 +350,18 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._refresh_configured_checks = True
|
||||
|
||||
def get_settings_version(self):
|
||||
return 4
|
||||
return 5
|
||||
|
||||
def on_settings_migrate(self, target, current=None):
|
||||
|
||||
if current is None or current < 4:
|
||||
if current == 4:
|
||||
# config version 4 didn't correctly remove the old settings for octoprint_restart_command
|
||||
# and environment_restart_command
|
||||
|
||||
self._settings.set(["environment_restart_command"], None)
|
||||
self._settings.set(["octoprint_restart_command"], None)
|
||||
|
||||
if current is None or current < 5:
|
||||
# config version 4 and higher moves octoprint_restart_command and
|
||||
# environment_restart_command to the core configuration
|
||||
|
||||
@@ -315,50 +385,27 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
if current is None or current == 2:
|
||||
# No config version and config version 2 need the same fix, stripping
|
||||
# accidentally persisted data off the checks
|
||||
# accidentally persisted data off the checks.
|
||||
#
|
||||
# We used to do the same processing for the plugin entries too here, but that interfered
|
||||
# with manual configuration entries. Stuff got deleted that wasn't supposed to be deleted.
|
||||
#
|
||||
# The problem is that we don't know if an entry we are looking at and which didn't come through
|
||||
# a plugin hook is simply an entry from a now uninstalled/unactive plugin, or if it was something
|
||||
# manually configured by the user. So instead of just blindly removing anything that doesn't
|
||||
# come from a plugin here we instead clean up anything that indeed comes from a plugin
|
||||
# during run time and leave everything else as is in the hopes that will not cause trouble.
|
||||
#
|
||||
# We still handle the "octoprint" entry here though.
|
||||
|
||||
configured_checks = self._settings.get(["checks"], incl_defaults=False)
|
||||
if configured_checks is None:
|
||||
configured_checks = dict()
|
||||
|
||||
check_keys = configured_checks.keys()
|
||||
|
||||
# take care of the octoprint entry
|
||||
if "octoprint" in configured_checks:
|
||||
if configured_checks is not None and "octoprint" in configured_checks:
|
||||
octoprint_check = dict(configured_checks["octoprint"])
|
||||
if "type" not in octoprint_check or octoprint_check["type"] != "github_commit":
|
||||
if "type" not in octoprint_check or octoprint_check["type"] not in self.COMMIT_TRACKING_TYPES:
|
||||
deletables=["current", "displayName", "displayVersion"]
|
||||
else:
|
||||
deletables=[]
|
||||
octoprint_check = self._clean_settings_check("octoprint", octoprint_check, self.get_settings_defaults()["checks"]["octoprint"], delete=deletables, save=False)
|
||||
check_keys.remove("octoprint")
|
||||
|
||||
# and the hooks
|
||||
update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config")
|
||||
for name, hook in update_check_hooks.items():
|
||||
try:
|
||||
hook_checks = hook()
|
||||
except:
|
||||
self._logger.exception("Error while retrieving update information from plugin {name}".format(**locals()))
|
||||
else:
|
||||
for key, data in hook_checks.items():
|
||||
if key in configured_checks:
|
||||
settings_check = dict(configured_checks[key])
|
||||
merged = dict_merge(data, settings_check)
|
||||
if "type" not in merged or merged["type"] != "github_commit":
|
||||
deletables = ["current", "displayVersion"]
|
||||
else:
|
||||
deletables = []
|
||||
|
||||
self._clean_settings_check(key, settings_check, data, delete=deletables, save=False)
|
||||
check_keys.remove(key)
|
||||
|
||||
# and anything that's left over we'll just remove now
|
||||
for key in check_keys:
|
||||
dummy_defaults = dict(plugins=dict())
|
||||
dummy_defaults["plugins"][self._identifier] = dict(checks=dict())
|
||||
dummy_defaults["plugins"][self._identifier]["checks"][key] = None
|
||||
self._settings.set(["checks", key], None, defaults=dummy_defaults)
|
||||
self._clean_settings_check("octoprint", octoprint_check, self.get_settings_defaults()["checks"]["octoprint"], delete=deletables, save=False)
|
||||
|
||||
elif current == 1:
|
||||
# config version 1 had the error that the octoprint check got accidentally
|
||||
@@ -377,6 +424,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._settings.set(["checks", "octoprint"], None, defaults=dummy_defaults)
|
||||
|
||||
def _clean_settings_check(self, key, data, defaults, delete=None, save=True):
|
||||
if not data:
|
||||
# nothing to do
|
||||
return data
|
||||
|
||||
if delete is None:
|
||||
delete = []
|
||||
|
||||
@@ -416,8 +467,18 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
def view():
|
||||
try:
|
||||
information, update_available, update_possible = self.get_current_versions(check_targets=check_targets, force=force)
|
||||
|
||||
# we don't want to transfer python_checker or python_updater values through json - replace with True
|
||||
for key, data in information.items():
|
||||
if "check" in data:
|
||||
if "python_checker" in data["check"]:
|
||||
data["check"]["python_checker"] = True
|
||||
if "python_updater" in data["check"]:
|
||||
data["check"]["python_updater"] = True
|
||||
|
||||
return flask.jsonify(dict(status="updatePossible" if update_available and update_possible else "updateAvailable" if update_available else "current",
|
||||
information=information))
|
||||
information=information,
|
||||
timestamp=self._version_cache_timestamp))
|
||||
except exceptions.ConfigurationInvalid as e:
|
||||
return flask.make_response("Update not properly configured, can't proceed: %s" % e.message, 500)
|
||||
|
||||
@@ -443,6 +504,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
hash.update(str(data["possible"]))
|
||||
|
||||
hash.update(",".join(targets))
|
||||
hash.update(str(self._version_cache_timestamp))
|
||||
return hash.hexdigest()
|
||||
|
||||
def condition():
|
||||
@@ -522,54 +584,70 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
update_possible = False
|
||||
information = dict()
|
||||
|
||||
for target, check in checks.items():
|
||||
if not target in check_targets:
|
||||
continue
|
||||
# we don't want to do the same work twice, so let's use a lock
|
||||
with self._get_versions_mutex:
|
||||
for target, check in checks.items():
|
||||
if not target in check_targets:
|
||||
continue
|
||||
|
||||
try:
|
||||
populated_check = self._populated_check(target, check)
|
||||
target_information, target_update_available, target_update_possible = self._get_current_version(target, populated_check, force=force)
|
||||
if target_information is None:
|
||||
target_information = dict()
|
||||
except exceptions.UnknownCheckType:
|
||||
self._logger.warn("Unknown update check type for target {}: {}".format(target, check.get("type", "<n/a>")))
|
||||
continue
|
||||
if not check:
|
||||
continue
|
||||
|
||||
target_information = dict_merge(dict(local=dict(name="unknown", value="unknown"), remote=dict(name="unknown", value="unknown", release_notes=None)), target_information)
|
||||
try:
|
||||
populated_check = self._populated_check(target, check)
|
||||
target_information, target_update_available, target_update_possible = self._get_current_version(target, populated_check, force=force)
|
||||
if target_information is None:
|
||||
target_information = dict()
|
||||
except exceptions.UnknownCheckType:
|
||||
self._logger.warn("Unknown update check type for target {}: {}".format(target, check.get("type", "<n/a>")))
|
||||
continue
|
||||
|
||||
update_available = update_available or target_update_available
|
||||
update_possible = update_possible or (target_update_possible and target_update_available)
|
||||
target_information = dict_merge(dict(local=dict(name="unknown", value="unknown"), remote=dict(name="unknown", value="unknown", release_notes=None)), target_information)
|
||||
|
||||
local_name = target_information["local"]["name"]
|
||||
local_value = target_information["local"]["value"]
|
||||
update_available = update_available or target_update_available
|
||||
update_possible = update_possible or (target_update_possible and target_update_available)
|
||||
|
||||
release_notes = None
|
||||
if target_information and target_information["remote"] and target_information["remote"]["value"]:
|
||||
if "release_notes" in populated_check and populated_check["release_notes"]:
|
||||
release_notes = populated_check["release_notes"]
|
||||
elif "release_notes" in target_information["remote"]:
|
||||
release_notes = target_information["remote"]["release_notes"]
|
||||
local_name = target_information["local"]["name"]
|
||||
local_value = target_information["local"]["value"]
|
||||
|
||||
if release_notes:
|
||||
release_notes = release_notes.format(octoprint_version=VERSION,
|
||||
target_name=target_information["remote"]["name"],
|
||||
target_version=target_information["remote"]["value"])
|
||||
release_notes = None
|
||||
if target_information and target_information["remote"] and target_information["remote"]["value"]:
|
||||
if "release_notes" in populated_check and populated_check["release_notes"]:
|
||||
release_notes = populated_check["release_notes"]
|
||||
elif "release_notes" in target_information["remote"]:
|
||||
release_notes = target_information["remote"]["release_notes"]
|
||||
|
||||
information[target] = dict(updateAvailable=target_update_available,
|
||||
updatePossible=target_update_possible,
|
||||
information=target_information,
|
||||
displayName=populated_check["displayName"],
|
||||
displayVersion=populated_check["displayVersion"].format(octoprint_version=VERSION, local_name=local_name, local_value=local_value),
|
||||
check=populated_check,
|
||||
releaseNotes=release_notes)
|
||||
if release_notes:
|
||||
release_notes = release_notes.format(octoprint_version=VERSION,
|
||||
target_name=target_information["remote"]["name"],
|
||||
target_version=target_information["remote"]["value"])
|
||||
|
||||
if self._version_cache_dirty:
|
||||
self._save_version_cache()
|
||||
information[target] = dict(updateAvailable=target_update_available,
|
||||
updatePossible=target_update_possible,
|
||||
information=target_information,
|
||||
displayName=populated_check["displayName"],
|
||||
displayVersion=populated_check["displayVersion"].format(octoprint_version=VERSION, local_name=local_name, local_value=local_value),
|
||||
check=populated_check,
|
||||
releaseNotes=release_notes)
|
||||
|
||||
if self._version_cache_dirty:
|
||||
self._save_version_cache()
|
||||
return information, update_available, update_possible
|
||||
|
||||
def _get_check_hash(self, check):
|
||||
def dict_to_sorted_repr(d):
|
||||
lines = []
|
||||
for key in sorted(d.keys()):
|
||||
value = d[key]
|
||||
if isinstance(value, dict):
|
||||
lines.append("{!r}: {}".format(key, dict_to_sorted_repr(value)))
|
||||
else:
|
||||
lines.append("{!r}: {!r}".format(key, value))
|
||||
|
||||
return "{" + ", ".join(lines) + "}"
|
||||
|
||||
hash = hashlib.md5()
|
||||
hash.update(repr(check))
|
||||
hash.update(dict_to_sorted_repr(check))
|
||||
return hash.hexdigest()
|
||||
|
||||
def _get_current_version(self, target, check, force=False):
|
||||
@@ -677,6 +755,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
target_restart_type = check["restart"]
|
||||
elif "pip" in check:
|
||||
target_restart_type = "octoprint"
|
||||
else:
|
||||
target_restart_type = None
|
||||
|
||||
# if our update requires a restart we have to determine which type
|
||||
if restart_type is None or (restart_type == "octoprint" and target_restart_type == "environment"):
|
||||
@@ -770,7 +850,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._settings.load()
|
||||
|
||||
# persist the new version if necessary for check type
|
||||
if check["type"] == "github_commit":
|
||||
if check["type"] in self.COMMIT_TRACKING_TYPES:
|
||||
dummy_default = dict(plugins=dict())
|
||||
dummy_default["plugins"][self._identifier] = dict(checks=dict())
|
||||
dummy_default["plugins"][self._identifier]["checks"][target] = dict(current=None)
|
||||
@@ -792,7 +872,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
self._logger.info("Restarting...")
|
||||
try:
|
||||
util.execute(restart_command)
|
||||
util.execute(restart_command, evaluate_returncode=False, async=True)
|
||||
except exceptions.ScriptError as e:
|
||||
self._logger.exception("Error while restarting via command {}".format(restart_command))
|
||||
self._logger.warn("Restart stdout:\n{}".format(e.stdout))
|
||||
@@ -807,8 +887,16 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
if target == "octoprint":
|
||||
from flask.ext.babel import gettext
|
||||
result["displayName"] = check.get("displayName", gettext("OctoPrint"))
|
||||
result["displayVersion"] = check.get("displayVersion", "{octoprint_version}")
|
||||
|
||||
result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
|
||||
if result["displayName"] is None:
|
||||
# displayName missing or set to None
|
||||
result["displayName"] = to_unicode(gettext("OctoPrint"), errors="replace")
|
||||
|
||||
result["displayVersion"] = to_unicode(check.get("displayVersion"), errors="replace")
|
||||
if result["displayVersion"] is None:
|
||||
# displayVersion missing or set to None
|
||||
result["displayVersion"] = u"{octoprint_version}"
|
||||
|
||||
stable_branch = "master"
|
||||
release_branches = []
|
||||
@@ -819,7 +907,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
release_branches += [x["branch"] for x in check["prerelease_branches"]]
|
||||
result["released_version"] = not release_branches or BRANCH in release_branches
|
||||
|
||||
if check["type"] == "github_commit":
|
||||
if check["type"] in self.COMMIT_TRACKING_TYPES:
|
||||
result["current"] = REVISION if REVISION else "unknown"
|
||||
else:
|
||||
result["current"] = VERSION
|
||||
@@ -833,8 +921,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
result["force_base"] = False
|
||||
|
||||
if check.get("update_script", None):
|
||||
# if we are using the update_script, we need to set our update_branch and force
|
||||
# to install the exact version we requested
|
||||
# if we are using the update_script, we need to set our update_branch
|
||||
|
||||
if check.get("prerelease", None):
|
||||
# we are tracking prereleases => we want to be on the correct prerelease channel/branch
|
||||
@@ -844,14 +931,13 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
# in case it's not already set
|
||||
result["update_branch"] = check.get("update_branch", channel)
|
||||
|
||||
# we also force our target version in the update
|
||||
result["force_exact_version"] = True
|
||||
|
||||
else:
|
||||
# we are not tracking prereleases, but aren't on the stable branch either => switch back
|
||||
# to stable branch on update
|
||||
result["update_branch"] = check.get("update_branch", stable_branch)
|
||||
|
||||
# we also force an exact version
|
||||
result["force_exact_version"] = True
|
||||
|
||||
if BRANCH != result.get("prerelease_channel"):
|
||||
# we force python unequality check here because that will also allow us to
|
||||
@@ -863,9 +949,17 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
result["release_compare"] = "python_unequal"
|
||||
|
||||
else:
|
||||
result["displayName"] = check.get("displayName", target)
|
||||
result["displayVersion"] = check.get("displayVersion", check.get("current", "unknown"))
|
||||
if check["type"] in ("github_commit",):
|
||||
result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
|
||||
if result["displayName"] is None:
|
||||
# displayName missing or None
|
||||
result["displayName"] = to_unicode(target, errors="replace")
|
||||
|
||||
result["displayVersion"] = to_unicode(check.get("displayVersion", check.get("current")), errors="replace")
|
||||
if result["displayVersion"] is None:
|
||||
# displayVersion AND current missing or None
|
||||
result["displayVersion"] = u"unknown"
|
||||
|
||||
if check["type"] in self.COMMIT_TRACKING_TYPES:
|
||||
result["current"] = check.get("current", None)
|
||||
else:
|
||||
result["current"] = check.get("current", check.get("displayVersion", None))
|
||||
@@ -897,18 +991,11 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
raise exceptions.ConfigurationInvalid("no check type defined")
|
||||
|
||||
check_type = check["type"]
|
||||
if check_type == "github_release":
|
||||
return version_checks.github_release
|
||||
elif check_type == "github_commit":
|
||||
return version_checks.github_commit
|
||||
elif check_type == "git_commit":
|
||||
return version_checks.git_commit
|
||||
elif check_type == "commandline":
|
||||
return version_checks.commandline
|
||||
elif check_type == "python_checker":
|
||||
return version_checks.python_checker
|
||||
else:
|
||||
method = getattr(version_checks, check_type)
|
||||
if method is None:
|
||||
raise exceptions.UnknownCheckType()
|
||||
else:
|
||||
return method
|
||||
|
||||
def _get_update_method(self, target, check, valid_methods=None):
|
||||
"""
|
||||
@@ -930,7 +1017,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
elif "pip" in check:
|
||||
method = "pip"
|
||||
elif "python_updater" in check:
|
||||
method = "python_updated"
|
||||
method = "python_updater"
|
||||
|
||||
if method is None or (valid_methods and not method in valid_methods):
|
||||
raise exceptions.UnknownUpdateType()
|
||||
@@ -967,8 +1054,11 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
__plugin_name__ = "Software Update"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
__plugin_url__ = "https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update"
|
||||
__plugin_url__ = "http://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html"
|
||||
__plugin_description__ = "Allows receiving update notifications and performing updates of OctoPrint and plugins"
|
||||
__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to "
|
||||
"update itself or any of your installed plugins which might put "
|
||||
"your system at risk.")
|
||||
__plugin_license__ = "AGPLv3"
|
||||
def __plugin_load__():
|
||||
global __plugin_implementation__
|
||||
|
||||
@@ -1 +1 @@
|
||||
td.settings_plugin_softwareupdate_column_update{width:16px}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:bold}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:bold;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:bold;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
td.settings_plugin_softwareupdate_column_update{width:16px}#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}
|
||||
@@ -1,17 +1,19 @@
|
||||
(function (global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["OctoPrint"], factory);
|
||||
define(["OctoPrintClient"], factory);
|
||||
} else {
|
||||
factory(window.OctoPrint);
|
||||
factory(global.OctoPrintClient);
|
||||
}
|
||||
})(window || this, function(OctoPrint) {
|
||||
var exports = {};
|
||||
})(this, function(OctoPrintClient) {
|
||||
var OctoPrintSoftwareUpdateClient = function(base) {
|
||||
this.base = base;
|
||||
|
||||
var url = OctoPrint.getBlueprintUrl("softwareupdate");
|
||||
var checkUrl = url + "check";
|
||||
var updateUrl = url + "update";
|
||||
var url = this.base.getBlueprintUrl("softwareupdate");
|
||||
this.checkUrl = url + "check";
|
||||
this.updateUrl = url + "update";
|
||||
};
|
||||
|
||||
exports.checkEntries = function(entries, force, opts) {
|
||||
OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
|
||||
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
||||
var params = arguments[0];
|
||||
entries = params.entries;
|
||||
@@ -31,20 +33,20 @@
|
||||
if (entries && entries.length) {
|
||||
data.check = entries.join(",");
|
||||
}
|
||||
return OctoPrint.getWithQuery(checkUrl, data, opts);
|
||||
return this.base.getWithQuery(this.checkUrl, data, opts);
|
||||
};
|
||||
|
||||
exports.check = function(force, opts) {
|
||||
OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
|
||||
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
||||
var params = arguments[0];
|
||||
force = params.force;
|
||||
opts = params.opts;
|
||||
}
|
||||
|
||||
return exports.checkEntries({entries: [], force: force, opts: opts});
|
||||
return this.checkEntries({entries: [], force: force, opts: opts});
|
||||
};
|
||||
|
||||
exports.update = function(entries, force, opts) {
|
||||
OctoPrintSoftwareUpdateClient.prototype.update = function(entries, force, opts) {
|
||||
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
||||
var params = arguments[0];
|
||||
entries = params.entries;
|
||||
@@ -61,10 +63,10 @@
|
||||
entries: entries,
|
||||
force: !!force
|
||||
};
|
||||
return OctoPrint.postJson(updateUrl, data, opts);
|
||||
return this.base.postJson(this.updateUrl, data, opts);
|
||||
};
|
||||
|
||||
exports.updateAll = function(force, opts) {
|
||||
OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
|
||||
if (arguments.length == 1 && _.isObject(arguments[0])) {
|
||||
var params = arguments[0];
|
||||
force = params.force;
|
||||
@@ -74,10 +76,11 @@
|
||||
var data = {
|
||||
force: !!force
|
||||
};
|
||||
return OctoPrint.postJson(updateUrl, data, opts);
|
||||
return this.base.postJson(this.updateUrl, data, opts);
|
||||
};
|
||||
|
||||
OctoPrint.plugins.softwareupdate = exports;
|
||||
OctoPrintClient.registerPluginComponent("softwareupdate", OctoPrintSoftwareUpdateClient);
|
||||
return OctoPrintSoftwareUpdateClient;
|
||||
});
|
||||
|
||||
$(function() {
|
||||
@@ -108,14 +111,21 @@ $(function() {
|
||||
self.octoprintUnconfigured = ko.observable();
|
||||
self.octoprintUnreleased = ko.observable();
|
||||
|
||||
self.cacheTimestamp = ko.observable();
|
||||
self.cacheTimestampText = ko.pureComputed(function() {
|
||||
return formatDate(self.cacheTimestamp());
|
||||
});
|
||||
|
||||
self.config_cacheTtl = ko.observable();
|
||||
self.config_notifyUsers = ko.observable();
|
||||
self.config_checkoutFolder = ko.observable();
|
||||
self.config_checkType = ko.observable();
|
||||
self.config_updateMethod = ko.observable();
|
||||
self.config_releaseChannel = ko.observable();
|
||||
|
||||
self.configurationDialog = $("#settings_plugin_softwareupdate_configurationdialog");
|
||||
self.confirmationDialog = $("#softwareupdate_confirmation_dialog");
|
||||
self.configurationDialog = undefined;
|
||||
self.confirmationDialog = undefined;
|
||||
self._updateClicked = false;
|
||||
|
||||
self.config_availableCheckTypes = ko.observableArray([]);
|
||||
self.config_availableReleaseChannels = ko.observableArray([]);
|
||||
@@ -150,9 +160,20 @@ $(function() {
|
||||
self.performCheck();
|
||||
};
|
||||
|
||||
self._showPopup = function(options, eventListeners) {
|
||||
self.onUserLoggedOut = function() {
|
||||
self._closePopup();
|
||||
self.popup = new PNotify(options);
|
||||
};
|
||||
|
||||
self._showPopup = function(options, eventListeners, singleButtonNotify) {
|
||||
singleButtonNotify = singleButtonNotify || false;
|
||||
|
||||
self._closePopup();
|
||||
|
||||
if (singleButtonNotify) {
|
||||
self.popup = PNotify.singleButtonNotify(options);
|
||||
} else {
|
||||
self.popup = new PNotify(options);
|
||||
}
|
||||
|
||||
if (eventListeners) {
|
||||
var popupObj = self.popup.get();
|
||||
@@ -183,12 +204,13 @@ $(function() {
|
||||
|
||||
self.savePluginSettings = function(viewModel, event) {
|
||||
var target = $(event.target);
|
||||
target.prepend('<i class="icon-spinner icon-spin"></i> ');
|
||||
target.prepend('<i class="fa fa-spinner fa-spin"></i> ');
|
||||
|
||||
var data = {
|
||||
plugins: {
|
||||
softwareupdate: {
|
||||
cache_ttl: parseInt(self.config_cacheTtl()),
|
||||
notify_users: self.config_notifyUsers(),
|
||||
octoprint_checkout_folder: self.config_checkoutFolder(),
|
||||
octoprint_type: self.config_checkType(),
|
||||
octoprint_release_channel: self.config_releaseChannel()
|
||||
@@ -202,7 +224,7 @@ $(function() {
|
||||
self.performCheck();
|
||||
},
|
||||
complete: function() {
|
||||
$("i.icon-spinner", target).remove();
|
||||
$("i.fa-spinner", target).remove();
|
||||
},
|
||||
sending: true
|
||||
});
|
||||
@@ -228,6 +250,7 @@ $(function() {
|
||||
|
||||
self.config_updateMethod(updateMethod);
|
||||
self.config_cacheTtl(self.settings.settings.plugins.softwareupdate.cache_ttl());
|
||||
self.config_notifyUsers(self.settings.settings.plugins.softwareupdate.notify_users());
|
||||
self.config_checkoutFolder(self.settings.settings.plugins.softwareupdate.octoprint_checkout_folder());
|
||||
self.config_checkType(self.settings.settings.plugins.softwareupdate.octoprint_type());
|
||||
self.config_releaseChannel(self.settings.settings.plugins.softwareupdate.octoprint_release_channel());
|
||||
@@ -239,6 +262,8 @@ $(function() {
|
||||
};
|
||||
|
||||
self.fromCheckResponse = function(data, ignoreSeen, showIfNothingNew) {
|
||||
self.cacheTimestamp(data.timestamp);
|
||||
|
||||
var versions = [];
|
||||
_.each(data.information, function(value, key) {
|
||||
value["key"] = key;
|
||||
@@ -285,14 +310,16 @@ $(function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!self.loginState.isAdmin() && !self.settings.settings.plugins.softwareupdate.notify_users()) return;
|
||||
|
||||
if (data.status == "updateAvailable" || data.status == "updatePossible") {
|
||||
var text = "<div class='softwareupdate_notification'>" + gettext("There are updates available for the following components:");
|
||||
|
||||
text += "<ul class='icons-ul'>";
|
||||
text += "<ul class='fa-ul'>";
|
||||
_.each(self.versions.items(), function(update_info) {
|
||||
if (update_info.updateAvailable) {
|
||||
text += "<li>"
|
||||
+ "<i class='icon-li " + (update_info.updatePossible ? "icon-ok" : "icon-remove")+ "'></i>"
|
||||
+ "<i class='fa fa-li " + (update_info.updatePossible ? "fa-check" : "fa-remove")+ "'></i>"
|
||||
+ "<span class='name' title='" + update_info.fullNameRemote + "'>" + update_info.fullNameRemote + "</span>"
|
||||
+ (update_info.releaseNotes ? "<a href=\"" + update_info.releaseNotes + "\" target=\"_blank\">" + gettext("Release Notes") + "</a>" : "")
|
||||
+ "</li>";
|
||||
@@ -300,7 +327,11 @@ $(function() {
|
||||
});
|
||||
text += "</ul>";
|
||||
|
||||
text += "<small>" + gettext("Those components marked with <i class=\"icon-ok\"></i> can be updated directly.") + "</small>";
|
||||
text += "<p><small>" + gettext("Those components marked with <i class=\"fa fa-check\"></i> can be updated directly.") + "</small></p>";
|
||||
|
||||
if (!self.loginState.isAdmin()) {
|
||||
text += "<p><small>" + gettext("To have updates applied, get in touch with an administrator of this OctoPrint instance.") + "</small></p>";
|
||||
}
|
||||
|
||||
text += "</div>";
|
||||
|
||||
@@ -311,8 +342,9 @@ $(function() {
|
||||
};
|
||||
var eventListeners = {};
|
||||
|
||||
var singleButtonNotify = false;
|
||||
if (data.status == "updatePossible" && self.loginState.isAdmin()) {
|
||||
// if user is admin, add action buttons
|
||||
// if update is possible and user is admin, add action buttons for ignore and update
|
||||
options["confirm"] = {
|
||||
confirm: true,
|
||||
buttons: [{
|
||||
@@ -326,17 +358,38 @@ $(function() {
|
||||
}, {
|
||||
text: gettext("Update now"),
|
||||
addClass: "btn-primary",
|
||||
click: self.update
|
||||
click: function() {
|
||||
if (self._updateClicked) return;
|
||||
self._updateClicked = true;
|
||||
self.update();
|
||||
}
|
||||
}]
|
||||
};
|
||||
options["buttons"] = {
|
||||
closer: false,
|
||||
sticker: false
|
||||
};
|
||||
} else {
|
||||
// if update is not possible or user is not admin, only add ignore button
|
||||
options["confirm"] = {
|
||||
confirm: true,
|
||||
buttons: [{
|
||||
text: gettext("Ignore"),
|
||||
click: function(notice) {
|
||||
notice.remove();
|
||||
self._markNotificationAsSeen(data.information);
|
||||
}
|
||||
}]
|
||||
};
|
||||
options["buttons"] = {
|
||||
closer: false,
|
||||
sticker: false
|
||||
};
|
||||
singleButtonNotify = true;
|
||||
}
|
||||
|
||||
if ((ignoreSeen || !self._hasNotificationBeenSeen(data.information)) && !OctoPrint.coreui.wizardOpen) {
|
||||
self._showPopup(options, eventListeners);
|
||||
self._showPopup(options, eventListeners, singleButtonNotify);
|
||||
}
|
||||
} else if (data.status == "current") {
|
||||
if (showIfNothingNew) {
|
||||
@@ -352,7 +405,8 @@ $(function() {
|
||||
};
|
||||
|
||||
self.performCheck = function(showIfNothingNew, force, ignoreSeen) {
|
||||
if (!self.loginState.isUser()) return;
|
||||
if (!self.loginState.isAdmin() && !self.settings.settings.plugins.softwareupdate.notify_users()) return;
|
||||
|
||||
self.checking(true);
|
||||
OctoPrint.plugins.softwareupdate.check(force)
|
||||
.done(function(data) {
|
||||
@@ -366,7 +420,18 @@ $(function() {
|
||||
self._markNotificationAsSeen = function(data) {
|
||||
if (!Modernizr.localstorage)
|
||||
return false;
|
||||
localStorage["plugin.softwareupdate.seen_information"] = JSON.stringify(self._informationToRemoteVersions(data));
|
||||
if (!self.loginState.isUser())
|
||||
return false;
|
||||
|
||||
var currentString = localStorage["plugin.softwareupdate.seen_information"];
|
||||
var current;
|
||||
if (currentString === undefined) {
|
||||
current = {};
|
||||
} else {
|
||||
current = JSON.parse(currentString);
|
||||
}
|
||||
current[self.loginState.username()] = self._informationToRemoteVersions(data);
|
||||
localStorage["plugin.softwareupdate.seen_information"] = JSON.stringify(current);
|
||||
};
|
||||
|
||||
self._hasNotificationBeenSeen = function(data) {
|
||||
@@ -377,11 +442,19 @@ $(function() {
|
||||
return false;
|
||||
|
||||
var knownData = JSON.parse(localStorage["plugin.softwareupdate.seen_information"]);
|
||||
|
||||
if (!self.loginState.isUser())
|
||||
return true;
|
||||
|
||||
var userData = knownData[self.loginState.username()];
|
||||
if (userData === undefined)
|
||||
return false;
|
||||
|
||||
var freshData = self._informationToRemoteVersions(data);
|
||||
|
||||
var hasBeenSeen = true;
|
||||
_.each(freshData, function(value, key) {
|
||||
if (!_.has(knownData, key) || knownData[key] != freshData[key]) {
|
||||
if (!_.has(userData, key) || userData[key] != freshData[key]) {
|
||||
hasBeenSeen = false;
|
||||
}
|
||||
});
|
||||
@@ -397,12 +470,14 @@ $(function() {
|
||||
};
|
||||
|
||||
self.performUpdate = function(force, items) {
|
||||
if (!self.loginState.isAdmin()) return;
|
||||
|
||||
self.updateInProgress = true;
|
||||
|
||||
var options = {
|
||||
title: gettext("Updating..."),
|
||||
text: gettext("Now updating, please wait."),
|
||||
icon: "icon-cog icon-spin",
|
||||
icon: "fa fa-cog fa-spin",
|
||||
hide: false,
|
||||
buttons: {
|
||||
closer: false,
|
||||
@@ -431,8 +506,14 @@ $(function() {
|
||||
};
|
||||
|
||||
self.update = function(force) {
|
||||
if (self.updateInProgress) return;
|
||||
if (!self.loginState.isAdmin()) return;
|
||||
if (self.updateInProgress) {
|
||||
self._updateClicked = false;
|
||||
return;
|
||||
}
|
||||
if (!self.loginState.isAdmin()) {
|
||||
self._updateClicked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.printerState.isPrinting()) {
|
||||
self._showPopup({
|
||||
@@ -440,6 +521,7 @@ $(function() {
|
||||
text: gettext("A print job is currently in progress. Updating will be prevented until it is done."),
|
||||
type: "error"
|
||||
});
|
||||
self._updateClicked = false;
|
||||
} else {
|
||||
self.forceUpdate = (force == true);
|
||||
self.confirmationDialog.modal("show");
|
||||
@@ -448,9 +530,13 @@ $(function() {
|
||||
};
|
||||
|
||||
self.confirmUpdate = function() {
|
||||
self.confirmationDialog.modal("hide");
|
||||
self.performUpdate(self.forceUpdate,
|
||||
_.map(self.availableAndPossible(), function(info) { return info.key }));
|
||||
self.confirmationDialog.modal("hide");
|
||||
};
|
||||
|
||||
self.confirmationHidden = function() {
|
||||
self._updateClicked = false;
|
||||
};
|
||||
|
||||
self._showWorkingDialog = function(title) {
|
||||
@@ -508,6 +594,10 @@ $(function() {
|
||||
self.onStartup = function() {
|
||||
self.workingDialog = $("#settings_plugin_softwareupdate_workingdialog");
|
||||
self.workingOutput = $("#settings_plugin_softwareupdate_workingdialog_output");
|
||||
self.configurationDialog = $("#settings_plugin_softwareupdate_configurationdialog");
|
||||
self.confirmationDialog = $("#softwareupdate_confirmation_dialog");
|
||||
|
||||
self.confirmationDialog.on("hidden", self.confirmationHidden);
|
||||
};
|
||||
|
||||
self.onServerDisconnect = function() {
|
||||
@@ -702,7 +792,10 @@ $(function() {
|
||||
}
|
||||
};
|
||||
|
||||
self._forcedStdoutLine = /You are using pip version .*?, however version .*? is available\.|You should consider upgrading via the '.*?' command\./;
|
||||
self._forcedStdoutPatterns = ["You are using pip version .*?, however version .*? is available\.",
|
||||
"You should consider upgrading via the '.*?' command\.",
|
||||
"'.*?' does not exist -- can't clean it"];
|
||||
self._forcedStdoutLine = new RegExp(self._forcedStdoutPatterns.join("|"));
|
||||
self._preprocessLine = function(line) {
|
||||
if (line.stream == "stderr" && line.line.match(self._forcedStdoutLine)) {
|
||||
line.stream = "stdout";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="alert" data-bind="visible: octoprintUnconfigured()">{% trans %}
|
||||
Please configure the <strong>checkout folder</strong> of OctoPrint, otherwise
|
||||
this plugin won't be able to update it. Click on the <i class="icon-wrench"></i> button
|
||||
this plugin won't be able to update it. Click on the <i class="fa fa-wrench"></i> button
|
||||
to do this. Also refer to the <a href="https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update" target="_blank">Documentation</a>.
|
||||
{% endtrans %}</div>
|
||||
<div class="alert" data-bind="visible: !octoprintUnconfigured() && octoprintUnreleased()">{% trans %}
|
||||
@@ -17,7 +17,7 @@
|
||||
{% endtrans %}</div>
|
||||
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="icon-wrench"></i></button>
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration') }}"><i class="fa fa-wrench"></i></button>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Current versions') }}</h3>
|
||||
@@ -26,10 +26,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="icon-bell" title="{{ _('Update available') }}"></i></span>
|
||||
<span data-bind="invisible: !updateAvailable"><i class="fa fa-bell-o" title="{{ _('Update available') }}"></i></span>
|
||||
</td>
|
||||
<td class="settings_plugin_softwareupdate_column_information">
|
||||
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="icon-exclamation-sign" title="{{ _('Update not possible, configuration ok?') }}"></i></span><br>
|
||||
<strong data-bind="text: displayName"></strong>: <span data-bind="text: displayVersion"></span> <span data-bind="invisible: updatePossible"><i class="fa fa-exclamation-triangle" title="{{ _('Update not possible, configuration ok?') }}"></i></span><br>
|
||||
<small class="muted">
|
||||
{{ _('Installed:') }} <span data-bind="text: information.local.name"></span><br>
|
||||
{{ _('Available:') }} <span data-bind="text: information.remote.name"></span><br>
|
||||
@@ -57,13 +57,14 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary btn-block" data-bind="click: function() { $root.performCheck(true, false, true); }, enable: !checking(), css: {disabled: checking()}"><i class="icon-spinner icon-spin" data-bind="visible: checking"></i> {{ _('Check for update now') }}</button>
|
||||
<button class="btn btn-primary btn-block" data-bind="click: function() { $root.performCheck(true, false, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fa fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Check for update now') }}</button>
|
||||
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('icon-caret-right icon-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="icon-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fa fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="icon-spinner icon-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); }">{{ _('Force update now (even if no new versions are available)') }}</button>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -86,6 +87,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: config_notifyUsers"> {{ _('Show update notifications to users') }}
|
||||
<span class="help-block">{{ _('If you uncheck this, only logged in admins will see update notifications. Update notifications shown to users do not include the "Update now" button.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -99,7 +108,7 @@
|
||||
<h3 data-bind="text: workingTitle"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<pre id="settings_plugin_softwareupdate_workingdialog_output" class="terminal pre-scrollable" style="height: 170px" data-bind="foreach: loglines"><span data-bind="text: line, css: {stdout: stream == 'stdout', stderr: stream == 'stderr', call: stream == 'call', message: stream == 'message'}"></span><br></pre>
|
||||
<pre id="settings_plugin_softwareupdate_workingdialog_output" class="pre-scrollable pre-output" style="height: 170px" data-bind="foreach: loglines"><span data-bind="text: line, css: {stdout: stream == 'stdout', stderr: stream == 'stderr', call: stream == 'call', message: stream == 'message'}"></span></pre>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" data-bind="enable: !$root.working()" aria-hidden="true">{{ _('Close') }}</button>
|
||||
|
||||
@@ -7,8 +7,8 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
|
||||
def can_perform_update(target, check):
|
||||
return "python_updater" in check and check["python_updater"] is not None
|
||||
return "python_updater" in check and check["python_updater"] is not None and hasattr(check["python_updater"], "perform_update")
|
||||
|
||||
|
||||
def perform_update(target, check, target_version, log_cb=None):
|
||||
return check["python_updater"].perform_update(target, check, target_version, log_cb=None)
|
||||
return check["python_updater"].perform_update(target, check, target_version, log_cb=log_cb)
|
||||
@@ -9,12 +9,12 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
from .exceptions import ScriptError
|
||||
|
||||
|
||||
def execute(command, cwd=None, evaluate_returncode=True):
|
||||
def execute(command, cwd=None, evaluate_returncode=True, async=False):
|
||||
import sarge
|
||||
p = None
|
||||
|
||||
try:
|
||||
p = sarge.run(command, cwd=cwd, stdout=sarge.Capture(), stderr=sarge.Capture())
|
||||
p = sarge.run(command, cwd=cwd, stdout=sarge.Capture(), stderr=sarge.Capture(), async=async)
|
||||
except:
|
||||
returncode = p.returncode if p is not None else None
|
||||
stdout = p.stdout.text if p is not None and p.stdout is not None else ""
|
||||
|
||||
@@ -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, python_checker
|
||||
from . import commandline, git_commit, github_commit, github_release, bitbucket_commit, python_checker
|
||||
|
||||
def log_github_ratelimit(logger, r):
|
||||
ratelimit = r.headers["X-RateLimit-Limit"] if "X-RateLimit-Limit" in r.headers else "?"
|
||||
@@ -17,4 +17,4 @@ def log_github_ratelimit(logger, r):
|
||||
except:
|
||||
reset = "?"
|
||||
|
||||
logger.debug("Github rate limit: %s/%s, reset at %s" % (remaining, ratelimit, reset))
|
||||
logger.debug("Github rate limit: %s/%s, reset at %s" % (remaining, ratelimit, reset))
|
||||
@@ -0,0 +1,52 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import requests
|
||||
import logging
|
||||
|
||||
from ..exceptions import ConfigurationInvalid
|
||||
|
||||
BRANCH_HEAD_URL = "https://api.bitbucket.org/2.0/repositories/{user}/{repo}/commit/{branch}"
|
||||
|
||||
logger = logging.getLogger("octoprint.plugins.softwareupdate.version_checks.bitbucket_commit")
|
||||
|
||||
def _get_latest_commit(user, repo, branch):
|
||||
r = requests.get(BRANCH_HEAD_URL.format(user=user, repo=repo, branch=branch))
|
||||
|
||||
if not r.status_code == requests.codes.ok:
|
||||
return None
|
||||
|
||||
reference = r.json()
|
||||
if not "hash" in reference:
|
||||
return None
|
||||
|
||||
return reference["hash"]
|
||||
|
||||
|
||||
def get_latest(target, check):
|
||||
if "user" not in check or "repo" not in check:
|
||||
raise ConfigurationInvalid("Update configuration for %s of type bitbucket_commit needs all of user and repo" % target)
|
||||
|
||||
branch = "master"
|
||||
if "branch" in check:
|
||||
branch = check["branch"]
|
||||
|
||||
current = None
|
||||
if "current" in check:
|
||||
current = check["current"]
|
||||
|
||||
remote_commit = _get_latest_commit(check["user"], check["repo"], branch)
|
||||
|
||||
information = dict(
|
||||
local=dict(name="Commit {commit}".format(commit=current if current is not None else "unknown"), value=current),
|
||||
remote=dict(name="Commit {commit}".format(commit=remote_commit if remote_commit is not None else "unknown"), value=remote_commit)
|
||||
)
|
||||
is_current = (current is not None and current == remote_commit) or remote_commit is None
|
||||
|
||||
logger.debug("Target: %s, local: %s, remote: %s" % (target, current, remote_commit))
|
||||
|
||||
return information, is_current
|
||||
|
||||
@@ -12,10 +12,11 @@ from ..exceptions import ConfigurationInvalid
|
||||
from ..util import execute
|
||||
|
||||
def get_latest(target, check):
|
||||
if not "command" in check:
|
||||
raise ConfigurationInvalid("Update configuration for %s of type commandline needs command defined" % target)
|
||||
command = check.get("command")
|
||||
if command is None:
|
||||
raise ConfigurationInvalid("Update configuration for {} of type commandline needs command set and not None".format(target))
|
||||
|
||||
returncode, stdout, stderr = execute(check["command"], evaluate_returncode=False)
|
||||
returncode, stdout, stderr = execute(command, evaluate_returncode=False)
|
||||
|
||||
# We expect command line check commands to
|
||||
#
|
||||
|
||||
Loaded 100 of 282 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user