Compare commits
1086
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67047c006c | ||
|
|
2d872baaec | ||
|
|
a412ff42cb | ||
|
|
06cd4ead8d | ||
|
|
13995e30b7 | ||
|
|
0d6d0f7256 | ||
|
|
1e8cb55be9 | ||
|
|
e63161ae17 | ||
|
|
f41dc58d97 | ||
|
|
522abbddbe | ||
|
|
fecc162b5d | ||
|
|
accb222a92 | ||
|
|
0768e3e72b | ||
|
|
4b04e8fd79 | ||
|
|
2edd2ba887 | ||
|
|
fcef3a1bbd | ||
|
|
d1d24dba9a | ||
|
|
2c640ff8b8 | ||
|
|
0331a25ae3 | ||
|
|
326422013a | ||
|
|
9b4da62e69 | ||
|
|
c0096c41a0 | ||
|
|
b46a66caa8 | ||
|
|
6711813fef | ||
|
|
7726e5c04e | ||
|
|
495d99fbe9 | ||
|
|
a35b7cddf2 | ||
|
|
f2af5e8b86 | ||
|
|
289c3a4d0f | ||
|
|
4cb67fe72c | ||
|
|
b79fc94a4e | ||
|
|
fca626a3d6 | ||
|
|
f5a04973c4 | ||
|
|
1c9ff91bae | ||
|
|
e1e521300b | ||
|
|
c1e8bc717a | ||
|
|
22d7392769 | ||
|
|
904e7d2ecd | ||
|
|
b3173386ae | ||
|
|
1e3b8dfb2c | ||
|
|
94d172ab67 | ||
|
|
7dac6ca433 | ||
|
|
9aeeb5fecc | ||
|
|
52f65b469d | ||
|
|
0843c0fbc7 | ||
|
|
11607fbc73 | ||
|
|
1521b76090 | ||
|
|
a33a7b4d67 | ||
|
|
c00fdbf73b | ||
|
|
af32858549 | ||
|
|
d1104ddbae | ||
|
|
e2519abbbe | ||
|
|
967b3bbff8 | ||
|
|
9721aec32a | ||
|
|
68952c20bd | ||
|
|
9775d99feb | ||
|
|
bfcff9a1cd | ||
|
|
5ca286f4e3 | ||
|
|
7dae700215 | ||
|
|
58806a3d00 | ||
|
|
72cc1afb45 | ||
|
|
323131cbc5 | ||
|
|
f389773036 | ||
|
|
0a04043922 | ||
|
|
84fa3b6073 | ||
|
|
d6576306b0 | ||
|
|
8970fb42b1 | ||
|
|
55e8cc1118 | ||
|
|
43e2f79575 | ||
|
|
132e2cb244 | ||
|
|
de6d1afdd6 | ||
|
|
0a1cc68a6b | ||
|
|
f1309dad1d | ||
|
|
b353c4eee2 | ||
|
|
34c30ed73f | ||
|
|
c28faa8032 | ||
|
|
8da5bb2d42 | ||
|
|
54c885f1ad | ||
|
|
65fe048ade | ||
|
|
3574c2ddf9 | ||
|
|
1dc0f1fb31 | ||
|
|
30ddbfd324 | ||
|
|
5c522d86ca | ||
|
|
f785c8180b | ||
|
|
18e7d2b72a | ||
|
|
410c3ee5f6 | ||
|
|
48825fd4c2 | ||
|
|
ff9c83ea25 | ||
|
|
2c18a40dcb | ||
|
|
0b6dd7e76e | ||
|
|
d68c7bfc67 | ||
|
|
c879ad27f4 | ||
|
|
d1914824c6 | ||
|
|
79196eeaf7 | ||
|
|
6491db730d | ||
|
|
bd07cda205 | ||
|
|
9c7ca0ab7a | ||
|
|
c4da5d6764 | ||
|
|
47187c233d | ||
|
|
982ed793d9 | ||
|
|
718306073e | ||
|
|
df6e94f7a3 | ||
|
|
1a2739c640 | ||
|
|
9d318a4031 | ||
|
|
292d608b97 | ||
|
|
2d7cb40633 | ||
|
|
ce9315850f | ||
|
|
b8dbc627cb | ||
|
|
73df8c2407 | ||
|
|
55ec8b1809 | ||
|
|
33eba705bf | ||
|
|
9ec3a6ae7a | ||
|
|
ec2ba63425 | ||
|
|
6097222b7b | ||
|
|
40396847e3 | ||
|
|
a296574c70 | ||
|
|
547962f4bc | ||
|
|
1d2ceefb72 | ||
|
|
3d4422021e | ||
|
|
3b5c11a2bb | ||
|
|
4908d94c97 | ||
|
|
17a7e508c3 | ||
|
|
0069c94d35 | ||
|
|
99e7824913 | ||
|
|
ceade46dd7 | ||
|
|
bc66d29d02 | ||
|
|
9ea1074b03 | ||
|
|
6e069211cc | ||
|
|
8d3befb01f | ||
|
|
42a6cab92e | ||
|
|
083e424529 | ||
|
|
d5eefcd1a5 | ||
|
|
c1670d03c8 | ||
|
|
b2637eb06a | ||
|
|
47179f2956 | ||
|
|
d64b8512ab | ||
|
|
602ec5c495 | ||
|
|
a63ee9355e | ||
|
|
e44ae7a024 | ||
|
|
76ad332287 | ||
|
|
93ab7bb089 | ||
|
|
b4e7e73e29 | ||
|
|
92ad53a9ec | ||
|
|
21c9c51858 | ||
|
|
38a321e175 | ||
|
|
32050c31ae | ||
|
|
f020fc1bc6 | ||
|
|
a1e8694073 | ||
|
|
e748b52098 | ||
|
|
961b41f0fe | ||
|
|
4f59e0fd48 | ||
|
|
e441976682 | ||
|
|
864ac12097 | ||
|
|
ee854f44cc | ||
|
|
cc5c19dde9 | ||
|
|
aab629d80e | ||
|
|
4e2afbc170 | ||
|
|
8668c6200a | ||
|
|
e01f391b30 | ||
|
|
92618362e1 | ||
|
|
d071684d41 | ||
|
|
7d0bd6a339 | ||
|
|
1b5a654a2d | ||
|
|
f0ee7f343e | ||
|
|
f36a6a0409 | ||
|
|
de8be65be7 | ||
|
|
780948fe7d | ||
|
|
c27936a9db | ||
|
|
caad7a3f60 | ||
|
|
7c75c882d3 | ||
|
|
9594b75b78 | ||
|
|
3e16f0901a | ||
|
|
8866ed716d | ||
|
|
cf16392e18 | ||
|
|
34e4a20866 | ||
|
|
0f157d3747 | ||
|
|
1b3a8acf0d | ||
|
|
fdb4e75241 | ||
|
|
4dbb24ecd7 | ||
|
|
a15e2de251 | ||
|
|
c652bed871 | ||
|
|
1ed6730400 | ||
|
|
dde99736e4 | ||
|
|
334f2c35f9 | ||
|
|
aacd59ae78 | ||
|
|
253a38c32d | ||
|
|
e08becbb4c | ||
|
|
09a043b393 | ||
|
|
9eafe9979a | ||
|
|
086a2c9f82 | ||
|
|
058dbd0c2e | ||
|
|
54c8923087 | ||
|
|
0c58566789 | ||
|
|
d2917346f5 | ||
|
|
e7f1302f3c | ||
|
|
eca74233eb | ||
|
|
1025f0be43 | ||
|
|
295b96f259 | ||
|
|
adea0db344 | ||
|
|
0c4f4383e3 | ||
|
|
36fb7805e5 | ||
|
|
c7afd7951c | ||
|
|
f489f4ffd1 | ||
|
|
9f2821fe96 | ||
|
|
dcc1148863 | ||
|
|
ba96ba8fe8 | ||
|
|
02566ae9d0 | ||
|
|
8080e65366 | ||
|
|
e972026ad0 | ||
|
|
6592be63f8 | ||
|
|
8b5626e49c | ||
|
|
be4a931e32 | ||
|
|
548da0d64f | ||
|
|
45aa26f13e | ||
|
|
25f26170ff | ||
|
|
4a64bc6023 | ||
|
|
8e6773d19f | ||
|
|
dfcddea581 | ||
|
|
ff59e275bf | ||
|
|
0f8f1ec8e0 | ||
|
|
0e302d440f | ||
|
|
980616519d | ||
|
|
434751634f | ||
|
|
c35708a422 | ||
|
|
64464a38ce | ||
|
|
4c76225c41 | ||
|
|
1f4bfa854b | ||
|
|
4be18c2668 | ||
|
|
225cca34e1 | ||
|
|
9a4149164b | ||
|
|
cf9243c2e7 | ||
|
|
0e482151fd | ||
|
|
c5bf58e1cc | ||
|
|
38b7be0142 | ||
|
|
28a515ba6a | ||
|
|
b6b562399e | ||
|
|
3654512085 | ||
|
|
e7dbd804ce | ||
|
|
7fd03265d4 | ||
|
|
369679bae5 | ||
|
|
27e1f2e6e7 | ||
|
|
109cbeea6a | ||
|
|
606199dcc9 | ||
|
|
38868303da | ||
|
|
75b5fe198f | ||
|
|
fe65f18f78 | ||
|
|
e1e302f93d | ||
|
|
1cea388481 | ||
|
|
14a3d903d7 | ||
|
|
34d6a6f8ce | ||
|
|
6a03532ea7 | ||
|
|
649bfdbe37 | ||
|
|
8ce2290d63 | ||
|
|
b1413abfff | ||
|
|
772914f38c | ||
|
|
c6b4eee437 | ||
|
|
e67f72ce3d | ||
|
|
de6da3f360 | ||
|
|
b744c341eb | ||
|
|
697af69e97 | ||
|
|
601451a3f1 | ||
|
|
81d523b73d | ||
|
|
deacd9c188 | ||
|
|
3c5aa60d2b | ||
|
|
6e0024149e | ||
|
|
1b876f1cf3 | ||
|
|
580e5f5122 | ||
|
|
22f6a38f0a | ||
|
|
620aa4dfe0 | ||
|
|
dd3b318327 | ||
|
|
1ccc787222 | ||
|
|
f8e7ae7436 | ||
|
|
3ae284d9a7 | ||
|
|
caf5be562e | ||
|
|
069e83c63c | ||
|
|
0cf345f29b | ||
|
|
0fda153d60 | ||
|
|
c01a34f358 | ||
|
|
deee737660 | ||
|
|
8425c7b973 | ||
|
|
1e42db040d | ||
|
|
e2d4b64510 | ||
|
|
61136edeea | ||
|
|
7614ef40d3 | ||
|
|
935639a51a | ||
|
|
ec689e3939 | ||
|
|
84f95b1099 | ||
|
|
fd8788dd34 | ||
|
|
32a8646135 | ||
|
|
09cc7cf5f7 | ||
|
|
496e9f0ec4 | ||
|
|
18b2ecd64c | ||
|
|
cc6f61c62e | ||
|
|
de149613cb | ||
|
|
a7ca374955 | ||
|
|
61ac8430d6 | ||
|
|
6b4dfcb960 | ||
|
|
d7d3272905 | ||
|
|
9eb29a8ce0 | ||
|
|
bf16bd1180 | ||
|
|
7b5315383b | ||
|
|
72729ad418 | ||
|
|
e6f902cbe7 | ||
|
|
9b14f32279 | ||
|
|
7ad4d75588 | ||
|
|
5a623b486c | ||
|
|
920283cf87 | ||
|
|
becd16b892 | ||
|
|
f59c1ce804 | ||
|
|
c71972c0f8 | ||
|
|
47a9a40ec9 | ||
|
|
5c1fffc3d0 | ||
|
|
fe090cc6cc | ||
|
|
ab3c4ab66c | ||
|
|
1d6b7244b5 | ||
|
|
ea17566aba | ||
|
|
315ed57916 | ||
|
|
1014582b4b | ||
|
|
cf77053901 | ||
|
|
f040482b18 | ||
|
|
523fadd930 | ||
|
|
97d0fbd2c9 | ||
|
|
3b820f6848 | ||
|
|
e8b9f385b4 | ||
|
|
95bc1006a0 | ||
|
|
14ef17163f | ||
|
|
9a1bd8af87 | ||
|
|
a292a12c4a | ||
|
|
200a3ef4eb | ||
|
|
88582beb55 | ||
|
|
6d7c8bbda6 | ||
|
|
9a7f92174a | ||
|
|
61431c0df3 | ||
|
|
a301fc6da9 | ||
|
|
cc0b63cbb9 | ||
|
|
e08dc0b5aa | ||
|
|
a368a7f1c9 | ||
|
|
020403dc54 | ||
|
|
6a601d4f8e | ||
|
|
7a3b370469 | ||
|
|
e676d53e9f | ||
|
|
40b231f692 | ||
|
|
86664fdb39 | ||
|
|
4ebb5cf42d | ||
|
|
e8bee435af | ||
|
|
082f977f7a | ||
|
|
237a2c0add | ||
|
|
2e47f49f7a | ||
|
|
05919363e1 | ||
|
|
7c8547555c | ||
|
|
ce0c77f0bf | ||
|
|
aec041b014 | ||
|
|
58b32803df | ||
|
|
6d447f8408 | ||
|
|
54d359f730 | ||
|
|
4d9f0fca41 | ||
|
|
41146c2b7c | ||
|
|
99d7157cb7 | ||
|
|
c8b5662ff2 | ||
|
|
b781681e0f | ||
|
|
5edeecdc8c | ||
|
|
f82ec61463 | ||
|
|
372a8d2ea8 | ||
|
|
9c5d1dec59 | ||
|
|
feff5e0978 | ||
|
|
019bf5acd4 | ||
|
|
717aafee08 | ||
|
|
67c5a5e168 | ||
|
|
6310afa261 | ||
|
|
cd6ae6e47b | ||
|
|
b01e1c269d | ||
|
|
49fb0f87d5 | ||
|
|
8956e7a173 | ||
|
|
9fa20f0e52 | ||
|
|
6bf8384c35 | ||
|
|
1dacbc35bf | ||
|
|
7522dbed1d | ||
|
|
d433c919ec | ||
|
|
a6f701802f | ||
|
|
e03feeb7ac | ||
|
|
00068114a1 | ||
|
|
6a7e11eb7c | ||
|
|
6f987577f4 | ||
|
|
819d690bc3 | ||
|
|
dbfe487f13 | ||
|
|
21a82bbdb6 | ||
|
|
47e9afa811 | ||
|
|
f9edea0c2c | ||
|
|
8ef3d1dcad | ||
|
|
fcfef25c93 | ||
|
|
604d2f7811 | ||
|
|
727fd12939 | ||
|
|
100fe5f290 | ||
|
|
a721256204 | ||
|
|
24d2efd3ce | ||
|
|
1acf69cb6d | ||
|
|
3815c340a8 | ||
|
|
5e8220055f | ||
|
|
38eff3fe6f | ||
|
|
4e47ecabf8 | ||
|
|
c36a378b60 | ||
|
|
9a7ebde76b | ||
|
|
c23bafd788 | ||
|
|
1aea92a5f1 | ||
|
|
df9617ac1e | ||
|
|
0b23417f45 | ||
|
|
828ba56952 | ||
|
|
63723baf07 | ||
|
|
b60b20d784 | ||
|
|
1e0bdc8b8c | ||
|
|
b47b39af99 | ||
|
|
6bc4d8fca4 | ||
|
|
1e01e587f3 | ||
|
|
d8f5dd701b | ||
|
|
bee609a316 | ||
|
|
fb38c396e8 | ||
|
|
904b3c6cf5 | ||
|
|
7f2b79bcd5 | ||
|
|
dd692d6f30 | ||
|
|
5d021d76a0 | ||
|
|
5794a347f1 | ||
|
|
2db230549e | ||
|
|
01484b630a | ||
|
|
5d8535cb9c | ||
|
|
21d3622c2e | ||
|
|
008cde6ef6 | ||
|
|
4df57cd8fe | ||
|
|
f53380c04e | ||
|
|
8af45e2f21 | ||
|
|
0da47858fa | ||
|
|
abfffa3231 | ||
|
|
e056ccdf29 | ||
|
|
e334d8b073 | ||
|
|
f1673c148f | ||
|
|
ae5a1dc6dc | ||
|
|
7fcc3551ca | ||
|
|
f3fdac7e5a | ||
|
|
d8088887e1 | ||
|
|
379411cea7 | ||
|
|
5e953c12a1 | ||
|
|
bd58138acf | ||
|
|
44b4c6cc40 | ||
|
|
f3f1061f9d | ||
|
|
bba95e9000 | ||
|
|
fa81791c29 | ||
|
|
a4072723bf | ||
|
|
d451acdd4f | ||
|
|
a1a15e40e0 | ||
|
|
0c264ca0d2 | ||
|
|
9e4b0f83d8 | ||
|
|
2b8d831308 | ||
|
|
fcb0f877b8 | ||
|
|
c74e3a0a0b | ||
|
|
ea64c017e8 | ||
|
|
70a104e32a | ||
|
|
75a37f5ce7 | ||
|
|
e4d083028c | ||
|
|
6bab550830 | ||
|
|
f9916783e9 | ||
|
|
e00375e586 | ||
|
|
41fab8a36c | ||
|
|
c05b6572c5 | ||
|
|
1ae6b73f7a | ||
|
|
670ca15997 | ||
|
|
ea5ef34cc1 | ||
|
|
958fc7600d | ||
|
|
13d894e74b | ||
|
|
353309fc60 | ||
|
|
3501179257 | ||
|
|
f993f744ba | ||
|
|
68410cb3d7 | ||
|
|
db009e3ba2 | ||
|
|
09d3c44161 | ||
|
|
c2814651f9 | ||
|
|
eb46815789 | ||
|
|
449fa0c7ec | ||
|
|
0489dfeaee | ||
|
|
a9b395dac8 | ||
|
|
44a40b8297 | ||
|
|
49728f18c6 | ||
|
|
f6ec0bca6e | ||
|
|
6a069de240 | ||
|
|
2287c65784 | ||
|
|
3b26a2f7d2 | ||
|
|
18ffdcff6b | ||
|
|
faab946aeb | ||
|
|
a48e069aa6 | ||
|
|
d4d5bed514 | ||
|
|
97f84f120c | ||
|
|
cdc69ea93c | ||
|
|
467dd344cf | ||
|
|
6b9c9f47da | ||
|
|
b7f17531d2 | ||
|
|
987379d6e7 | ||
|
|
62b1d91901 | ||
|
|
7cb5013b08 | ||
|
|
06a3baa588 | ||
|
|
07934d26eb | ||
|
|
3ae97a3e13 | ||
|
|
5f22e68985 | ||
|
|
df1dc17c51 | ||
|
|
71aa405b26 | ||
|
|
2d2986922d | ||
|
|
7b5dbef166 | ||
|
|
da61a49bd8 | ||
|
|
002802bb20 | ||
|
|
45b59494ca | ||
|
|
83530ec7b9 | ||
|
|
918b70185e | ||
|
|
6aa89b77dc | ||
|
|
1679b45cd6 | ||
|
|
4728a1a5a9 | ||
|
|
c35a387520 | ||
|
|
d7aae66886 | ||
|
|
67ab9d577a | ||
|
|
d987cb23c1 | ||
|
|
10d045d743 | ||
|
|
44818993ff | ||
|
|
970b9c3384 | ||
|
|
89f94be96a | ||
|
|
52cfd93301 | ||
|
|
2a8d103dc6 | ||
|
|
d452051c0a | ||
|
|
99b32fc6c3 | ||
|
|
5b4f4e3d77 | ||
|
|
c66b451efd | ||
|
|
4e9437114b | ||
|
|
52c7321c78 | ||
|
|
ef94646083 | ||
|
|
37f3396be3 | ||
|
|
f8f461b804 | ||
|
|
5396daa7f6 | ||
|
|
bb51dc23fc | ||
|
|
2733838574 | ||
|
|
a23d92158b | ||
|
|
99225244f1 | ||
|
|
e30f1b9f82 | ||
|
|
054bbead72 | ||
|
|
30294e9009 | ||
|
|
bf5bc14c87 | ||
|
|
f6dd13af7a | ||
|
|
5760b4b264 | ||
|
|
49b995b234 | ||
|
|
8cf5ca9589 | ||
|
|
ae36a3905a | ||
|
|
bfd847f0a6 | ||
|
|
e14cb44e13 | ||
|
|
17ad63dabf | ||
|
|
ef81702219 | ||
|
|
7cbe6244ae | ||
|
|
112a8b9c8b | ||
|
|
98b692d845 | ||
|
|
f4f7c87640 | ||
|
|
39cda08d07 | ||
|
|
3a1611e5c4 | ||
|
|
5af5cbbb37 | ||
|
|
a657ebd528 | ||
|
|
e628aedbc1 | ||
|
|
7736cf1e6d | ||
|
|
41e74df8d3 | ||
|
|
ac3b8ebfcc | ||
|
|
e0543de8ef | ||
|
|
f243a52823 | ||
|
|
94013ddb70 | ||
|
|
9cfcbd3929 | ||
|
|
6cfbdc6062 | ||
|
|
d3334b29d9 | ||
|
|
94ce6f1dd1 | ||
|
|
c623e90ebc | ||
|
|
b6e49b59a7 | ||
|
|
f416e96414 | ||
|
|
347f53baa4 | ||
|
|
9ecf39febe | ||
|
|
582b03f21f | ||
|
|
ff0b94c78d | ||
|
|
f5c8b04958 | ||
|
|
36818057a3 | ||
|
|
a5cff5bc3d | ||
|
|
a4bff305b3 | ||
|
|
6b149e2fc9 | ||
|
|
38fce1665b | ||
|
|
f51a98768c | ||
|
|
4d04c323f6 | ||
|
|
94116bfd53 | ||
|
|
a05761e63f | ||
|
|
89469d38ae | ||
|
|
bd2616e888 | ||
|
|
02e996436d | ||
|
|
a3f2e0b56c | ||
|
|
337e49208a | ||
|
|
b052925424 | ||
|
|
970c867ee4 | ||
|
|
c4295d6a81 | ||
|
|
d60cab1962 | ||
|
|
b01e327f9d | ||
|
|
09af2813d0 | ||
|
|
2f69a84352 | ||
|
|
13260fa219 | ||
|
|
9a90093dda | ||
|
|
8292408c79 | ||
|
|
9165f83084 | ||
|
|
c2ef371089 | ||
|
|
fa9472d4aa | ||
|
|
037e92c447 | ||
|
|
170804d4df | ||
|
|
ac129a2576 | ||
|
|
db8d420860 | ||
|
|
7d7cbb1760 | ||
|
|
89979f1bee | ||
|
|
bd241e8e6c | ||
|
|
7939b0ae4d | ||
|
|
6b57ba2d7d | ||
|
|
2c5465f9a6 | ||
|
|
1565129cfb | ||
|
|
b8d4a58207 | ||
|
|
900f03dc8a | ||
|
|
0c4c4a9d18 | ||
|
|
ff4ed38329 | ||
|
|
5f78ab7b73 | ||
|
|
6556d555bd | ||
|
|
d318ff82b8 | ||
|
|
ff53a826f9 | ||
|
|
abb14dc17a | ||
|
|
a45c86eed1 | ||
|
|
c30380d423 | ||
|
|
d79e777911 | ||
|
|
335e635ec7 | ||
|
|
a5754a8552 | ||
|
|
a8c91ff6ba | ||
|
|
6285fd8010 | ||
|
|
c69f20c648 | ||
|
|
88c93a7c11 | ||
|
|
92629468c0 | ||
|
|
56a1d4f966 | ||
|
|
799aedcaed | ||
|
|
de42ce73f7 | ||
|
|
962e09906e | ||
|
|
f607f55683 | ||
|
|
8e464f59ac | ||
|
|
91b524813c | ||
|
|
1b45047826 | ||
|
|
edd4d90b12 | ||
|
|
0a3ad8a880 | ||
|
|
82615791a2 | ||
|
|
4548be34f0 | ||
|
|
2b5af2c36a | ||
|
|
a939130748 | ||
|
|
b7e373c40f | ||
|
|
dae0264a58 | ||
|
|
b2e50e13d4 | ||
|
|
cb4404a833 | ||
|
|
38bb81cfe7 | ||
|
|
1667f9bd52 | ||
|
|
1ec61a9fe6 | ||
|
|
98c84b6bb9 | ||
|
|
76f48b3b13 | ||
|
|
8596ae5c4a | ||
|
|
c1482eaacd | ||
|
|
e23fe4a925 | ||
|
|
8939537fb5 | ||
|
|
2f08b90200 | ||
|
|
68ca2c5e51 | ||
|
|
343195477b | ||
|
|
4caf4ef09b | ||
|
|
54677f96f4 | ||
|
|
0ba987e126 | ||
|
|
0325628693 | ||
|
|
e522633c98 | ||
|
|
e14c00f135 | ||
|
|
b0a4a49f99 | ||
|
|
5b4839369e | ||
|
|
1ff02b9f1c | ||
|
|
e2c1fa3d43 | ||
|
|
39a466e316 | ||
|
|
9e940eacc3 | ||
|
|
2e38f237de | ||
|
|
7f36ffdafd | ||
|
|
39b2da3230 | ||
|
|
c489829efb | ||
|
|
e30e129e2a | ||
|
|
32d5b25013 | ||
|
|
6227a0dfb9 | ||
|
|
e234c6146e | ||
|
|
c146731e5a | ||
|
|
5ee242be4a | ||
|
|
556878a774 | ||
|
|
00aa4876e9 | ||
|
|
f72f948744 | ||
|
|
3ad4818488 | ||
|
|
b3cc44cea5 | ||
|
|
2f89082df2 | ||
|
|
108db045ce | ||
|
|
9cb3631ad0 | ||
|
|
743ff35bcf | ||
|
|
df706f61db | ||
|
|
791e759b40 | ||
|
|
22fdc1d933 | ||
|
|
aa383e3ca1 | ||
|
|
472fda6645 | ||
|
|
bd35de80c3 | ||
|
|
52fe19e5f9 | ||
|
|
c2f09b1715 | ||
|
|
1ccc1fa47b | ||
|
|
2972d38cef | ||
|
|
4662606907 | ||
|
|
2c50aa789a | ||
|
|
9e62b250ac | ||
|
|
03722e5e70 | ||
|
|
7867052339 | ||
|
|
8a0252ccfe | ||
|
|
e84293c415 | ||
|
|
250e83ad7e | ||
|
|
660724741c | ||
|
|
a5f87597ad | ||
|
|
ebef35a573 | ||
|
|
44fcd4e305 | ||
|
|
90704e292b | ||
|
|
b83dd76c89 | ||
|
|
7ab4b90d07 | ||
|
|
fd4ff2bf37 | ||
|
|
76f93d8875 | ||
|
|
30359f52ab | ||
|
|
0020f029d1 | ||
|
|
d248df3826 | ||
|
|
dc19ad4c4c | ||
|
|
8eba3fef0a | ||
|
|
e93d2104fd | ||
|
|
a7aa58e524 | ||
|
|
c442906379 | ||
|
|
bb0b01aa01 | ||
|
|
88a962b3ab | ||
|
|
3173783620 | ||
|
|
5d0cb14f71 | ||
|
|
60d84b7d06 | ||
|
|
93d77e6b25 | ||
|
|
fd13b18ef7 | ||
|
|
033e567d2a | ||
|
|
d03d4b7b4c | ||
|
|
38ddd3102d | ||
|
|
6dd501217a | ||
|
|
e58387b4f2 | ||
|
|
1de58b7be1 | ||
|
|
58d8deefcd | ||
|
|
acd05cdcc5 | ||
|
|
1a67b5b3fc | ||
|
|
473d4a752a | ||
|
|
33a5e389fd | ||
|
|
287a13b944 | ||
|
|
5282db6871 | ||
|
|
b79618d752 | ||
|
|
391930e2cb | ||
|
|
4630cc8ee0 | ||
|
|
4e83466af3 | ||
|
|
b7e08c7ddc | ||
|
|
701208484a | ||
|
|
02252d1254 | ||
|
|
8347f182ef | ||
|
|
7e4faa20b7 | ||
|
|
717eef25da | ||
|
|
31fbebdbb9 | ||
|
|
afe224ae08 | ||
|
|
d09f75a815 | ||
|
|
812ce40e35 | ||
|
|
f8e6e4e3db | ||
|
|
66cad78c41 | ||
|
|
4e91f47e8b | ||
|
|
4b753d03dc | ||
|
|
6f18749df1 | ||
|
|
eab0ce8aee | ||
|
|
ba00b4d675 | ||
|
|
9bc8638d80 | ||
|
|
d9c8351025 | ||
|
|
73a16f6075 | ||
|
|
a92372ec7e | ||
|
|
4967d19b6a | ||
|
|
7b773f6fd2 | ||
|
|
69681a27d6 | ||
|
|
0adcfc693d | ||
|
|
b73507fd2b | ||
|
|
bea6bd013c | ||
|
|
9a881012e2 | ||
|
|
d62df7643b | ||
|
|
7d40320a5b | ||
|
|
09456b923f | ||
|
|
39e6c11c39 | ||
|
|
5aef014773 | ||
|
|
9738884ff8 | ||
|
|
27b625a614 | ||
|
|
096e9fc326 | ||
|
|
f577d6b45d | ||
|
|
bd7a28af5b | ||
|
|
104b0a504c | ||
|
|
40bfbe0d7b | ||
|
|
4bf5984ace | ||
|
|
4b64fb7f47 | ||
|
|
7e11104b9c | ||
|
|
8369d311bf | ||
|
|
d8eb57548d | ||
|
|
d8072f0e05 | ||
|
|
3d7016f500 | ||
|
|
41e3a0390f | ||
|
|
42a9a1976d | ||
|
|
569991e55c | ||
|
|
b7adf115ee | ||
|
|
7cf0f552f5 | ||
|
|
246c614635 | ||
|
|
df62f08ec3 | ||
|
|
b6f71eeb3b | ||
|
|
e2a7e07a0a | ||
|
|
b3acd36092 | ||
|
|
7a037b9c66 | ||
|
|
c1cf359b43 | ||
|
|
2d883d6d20 | ||
|
|
2fa18f5855 | ||
|
|
a4ce92c963 | ||
|
|
c84d39a803 | ||
|
|
d59eaa2a91 | ||
|
|
f7ad87449a | ||
|
|
08bfae216c | ||
|
|
64db784d8d | ||
|
|
5a91b8db48 | ||
|
|
58f73f3ed9 | ||
|
|
1852578136 | ||
|
|
fdb2ba8146 | ||
|
|
92ea6ee9aa | ||
|
|
fb4e95bf8e | ||
|
|
cedbf039d2 | ||
|
|
d1711f0376 | ||
|
|
047b9f544a | ||
|
|
8ea7528d41 | ||
|
|
43bf55d503 | ||
|
|
b9a5e1db69 | ||
|
|
03d421c629 | ||
|
|
066e7d1e39 | ||
|
|
4fd641dc74 | ||
|
|
16b690089d | ||
|
|
a77fbfe0c2 | ||
|
|
b36a776f51 | ||
|
|
9c39dd7303 | ||
|
|
eb5a3d1d36 | ||
|
|
d465f23309 | ||
|
|
987a6b3cf8 | ||
|
|
6b3d68f9aa | ||
|
|
fcd34265c8 | ||
|
|
088b0cf1e7 | ||
|
|
e6061fdd9c | ||
|
|
cf8a30cc4e | ||
|
|
6ba1e10b8b | ||
|
|
2a96864c07 | ||
|
|
48fceac0fe | ||
|
|
ad246deb9e | ||
|
|
c2509fad9c | ||
|
|
eeb216e08d | ||
|
|
2761608c1e | ||
|
|
27536388f2 | ||
|
|
21c8bd54f5 | ||
|
|
fa5619fad7 | ||
|
|
022c59a094 | ||
|
|
bc8abdfc62 | ||
|
|
d8cffc4b22 | ||
|
|
312760f86a | ||
|
|
5ea22c602c | ||
|
|
7540aa6b72 | ||
|
|
84cc89832b | ||
|
|
9554079e4b | ||
|
|
481faf8da1 | ||
|
|
fd6c7cd48f | ||
|
|
9441ea572d | ||
|
|
0414e4a6a6 | ||
|
|
158f14df89 | ||
|
|
93a80fe256 | ||
|
|
398e10588c | ||
|
|
6d1f610085 | ||
|
|
bd95dad85e | ||
|
|
bf8301bd6a | ||
|
|
231006ab26 | ||
|
|
744f4d0f42 | ||
|
|
ad269751b8 | ||
|
|
4c77f07bc9 | ||
|
|
e974cb8ec5 | ||
|
|
48c02e1018 | ||
|
|
f398ee90b0 | ||
|
|
23fcdc0365 | ||
|
|
e91da1cd8d | ||
|
|
4e0d3725cb | ||
|
|
f45cb1560f | ||
|
|
7214b9f2c2 | ||
|
|
37990996b7 | ||
|
|
024b58097e | ||
|
|
2cc1fe7fe2 | ||
|
|
e0cd48df92 | ||
|
|
d45d2f5123 | ||
|
|
eb5e2c94a3 | ||
|
|
ced74f5b45 | ||
|
|
01e557a689 | ||
|
|
b8b01558ce | ||
|
|
08c90e0909 | ||
|
|
052408982a | ||
|
|
68c57cc4eb | ||
|
|
9eb4f3f843 | ||
|
|
4ad7b38648 | ||
|
|
ce2463588d | ||
|
|
9804e3eca0 | ||
|
|
e9fb3a3ebb | ||
|
|
b65b97870f | ||
|
|
0c243e0dc2 | ||
|
|
d88b1fbec0 | ||
|
|
0781cb1d41 | ||
|
|
eb2ed341a2 | ||
|
|
e5f6824304 | ||
|
|
880124bbe0 | ||
|
|
b719fd1c15 | ||
|
|
464b431741 | ||
|
|
ff0e4f50da | ||
|
|
8ba23e84ca | ||
|
|
4cbddf66d3 | ||
|
|
9ba9c3b9c5 | ||
|
|
adbcc07bae | ||
|
|
83ed6a4297 | ||
|
|
1c07974f6c | ||
|
|
c3e430b472 | ||
|
|
a8fef06aa8 | ||
|
|
281eb346a5 | ||
|
|
15c8bd7d6d | ||
|
|
d0d1da3456 | ||
|
|
7c73ff78bc | ||
|
|
e0309dc6c0 | ||
|
|
cd6009c180 | ||
|
|
29bd4e96d6 | ||
|
|
5d5ca0d7aa | ||
|
|
e7df4b8d6d | ||
|
|
fbd8a97ffd | ||
|
|
4147ffa503 | ||
|
|
be2ef79686 | ||
|
|
120406d115 | ||
|
|
d72ae6102b | ||
|
|
4adfad8708 | ||
|
|
2e6d65378f | ||
|
|
4ec1a9af39 | ||
|
|
1109bd35e7 | ||
|
|
81efd3251c | ||
|
|
24dc12023b | ||
|
|
f53be57f0d | ||
|
|
9db4559b0c | ||
|
|
23a249ca0f | ||
|
|
3171958a8c | ||
|
|
422f1b2b5e | ||
|
|
fed3ec9616 | ||
|
|
751867d5b8 | ||
|
|
c4fcc59efd | ||
|
|
528bbba6ed | ||
|
|
905c05ba06 | ||
|
|
fcacf28c45 | ||
|
|
3e5d82c665 | ||
|
|
1bea7654b8 | ||
|
|
38ea778ccf | ||
|
|
31f300f6d8 | ||
|
|
4e8bb688aa | ||
|
|
563d623278 | ||
|
|
24790e8b2a | ||
|
|
58806dee68 | ||
|
|
4fda12b512 | ||
|
|
0c62465a22 | ||
|
|
785b0caaf2 | ||
|
|
3d4c50d481 | ||
|
|
c0975ed15e | ||
|
|
ce6de6efa6 | ||
|
|
561c1fc338 | ||
|
|
e94affe588 | ||
|
|
43e3648ba7 | ||
|
|
63938c6fd3 | ||
|
|
f21a1093f3 | ||
|
|
72318fa696 | ||
|
|
babc581c5d | ||
|
|
c28fb4164b | ||
|
|
a6db08992f | ||
|
|
2dea5e0ffc | ||
|
|
9cab4d510a | ||
|
|
41621826d8 | ||
|
|
2149030dbb | ||
|
|
8c0bd7e5e3 | ||
|
|
5283682c47 | ||
|
|
b53d20d2ee | ||
|
|
ed6bdf97d1 | ||
|
|
93cfa564f7 | ||
|
|
579b8fce96 | ||
|
|
d1d9462423 | ||
|
|
299f9c4a26 | ||
|
|
5c27e974fb | ||
|
|
53bd4b1ea9 | ||
|
|
3d10fff7de | ||
|
|
8107d65504 | ||
|
|
9a4cebfb61 | ||
|
|
5c81833415 | ||
|
|
d88ca50de0 | ||
|
|
b75b53d05a | ||
|
|
c2cae5b2fc | ||
|
|
30e962b447 | ||
|
|
f710bb535e | ||
|
|
814b02900b | ||
|
|
4958353335 | ||
|
|
9884c52c4e | ||
|
|
0cd4fc8655 | ||
|
|
5d07c5a0b2 | ||
|
|
cf20b3a3c3 | ||
|
|
dbe4acd47d | ||
|
|
b7a0f5bee5 | ||
|
|
0adb62b485 | ||
|
|
a439608fe7 | ||
|
|
e82efd24d3 | ||
|
|
3d1f3ed068 | ||
|
|
bac972de53 | ||
|
|
95310991b8 | ||
|
|
f60a759dca | ||
|
|
4f6f829dc3 | ||
|
|
8962ebd175 | ||
|
|
218b3c87db | ||
|
|
c12a0f8cdf | ||
|
|
4a41ccb4e6 | ||
|
|
0d1f53d58d | ||
|
|
fea07917fa | ||
|
|
003c2e0dca | ||
|
|
ce38ef6289 | ||
|
|
2457c58817 | ||
|
|
ab6dd66bad | ||
|
|
d430fe35c5 | ||
|
|
9650c71155 | ||
|
|
95da7551d2 | ||
|
|
667473f90e | ||
|
|
cf9e17ebfd | ||
|
|
ec55909305 | ||
|
|
3e03f7c12a | ||
|
|
edc2005b2c | ||
|
|
72f3fa6eda | ||
|
|
48c02c6f55 | ||
|
|
8b7643332b | ||
|
|
639619ff93 | ||
|
|
0a08ef0ed4 | ||
|
|
b3f35c579b | ||
|
|
bcb74d01b6 | ||
|
|
8a8b88af13 | ||
|
|
58ed405c88 | ||
|
|
a3d4f80599 | ||
|
|
7bfd55f3f0 | ||
|
|
153b5de1d4 | ||
|
|
932b7a094d | ||
|
|
47b8c661e7 | ||
|
|
3bb0f51d08 | ||
|
|
32fc5ccd3e | ||
|
|
4f3cba32da | ||
|
|
b2c60ba884 | ||
|
|
a2323a7bb2 | ||
|
|
537ed2d11f | ||
|
|
f318cc5e28 | ||
|
|
1001cc607e | ||
|
|
35d480bc48 | ||
|
|
37f51ef983 | ||
|
|
943d7ce31a | ||
|
|
bc54ddf19f | ||
|
|
7d091d18ee | ||
|
|
599e24634c | ||
|
|
e998edd083 | ||
|
|
e15ca55558 | ||
|
|
23a2801284 | ||
|
|
9a6da3f46f | ||
|
|
fbb881bb42 | ||
|
|
87d65c150b | ||
|
|
bb2fcd5b00 | ||
|
|
cfe8b1a764 | ||
|
|
aee1dff718 | ||
|
|
54bd41903b | ||
|
|
c813df9afe | ||
|
|
e312f66823 | ||
|
|
648c10c91f | ||
|
|
2cf902c6c3 | ||
|
|
26934fae02 | ||
|
|
74ba9364f4 | ||
|
|
18222420ee | ||
|
|
89a37766df | ||
|
|
cf02471db7 | ||
|
|
ff9b7de615 | ||
|
|
b7ad8faaee | ||
|
|
34facfe764 | ||
|
|
c83b6288aa | ||
|
|
b66f86de71 | ||
|
|
581cd19446 |
No files matched your search
@@ -1,3 +1,9 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help improve OctoPrint
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
READ THE FOLLOWING FIRST:
|
READ THE FOLLOWING FIRST:
|
||||||
|
|
||||||
@@ -12,7 +18,7 @@ plugins and not unofficial OctoPrint versions).
|
|||||||
|
|
||||||
Do not seek support here ("I need help with ...", "I have a
|
Do not seek support here ("I need help with ...", "I have a
|
||||||
question ..."), that belongs on the community forum at
|
question ..."), that belongs on the community forum at
|
||||||
discourse.octoprint.org, NOT here.
|
community.octoprint.org, NOT here.
|
||||||
|
|
||||||
Mark requests with a "[Request]" prefix in the title please. For bug
|
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
|
reports fully fill out the bug reporting template (if you don't know
|
||||||
@@ -39,9 +45,10 @@ 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:
|
Ideally provide exact steps to follow in order to reproduce your problem:
|
||||||
-->
|
-->
|
||||||
|
|
||||||
1. ...
|
1. Go to '...'
|
||||||
2. ...
|
2. Click on '....'
|
||||||
3. ...
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
If you encountered a problem with specific files of any sorts, make sure
|
If you encountered a problem with specific files of any sorts, make sure
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Please make sure to add [Request] to your issue's title. Thank you!
|
||||||
|
-->
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
@@ -31,9 +31,12 @@ OctoPrint.egg-info
|
|||||||
*.codekit
|
*.codekit
|
||||||
|
|
||||||
venv
|
venv
|
||||||
|
venv2
|
||||||
|
venv3
|
||||||
venv26
|
venv26
|
||||||
venv27
|
venv27
|
||||||
venv33
|
venv33
|
||||||
venv34
|
venv34
|
||||||
venv35
|
venv35
|
||||||
venv36
|
venv36
|
||||||
|
venv37
|
||||||
+11
-1
@@ -1,12 +1,22 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
language: python
|
language: python
|
||||||
|
dist: xenial
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- python: '3.7'
|
||||||
|
env: RUN_FLAKE8=true
|
||||||
|
|
||||||
python:
|
python:
|
||||||
|
- "3.7"
|
||||||
|
- "3.6"
|
||||||
- "2.7"
|
- "2.7"
|
||||||
install:
|
install:
|
||||||
- pip install -e .[develop]
|
- pip install -e .[develop]
|
||||||
script:
|
script:
|
||||||
- nosetests --with-doctest
|
- test -n "$RUN_FLAKE8" || pytest
|
||||||
|
- test -z "$RUN_FLAKE8" || flake8 --ignore=D,E,W,F401 src/ tests setup.py
|
||||||
sudo: false
|
sudo: false
|
||||||
git:
|
git:
|
||||||
depth: 250
|
depth: 250
|
||||||
+7
-7
@@ -18,16 +18,16 @@ prerelease
|
|||||||
HEAD
|
HEAD
|
||||||
\(detached.*
|
\(detached.*
|
||||||
|
|
||||||
# maintenance is currently the branch for preparation of maintenance release 1.3.9
|
# maintenance is currently the branch for preparation of maintenance release 1.3.12
|
||||||
# so are any fix/... and improve/... branches
|
# so are any fix/... and improve/... branches
|
||||||
maintenance 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
maintenance 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
|
||||||
fix/.* 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
fix/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
|
||||||
improve/.* 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
improve/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev
|
||||||
|
|
||||||
# staging/maintenance is currently the branch for preparation of 1.3.9rc5
|
# staging/maintenance is currently the branch for preparation of 1.3.11rc4
|
||||||
# so is regressionfix/...
|
# so is regressionfix/...
|
||||||
staging/maintenance 1.3.9rc5 71b2cc87a36d403e09325c90134a002c5229b6aa pep440-dev
|
staging/maintenance 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev
|
||||||
regressionfix/.* 1.3.9rc5 71b2cc87a36d403e09325c90134a002c5229b6aa pep440-dev
|
regressionfix/.* 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev
|
||||||
|
|
||||||
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
|
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
|
||||||
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
|
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
|
||||||
+14
-1
@@ -69,12 +69,13 @@ date of first contribution):
|
|||||||
* [Philipp Baum](https://github.com/philphilphil)
|
* [Philipp Baum](https://github.com/philphilphil)
|
||||||
* [Kyle Evans](https://github.com/kevans91)
|
* [Kyle Evans](https://github.com/kevans91)
|
||||||
* [Javier Martínez Arrieta](https://github.com/Javierma)
|
* [Javier Martínez Arrieta](https://github.com/Javierma)
|
||||||
* ["MirceaDan"](https://github.com/ByReaL)
|
* [Mircea Dan Gheorghe](https://github.com/ByReaL)
|
||||||
* [Ovidiu Hossu](https://github.com/MoonshineSG)
|
* [Ovidiu Hossu](https://github.com/MoonshineSG)
|
||||||
* [Eyck Jentzsch](https://github.com/eyck)
|
* [Eyck Jentzsch](https://github.com/eyck)
|
||||||
* [Mathias Rangel Wulff](https://github.com/mathiasrw)
|
* [Mathias Rangel Wulff](https://github.com/mathiasrw)
|
||||||
* [Clemens Niemeyer](https://github.com/clemniem)
|
* [Clemens Niemeyer](https://github.com/clemniem)
|
||||||
* ["I-am-me"](https://github.com/I-am-me)
|
* ["I-am-me"](https://github.com/I-am-me)
|
||||||
|
* [J-J Heinonen](https://github.com/jammi)
|
||||||
* [Noah Martin](https://github.com/noahsmartin)
|
* [Noah Martin](https://github.com/noahsmartin)
|
||||||
* [Eyal Soha](https://github.com/eyal0)
|
* [Eyal Soha](https://github.com/eyal0)
|
||||||
* [Greg Hulands](https://github.com/ghulands)
|
* [Greg Hulands](https://github.com/ghulands)
|
||||||
@@ -91,7 +92,19 @@ date of first contribution):
|
|||||||
* [Ganey](https://github.com/ganey)
|
* [Ganey](https://github.com/ganey)
|
||||||
* [Sven Lohrmann](https://github.com/malnvenshorn)
|
* [Sven Lohrmann](https://github.com/malnvenshorn)
|
||||||
* [Andy Castille](https://github.com/klikini)
|
* [Andy Castille](https://github.com/klikini)
|
||||||
|
* [Zachary Nofzinger](https://github.com/ZachNo)
|
||||||
|
* [Gaston Dombiak](https://github.com/gdombiak)
|
||||||
* [Brad Fisher](https://github.com/bradcfisher)
|
* [Brad Fisher](https://github.com/bradcfisher)
|
||||||
|
* [Aldo Hoeben](https://github.com/fieldofview)
|
||||||
|
* [Henning Groß](https://github.com/hgross)
|
||||||
|
* [Jubaleth](https://github.com/jubaleth)
|
||||||
|
* [Matthias Urlichs](https://github.com/smurfix)
|
||||||
|
* [Daniel Joyce](https://github.com/DanielJoyce)
|
||||||
|
* [Andy Qua](https://github.com/AndyQ)
|
||||||
|
* [Fabio Santos](https://github.com/Fabi0San)
|
||||||
|
* [Jack Wilsdon](https://github.com/jackwilsdon)
|
||||||
|
* [Ryan Finnie](https://github.com/rfinnie)
|
||||||
|
* [Timur Duehr](https://github.com/tduehr)
|
||||||
|
|
||||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
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
|
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||||
|
|||||||
+287
-1017
File diff suppressed because it is too large.
Load diff
+9
-9
@@ -36,14 +36,14 @@ nothing but ticket management.
|
|||||||
- If you want to post a **feature request** or a **documentation request**, add `[Request]`
|
- If you want to post a **feature request** or a **documentation request**, add `[Request]`
|
||||||
to your issue's title (e.g. `[Request] Awesome new feature`). A question on how to run/change/setup
|
to your issue's title (e.g. `[Request] Awesome new feature`). A question on how to run/change/setup
|
||||||
something is **not** what qualifies as a request here, use the
|
something is **not** what qualifies as a request here, use the
|
||||||
[community forum at discourse.octoprint.org](https://discourse.octoprint.org) for
|
[community forum at community.octoprint.org](https://community.octoprint.org) for
|
||||||
such support issues.
|
such support issues.
|
||||||
- If you are a **developer** that wants to brainstorm a pull request or possible
|
- If you are a **developer** that wants to brainstorm a pull request or possible
|
||||||
changes to the plugin system, please get in touch on the
|
changes to the plugin system, please get in touch on the
|
||||||
[community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/development).
|
[community forum at community.octoprint.org](https://community.octoprint.org/c/development).
|
||||||
- If you need **support**, have a **question** or some **other reason** that
|
- If you need **support**, have a **question** or some **other reason** that
|
||||||
doesn't fit any of the above categories, the issue tracker is not the right place.
|
doesn't fit any of the above categories, the issue tracker is not the right place.
|
||||||
Consult the [community forum at discourse.octoprint.org](https://discourse.octoprint.org/c/support) instead.
|
Consult the [community forum at community.octoprint.org](https://community.octoprint.org/c/support) instead.
|
||||||
|
|
||||||
No matter what kind of ticket you create, never mix two or more "ticket reasons"
|
No matter what kind of ticket you create, never mix two or more "ticket reasons"
|
||||||
into one ticket: One ticket per bug, request, brainstorming thread please.
|
into one ticket: One ticket per bug, request, brainstorming thread please.
|
||||||
@@ -75,7 +75,7 @@ following section *completely* and also follow the instructions in the
|
|||||||
**OctoPrint doesn't manage your network connection or your webcam nor
|
**OctoPrint doesn't manage your network connection or your webcam nor
|
||||||
can it fix your printer not getting detected as a serial interface** -
|
can it fix your printer not getting detected as a serial interface** -
|
||||||
if you have any kinds of problems with that, get in touch on the
|
if you have any kinds of problems with that, get in touch on the
|
||||||
[community forum](https://discourse.octoprint.org).
|
[community forum](https://community.octoprint.org).
|
||||||
|
|
||||||
**This is not the bug tracker of OctoPi**, which is the preconfigured
|
**This is not the bug tracker of OctoPi**, which is the preconfigured
|
||||||
Raspberry Pi image including OctoPrint among other things - that one can be found
|
Raspberry Pi image including OctoPrint among other things - that one can be found
|
||||||
@@ -126,7 +126,7 @@ following section *completely* and also follow the instructions in the
|
|||||||
there's now also a [red herring](https://en.wikipedia.org/wiki/Red_herring) interfering - so please be
|
there's now also a [red herring](https://en.wikipedia.org/wiki/Red_herring) interfering - so please be
|
||||||
very diligent here!
|
very diligent here!
|
||||||
|
|
||||||
If in doubt about any of the above - get in touch on the [community forum](https://discourse.octoprint.org)
|
If in doubt about any of the above - get in touch on the [community forum](https://community.octoprint.org)
|
||||||
instead of opening a ticket here. If you are actually running into a bug, we'll figure it out together
|
instead of opening a ticket here. If you are actually running into a bug, we'll figure it out together
|
||||||
there.
|
there.
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ plugins and not unofficial OctoPrint versions).
|
|||||||
|
|
||||||
Do not seek support here ("I need help with ...", "I have a
|
Do not seek support here ("I need help with ...", "I have a
|
||||||
question ..."), that belongs on the community forum at
|
question ..."), that belongs on the community forum at
|
||||||
discourse.octoprint.org, NOT here.
|
community.octoprint.org, NOT here.
|
||||||
|
|
||||||
Mark requests with a "[Request]" prefix in the title please. For bug
|
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
|
reports fully fill out the bug reporting template (if you don't know
|
||||||
@@ -275,11 +275,11 @@ all requested information or your ticket will be closed.
|
|||||||
|
|
||||||
### Where can I find which version and branch I'm on?
|
### Where can I find which version and branch I'm on?
|
||||||
|
|
||||||
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/how-can-i-find-out-the-version-of-octoprint-or-octopi-i-am-running/204/1).
|
Please refer to [this FAQ entry](https://community.octoprint.org/t/how-can-i-find-out-the-version-of-octoprint-or-octopi-i-am-running/204/1).
|
||||||
|
|
||||||
### Where can I find those log files you keep talking about?
|
### Where can I find those log files you keep talking about?
|
||||||
|
|
||||||
Please refer to [this FAQ entry](https://discourse.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299/1).
|
Please refer to [this FAQ entry](https://community.octoprint.org/t/where-can-i-find-octoprints-and-octopis-log-files/299/1).
|
||||||
|
|
||||||
### Where can I find my browser's error console?
|
### Where can I find my browser's error console?
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ the documentation.
|
|||||||
system - maybe that's the actual PR you have been waiting for to contribute :)
|
system - maybe that's the actual PR you have been waiting for to contribute :)
|
||||||
2. If you plan to make **any large or otherwise disruptive changes to the
|
2. If you plan to make **any large or otherwise disruptive changes to the
|
||||||
code or appearance, please get in touch on the
|
code or appearance, please get in touch on the
|
||||||
[forums](https://discourse.octoprint.org/c/development)** first so
|
[forums](https://community.octoprint.org/c/development)** first so
|
||||||
that we can determine if it's a good time for your specific pull
|
that we can determine if it's a good time for your specific pull
|
||||||
request. It might be that we're currently in the process of making
|
request. It might be that we're currently in the process of making
|
||||||
heavy changes to the code locations you'd target as well, or your
|
heavy changes to the code locations you'd target as well, or your
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||

|

|
||||||
[](https://travis-ci.org/foosel/OctoPrint)
|
[](https://travis-ci.org/foosel/OctoPrint)
|
||||||
[](https://discourse.octoprint.org)
|
[](https://community.octoprint.org)
|
||||||
[](https://chat.octoprint.org)
|
[](https://chat.octoprint.org)
|
||||||
[](https://twitter.com/OctoPrint3d)
|
[](https://twitter.com/OctoPrint3d)
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ and released under the [GNU Affero General Public License V3](http://www.gnu.org
|
|||||||
|
|
||||||
Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme).
|
Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme).
|
||||||
|
|
||||||
The community forum is available at [discourse.octoprint.org](https://discourse.octoprint.org/?utm_source=github&utm_medium=readme).
|
The community forum is available at [community.octoprint.org](https://community.octoprint.org/?utm_source=github&utm_medium=readme).
|
||||||
|
|
||||||
The official IRC channel is [#octoprint on freenode](https://chat.octoprint.org). Its logs can be found [here](https://freenode.logbot.info/octoprint).
|
The official IRC channel is [#octoprint on freenode](https://chat.octoprint.org). Its logs can be found [here](https://freenode.logbot.info/octoprint).
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ You are currently looking at the source code repository of OctoPrint. If you alr
|
|||||||
(e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only
|
(e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only
|
||||||
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
|
want to find out how to use it, [the documentation](http://docs.octoprint.org/) and [the public wiki](https://github.com/foosel/OctoPrint/wiki)
|
||||||
might be of more interest for you. You might also want to subscribe to join
|
might be of more interest for you. You might also want to subscribe to join
|
||||||
[the community forum at discourse.octoprint.org](https://discourse.octoprint.org) where there are other active users who might be
|
[the community forum at community.octoprint.org](https://community.octoprint.org) where there are other active users who might be
|
||||||
able to help you with any questions you might have.
|
able to help you with any questions you might have.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
@@ -40,7 +40,7 @@ able to help you with any questions you might have.
|
|||||||
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
|
Contributions of all kinds are welcome, not only in the form of code but also with regards to the
|
||||||
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), debugging help
|
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), debugging help
|
||||||
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
|
in the [bug tracker](https://github.com/foosel/OctoPrint/issues), support of other users on
|
||||||
[the community forum at discourse.octoprint.org](https://discourse.octoprint.org)
|
[the community forum at community.octoprint.org](https://community.octoprint.org)
|
||||||
and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
|
and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
|
||||||
|
|
||||||
If you think something is bad about OctoPrint or its documentation the way it is, please help
|
If you think something is bad about OctoPrint or its documentation the way it is, please help
|
||||||
@@ -61,7 +61,7 @@ which is a custom SD card image that includes OctoPrint plus dependencies.
|
|||||||
The generic steps that should basically be done regardless of operating system
|
The generic steps that should basically be done regardless of operating system
|
||||||
and runtime environment are the following (as *regular
|
and runtime environment are the following (as *regular
|
||||||
user*, please keep your hands *off* of the `sudo` command here!) - this assumes
|
user*, please keep your hands *off* of the `sudo` command here!) - this assumes
|
||||||
you already have Python 2.7, pip and virtualenv set up on your system:
|
you already have Python 2.7, 3.6 or 3.7, pip and virtualenv set up on your system:
|
||||||
|
|
||||||
1. Checkout OctoPrint: `git clone https://github.com/foosel/OctoPrint.git`
|
1. Checkout OctoPrint: `git clone https://github.com/foosel/OctoPrint.git`
|
||||||
2. Change into the OctoPrint folder: `cd OctoPrint`
|
2. Change into the OctoPrint folder: `cd OctoPrint`
|
||||||
@@ -83,7 +83,7 @@ OctoPrint via `pip`:
|
|||||||
|
|
||||||
You should do this every time after pulling from the repository, since the dependencies may 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.
|
OctoPrint currently supports Python 2.7, 3.6 and 3.7.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -142,5 +142,8 @@ be edited from OctoPrint's settings dialog.
|
|||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
|
|
||||||
Cross-browser testing services are kindly provided by [BrowserStack](http://www.browserstack.com/).
|
Cross-browser testing services are kindly provided by [BrowserStack](https://www.browserstack.com/).
|
||||||
Profiling is done with the help of [PyVmMonitor](http://www.pyvmmonitor.com).
|
|
||||||
|
Profiling is done with the help of [PyVmMonitor](https://www.pyvmmonitor.com).
|
||||||
|
|
||||||
|
Error tracking is powered and sponsored by [Sentry](https://sentry.io).
|
||||||
+14
-20
@@ -6,58 +6,52 @@ thanks to everyone who contributed!
|
|||||||
|
|
||||||
## Patreon Patrons
|
## Patreon Patrons
|
||||||
|
|
||||||
|
* Andre Bubel
|
||||||
* Andrew Moorby
|
* Andrew Moorby
|
||||||
* Arnljot Arntsen
|
* Arnljot Arntsen
|
||||||
|
* Bjorn Breckenridge
|
||||||
* Boris Hussein
|
* Boris Hussein
|
||||||
* Brad Jackson
|
* Brad Jackson
|
||||||
* Brian E. Tyler
|
|
||||||
* Christian Petropolis
|
* Christian Petropolis
|
||||||
* Christian Wolf
|
* Christian Wolf
|
||||||
* COLLE+McVOY
|
* COLLE+McVOY
|
||||||
* D Brian Kimmel
|
* D Brian Kimmel
|
||||||
* DeltaMaker 3D Printers
|
* DeltaMaker 3D Printers
|
||||||
|
* Dorian Gray
|
||||||
* E3D BigBox
|
* E3D BigBox
|
||||||
|
* Eric Betts
|
||||||
* Ernesto Martinez
|
* Ernesto Martinez
|
||||||
* F. Kunsmann
|
* Franziska Kunsmann
|
||||||
* Frank Sander
|
|
||||||
* George Robles
|
* George Robles
|
||||||
* günter weber
|
* jean-claude migneault
|
||||||
* Hydra Research LLC
|
|
||||||
* James Seigel
|
|
||||||
* Jeff Moe
|
|
||||||
* Jeff Renfer
|
* Jeff Renfer
|
||||||
* Jefferson Hunt
|
* Jefferson Hunt
|
||||||
* Jeremiah Avery
|
* Jeremiah Avery
|
||||||
* Joseph Payne
|
* Joseph Payne
|
||||||
* Josh Daniels
|
|
||||||
* Joshua Wills
|
* Joshua Wills
|
||||||
* Justin Kaufman
|
* Justin Kaufman
|
||||||
* Kaile Riser
|
* Kaile Riser
|
||||||
* Kale Stedman
|
* Kale Stedman
|
||||||
* Kazuhiro Ogura
|
* Kazuhiro Ogura
|
||||||
* Kodama Inc.
|
* LA 3D Printer Repair
|
||||||
* Lewis Newby
|
|
||||||
* LulzBot®
|
* LulzBot®
|
||||||
* Makespace Madrid
|
* Makespace Madrid
|
||||||
* Mark Walker
|
* Mark Walker
|
||||||
* Martin Beattie
|
|
||||||
* Michael Aumock
|
* Michael Aumock
|
||||||
* Miles Flavel
|
* Miles Flavel
|
||||||
* mitchell hirsch
|
* Mosaic Manufacturing
|
||||||
* Noe Ruiz
|
* OMER MEHMET SUTAS
|
||||||
* Patrick McGinnis
|
* Patrick McGinnis
|
||||||
|
* Prof Yuh Wen Chen
|
||||||
* Randy C. Will
|
* Randy C. Will
|
||||||
* Robert Gusek
|
* Robert Gusek
|
||||||
* Roger Strolz
|
|
||||||
* Roy Cortes
|
|
||||||
* Rudolff Vang
|
|
||||||
* Samer Najia
|
* Samer Najia
|
||||||
|
* Shawn Lewis
|
||||||
* Simon Hallam
|
* Simon Hallam
|
||||||
* Stefan Krister
|
* Stefan Krister
|
||||||
* Sven Mueller
|
* Sven Mueller
|
||||||
* Symbiotic Devices
|
* TEVO 3D Printers
|
||||||
* Thomas Hatley
|
|
||||||
* Timothy D Hoogland
|
|
||||||
* Trent Shumay
|
* Trent Shumay
|
||||||
|
* Ulrich Kempken
|
||||||
|
|
||||||
and 1351 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
and 1544 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
* [Bootstrap Slider Knockout Binding](https://github.com/cosminstefanxp/bootstrap-slider-knockout-binding): MIT
|
* [Bootstrap Slider Knockout Binding](https://github.com/cosminstefanxp/bootstrap-slider-knockout-binding): MIT
|
||||||
* [Bootstrap Slider](http://seiyria.com/bootstrap-slider/): Apache License 2.0
|
* [Bootstrap Slider](http://seiyria.com/bootstrap-slider/): Apache License 2.0
|
||||||
* [Bootstrap Tabdrop](http://www.eyecon.ro/bootstrap-tabdrop): Apache License 2.0
|
* [Bootstrap Tabdrop](http://www.eyecon.ro/bootstrap-tabdrop): Apache License 2.0
|
||||||
|
* [css-element-queries](https://github.com/marcj/css-element-queries): MIT
|
||||||
* [Detect Mobile Browser](http://detectmobilebrowsers.com/): Public Domain
|
* [Detect Mobile Browser](http://detectmobilebrowsers.com/): Public Domain
|
||||||
* [Flot](http://www.flotcharts.org/): MIT
|
* [Flot](http://www.flotcharts.org/): MIT
|
||||||
* [JavaScript MD5](https://github.com/blueimp/JavaScript-MD5): MIT
|
* [JavaScript MD5](https://github.com/blueimp/JavaScript-MD5): MIT
|
||||||
@@ -36,7 +37,6 @@
|
|||||||
* [Awesome-Slugify](https://pypi.python.org/pypi/awesome-slugify): GPLv3
|
* [Awesome-Slugify](https://pypi.python.org/pypi/awesome-slugify): GPLv3
|
||||||
* [chainmap](https://bitbucket.org/jeunice/chainmap): Python
|
* [chainmap](https://bitbucket.org/jeunice/chainmap): Python
|
||||||
* [Click](http://click.pocoo.org/): BSD
|
* [Click](http://click.pocoo.org/): BSD
|
||||||
* [dateutil](https://dateutil.readthedocs.io/): BSD
|
|
||||||
* [emoji](https://github.com/carpedm20/emoji/): BSD
|
* [emoji](https://github.com/carpedm20/emoji/): BSD
|
||||||
* [feedparser](https://github.com/kurtmckee/feedparser): BSD
|
* [feedparser](https://github.com/kurtmckee/feedparser): BSD
|
||||||
* [Flask](http://flask.pocoo.org/): BSD
|
* [Flask](http://flask.pocoo.org/): BSD
|
||||||
|
|||||||
@@ -1,170 +0,0 @@
|
|||||||
.. _sec-api-apps:
|
|
||||||
|
|
||||||
****
|
|
||||||
Apps
|
|
||||||
****
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
|
|
||||||
.. _sec-api-apps-sessionkey:
|
|
||||||
|
|
||||||
Session Keys
|
|
||||||
============
|
|
||||||
|
|
||||||
OctoPrint offers a special API key type for apps to use, the so called App Session Key. These keys have a time based
|
|
||||||
validity and are generated by OctoPrint for requesting apps.
|
|
||||||
|
|
||||||
Obtaining those keys is based on a handshake procedure backed by cryptographic signatures using RSA. OctoPrint needs to
|
|
||||||
be aware of apps and their associated public keys (this can be achieved either via entries in ``config.yaml`` or by
|
|
||||||
installing app specific plugins which implement the ``AppPlugin`` type).
|
|
||||||
|
|
||||||
Apps can be registered within OctoPrint via ``config.yaml`` by adding them to the ``api`` > ``apps`` section, using the
|
|
||||||
application's id concatenated with its version as key, with the public key provided as item ``pubkey`` (stripped of the
|
|
||||||
``BEGIN RSA PUBLIC KEY`` and ``END RSA PUBLIC KEY`` separators and also newlines) and optionally also whether the app is
|
|
||||||
enabled or not (defaults to enabled, so can be left out if it's not to be set to disabled explicitly).
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
.. sourcecode:: yaml
|
|
||||||
|
|
||||||
api:
|
|
||||||
apps:
|
|
||||||
"com.example.my_octoprint_app:0.9":
|
|
||||||
pubkey: MEgCQQDYkr5Fv/YXK5ZL1uwRN4A61IagZaYLGqJ5JJGFo8wDrmpAMRqE9kK4+5hIDblC5DzfEr5oP7OA3tRO48Rf5yInAgMBAAE=
|
|
||||||
enabled: false
|
|
||||||
"com.example.my_octoprint_app:1.0":
|
|
||||||
pubkey: MEgCQQCIWfi7Nc8bcnfZJJtA6a4RyMC+sKBlMOb25OVNNB4L2v0TiGO72jVKR4osvb4oztlbRW5GkdiY0T2LJcfDYvkJAgMBAAE=
|
|
||||||
|
|
||||||
In the example, the app ``com.example.my_octoprint_app`` in version 0.9 has been disabled (e.g. due to the key having
|
|
||||||
leaked) whereas version 1.0 is fully registered with OctoPrint and may verify app session keys.
|
|
||||||
|
|
||||||
|
|
||||||
.. _sec-api-apps-sessionkey-workflow:
|
|
||||||
|
|
||||||
Workflow
|
|
||||||
--------
|
|
||||||
|
|
||||||
Apps perform the handshake by first requesting a temporary key with very limited validity,
|
|
||||||
then sending a message back to OctoPrint containing their id, version, the temporary key and a signature created with their
|
|
||||||
private key over these three pieces of data. OctoPrint then tries to verify the signature and if successful unlocks the
|
|
||||||
key to be used as a fully recognized API key.
|
|
||||||
|
|
||||||
For performing the handshake a special API exists within OctoPrint for which no API key is needed which is described below.
|
|
||||||
|
|
||||||
.. _sec-api-apps-sessionkey-get:
|
|
||||||
|
|
||||||
Obtaining a temporary session key
|
|
||||||
---------------------------------
|
|
||||||
|
|
||||||
.. http:get:: /apps/auth
|
|
||||||
|
|
||||||
Retrieve a temporary session key with a minimum validity. It can only be used as a proper API key after having been
|
|
||||||
:ref:`verified <sec-api-apps-sessionkey-verify>`.
|
|
||||||
|
|
||||||
Returns the temporary session key and the timestamp until it's valid.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
|
|
||||||
.. sourcecode:: http
|
|
||||||
|
|
||||||
GET /apps/auth HTTP/1.1
|
|
||||||
Host: example.com
|
|
||||||
|
|
||||||
.. sourcecode:: http
|
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"unverifiedKey": "F43A844750F74AD080FE9F438D47B33C",
|
|
||||||
"validUntil": 1416220357.011
|
|
||||||
}
|
|
||||||
|
|
||||||
:statuscode 200: No error
|
|
||||||
|
|
||||||
.. _sec-api-apps-sessionkey-verify:
|
|
||||||
|
|
||||||
Verifying a temporary session key
|
|
||||||
---------------------------------
|
|
||||||
|
|
||||||
.. http:post:: /apps/auth
|
|
||||||
|
|
||||||
Verify a formerly :ref:`retrieved <sec-api-apps-sessionkey-get>` temporary session key by providing credentials and a
|
|
||||||
cryptographic signature over these credentials and the temporary key.
|
|
||||||
|
|
||||||
Returns the now verified session key and the new validity.
|
|
||||||
|
|
||||||
**Example**:
|
|
||||||
|
|
||||||
.. sourcecode:: http
|
|
||||||
|
|
||||||
POST /apps/auth HTTP/1.1
|
|
||||||
Host: example.com
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"appid": "com.example.my_octoprint_app",
|
|
||||||
"appversion": "1.0",
|
|
||||||
"key": "F43A844750F74AD080FE9F438D47B33C",
|
|
||||||
"_sig": "LGVCiolQWDc4AVn1DOcWljY0cFQxWF4pldVveUjjmL9JhiL0LnCKBbGwZ/CwKBWswFAxPaxQ0kDusVdOmCUa/w=="
|
|
||||||
}
|
|
||||||
|
|
||||||
.. sourcecode:: http
|
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"key": "F43A844750F74AD080FE9F438D47B33C",
|
|
||||||
"validUntil": 1416227497.011
|
|
||||||
}
|
|
||||||
|
|
||||||
.. _sec-api-apps-sessionkey-signature:
|
|
||||||
|
|
||||||
Creating the signature
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
The signature is created by concatenating the ``appid``, ``appversion`` and ``key`` fields, separated by a ``:`` (colon),
|
|
||||||
signing the result with the app's private key using SHA-1 and then BASE64-encoding the result, stripping newlines.
|
|
||||||
|
|
||||||
Example for signature generation using Python and the `Python RSA library <https://pypi.python.org/pypi/rsa>`_:
|
|
||||||
|
|
||||||
.. sourcecode:: python
|
|
||||||
|
|
||||||
import base64
|
|
||||||
import rsa
|
|
||||||
|
|
||||||
appid = "com.example.my_octoprint_app"
|
|
||||||
version = "1.0"
|
|
||||||
unverified_key = "F43A844750F74AD080FE9F438D47B33C"
|
|
||||||
message_to_sign = appid + ":" + version + ":" + unverified_key
|
|
||||||
// => "com.example.my_octoprint_app:1.0:F43A844750F74AD080FE9F438D47B33C"
|
|
||||||
|
|
||||||
private_key = rsa.PrivateKey.load_pkcs1("...")
|
|
||||||
signature = base64.encodestring(rsa.sign(message_to_sign, private_key, "SHA-1")).replace("\n", "")
|
|
||||||
// => "LGVCiolQWDc4AVn1DOcWljY0cFQxWF4pldVveUjjmL9JhiL0LnCKBbGwZ/CwKBWswFAxPaxQ0kDusVdOmCUa/w=="
|
|
||||||
|
|
||||||
|
|
||||||
.. _sec-api-apps-sessionkey-testing:
|
|
||||||
|
|
||||||
Testing your implementation
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
If you want to use app session keys, here is the key pair with which the above examples were created, in order for you
|
|
||||||
to verify your signature implementation::
|
|
||||||
|
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIBPQIBAAJBAIhZ+Ls1zxtyd9kkm0DprhHIwL6woGUw5vbk5U00Hgva/ROIY7va
|
|
||||||
NUpHiiy9vijO2VtFbkaR2JjRPYslx8Ni+QkCAwEAAQJARK4lFo+FEcs3yR2iQjEy
|
|
||||||
p+yaAbNQJ4hZXlVvltLAYICzOM3kyKx53/eKU59NjskLz9q6QxfleymYPWAgl4NW
|
|
||||||
fQIjAJVH8MjwNcaAquTM9z2OiFi3OC8WgaKOi5W/T+r2+B70wG8CHwDp08dqOZ/u
|
|
||||||
xcBiy4Wzpcme9bckqoVuS3gWMm+YqgcCIwCMFU07kkY0NyumtzxPdIA4F/7OGSWf
|
|
||||||
IHqWFEfvasAddHlbAh8A5UgkB3Zf7Bt+7aFSBnlvve6FWm/XDPL12xYztYgrAiIa
|
|
||||||
W3miN6FjIm+8TDowrk+nyYXG2GZefeY7QXOjYr6tlDn0
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
|
|
||||||
-----BEGIN RSA PUBLIC KEY-----
|
|
||||||
MEgCQQCIWfi7Nc8bcnfZJJtA6a4RyMC+sKBlMOb25OVNNB4L2v0TiGO72jVKR4os
|
|
||||||
vb4oztlbRW5GkdiY0T2LJcfDYvkJAgMBAAE=
|
|
||||||
-----END RSA PUBLIC KEY-----
|
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ Issue a connection command
|
|||||||
Issue a connection command. Currently available command are:
|
Issue a connection command. Currently available command are:
|
||||||
|
|
||||||
connect
|
connect
|
||||||
Instructs OctoPrint to connect to the printer. Additional parameters are:
|
Instructs OctoPrint to connect or, if already connected, reconnect to the printer. Additional parameters are:
|
||||||
|
|
||||||
* ``port``: Optional, specific port to connect to. If not set the current ``portPreference`` will be used, or if
|
* ``port``: Optional, specific port to connect to. If not set the current ``portPreference`` will be used, or if
|
||||||
no preference is available auto detection will be attempted.
|
no preference is available auto detection will be attempted.
|
||||||
|
|||||||
+21
-10
@@ -11,9 +11,9 @@ General information
|
|||||||
Authorization
|
Authorization
|
||||||
=============
|
=============
|
||||||
|
|
||||||
OctoPrint's API expects an API key to be supplied with each request. This API key can be either the globally
|
If :ref:`Access Control <sec-features-access_control>` is enabled OctoPrint's API expects an API key to be supplied with each request. This API
|
||||||
configured one, a user specific one if "Access Control" is enabled or an app and user specific one as generated
|
key can be either the globally configured one, a user specific one or an app and user specific one as generated by the
|
||||||
by the authorization workflow implemented by the bundled :ref:`Application Keys Plugin <sec-bundledplugins-appkeys>` (since 1.3.10).
|
authorization workflow implemented by the bundled :ref:`Application Keys Plugin <sec-bundledplugins-appkeys>` (since 1.3.10).
|
||||||
|
|
||||||
Clients are advised to implement the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` first and
|
Clients are advised to implement the :ref:`Application Keys Plugin workflow <sec-bundledplugins-appkeys-workflow>` first and
|
||||||
fallback on directing the user to manually supply the the user specific API key. The global key should rarely be used.
|
fallback on directing the user to manually supply the the user specific API key. The global key should rarely be used.
|
||||||
@@ -26,8 +26,6 @@ The API key must be supplied in the custom HTTP header ``X-Api-Key``, e.g.
|
|||||||
Host: example.com
|
Host: example.com
|
||||||
X-Api-Key: abcdef...
|
X-Api-Key: abcdef...
|
||||||
|
|
||||||
If it is missing or included but invalid, OctoPrint will directly return a response with status :http:statuscode:`403`.
|
|
||||||
|
|
||||||
For testing purposes it is also possible to supply the API key via a query parameter ``apikey``, e.g.
|
For testing purposes it is also possible to supply the API key via a query parameter ``apikey``, e.g.
|
||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
@@ -37,6 +35,24 @@ For testing purposes it is also possible to supply the API key via a query param
|
|||||||
|
|
||||||
Please be advised that clients should use the header field variant if at all possible.
|
Please be advised that clients should use the header field variant if at all possible.
|
||||||
|
|
||||||
|
If the key is missing or invalid, OctoPrint will treat the request as it would any unauthenticated anonymous request to the endpoint.
|
||||||
|
Consequently, if the bundled :ref:`ForceLogin plugin <sec-bundledplugins-forcelogin>` is active (which is the default), that means
|
||||||
|
that any requests without or with an invalid API key targeting other API endpoints than :ref:`Login <sec-api-general-login>`
|
||||||
|
will be denied with a :http:statuscode:`403`.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
If :ref:`Access Control <sec-features-access_control>` is disabled, OctoPrint will treat any unauthenticated anonymous requests and thus also requests
|
||||||
|
with an invalid or outright missing API key as requests with full admin rights!
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
The API key requirements changed in 1.3.11. Up to that version, even if Access Control was disabled, all requests needed to
|
||||||
|
be supplied with an API Key. To make the webinterface work under these circumstances, an unauthenticated anonymous API key was injected into the
|
||||||
|
HTML page and also available on the :ref:`Push API <sec-api-push>`. The presence and ready availability of this unauthenticated
|
||||||
|
anonymous "UI API key" caused confusion and false alarm among users and didn't contribute to the security of the platform in a
|
||||||
|
meaningful way, so it was finally abandoned in 1.3.11.
|
||||||
|
|
||||||
.. _fig-api-general-globalapikey:
|
.. _fig-api-general-globalapikey:
|
||||||
.. figure:: ../images/settings-global-api-key.png
|
.. figure:: ../images/settings-global-api-key.png
|
||||||
:align: center
|
:align: center
|
||||||
@@ -58,11 +74,6 @@ Please be advised that clients should use the header field variant if at all pos
|
|||||||
|
|
||||||
The API key options in the "Change password" dialog. Users can generate and revoke their custom API key here.
|
The API key options in the "Change password" dialog. Users can generate and revoke their custom API key here.
|
||||||
|
|
||||||
.. note::
|
|
||||||
OctoPrint's web interface uses a custom API key that is freshly generated on every server start. This key is not
|
|
||||||
intended to be used by any other client and would not be very useful in any case, since it basically represents
|
|
||||||
a completely anonymous client.
|
|
||||||
|
|
||||||
.. _sec-api-general-contenttype:
|
.. _sec-api-general-contenttype:
|
||||||
|
|
||||||
Content Type
|
Content Type
|
||||||
|
|||||||
+7
-2
@@ -212,7 +212,8 @@ Retrieve information about the current job
|
|||||||
"filepos": 337942,
|
"filepos": 337942,
|
||||||
"printTime": 276,
|
"printTime": 276,
|
||||||
"printTimeLeft": 912
|
"printTimeLeft": 912
|
||||||
}
|
},
|
||||||
|
"state": "Printing"
|
||||||
}
|
}
|
||||||
|
|
||||||
:statuscode 200: No error
|
:statuscode 200: No error
|
||||||
@@ -243,4 +244,8 @@ Job information response
|
|||||||
- 1
|
- 1
|
||||||
- :ref:`sec-api-datamodel-jobs-progress`
|
- :ref:`sec-api-datamodel-jobs-progress`
|
||||||
- Information regarding the progress of the current print job
|
- Information regarding the progress of the current print job
|
||||||
|
* - ``state``
|
||||||
|
- 1
|
||||||
|
- String
|
||||||
|
- A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused",
|
||||||
|
"Cancelling", "Error" or "Offline".
|
||||||
+159
-4
@@ -22,6 +22,11 @@ Bed
|
|||||||
corresponding resource returns temperature information including an optional history. Note that Bed commands
|
corresponding resource returns temperature information including an optional history. Note that Bed commands
|
||||||
are only available if the currently selected printer profile has a heated bed.
|
are only available if the currently selected printer profile has a heated bed.
|
||||||
See :ref:`sec-api-printer-bedcommand`.
|
See :ref:`sec-api-printer-bedcommand`.
|
||||||
|
Chamber
|
||||||
|
Chamber commands allow setting the temperature and temperature offset for the printer's heated chamber. Querying
|
||||||
|
the corresponding resource returns temperature information including an option history. Note that Chamber commands
|
||||||
|
are only available if the currently selected printer profile has a heated chamber.
|
||||||
|
See :ref:`sec-api-printer-chambercommand`.
|
||||||
SD card
|
SD card
|
||||||
SD commands allow initialization, refresh and release of the printer's SD card (if available). Querying the
|
SD commands allow initialization, refresh and release of the printer's SD card (if available). Querying the
|
||||||
corresponding resource returns the current SD card state.
|
corresponding resource returns the current SD card state.
|
||||||
@@ -219,7 +224,7 @@ Issue a print head command
|
|||||||
axes values are relative amounts) or to absolute position (provided axes values are coordinates)
|
axes values are relative amounts) or to absolute position (provided axes values are coordinates)
|
||||||
* ``speed``: Optional. Speed at which to move. If not provided, minimum speed for all selected axes from printer
|
* ``speed``: Optional. Speed at which to move. If not provided, minimum speed for all selected axes from printer
|
||||||
profile will be used. If provided but ``false``, no speed parameter will be appended to the command. Otherwise
|
profile will be used. If provided but ``false``, no speed parameter will be appended to the command. Otherwise
|
||||||
interpreted as an integer signifying the speed in mm/s, to append to the command.
|
interpreted as an integer signifying the speed in mm/min, to append to the command.
|
||||||
|
|
||||||
home
|
home
|
||||||
Homes the print head in all of the given axes. Additional parameters are:
|
Homes the print head in all of the given axes. Additional parameters are:
|
||||||
@@ -362,6 +367,8 @@ Issue a tool command
|
|||||||
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
|
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
|
||||||
|
|
||||||
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
||||||
|
* ``speed``: Optional. Speed at which to extrude. If not provided, maximum speed for E axis from printer
|
||||||
|
profile will be used. Otherwise interpreted as an integer signifying the speed in mm/min, to append to the command.
|
||||||
|
|
||||||
flowrate
|
flowrate
|
||||||
Changes the flow rate factor to apply to extrusion of the tool.
|
Changes the flow rate factor to apply to extrusion of the tool.
|
||||||
@@ -621,12 +628,12 @@ Issue a bed command
|
|||||||
are:
|
are:
|
||||||
|
|
||||||
target
|
target
|
||||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
Sets the given target temperature on the printer's bed. Additional parameters:
|
||||||
|
|
||||||
* ``target``: Target temperature to set.
|
* ``target``: Target temperature to set.
|
||||||
|
|
||||||
offset
|
offset
|
||||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
Sets the given temperature offset on the printer's bed. Additional parameters:
|
||||||
|
|
||||||
* ``offset``: Offset to set.
|
* ``offset``: Offset to set.
|
||||||
|
|
||||||
@@ -708,7 +715,7 @@ Retrieve the current bed state
|
|||||||
an :http:statuscode:`409`.
|
an :http:statuscode:`409`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
If you want both tool and bed temperature information at the same time, take a look at
|
If you want tool, bed and chamber temperature information at the same time, take a look at
|
||||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
@@ -758,6 +765,154 @@ Retrieve the current bed state
|
|||||||
:statuscode 409: If the printer is not operational or the selected printer profile
|
:statuscode 409: If the printer is not operational or the selected printer profile
|
||||||
does not have a heated bed.
|
does not have a heated bed.
|
||||||
|
|
||||||
|
.. _sec-api-printer-chambercommand:
|
||||||
|
|
||||||
|
Issue a chamber command
|
||||||
|
=======================
|
||||||
|
|
||||||
|
.. http:post:: /api/printer/bed
|
||||||
|
|
||||||
|
Chamber commands allow setting the temperature and temperature offsets for the printer's heated chamber. Available commands
|
||||||
|
are:
|
||||||
|
|
||||||
|
target
|
||||||
|
Sets the given target temperature on the printer's chamber. Additional parameters:
|
||||||
|
|
||||||
|
* ``target``: Target temperature to set.
|
||||||
|
|
||||||
|
offset
|
||||||
|
Sets the given temperature offset on the printer's chamber. Additional parameters:
|
||||||
|
|
||||||
|
* ``offset``: Offset to set.
|
||||||
|
|
||||||
|
All of these commands may only be sent if the printer is currently operational. Otherwise a :http:statuscode:`409`
|
||||||
|
is returned.
|
||||||
|
|
||||||
|
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||||
|
|
||||||
|
If no heated chambed is configured for the currently selected printer profile, the resource will return
|
||||||
|
an :http:statuscode:`409`.
|
||||||
|
|
||||||
|
Requires user rights.
|
||||||
|
|
||||||
|
**Example Target Temperature Request**
|
||||||
|
|
||||||
|
Set the target temperature for the printer's heated chamber to 50°C.
|
||||||
|
|
||||||
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
POST /api/printer/chamber HTTP/1.1
|
||||||
|
Host: example.com
|
||||||
|
Content-Type: application/json
|
||||||
|
X-Api-Key: abcdef...
|
||||||
|
|
||||||
|
{
|
||||||
|
"command": "target",
|
||||||
|
"target": 50
|
||||||
|
}
|
||||||
|
|
||||||
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
HTTP/1.1 204 No Content
|
||||||
|
|
||||||
|
**Example Offset Temperature Request**
|
||||||
|
|
||||||
|
Set the temperature offset for the heated chamber to -5°C.
|
||||||
|
|
||||||
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
POST /api/printer/chamber HTTP/1.1
|
||||||
|
Host: example.com
|
||||||
|
Content-Type: application/json
|
||||||
|
X-Api-Key: abcdef...
|
||||||
|
|
||||||
|
{
|
||||||
|
"command": "offset",
|
||||||
|
"offset": -5
|
||||||
|
}
|
||||||
|
|
||||||
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
HTTP/1.1 204 No Content
|
||||||
|
|
||||||
|
:json string command: The command to issue, either ``target`` or ``offset``.
|
||||||
|
:json object target: ``target`` command: The target temperature to set.
|
||||||
|
:json object offset: ``offset`` command: The offset temperature to set.
|
||||||
|
:statuscode 204: No error
|
||||||
|
:statuscode 400: If ``target`` or ``offset`` is not a valid number or outside of the supported range, or if the
|
||||||
|
request is otherwise invalid.
|
||||||
|
:statuscode 409: If the printer is not operational or the selected printer profile
|
||||||
|
does not have a heated chamber.
|
||||||
|
|
||||||
|
.. _sec-api-printer-chamberstate:
|
||||||
|
|
||||||
|
Retrieve the current chamber state
|
||||||
|
==================================
|
||||||
|
|
||||||
|
.. http:get:: /api/printer/chamber
|
||||||
|
|
||||||
|
Retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target,
|
||||||
|
timestamp) for the printer's heated chamber.
|
||||||
|
|
||||||
|
It's also possible to retrieve the temperature history by supplying the ``history`` query parameter set to ``true``. The
|
||||||
|
amount of returned history data points can be limited using the ``limit`` query parameter.
|
||||||
|
|
||||||
|
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
|
||||||
|
|
||||||
|
If no heated chamber is configured for the currently selected printer profile, the resource will return
|
||||||
|
an :http:statuscode:`409`.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If you want tool, bed and chamber temperature information at the same time, take a look at
|
||||||
|
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
Query the chamber temperature data and also include the temperature history but limit it to two entries.
|
||||||
|
|
||||||
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
GET /api/printer/chamber?history=true&limit=2 HTTP/1.1
|
||||||
|
Host: example.com
|
||||||
|
X-Api-Key: abcdef...
|
||||||
|
|
||||||
|
.. sourcecode:: http
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"chamber": {
|
||||||
|
"actual": 50.221,
|
||||||
|
"target": 70.0,
|
||||||
|
"offset": 5
|
||||||
|
},
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"time": 1395651928,
|
||||||
|
"chamber": {
|
||||||
|
"actual": 50.221,
|
||||||
|
"target": 70.0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"time": 1395651926,
|
||||||
|
"chamber": {
|
||||||
|
"actual": 49.1123,
|
||||||
|
"target": 70.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||||
|
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||||
|
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||||
|
will be returned. Will be ignored if ``history`` is not enabled.
|
||||||
|
:statuscode 200: No error
|
||||||
|
:statuscode 409: If the printer is not operational or the selected printer profile
|
||||||
|
does not have a heated chamber.
|
||||||
|
|
||||||
.. _sec-api-printer-sdcommand:
|
.. _sec-api-printer-sdcommand:
|
||||||
|
|
||||||
Issue an SD command
|
Issue an SD command
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ Retrieve all printer profiles
|
|||||||
"height": 200
|
"height": 200
|
||||||
},
|
},
|
||||||
"heatedBed": true,
|
"heatedBed": true,
|
||||||
|
"heatedChamber": false,
|
||||||
"axes": {
|
"axes": {
|
||||||
"x": {
|
"x": {
|
||||||
"speed": 6000,
|
"speed": 6000,
|
||||||
@@ -93,6 +94,7 @@ Retrieve all printer profiles
|
|||||||
"height": 200
|
"height": 200
|
||||||
},
|
},
|
||||||
"heatedBed": true,
|
"heatedBed": true,
|
||||||
|
"heatedChamber": true,
|
||||||
"axes": {
|
"axes": {
|
||||||
"x": {
|
"x": {
|
||||||
"speed": 6000,
|
"speed": 6000,
|
||||||
@@ -184,6 +186,7 @@ Add a new printer profile
|
|||||||
"height": 200
|
"height": 200
|
||||||
},
|
},
|
||||||
"heatedBed": true,
|
"heatedBed": true,
|
||||||
|
"heatedChamber": false,
|
||||||
"axes": {
|
"axes": {
|
||||||
"x": {
|
"x": {
|
||||||
"speed": 6000,
|
"speed": 6000,
|
||||||
@@ -267,6 +270,7 @@ Add a new printer profile
|
|||||||
"height": 300
|
"height": 300
|
||||||
},
|
},
|
||||||
"heatedBed": false,
|
"heatedBed": false,
|
||||||
|
"heatedChamber": false,
|
||||||
"axes": {
|
"axes": {
|
||||||
"x": {
|
"x": {
|
||||||
"speed": 6000,
|
"speed": 6000,
|
||||||
@@ -352,6 +356,7 @@ Update an existing printer profile
|
|||||||
"height": 200
|
"height": 200
|
||||||
},
|
},
|
||||||
"heatedBed": true,
|
"heatedBed": true,
|
||||||
|
"heatedChamber": false,
|
||||||
"axes": {
|
"axes": {
|
||||||
"x": {
|
"x": {
|
||||||
"speed": 6000,
|
"speed": 6000,
|
||||||
@@ -578,6 +583,10 @@ Profile
|
|||||||
- 0..1
|
- 0..1
|
||||||
- ``boolean``
|
- ``boolean``
|
||||||
- Whether the printer has a heated bed (``true``) or not (``false``)
|
- Whether the printer has a heated bed (``true``) or not (``false``)
|
||||||
|
* - ``heatedChamber``
|
||||||
|
- 0..1
|
||||||
|
- ``boolean``
|
||||||
|
- Whether the printer has a heated chamber (``true``) or not (``false``)
|
||||||
* - ``axes``
|
* - ``axes``
|
||||||
- 0..1
|
- 0..1
|
||||||
- Object
|
- Object
|
||||||
|
|||||||
@@ -274,10 +274,10 @@ Fetch template data
|
|||||||
"plugin_name": "Action Command Prompt Support"
|
"plugin_name": "Action Command Prompt Support"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "plugin_cura",
|
"id": "plugin_curalegacy",
|
||||||
"name": "CuraEngine (<= 15.04)",
|
"name": "Cura Legacy",
|
||||||
"plugin_id": "cura",
|
"plugin_id": "curalegacy",
|
||||||
"plugin_name": "CuraEngine (<= 15.04)"
|
"plugin_name": "Cura Legacy"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"sidebar": [
|
"sidebar": [
|
||||||
@@ -514,6 +514,8 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
|
|||||||
-
|
-
|
||||||
* - ``webcam.ffmpegThreads``
|
* - ``webcam.ffmpegThreads``
|
||||||
-
|
-
|
||||||
|
* - ``webcam.ffmpegVideoCodec``
|
||||||
|
-
|
||||||
* - ``webcam.watermark``
|
* - ``webcam.watermark``
|
||||||
-
|
-
|
||||||
* - ``webcam.flipH``
|
* - ``webcam.flipH``
|
||||||
|
|||||||
+14
-14
@@ -42,22 +42,22 @@ List All Slicers and Slicing Profiles
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"cura": {
|
"curalegacy": {
|
||||||
"key": "cura",
|
"key": "curalegacy",
|
||||||
"displayName": "CuraEngine",
|
"displayName": "Cura Legacy",
|
||||||
"default": true,
|
"default": true,
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"high_quality": {
|
"high_quality": {
|
||||||
"key": "high_quality",
|
"key": "high_quality",
|
||||||
"displayName": "High Quality",
|
"displayName": "High Quality",
|
||||||
"default": false,
|
"default": false,
|
||||||
"resource": "http://example.com/api/slicing/cura/profiles/high_quality"
|
"resource": "http://example.com/api/slicing/curalegacy/profiles/high_quality"
|
||||||
},
|
},
|
||||||
"medium_quality": {
|
"medium_quality": {
|
||||||
"key": "medium_quality",
|
"key": "medium_quality",
|
||||||
"displayName": "Medium Quality",
|
"displayName": "Medium Quality",
|
||||||
"default": true,
|
"default": true,
|
||||||
"resource": "http://example.com/api/slicing/cura/profiles/medium_quality"
|
"resource": "http://example.com/api/slicing/curalegacy/profiles/medium_quality"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ List Slicing Profiles of a Specific Slicer
|
|||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
GET /api/slicing/cura/profiles HTTP/1.1
|
GET /api/slicing/curalegacy/profiles HTTP/1.1
|
||||||
Host: example.com
|
Host: example.com
|
||||||
X-Api-Key: abcdef...
|
X-Api-Key: abcdef...
|
||||||
|
|
||||||
@@ -95,13 +95,13 @@ List Slicing Profiles of a Specific Slicer
|
|||||||
"key": "high_quality",
|
"key": "high_quality",
|
||||||
"displayName": "High Quality",
|
"displayName": "High Quality",
|
||||||
"default": false,
|
"default": false,
|
||||||
"resource": "http://example.com/api/slicing/cura/profiles/high_quality"
|
"resource": "http://example.com/api/slicing/curalegacy/profiles/high_quality"
|
||||||
},
|
},
|
||||||
"medium_quality": {
|
"medium_quality": {
|
||||||
"key": "medium_quality",
|
"key": "medium_quality",
|
||||||
"displayName": "Medium Quality",
|
"displayName": "Medium Quality",
|
||||||
"default": true,
|
"default": true,
|
||||||
"resource": "http://example.com/api/slicing/cura/profiles/medium_quality"
|
"resource": "http://example.com/api/slicing/curalegacy/profiles/medium_quality"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ Retrieve Specific Profile
|
|||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
GET /api/slicing/cura/profiles/quick_test HTTP/1.1
|
GET /api/slicing/curalegacy/profiles/quick_test HTTP/1.1
|
||||||
Host: example.com
|
Host: example.com
|
||||||
X-Api-Key: abcdef...
|
X-Api-Key: abcdef...
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ Retrieve Specific Profile
|
|||||||
{
|
{
|
||||||
"displayName": "Just a test",
|
"displayName": "Just a test",
|
||||||
"description": "This is just a test",
|
"description": "This is just a test",
|
||||||
"resource": "http://example.com/api/slicing/cura/profiles/quick_test",
|
"resource": "http://example.com/api/slicing/curalegacy/profiles/quick_test",
|
||||||
"data": {
|
"data": {
|
||||||
"bottom_layer_speed": 20.0,
|
"bottom_layer_speed": 20.0,
|
||||||
"bottom_thickness": 0.3,
|
"bottom_thickness": 0.3,
|
||||||
@@ -174,14 +174,14 @@ Add Slicing Profile
|
|||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
PUT /api/slicing/cura/profiles/quick_test HTTP/1.1
|
PUT /api/slicing/curalegacy/profiles/quick_test HTTP/1.1
|
||||||
Host: example.com
|
Host: example.com
|
||||||
X-Api-Key: abcdef...
|
X-Api-Key: abcdef...
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"displayName": "Just a test",
|
"displayName": "Just a test",
|
||||||
"description": "This is just a test to show how to create a cura profile with a different layer height and skirt count",
|
"description": "This is just a test to show how to create a curalegacy profile with a different layer height and skirt count",
|
||||||
"data": {
|
"data": {
|
||||||
"layer_height": 0.2,
|
"layer_height": 0.2,
|
||||||
"skirt_line_count": 3
|
"skirt_line_count": 3
|
||||||
@@ -197,8 +197,8 @@ Add Slicing Profile
|
|||||||
|
|
||||||
{
|
{
|
||||||
"displayName": "Just a test",
|
"displayName": "Just a test",
|
||||||
"description": "This is just a test to show how to create a cura profile with a different layer height and skirt count",
|
"description": "This is just a test to show how to create a curalegacy profile with a different layer height and skirt count",
|
||||||
"resource": "http://example.com/api/slicing/cura/profiles/quick_test"
|
"resource": "http://example.com/api/slicing/curalegacy/profiles/quick_test"
|
||||||
}
|
}
|
||||||
|
|
||||||
:param slicer: The identifying key of the slicer for which to add the profile
|
:param slicer: The identifying key of the slicer for which to add the profile
|
||||||
|
|||||||
+47
-23
@@ -38,30 +38,21 @@ List all registered system commands
|
|||||||
{
|
{
|
||||||
"action": "shutdown",
|
"action": "shutdown",
|
||||||
"name": "Shutdown",
|
"name": "Shutdown",
|
||||||
"command": "sudo shutdown -h now",
|
|
||||||
"confirm": "<strong>You are about to shutdown the system.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
"confirm": "<strong>You are about to shutdown the system.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
||||||
"async": true,
|
|
||||||
"ignore": true,
|
|
||||||
"source": "core",
|
"source": "core",
|
||||||
"resource": "http://example.com/api/system/commands/core/shutdown"
|
"resource": "http://example.com/api/system/commands/core/shutdown"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "reboot",
|
"action": "reboot",
|
||||||
"name": "Reboot",
|
"name": "Reboot",
|
||||||
"command": "sudo reboot",
|
|
||||||
"confirm": "<strong>You are about to reboot the system.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
"confirm": "<strong>You are about to reboot the system.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
||||||
"async": true,
|
|
||||||
"ignore": true,
|
|
||||||
"source": "core",
|
"source": "core",
|
||||||
"resource": "http://example.com/api/system/commands/core/reboot"
|
"resource": "http://example.com/api/system/commands/core/reboot"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "restart",
|
"action": "restart",
|
||||||
"name": "Restart OctoPrint",
|
"name": "Restart OctoPrint",
|
||||||
"command": "sudo service octoprint restart",
|
|
||||||
"confirm": "<strong>You are about to restart the OctoPrint server.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
"confirm": "<strong>You are about to restart the OctoPrint server.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
||||||
"async": true,
|
|
||||||
"ignore": true,
|
|
||||||
"source": "core",
|
"source": "core",
|
||||||
"resource": "http://example.com/api/system/commands/core/restart"
|
"resource": "http://example.com/api/system/commands/core/restart"
|
||||||
}
|
}
|
||||||
@@ -99,30 +90,21 @@ List all registered system commands for a source
|
|||||||
{
|
{
|
||||||
"action": "shutdown",
|
"action": "shutdown",
|
||||||
"name": "Shutdown",
|
"name": "Shutdown",
|
||||||
"command": "sudo shutdown -h now",
|
"confirm": "<strong>You are about to shutdown the system.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
||||||
"confirm": "<b>You are about to shutdown the system.</b></p><p> This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
|
||||||
"async": true,
|
|
||||||
"ignore": true,
|
|
||||||
"source": "core",
|
"source": "core",
|
||||||
"resource": "http://example.com/api/system/commands/core/shutdown"
|
"resource": "http://example.com/api/system/commands/core/shutdown"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "reboot",
|
"action": "reboot",
|
||||||
"name": "Reboot",
|
"name": "Reboot",
|
||||||
"command": "sudo reboot",
|
"confirm": "<strong>You are about to reboot the system.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
||||||
"confirm": "<b>You are about to reboot the system.</b></p><p> This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
|
||||||
"async": true,
|
|
||||||
"ignore": true,
|
|
||||||
"source": "core",
|
"source": "core",
|
||||||
"resource": "http://example.com/api/system/commands/core/reboot"
|
"resource": "http://example.com/api/system/commands/core/reboot"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"action": "restart",
|
"action": "restart",
|
||||||
"name": "Restart OctoPrint",
|
"name": "Restart OctoPrint",
|
||||||
"command": "sudo service octoprint restart",
|
"confirm": "<strong>You are about to restart the OctoPrint server.</strong></p><p>This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
||||||
"confirm": "<b>You are about to restart the OctoPrint server.</b></p><p> This action may disrupt any ongoing print jobs (depending on your printer's controller and general setup that might also apply to prints run directly from your printer's internal storage).",
|
|
||||||
"async": true,
|
|
||||||
"ignore": true,
|
|
||||||
"source": "core",
|
"source": "core",
|
||||||
"resource": "http://example.com/api/system/commands/core/restart"
|
"resource": "http://example.com/api/system/commands/core/restart"
|
||||||
}
|
}
|
||||||
@@ -184,18 +166,60 @@ List all response
|
|||||||
- Description
|
- Description
|
||||||
* - ``core``
|
* - ``core``
|
||||||
- 0..n
|
- 0..n
|
||||||
- List of :ref:`command definitions <sec-api-system-commands-definiton>`
|
- List of :ref:`client command definitions <sec-api-client-system-commands-definiton>`
|
||||||
- List of all core commands defined.
|
- List of all core commands defined.
|
||||||
* - ``custom``
|
* - ``custom``
|
||||||
- 0..n
|
- 0..n
|
||||||
- List of :ref:`command definitions <sec-api-system-commands-definiton>`
|
- List of :ref:`client command definitions <sec-api-client-system-commands-definiton>`
|
||||||
- List of all custom commands defined in ``config.yaml``.
|
- List of all custom commands defined in ``config.yaml``.
|
||||||
|
|
||||||
|
.. _sec-api-client-system-commands-definiton:
|
||||||
|
|
||||||
|
Client command definitions
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
A restricted form of the full :ref:`command definition <sec-api-system-commands-definiton>`.
|
||||||
|
For exposing via the API.
|
||||||
|
|
||||||
|
.. list-table::
|
||||||
|
:widths: 15 5 10 30
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
* - Name
|
||||||
|
- Multiplicity
|
||||||
|
- Type
|
||||||
|
- Description
|
||||||
|
* - ``name``
|
||||||
|
- 1
|
||||||
|
- string
|
||||||
|
- The name of the command to display in the System menu.
|
||||||
|
* - ``action``
|
||||||
|
- 1
|
||||||
|
- string
|
||||||
|
- An identifier to refer to the command programmatically. The special ``action`` string
|
||||||
|
``divider`` signifies a divider in the menu.
|
||||||
|
* - ``confirm``
|
||||||
|
- 0..1
|
||||||
|
- string
|
||||||
|
- If present and set, this text will be displayed to the user in a confirmation dialog
|
||||||
|
they have to acknowledge in order to really execute the command.
|
||||||
|
* - ``source``
|
||||||
|
- 1
|
||||||
|
- string
|
||||||
|
- Source of the command definition, currently either ``core`` (for system actions defined by
|
||||||
|
OctoPrint itself) or ``custom`` (for custom system commands defined by the user through ``config.yaml``).
|
||||||
|
* - ``resource``
|
||||||
|
- 1
|
||||||
|
- string
|
||||||
|
- The URL of the command to use for executing it.
|
||||||
|
|
||||||
.. _sec-api-system-commands-definiton:
|
.. _sec-api-system-commands-definiton:
|
||||||
|
|
||||||
Command definition
|
Command definition
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
The full command definition is not available via the API.
|
||||||
|
|
||||||
.. list-table::
|
.. list-table::
|
||||||
:widths: 15 5 10 30
|
:widths: 15 5 10 30
|
||||||
:header-rows: 1
|
:header-rows: 1
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ Version information
|
|||||||
.. http:get:: /api/version
|
.. http:get:: /api/version
|
||||||
|
|
||||||
Retrieve information regarding server and API version. Returns a JSON object with two keys, ``api`` containing
|
Retrieve information regarding server and API version. Returns a JSON object with two keys, ``api`` containing
|
||||||
the API version, ``server`` containing the server version.
|
the API version, ``server`` containing the server version, ``text`` containing the server version including
|
||||||
|
the prefix ``OctoPrint `` (to determine that this is indeed a genuine OctoPrint instance).
|
||||||
|
|
||||||
**Example Request**
|
**Example Request**
|
||||||
|
|
||||||
@@ -26,7 +27,8 @@ Version information
|
|||||||
|
|
||||||
{
|
{
|
||||||
"api": "0.1",
|
"api": "0.1",
|
||||||
"server": "1.1.0"
|
"server": "1.3.10",
|
||||||
|
"text": "OctoPrint 1.3.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
:statuscode 200: No error
|
:statuscode 200: No error
|
||||||
@@ -40,15 +40,18 @@ of the following steps:
|
|||||||
|
|
||||||
1. The User opens the App and gets prompted to enter or select an instance URL. Optionally (recommended!) the User also
|
1. The User opens the App and gets prompted to enter or select an instance URL. Optionally (recommended!) the User also
|
||||||
enters their username which is also their user ID into the App.
|
enters their username which is also their user ID into the App.
|
||||||
2. The App sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
|
2. The App :ref:`probes for workflow support <sec-bundledplugins-appkeys-api-probe>` on the Server. If this request
|
||||||
|
doesn't get an HTTP :http:statuscode:`204` the App needs to direct the user to an alternative manual workflow
|
||||||
|
(copy-paste API key) and abort this one. Otherwise it proceeds to the next step.
|
||||||
|
3. The App sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
|
||||||
authorization process.
|
authorization process.
|
||||||
3. The Server triggers a confirmation dialog for the User on the Webinterface and returns an endpoint to the
|
4. The Server triggers a confirmation dialog for the User on the Webinterface and returns an endpoint to the
|
||||||
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`.
|
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`.
|
||||||
4. The App uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
|
5. The App uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
|
||||||
signals that no decision has been made yet.
|
signals that no decision has been made yet.
|
||||||
5. The User either accepts or denies the access request which makes the Webinterface send a
|
6. The User either accepts or denies the access request which makes the Webinterface send a
|
||||||
:ref:`decision request <sec-bundledplugins-appkey-datamodel-decisionrequest>` to the Server.
|
:ref:`decision request <sec-bundledplugins-appkey-datamodel-decisionrequest>` to the Server.
|
||||||
6. If the User accepted the request, the App receives an HTTP :http:statuscode:`200` with an attached
|
7. If the User accepted the request, the App receives an HTTP :http:statuscode:`200` with an attached
|
||||||
:ref:`API key response <sec-bundledplugins-appkey-datamodel-keyresponse>`. If they deny it, the App will receive
|
:ref:`API key response <sec-bundledplugins-appkey-datamodel-keyresponse>`. If they deny it, the App will receive
|
||||||
an HTTP :http:statuscode:`404`.
|
an HTTP :http:statuscode:`404`.
|
||||||
|
|
||||||
@@ -61,31 +64,35 @@ of the following steps:
|
|||||||
participant Webinterface
|
participant Webinterface
|
||||||
participant Server
|
participant Server
|
||||||
|
|
||||||
note over User, Server: Step 1 & 2
|
note over User, Server: Step 1, 2 & 3
|
||||||
|
|
||||||
User->>App: enters URL of instance to connect to
|
User->>App: enters URL of instance to connect to and optional user_id
|
||||||
|
|
||||||
|
App->>Server: GET /plugin/appkeys/probe
|
||||||
|
|
||||||
|
alt Workflow unsupported
|
||||||
|
|
||||||
|
Server->>App: 404
|
||||||
|
App->>User: alternative workflow, copy-paste key manually
|
||||||
|
|
||||||
|
else Workflow supported
|
||||||
|
|
||||||
alt Limit to specific user
|
|
||||||
User->>App: enters user_id
|
|
||||||
App->>Server: POST /plugin/appkeys/request, (app_name, user_id)
|
App->>Server: POST /plugin/appkeys/request, (app_name, user_id)
|
||||||
else
|
|
||||||
App->>Server: POST /plugin/appkeys/request, (app_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
note over User, Server: Step 3
|
note over User, Server: Step 4
|
||||||
|
|
||||||
Server-->>Webinterface: plugin message for "appkeys" w/ (app_name, user_token, user_id)
|
Server-->>Webinterface: plugin message for "appkeys" w/ (app_name, user_token, user_id)
|
||||||
Webinterface-->>User: Display confirmation dialog
|
Webinterface-->>User: Display confirmation dialog
|
||||||
Server->>App: 201, Location: /plugin/appkeys/request/<app_token>
|
Server->>App: 201, Location: /plugin/appkeys/request/<app_token>
|
||||||
|
|
||||||
note over User, Server: Step 4
|
note over User, Server: Step 5
|
||||||
|
|
||||||
loop
|
loop Poll for decision
|
||||||
App->>Server: GET /plugin/appkeys/request/<app_token>
|
App->>Server: GET /plugin/appkeys/request/<app_token>
|
||||||
Server->>App: 202
|
Server->>App: 202
|
||||||
end
|
end
|
||||||
|
|
||||||
note over User, Server: Step 5 & 6
|
note over User, Server: Step 6 & 7
|
||||||
|
|
||||||
alt User accepts
|
alt User accepts
|
||||||
|
|
||||||
@@ -105,11 +112,27 @@ of the following steps:
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
.. _sec-bundledplugins-appkeys-api:
|
.. _sec-bundledplugins-appkeys-api:
|
||||||
|
|
||||||
API
|
API
|
||||||
---
|
---
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-appkeys-api-probe:
|
||||||
|
|
||||||
|
Probe for workflow support
|
||||||
|
..........................
|
||||||
|
|
||||||
|
.. http:get:: /plugin/appkeys/probe
|
||||||
|
|
||||||
|
Probes for support of the workflow.
|
||||||
|
|
||||||
|
Normally returns an HTTP :http:statuscode:`204`, indicating workflow availability. If a different status code is returned
|
||||||
|
(usually an HTTP :http:statuscode:`404`), the plugin is disabled or not installed. Fall back to manual api key exchange.
|
||||||
|
|
||||||
|
:status 204: the workflow is supported
|
||||||
|
|
||||||
.. _sec-bundledplugins-appkeys-api-startauthprocess:
|
.. _sec-bundledplugins-appkeys-api-startauthprocess:
|
||||||
|
|
||||||
Start authorization process
|
Start authorization process
|
||||||
@@ -131,12 +154,6 @@ Start authorization process
|
|||||||
it in the ``user`` parameter. OctoPrint will then only display the authorization request on browsers the user ``me``
|
it in the ``user`` parameter. OctoPrint will then only display the authorization request on browsers the user ``me``
|
||||||
is logged in on.
|
is logged in on.
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
If this endpoint produces an HTTP :http:statuscode:`404` and the instance URL is correct, the bundled
|
|
||||||
Application Keys Plugin has in all likelihood been disabled by the user. Fall back on manual API key copy-pasting
|
|
||||||
by the user.
|
|
||||||
|
|
||||||
:json app: application identifier to use for the request, case insensitive
|
:json app: application identifier to use for the request, case insensitive
|
||||||
:json user: optional user id to restrict the decision to the specified user
|
:json user: optional user id to restrict the decision to the specified user
|
||||||
:status 201: authorization process started, polling URL to query can be found in ``Location`` header
|
:status 201: authorization process started, polling URL to query can be found in ``Location`` header
|
||||||
@@ -154,6 +171,11 @@ Poll for decision on existing request
|
|||||||
a :ref:`Key response <sec-bundledplugins-appkey-datamodel-keyresponse>` if access has been granted and an
|
a :ref:`Key response <sec-bundledplugins-appkey-datamodel-keyresponse>` if access has been granted and an
|
||||||
HTTP :http:statuscode:`404` if the request has been denied or timed out.
|
HTTP :http:statuscode:`404` if the request has been denied or timed out.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
The request will be considered stale and deleted internally if the polling endpoint for it isn't called
|
||||||
|
for more than 5s.
|
||||||
|
|
||||||
:status 200: access granted, API key in response body
|
:status 200: access granted, API key in response body
|
||||||
:status 202: no decision has been made yet, continue polling
|
:status 202: no decision has been made yet, continue polling
|
||||||
:status 404: access denied or request timed out
|
:status 404: access denied or request timed out
|
||||||
@@ -452,6 +474,15 @@ JavaScript Client Library
|
|||||||
:param object opts: Additional options for the request
|
:param object opts: Additional options for the request
|
||||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||||
|
|
||||||
|
.. js:function:: OctoPrintClient.plugins.appkeys.probe(opts)
|
||||||
|
|
||||||
|
Probes for workflow support.
|
||||||
|
|
||||||
|
See :ref:`Probe for workflow support <sec-bundledplugins-appkeys-api-probe>` for more details.
|
||||||
|
|
||||||
|
: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.plugins.appkeys.request(app, opts)
|
.. js:function:: OctoPrintClient.plugins.appkeys.request(app, opts)
|
||||||
|
|
||||||
Starts a new authorization request for the provided ``app`` identifier.
|
Starts a new authorization request for the provided ``app`` identifier.
|
||||||
@@ -481,9 +512,10 @@ JavaScript Client Library
|
|||||||
|
|
||||||
.. js:function:: OctoPrintClient.plugins.appkeys.authenticate(app, user, opts)
|
.. js:function:: OctoPrintClient.plugins.appkeys.authenticate(app, user, opts)
|
||||||
|
|
||||||
Convenience function that issues a request and then automatically starts polling for a decision on the returned
|
Convenience function that probes for support, issues a request and then automatically starts polling for a decision
|
||||||
polling endpoint every 1s, until either a positive or negative decision is returned. On success the returned
|
on the returned polling endpoint every 1s, until either a positive or negative decision is returned. On success the
|
||||||
promise is resolved with the generated API key as argument.
|
returned promise is resolved with the generated API key as argument. If anything goes wrong or there is no support
|
||||||
|
for the workflow, the promise is rejected.
|
||||||
|
|
||||||
**Example usage**
|
**Example usage**
|
||||||
|
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
.. _sec-bundledplugins-cura:
|
|
||||||
|
|
||||||
Cura
|
|
||||||
====
|
|
||||||
|
|
||||||
The Cura Plugin allows slicing of STL files uploaded to OctoPrint directly via
|
|
||||||
the `CuraEngine <http://github.com/Ultimaker/CuraEngine>`_ **up to and
|
|
||||||
including version 15.04.x** and supersedes the slicing support integrated into
|
|
||||||
OctoPrint so far. It comes bundled with OctoPrint starting with version 1.2.0.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Versions of CuraEngine later than 15.04.x have changed their calling
|
|
||||||
parameters in such a way that the current implementation of OctoPrint's Cura plugin
|
|
||||||
is not compatible to it. For this reason, please use only CuraEngine versions up to
|
|
||||||
and including 15.04 for now, as available in the ``legacy`` branch of the CuraEngine
|
|
||||||
repository on Github.
|
|
||||||
|
|
||||||
The plugin offers a settings module that allows configuring the path to the
|
|
||||||
CuraEngine executable to use, as well as importing and managing slicing
|
|
||||||
profiles to be used. Please note that the Cura Plugin will use the printer
|
|
||||||
parameters you configured within OctoPrint (meaning bed size and extruder
|
|
||||||
count and offsets) for slicing.
|
|
||||||
|
|
||||||
.. _sec-bundledplugins-cura-firststeps:
|
|
||||||
|
|
||||||
First Steps
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Before you can slice from within OctoPrint, you'll need to
|
|
||||||
|
|
||||||
#. :ref:`Install CuraEngine <sec-bundledplugins-cura-installing>`
|
|
||||||
#. :ref:`Configure the path to CuraEngine within OctoPrint <sec-bundledplugins-cura-configuring>`
|
|
||||||
#. :ref:`Export a slicing profile from Cura and import it within OctoPrint <sec-bundledplugins-cura-profiles>`
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
OctoPi 0.12.0 and later ships with steps 1 and 2 already done, you only need to
|
|
||||||
supply one or more slicing profiles to get going :)
|
|
||||||
|
|
||||||
.. _sec-bundledplugins-cura-installing:
|
|
||||||
|
|
||||||
Installing CuraEngine
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
You'll need a build of ``legacy`` branch of `CuraEngine <http://github.com/Ultimaker/CuraEngine>`_
|
|
||||||
in order to be able to use the Cura OctoPrint plugin. You can find the ``legacy`` branch
|
|
||||||
`here <https://github.com/ultimaker/curaengine/tree/legacy>`__.
|
|
||||||
|
|
||||||
If you previously used the `old variant of the Cura integration <https://github.com/foosel/OctoPrint/wiki/Cura-Integration>`_,
|
|
||||||
you probably still have a fully functional binary lying around in the
|
|
||||||
installation folder of the full install of Cura you used then -- just put the
|
|
||||||
path to that in the plugin settings.
|
|
||||||
|
|
||||||
.. _sec-bundledplugins-cura-installing-raspbian:
|
|
||||||
|
|
||||||
Compiling for Raspbian
|
|
||||||
++++++++++++++++++++++
|
|
||||||
|
|
||||||
Raspbian Jessie and later
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Building on Raspbian Jessie and later is as easy as::
|
|
||||||
|
|
||||||
sudo apt-get -y install gcc-4.7 g++-4.7
|
|
||||||
git clone -b legacy https://github.com/Ultimaker/CuraEngine.git
|
|
||||||
cd CuraEngine
|
|
||||||
make
|
|
||||||
|
|
||||||
After this has completed, you'll find your shiny new build of CuraEngine in
|
|
||||||
the `build` folder (full path for above example:
|
|
||||||
``~/CuraEngine/build/CuraEngine``).
|
|
||||||
|
|
||||||
Raspbian Wheezy
|
|
||||||
~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
You'll need to install a new version of gcc and g++ and patch CuraEngine's
|
|
||||||
Makefile (see `this post <http://umforum.ultimaker.com/index.php?/topic/5943-recent-build-of-curaengine-wont-compile-on-raspberry-pi/#entry58539>`_)
|
|
||||||
in order for the compilation to work on current Raspbian builds (e.g. OctoPi)::
|
|
||||||
|
|
||||||
sudo apt-get -y install gcc-4.7 g++-4.7
|
|
||||||
git clone -b legacy https://github.com/Ultimaker/CuraEngine.git
|
|
||||||
cd CuraEngine
|
|
||||||
wget http://bit.ly/curaengine_makefile_patch -O CuraEngine.patch
|
|
||||||
patch < CuraEngine.patch
|
|
||||||
make CXX=g++-4.7
|
|
||||||
|
|
||||||
After this has completed, you'll find your shiny new build of CuraEngine in
|
|
||||||
the `build` folder (full path for above example:
|
|
||||||
``~/CuraEngine/build/CuraEngine``).
|
|
||||||
|
|
||||||
.. _sec-bundledplugins-cura-configuring:
|
|
||||||
|
|
||||||
Configuring the plugin
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
The Cura plugin needs to be configured with the full path to your copy of the
|
|
||||||
CuraEngine executable that it's supposed to use. You can do this either via
|
|
||||||
the Cura plugin settings dialog or by manually configuring the path to the
|
|
||||||
executable via ``config.yaml``, example:
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
cura:
|
|
||||||
cura_engine: /path/to/CuraEngine
|
|
||||||
|
|
||||||
.. _sec-bundledplugins-cura-profiles:
|
|
||||||
|
|
||||||
Using Cura Profiles
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
The Cura Plugin supports importing your existing profiles for Cura **up to and
|
|
||||||
including Cura 15.04.x**. Newer Cura releases (e.g. 15.06 or 2.x) use a different
|
|
||||||
internal format that will *not* work with the current version of the Cura Plugin.
|
|
||||||
|
|
||||||
You can find downloads of Cura 15.04.x for Windows, Mac and Linux `on Ultimaker's download page <https://ultimaker.com/en/products/cura-software/list>`_.
|
|
||||||
|
|
||||||
In order to export a slicing profile from the Cura desktop UI, open it,
|
|
||||||
set up your profile, then click on "File" and there on "Save Profile". You can
|
|
||||||
import the .ini-file this creates via the "Import Profile" button in the
|
|
||||||
Cura Settings within OctoPrint.
|
|
||||||
|
|
||||||
.. _sec-bundledplugins-cura-sourcecode:
|
|
||||||
|
|
||||||
Source code
|
|
||||||
-----------
|
|
||||||
|
|
||||||
The source of the Cura plugin is bundled with OctoPrint and can be found in
|
|
||||||
its source repository under ``src/octoprint/plugins/cura``.
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
.. _sec-bundledplugins-errortracking:
|
||||||
|
|
||||||
|
Error Tracking Plugin
|
||||||
|
=====================
|
||||||
|
|
||||||
|
The Error Tracking plugin will cause any logged exceptions in the server and the browser interface to be sent to
|
||||||
|
OctoPrint's `Sentry instance <https://sentry.io/>`_.
|
||||||
|
|
||||||
|
By enabling it you help to gather detailed information on the cause of bugs or other issues. This is especially
|
||||||
|
valuable on release candidates, which is why this plugin will also prompt you to enable error tracking if it detects
|
||||||
|
that you are subscribed to an RC release channel.
|
||||||
|
|
||||||
|
By default, even when enabled it will only be active if you are running a released OctoPrint version, so either a stable
|
||||||
|
release or a release candidate.
|
||||||
|
|
||||||
|
The Error Tracking plugin is using a Sentry instance kindly provided by `sentry.io <https://sentry.io/>`_. For information on their service
|
||||||
|
please refer to their `Security & Compliance documentation <https://sentry.io/security/>`_
|
||||||
|
and their `Privacy Policy <https://sentry.io/privacy/>`_.
|
||||||
|
|
||||||
|
The Error Tracking plugin has been bundled with OctoPrint since version 1.3.11.
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-errortracking-configuration:
|
||||||
|
|
||||||
|
Configuring the plugin
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The plugin supports the following configuration keys:
|
||||||
|
|
||||||
|
* ``enabled``: Whether to enable error tracking. Defaults to ``false``.
|
||||||
|
* ``enabled_unreleased``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases
|
||||||
|
or release candidates). Defaults to ``false``.
|
||||||
|
* ``unique_id``: Unique instance identifier, auto generated on first activation
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-errortracking-sourcecode:
|
||||||
|
|
||||||
|
Source Code
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The source of the Error Tracking plugin is bundled with OctoPrint and can be
|
||||||
|
found in its source repository under ``src/octoprint/plugins/errortracking``.
|
||||||
@@ -9,10 +9,11 @@ Bundled Plugins
|
|||||||
|
|
||||||
action_command_prompt.rst
|
action_command_prompt.rst
|
||||||
announcements.rst
|
announcements.rst
|
||||||
|
tracking.rst
|
||||||
appkeys.rst
|
appkeys.rst
|
||||||
backup.rst
|
backup.rst
|
||||||
cura.rst
|
|
||||||
discovery.rst
|
discovery.rst
|
||||||
|
errortracking.rst
|
||||||
forcelogin.rst
|
forcelogin.rst
|
||||||
logging.rst
|
logging.rst
|
||||||
pluginmanager.rst
|
pluginmanager.rst
|
||||||
|
|||||||
@@ -82,6 +82,45 @@ under Settings > Plugin Manager, or by directly editing ``config.yaml``:
|
|||||||
- hidden
|
- hidden
|
||||||
- plugins
|
- plugins
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-pluginmanager-events:
|
||||||
|
|
||||||
|
Events
|
||||||
|
------
|
||||||
|
|
||||||
|
plugin_pluginmanager_install_plugin
|
||||||
|
A plugin was installed.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``id``: the identifier of the installed plugin
|
||||||
|
* ``version``: the version of the installed plugin
|
||||||
|
* ``source``: source from which the plugin was installed, can be an URL or a path in the local file system
|
||||||
|
* ``source_type``: type of source from which the plugin was installed, can be ``url`` or ``path``
|
||||||
|
|
||||||
|
plugin_pluginmanager_uninstall_plugin
|
||||||
|
A plugin was uninstalled.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``id``: the identifier of the uninstalled plugin
|
||||||
|
* ``version``: the version of the uninstalled plugin
|
||||||
|
|
||||||
|
plugin_pluginmanager_enable_plugin
|
||||||
|
A plugin was enabled.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``id``: the identifier of the enabled plugin
|
||||||
|
* ``version``: the version of the enabled plugin
|
||||||
|
|
||||||
|
plugin_pluginmanager_disabled_plugin
|
||||||
|
A plugin was disabled.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``id``: the identifier of the disabled plugin
|
||||||
|
* ``version``: the version of the disabled plugin
|
||||||
|
|
||||||
.. _sec-bundledplugins-pluginmanager-hooks:
|
.. _sec-bundledplugins-pluginmanager-hooks:
|
||||||
|
|
||||||
Hooks
|
Hooks
|
||||||
|
|||||||
@@ -29,6 +29,20 @@ If you know of further printers/printer firmwares that need to be added here, pl
|
|||||||
unexpectedly and with `catastrophic <https://www.thissmarthouse.net/dont-burn-your-house-down-3d-printing-a-cautionary-tale/>`_
|
unexpectedly and with `catastrophic <https://www.thissmarthouse.net/dont-burn-your-house-down-3d-printing-a-cautionary-tale/>`_
|
||||||
`results <https://www.reddit.com/r/3Dprinting/comments/6cekgk/house_fire_thanks_to_cheap_printer_from_china/>`_.
|
`results <https://www.reddit.com/r/3Dprinting/comments/6cekgk/house_fire_thanks_to_cheap_printer_from_china/>`_.
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-printer_safety_check-events:
|
||||||
|
|
||||||
|
Events
|
||||||
|
------
|
||||||
|
|
||||||
|
warning
|
||||||
|
A printer safety warning was triggered.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``check_type``: type of check that was triggered (e.g. ``m115``, ``received`` or ``cap``)
|
||||||
|
* ``check_name``: name of check that was triggered (e.g. ``aneta8``)
|
||||||
|
* ``warning_type``: type of warning that was triggered (e.g. ``firmware-unsafe``)
|
||||||
|
|
||||||
.. _sec-bundledplugins-printer_safety_check-source:
|
.. _sec-bundledplugins-printer_safety_check-source:
|
||||||
|
|
||||||
Source Code
|
Source Code
|
||||||
|
|||||||
@@ -325,6 +325,29 @@ The same, but tracking all commits pushed to branch ``devel`` (thus allowing
|
|||||||
branch: devel
|
branch: devel
|
||||||
pip: 'https://github.com/someUser/OctoPrint-SomePlugin/archive/{target}.zip'
|
pip: 'https://github.com/someUser/OctoPrint-SomePlugin/archive/{target}.zip'
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-softwareupdate-events:
|
||||||
|
|
||||||
|
Events
|
||||||
|
------
|
||||||
|
|
||||||
|
plugin_softwareupdate_update_succeeded
|
||||||
|
An update succeeded.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``target``: update target
|
||||||
|
* ``from_version``: version from which was updated
|
||||||
|
* ``to_version``: version to which was updated
|
||||||
|
|
||||||
|
plugin_softwareupdate_update_failed
|
||||||
|
An update failed.
|
||||||
|
|
||||||
|
Payload:
|
||||||
|
|
||||||
|
* ``target``: update target
|
||||||
|
* ``from_version``: version from which was updated
|
||||||
|
* ``to_version``: version to which was updated
|
||||||
|
|
||||||
.. _sec-bundledplugins-softwareupdate-hooks:
|
.. _sec-bundledplugins-softwareupdate-hooks:
|
||||||
|
|
||||||
Hooks
|
Hooks
|
||||||
@@ -362,8 +385,8 @@ octoprint.plugin.softwareupdate.check_config
|
|||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
def get_update_information(*args, **kwargs):
|
def get_update_information(*args, **kwargs):
|
||||||
return dict(
|
return dict(
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
.. _sec-bundledplugins-tracking:
|
||||||
|
|
||||||
|
Anonymous Usage Tracking Plugin
|
||||||
|
===============================
|
||||||
|
|
||||||
|
The Anonymous Usage Tracking plugin provides valuable insights into how many instances running what versions of
|
||||||
|
OctoPrint are out there, whether they are successfully completing print jobs and various other metrics.
|
||||||
|
|
||||||
|
By enabling it you help to identify problems with new releases and release candidates early on, and to better tailor
|
||||||
|
OctoPrint's future development to actual use.
|
||||||
|
|
||||||
|
For details on what gets tracked, please refer to `tracking.octoprint.org <https://tracking.octoprint.org>`_
|
||||||
|
and also the `Privacy Policy at tracking.octoprint.org <https://tracking.octoprint.org/privacy>`_.
|
||||||
|
|
||||||
|
The Anonymous Usage Tracking plugin has been bundled with OctoPrint since version 1.3.10.
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-tracking-configuration:
|
||||||
|
|
||||||
|
Configuring the plugin
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The plugin supports the following configuration keys:
|
||||||
|
|
||||||
|
* ``enabled``: Whether to enable usage tracking. Defaults to ``false``.
|
||||||
|
* ``unique_id``: Unique instance identifier, auto generated on first activation
|
||||||
|
* ``server``: The tracking server to track against. Defaults to a tracking endpoint on ``https://tracking.octoprint.org``.
|
||||||
|
* ``ping``: How often to send a ``ping`` tracking event, in seconds. Defaults to a 15min interval.
|
||||||
|
* ``events``: Granular configuration of enabled tracking events. All default to ``true``.
|
||||||
|
|
||||||
|
* ``startup``: Whether to track startup/shutdown events
|
||||||
|
* ``printjob``: Whether to track print job related events (start, completion, cancel, ...)
|
||||||
|
* ``commerror``: Whether to track communication errors with the printer
|
||||||
|
* ``plugin``: Whether to track plugin related events (install, uninstall, ...)
|
||||||
|
* ``update``: Whether to track update related events (update successful or not, ...)
|
||||||
|
* ``printer``: Whether to track printer related events (connected, firmware, ...)
|
||||||
|
* ``printer_safety_check``: Whether to track warnings of the :ref:`Printer Safety Check <sec-bundledplugins-printer_safety_check>`
|
||||||
|
* ``throttled``: Whether to track throttle events detected on the underlying system
|
||||||
|
|
||||||
|
.. _sec-bundledplugins-tracking-sourcecode:
|
||||||
|
|
||||||
|
Source Code
|
||||||
|
-----------
|
||||||
|
|
||||||
|
The source of the Anonymous Usage Tracking plugin is bundled with OctoPrint and can be
|
||||||
|
found in its source repository under ``src/octoprint/plugins/tracking``.
|
||||||
+10
-8
@@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
#
|
#
|
||||||
# OctoPrint documentation build configuration file, created by
|
# OctoPrint documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Mon Dec 02 17:08:50 2013.
|
# sphinx-quickstart on Mon Dec 02 17:08:50 2013.
|
||||||
@@ -49,8 +51,8 @@ source_suffix = '.rst'
|
|||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'OctoPrint'
|
project = 'OctoPrint'
|
||||||
copyright = u'%d-%d, Gina Häußge' % (year_since, year_current) if year_current > year_since else u'%d, Gina Häußge' % year_since
|
copyright = '%d-%d, Gina Häußge' % (year_since, year_current) if year_current > year_since else '%d, Gina Häußge' % year_since
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
@@ -207,8 +209,8 @@ htmlhelp_basename = 'OctoPrintdoc'
|
|||||||
# Grouping the document tree into LaTeX files. List of tuples
|
# Grouping the document tree into LaTeX files. List of tuples
|
||||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||||
#latex_documents = [
|
#latex_documents = [
|
||||||
# ('index', 'OctoPrint.tex', u'OctoPrint Documentation',
|
# ('index', 'OctoPrint.tex', 'OctoPrint Documentation',
|
||||||
# u'Gina Häußge', 'manual'),
|
# 'Gina Häußge', 'manual'),
|
||||||
#]
|
#]
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
# The name of an image file (relative to this directory) to place at the top of
|
||||||
@@ -237,8 +239,8 @@ htmlhelp_basename = 'OctoPrintdoc'
|
|||||||
# One entry per manual page. List of tuples
|
# One entry per manual page. List of tuples
|
||||||
# (source start file, name, description, authors, manual section).
|
# (source start file, name, description, authors, manual section).
|
||||||
man_pages = [
|
man_pages = [
|
||||||
('index', 'octoprint', u'OctoPrint Documentation',
|
('index', 'octoprint', 'OctoPrint Documentation',
|
||||||
[u'Gina Häußge'], 1)
|
['Gina Häußge'], 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
# If true, show URL addresses after external links.
|
||||||
@@ -251,8 +253,8 @@ man_pages = [
|
|||||||
# (source start file, target name, title, author,
|
# (source start file, target name, title, author,
|
||||||
# dir menu entry, description, category)
|
# dir menu entry, description, category)
|
||||||
texinfo_documents = [
|
texinfo_documents = [
|
||||||
('index', 'OctoPrint', u'OctoPrint Documentation',
|
('index', 'OctoPrint', 'OctoPrint Documentation',
|
||||||
u'Gina Häußge', 'OctoPrint', 'One line description of project.',
|
'Gina Häußge', 'OctoPrint', 'One line description of project.',
|
||||||
'Miscellaneous'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Use the following settings to enable access control:
|
|||||||
# The user manager implementation to use for accessing user information. Currently only a filebased
|
# The user manager implementation to use for accessing user information. Currently only a filebased
|
||||||
# user manager is implemented which stores configured accounts in a YAML file (Default: users.yaml
|
# user manager is implemented which stores configured accounts in a YAML file (Default: users.yaml
|
||||||
# in the default configuration folder, see below)
|
# in the default configuration folder, see below)
|
||||||
userManager: octoprint.users.FilebasedUserManager
|
userManager: octoprint.access.users.FilebasedUserManager
|
||||||
|
|
||||||
# The YAML user file to use. If left out defaults to users.yaml in the default configuration folder.
|
# The YAML user file to use. If left out defaults to users.yaml in the default configuration folder.
|
||||||
userFile: /path/to/users.yaml
|
userFile: /path/to/users.yaml
|
||||||
@@ -62,6 +62,18 @@ Use the following settings to enable access control:
|
|||||||
# header and login the user without further checks. Use with caution.
|
# header and login the user without further checks. Use with caution.
|
||||||
checkBasicAuthenticationPassword: true
|
checkBasicAuthenticationPassword: true
|
||||||
|
|
||||||
|
# Whether to trust remote user headers. If you have setup authentication in front of
|
||||||
|
# OctoPrint and the user names you use there match OctoPrint accounts, by setting this to true users will
|
||||||
|
# be logged into OctoPrint as the user provided in the header. Your should ONLY ENABLE THIS if your
|
||||||
|
# OctoPrint instance is only accessible through a connection locked down through an authenticating reverse proxy!
|
||||||
|
trustRemoteUser: false
|
||||||
|
|
||||||
|
# Header used by the reverse proxy to convey the authenticated user.
|
||||||
|
remoteUserHeader: REMOTE_USER
|
||||||
|
|
||||||
|
# If a remote user is not found, add them. Use this only if all users from the remote system can use OctoPrint.
|
||||||
|
addRemoteUsers: false
|
||||||
|
|
||||||
.. _sec-configuration-config_yaml-api:
|
.. _sec-configuration-config_yaml-api:
|
||||||
|
|
||||||
API
|
API
|
||||||
@@ -81,7 +93,8 @@ Settings for the REST API:
|
|||||||
# Whether to allow cross origin access to the API or not
|
# Whether to allow cross origin access to the API or not
|
||||||
allowCrossOrigin: false
|
allowCrossOrigin: false
|
||||||
|
|
||||||
# Additional app api keys, see REST API > Apps in the docs
|
# Additional app api keys, see REST API > Apps in the docs.
|
||||||
|
# Deprecated since 1.3.11, to be removed in 1.4.0!
|
||||||
apps:
|
apps:
|
||||||
"some.app.identifier:some_version":
|
"some.app.identifier:some_version":
|
||||||
pubkey: <RSA pubkey>
|
pubkey: <RSA pubkey>
|
||||||
@@ -322,6 +335,9 @@ The following settings are only relevant to you if you want to do OctoPrint deve
|
|||||||
# Whether the simulated printer should also simulate a heated bed or not
|
# Whether the simulated printer should also simulate a heated bed or not
|
||||||
hasBed: true
|
hasBed: true
|
||||||
|
|
||||||
|
# Whether the simulated printer should also simulate a heated chamber or not
|
||||||
|
hasChamber: false
|
||||||
|
|
||||||
# If enabled, reports the set target temperatures as separate messages from the firmware
|
# If enabled, reports the set target temperatures as separate messages from the firmware
|
||||||
#
|
#
|
||||||
# True: > M109 S220.0
|
# True: > M109 S220.0
|
||||||
@@ -562,6 +578,9 @@ Use the following settings to enable or disable OctoPrint features:
|
|||||||
- M117
|
- M117
|
||||||
- M118
|
- M118
|
||||||
|
|
||||||
|
# whether G90/G91 also influence absolute/relative mode of extruders
|
||||||
|
g90InfluencesExtruder: false
|
||||||
|
|
||||||
.. _sec-configuration-config_yaml-folder:
|
.. _sec-configuration-config_yaml-folder:
|
||||||
|
|
||||||
Folder
|
Folder
|
||||||
@@ -666,6 +685,11 @@ plugins are tracked:
|
|||||||
_disabled:
|
_disabled:
|
||||||
- ...
|
- ...
|
||||||
|
|
||||||
|
# Identifiers of plugins for which python compatibility information will be ignored and
|
||||||
|
# the plugin considered compatible in any case. Only for development, do NOT use in production.
|
||||||
|
_forcedCompatible:
|
||||||
|
- ...
|
||||||
|
|
||||||
# The rest are individual plugin settings, each tracked by their identifier, e.g.:
|
# The rest are individual plugin settings, each tracked by their identifier, e.g.:
|
||||||
some_plugin:
|
some_plugin:
|
||||||
some_setting: true
|
some_setting: true
|
||||||
@@ -806,6 +830,19 @@ Use the following settings to configure the serial connection to the printer:
|
|||||||
additionalBaudrates:
|
additionalBaudrates:
|
||||||
- 123456
|
- 123456
|
||||||
|
|
||||||
|
# Commands which should not be sent to the printer, e.g. because they are known to block serial
|
||||||
|
# communication until physical interaction with the printer as is the case on most firmwares with
|
||||||
|
# the default M0 and M1.
|
||||||
|
blockedCommands:
|
||||||
|
- M0
|
||||||
|
- M1
|
||||||
|
|
||||||
|
# Commands which should cause OctoPrint to pause any ongoing prints.
|
||||||
|
pausingCommands:
|
||||||
|
- M0
|
||||||
|
- M1
|
||||||
|
- M25
|
||||||
|
|
||||||
# Commands which are known to take a long time to be acknowledged by the firmware. E.g.
|
# Commands which are known to take a long time to be acknowledged by the firmware. E.g.
|
||||||
# homing, dwelling, auto leveling etc. Defaults to the below commands.
|
# homing, dwelling, auto leveling etc. Defaults to the below commands.
|
||||||
longRunningCommands:
|
longRunningCommands:
|
||||||
@@ -932,6 +969,13 @@ Use the following settings to configure the server:
|
|||||||
# reset the setting to false
|
# reset the setting to false
|
||||||
startOnceInSafeMode: false
|
startOnceInSafeMode: false
|
||||||
|
|
||||||
|
# Signals to OctoPrint that the last startup was incomplete. OctoPrint will then startup
|
||||||
|
# in safe mode
|
||||||
|
incompleteStartup: false
|
||||||
|
|
||||||
|
# Set this to true to make OctoPrint ignore incomplete startups. Helpful for development.
|
||||||
|
ignoreIncompleteStartup: false
|
||||||
|
|
||||||
# Secret key for encrypting cookies and such, randomly generated on first run
|
# Secret key for encrypting cookies and such, randomly generated on first run
|
||||||
secretKey: someSecretKey
|
secretKey: someSecretKey
|
||||||
|
|
||||||
@@ -1058,6 +1102,15 @@ Use the following settings to configure the server:
|
|||||||
# How many days to leave unused entries in the preemptive cache config
|
# How many days to leave unused entries in the preemptive cache config
|
||||||
until: 7
|
until: 7
|
||||||
|
|
||||||
|
# Configuration of the client IP check to warn about connections from external networks
|
||||||
|
ipCheck:
|
||||||
|
|
||||||
|
# whether to enable the check, defaults to true
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# additional non-local subnets to consider trusted, in CIDR notation, e.g. "192.168.1.0/24"
|
||||||
|
trustedSubnets: []
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@@ -1087,14 +1140,14 @@ Settings for the built-in slicing support:
|
|||||||
slicing:
|
slicing:
|
||||||
|
|
||||||
# Whether to enable slicing support or not
|
# Whether to enable slicing support or not
|
||||||
enabled:
|
enabled: true
|
||||||
|
|
||||||
# Default slicer to use
|
# Default slicer to use
|
||||||
defaultSlicer: cura
|
defaultSlicer: null
|
||||||
|
|
||||||
# Default slicing profiles per slicer
|
# Default slicing profiles per slicer
|
||||||
defaultProfiles:
|
defaultProfiles:
|
||||||
cura: ...
|
curalegacy: ...
|
||||||
|
|
||||||
.. _sec-configuration-config_yaml-system:
|
.. _sec-configuration-config_yaml-system:
|
||||||
|
|
||||||
@@ -1197,6 +1250,9 @@ Use the following settings to configure webcam support:
|
|||||||
# Should be left at 1 for RPi1.
|
# Should be left at 1 for RPi1.
|
||||||
ffmpegThreads: 1
|
ffmpegThreads: 1
|
||||||
|
|
||||||
|
# Videocodec to be used for encoding. Defaults to mpeg2video.
|
||||||
|
ffmpegVideoCodec: mpeg2video
|
||||||
|
|
||||||
# The bitrate to use for rendering the timelapse video. This gets directly passed to ffmpeg.
|
# The bitrate to use for rendering the timelapse video. This gets directly passed to ffmpeg.
|
||||||
bitrate: 5000k
|
bitrate: 5000k
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ A list of important components for which an increase in logging might be interes
|
|||||||
* ``octoprint.filemanager``: the file management layer
|
* ``octoprint.filemanager``: the file management layer
|
||||||
* ``octoprint.plugin``: the plugin sub system
|
* ``octoprint.plugin``: the plugin sub system
|
||||||
* ``octoprint.plugins.<plugin>``: the plugin ``<plugin>``, e.g. ``octoprint.plugins.discovery`` to change the log level of
|
* ``octoprint.plugins.<plugin>``: the plugin ``<plugin>``, e.g. ``octoprint.plugins.discovery`` to change the log level of
|
||||||
the `Discovery plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Discovery>`_ or ``octoprint.plugins.cura``
|
the :ref:`Discovery plugin <sec-bundledplugins-discovery>` or ``octoprint.plugins.backup``
|
||||||
to change the log level of the `Cura plugin <https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura>`_.
|
to change the log level of the :ref:`Backup plugin <sec-bundledplugins-backup>`.
|
||||||
* ``octoprint.slicing``: the slicing sub system
|
* ``octoprint.slicing``: the slicing sub system
|
||||||
|
|
||||||
This list will be expanded when deemed necessary.
|
This list will be expanded when deemed necessary.
|
||||||
|
|||||||
@@ -14,18 +14,25 @@ below.
|
|||||||
* Prerequisites:
|
* Prerequisites:
|
||||||
|
|
||||||
* `Python 2.7 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv``
|
* `Python 2.7 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv``
|
||||||
|
* `Python 3.7 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv``
|
||||||
* `Git <https://git-scm.com>`_
|
* `Git <https://git-scm.com>`_
|
||||||
|
|
||||||
* Checkout the OctoPrint sources from their Git repository: ``git clone https://github.com/foosel/OctoPrint.git``
|
* Checkout the OctoPrint sources from their Git repository:
|
||||||
|
* ``git clone -b devel https://github.com/foosel/OctoPrint.git``
|
||||||
* Enter the checked out source folder: ``cd OctoPrint``
|
* Enter the checked out source folder: ``cd OctoPrint``
|
||||||
* Create a virtual environment in the checked out source folder to use for installing and running OctoPrint and its
|
* Create virtual environments in the checked out source folder for both Python 2.7 and Python 3.7 to use for
|
||||||
dependencies (this avoids potential versioning issues for the dependencies with system wide installed
|
installing and running OctoPrint and its dependencies (this avoids potential versioning issues for the dependencies
|
||||||
instances): ``virtualenv venv``
|
with system wide installed instances):
|
||||||
* Activate the virtual environment: ``source venv/bin/activate`` (Linux, MacOS) or
|
* PY2: ``virtualenv --python=python2 venv2``
|
||||||
``source venv/Scripts/activate`` (Git Bash under Windows, see below)
|
* PY3: ``virtualenv --python=python3 venv3``
|
||||||
* Update ``pip`` in the virtual environment: ``pip install --upgrade pip``
|
* Activate one of the virtual environments:
|
||||||
|
* PY2: ``source venv2/bin/activate`` (Linux, MacOS) or ``source venv2/Scripts/activate`` (Git Bash under Windows, see below)
|
||||||
|
* PY3: ``source venv3/bin/activate`` (Linux, MacOS) or ``source venv3/Scripts/activate`` (Git Bash under Windows, see below)
|
||||||
|
* Update ``pip`` in the virtual environment:
|
||||||
|
* ``pip install --upgrade pip``
|
||||||
* Install OctoPrint in `"editable" mode <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_,
|
* Install OctoPrint in `"editable" mode <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_,
|
||||||
including its regular *and* development and plugin development dependencies: ``pip install -e .[develop,plugins]``
|
including its regular *and* development and plugin development dependencies:
|
||||||
|
* ``pip install -e .[develop,plugins]``
|
||||||
|
|
||||||
When the virtual environment is activated you can then:
|
When the virtual environment is activated you can then:
|
||||||
|
|
||||||
@@ -33,11 +40,19 @@ When the virtual environment is activated you can then:
|
|||||||
* run the test suite from the checked out source folder via ``nosetests --with-doctest``
|
* run the test suite from the checked out source folder via ``nosetests --with-doctest``
|
||||||
* build the documentation from the ``docs`` sub folder of the checked out sources via ``sphinx-build -b html . _build``
|
* build the documentation from the ``docs`` sub folder of the checked out sources via ``sphinx-build -b html . _build``
|
||||||
|
|
||||||
|
To switch the activated virtual environment, simply activate the new environment as described above.
|
||||||
|
|
||||||
|
To deactivate the virtual environment and return to the system's default Python: ``deactivate``.
|
||||||
|
|
||||||
.. _sec-development-environment-source-linux:
|
.. _sec-development-environment-source-linux:
|
||||||
|
|
||||||
Linux
|
Linux
|
||||||
.....
|
.....
|
||||||
|
|
||||||
|
.. todo::
|
||||||
|
|
||||||
|
This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development.
|
||||||
|
|
||||||
This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different
|
This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different
|
||||||
location, please substitute accordingly.
|
location, please substitute accordingly.
|
||||||
|
|
||||||
@@ -70,7 +85,7 @@ Then:
|
|||||||
.. code-block:: none
|
.. code-block:: none
|
||||||
|
|
||||||
cd ~/devel
|
cd ~/devel
|
||||||
git clone https://github.com/foosel/OctoPrint.git
|
git clone -b devel https://github.com/foosel/OctoPrint.git
|
||||||
cd OctoPrint
|
cd OctoPrint
|
||||||
virtualenv venv
|
virtualenv venv
|
||||||
source ./venv/bin/activate
|
source ./venv/bin/activate
|
||||||
@@ -85,12 +100,16 @@ environment.
|
|||||||
Windows
|
Windows
|
||||||
.......
|
.......
|
||||||
|
|
||||||
|
.. todo::
|
||||||
|
|
||||||
|
This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development.
|
||||||
|
|
||||||
This assumes you'll host your OctoPrint development checkout at ``C:\Devel\OctoPrint``. If you want to use a different
|
This assumes you'll host your OctoPrint development checkout at ``C:\Devel\OctoPrint``. If you want to use a different
|
||||||
location, please substitute accordingly.
|
location, please substitute accordingly.
|
||||||
|
|
||||||
First download & install:
|
First download & install:
|
||||||
|
|
||||||
* `Python 2.7.12 Windows x86 MSI installer <https://www.python.org/downloads/release/python-2712/>`_
|
* `Python 2.7.15 Windows x86 MSI installer <https://www.python.org/downloads/release/python-2715/>`_
|
||||||
|
|
||||||
* make sure to have the installer add Python to the ``PATH`` and have it install ``pip`` too
|
* make sure to have the installer add Python to the ``PATH`` and have it install ``pip`` too
|
||||||
|
|
||||||
@@ -120,6 +139,10 @@ Mac OS X
|
|||||||
This guide is based on the `Setup Guide for Mac OS X on OctoPrint's wiki <https://github.com/foosel/OctoPrint/wiki/Setup-on-Mac/>`_.
|
This guide is based on the `Setup Guide for Mac OS X on OctoPrint's wiki <https://github.com/foosel/OctoPrint/wiki/Setup-on-Mac/>`_.
|
||||||
Please report back if it works for you, due to lack of access to a Mac I cannot test it myself. Thanks.
|
Please report back if it works for you, due to lack of access to a Mac I cannot test it myself. Thanks.
|
||||||
|
|
||||||
|
.. todo::
|
||||||
|
|
||||||
|
This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development.
|
||||||
|
|
||||||
This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different
|
This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different
|
||||||
location, please substitute accordingly.
|
location, please substitute accordingly.
|
||||||
|
|
||||||
@@ -158,6 +181,10 @@ You'll need a user account with administrator privileges.
|
|||||||
IDE Setup
|
IDE Setup
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
.. todo::
|
||||||
|
|
||||||
|
This guide is not yet adapted to the concurrent use of Python 2.7 and 3.7 environments during development.
|
||||||
|
|
||||||
.. todo::
|
.. todo::
|
||||||
|
|
||||||
Using another IDE than the ones below? Please send a
|
Using another IDE than the ones below? Please send a
|
||||||
|
|||||||
+76
-49
@@ -6,15 +6,6 @@ Events
|
|||||||
|
|
||||||
.. contents::
|
.. contents::
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
With release of OctoPrint 1.1.0, the payload data has been harmonized, it is now a key-value-map for all events.
|
|
||||||
Additionally, the format of the placeholders in both system command and gcode command triggers has been changed to
|
|
||||||
accommodate for this new format. Last but not least, the way of specifying event hooks has changed, OctoPrint no longer
|
|
||||||
separates hooks into two sections (gcodeCommandTrigger and systemCommandTrigger) but instead event hooks are now typed
|
|
||||||
to indicate what to do with the command contained.
|
|
||||||
|
|
||||||
.. _sec-events-configuration:
|
.. _sec-events-configuration:
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
@@ -47,6 +38,13 @@ Example
|
|||||||
- event: PrintDone
|
- event: PrintDone
|
||||||
command: python ~/growl.py -t mygrowlserver -d "Completed {file}" -a OctoPrint -i http://raspi/Octoprint_logo.png
|
command: python ~/growl.py -t mygrowlserver -d "Completed {file}" -a OctoPrint -i http://raspi/Octoprint_logo.png
|
||||||
type: system
|
type: system
|
||||||
|
- event:
|
||||||
|
- PrintStarted
|
||||||
|
- PrintFailed
|
||||||
|
- PrintDone
|
||||||
|
- PrintCancelled
|
||||||
|
command: python ~/growl.py -t mygrowlserver -d "Event {__eventname} ({name})" -a OctoPrint -i http://raspi/Octoprint_logo.png
|
||||||
|
type: system
|
||||||
- event: Connected
|
- event: Connected
|
||||||
command:
|
command:
|
||||||
- M115
|
- M115
|
||||||
@@ -62,6 +60,7 @@ Placeholders
|
|||||||
You can use the following generic placeholders in your event hooks:
|
You can use the following generic placeholders in your event hooks:
|
||||||
|
|
||||||
* ``{__currentZ}``: the current Z position of the head if known, -1 if not available
|
* ``{__currentZ}``: the current Z position of the head if known, -1 if not available
|
||||||
|
* ``{__eventname}`` : the name of the event hook being triggered
|
||||||
* ``{__filename}`` : name of currently selected file, or ``NO FILE`` if no file is selected
|
* ``{__filename}`` : name of currently selected file, or ``NO FILE`` if no file is selected
|
||||||
* ``{__filepath}`` : path in origin location of currently selected file, or ``NO FILE`` if no file is selected
|
* ``{__filepath}`` : path in origin location of currently selected file, or ``NO FILE`` if no file is selected
|
||||||
* ``{__fileorigin}`` : origin of currently selected file, or ``NO FILE`` if no file is selected
|
* ``{__fileorigin}`` : origin of currently selected file, or ``NO FILE`` if no file is selected
|
||||||
@@ -85,6 +84,12 @@ and its origin via the placeholder ``{origin}``.
|
|||||||
Available Events
|
Available Events
|
||||||
================
|
================
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Plugins may add additional events via the :ref:`octoprint.events.register_custom_events hook <sec-plugins-hook-events-register_custom_events>`.
|
||||||
|
|
||||||
|
.. _sec-events-available_events-server:
|
||||||
|
|
||||||
Server
|
Server
|
||||||
------
|
------
|
||||||
|
|
||||||
@@ -118,6 +123,8 @@ ConnectivityChanged
|
|||||||
* ``old``: Old connectivity value (true for online, false for offline)
|
* ``old``: Old connectivity value (true for online, false for offline)
|
||||||
* ``new``: New connectivity value (true for online, false for offline)
|
* ``new``: New connectivity value (true for online, false for offline)
|
||||||
|
|
||||||
|
.. _sec-events-available_events-printer_commmunication:
|
||||||
|
|
||||||
Printer communication
|
Printer communication
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
@@ -141,7 +148,8 @@ Disconnected
|
|||||||
The server has disconnected from the printer
|
The server has disconnected from the printer
|
||||||
|
|
||||||
Error
|
Error
|
||||||
An error has occurred in the printer communication.
|
An unrecoverable error has been encountered, either as reported by the firmware (e.g. a thermal runaway) or
|
||||||
|
on the connection.
|
||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
@@ -156,6 +164,8 @@ PrinterStateChanged
|
|||||||
:func:`~octoprint.printer.PrinterInterface.get_state_id` for possible values.
|
:func:`~octoprint.printer.PrinterInterface.get_state_id` for possible values.
|
||||||
* ``state_string``: Text representation of the new state.
|
* ``state_string``: Text representation of the new state.
|
||||||
|
|
||||||
|
.. _sec-events-available_events-file_handling:
|
||||||
|
|
||||||
File handling
|
File handling
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
@@ -169,9 +179,7 @@ Upload
|
|||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's path within its storage location
|
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
FileAdded
|
FileAdded
|
||||||
A file has been added to a storage.
|
A file has been added to a storage.
|
||||||
@@ -253,9 +261,7 @@ MetadataAnalysisStarted
|
|||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's path within its storage location
|
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
MetadataAnalysisFinished
|
MetadataAnalysisFinished
|
||||||
The metadata analysis of a file has finished.
|
The metadata analysis of a file has finished.
|
||||||
@@ -269,9 +275,7 @@ MetadataAnalysisFinished
|
|||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's path within its storage location
|
* ``file``: the file's path within its storage location. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
FileSelected
|
FileSelected
|
||||||
A file has been selected for printing.
|
A file has been selected for printing.
|
||||||
@@ -284,10 +288,8 @@ FileSelected
|
|||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
FileDeselected
|
FileDeselected
|
||||||
No file is selected any more for printing.
|
No file is selected any more for printing.
|
||||||
@@ -311,6 +313,8 @@ TransferDone
|
|||||||
* ``local``: the file's name as stored locally
|
* ``local``: the file's name as stored locally
|
||||||
* ``remote``: the file's name as stored on SD
|
* ``remote``: the file's name as stored on SD
|
||||||
|
|
||||||
|
.. _sec-events-available_events-printing:
|
||||||
|
|
||||||
Printing
|
Printing
|
||||||
--------
|
--------
|
||||||
|
|
||||||
@@ -322,13 +326,14 @@ PrintStarted
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
|
* ``user``: the user who started the print job (if available)
|
||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
PrintFailed
|
PrintFailed
|
||||||
A print failed.
|
A print failed.
|
||||||
@@ -338,13 +343,15 @@ PrintFailed
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
|
* ``time``: the elapsed time of the print when it failed, in seconds (float)
|
||||||
|
* ``reason``: the reason the print failed, either ``cancelled`` or ``error``
|
||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
PrintDone
|
PrintDone
|
||||||
A print completed successfully.
|
A print completed successfully.
|
||||||
@@ -354,14 +361,14 @@ PrintDone
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
* ``time``: the time needed for the print, in seconds (float)
|
* ``time``: the time needed for the print, in seconds (float)
|
||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
PrintCancelling
|
PrintCancelling
|
||||||
The print is about to be cancelled.
|
The print is about to be cancelled.
|
||||||
@@ -371,6 +378,9 @@ PrintCancelling
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
|
* ``user``: the user who cancelled the print job (if available)
|
||||||
* ``firmwareError``: the firmware error that caused cancelling the print job, if any
|
* ``firmwareError``: the firmware error that caused cancelling the print job, if any
|
||||||
|
|
||||||
PrintCancelled
|
PrintCancelled
|
||||||
@@ -381,7 +391,12 @@ PrintCancelled
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
* ``position``: the print head position at the time of cancelling, if available
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
|
* ``time``: the elapsed time of the print when it was cancelled, in seconds (float)
|
||||||
|
* ``user``: the user who cancelled the print job (if available)
|
||||||
|
* ``position``: the print head position at the time of cancelling (if available, not available if recording of the
|
||||||
|
position on cancel is disabled)
|
||||||
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
|
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
|
||||||
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
|
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
|
||||||
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
|
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
|
||||||
@@ -395,10 +410,8 @@ PrintCancelled
|
|||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
PrintPaused
|
PrintPaused
|
||||||
The print has been paused.
|
The print has been paused.
|
||||||
@@ -408,7 +421,11 @@ PrintPaused
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
* ``position``: the print head position at the time of pausing, if available
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
|
* ``user``: the user who paused the print job (if available)
|
||||||
|
* ``position``: the print head position at the time of pausing (if available, not available if the recording of
|
||||||
|
the position on pause is disabled or the pause is completely handled by the printer's firmware)
|
||||||
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
|
* ``position.x``: x coordinate, as reported back from the firmware through `M114`
|
||||||
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
|
* ``position.y``: y coordinate, as reported back from the firmware through `M114`
|
||||||
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
|
* ``position.z``: z coordinate, as reported back from the firmware through `M114`
|
||||||
@@ -422,10 +439,8 @@ PrintPaused
|
|||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
|
||||||
|
|
||||||
PrintResumed
|
PrintResumed
|
||||||
The print has been resumed.
|
The print has been resumed.
|
||||||
@@ -435,13 +450,16 @@ PrintResumed
|
|||||||
* ``name``: the file's name
|
* ``name``: the file's name
|
||||||
* ``path``: the file's path within its storage location
|
* ``path``: the file's path within its storage location
|
||||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||||
|
* ``size``: the file's size in bytes (if available)
|
||||||
|
* ``owner``: the user who started the print job (if available)
|
||||||
|
* ``user``: the user who resumed the print job (if available)
|
||||||
|
|
||||||
.. deprecated:: 1.3.0
|
.. deprecated:: 1.3.0
|
||||||
|
|
||||||
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``)
|
* ``file``: the file's full path on disk (``local``) or within its storage (``sdcard``). To be removed in 1.4.0.
|
||||||
* ``filename``: the file's name
|
* ``filename``: the file's name. To be removed in 1.4.0.
|
||||||
|
|
||||||
Still available for reasons of backwards compatibility. Will be removed with 1.4.0.
|
.. _sec-events-available_events-gcode_processing:
|
||||||
|
|
||||||
GCODE processing
|
GCODE processing
|
||||||
----------------
|
----------------
|
||||||
@@ -504,6 +522,8 @@ ToolChange
|
|||||||
* ``old``: old tool index
|
* ``old``: old tool index
|
||||||
* ``new``: new tool index
|
* ``new``: new tool index
|
||||||
|
|
||||||
|
.. _sec-events-available_events-timelapses:
|
||||||
|
|
||||||
Timelapses
|
Timelapses
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@@ -558,6 +578,8 @@ MovieFailed
|
|||||||
returned a non-0 return code, ``no_frames`` if no frames were captured that could be rendered
|
returned a non-0 return code, ``no_frames`` if no frames were captured that could be rendered
|
||||||
to a timelapse, or ``unknown`` for any other reason of failure to render.
|
to a timelapse, or ``unknown`` for any other reason of failure to render.
|
||||||
|
|
||||||
|
.. _sec-events-available_events-slicing:
|
||||||
|
|
||||||
Slicing
|
Slicing
|
||||||
-------
|
-------
|
||||||
|
|
||||||
@@ -629,8 +651,13 @@ SlicingProfileDeleted
|
|||||||
* ``slicer``: the slicer for which the profile was deleted
|
* ``slicer``: the slicer for which the profile was deleted
|
||||||
* ``profile``: the profile that was deleted
|
* ``profile``: the profile that was deleted
|
||||||
|
|
||||||
|
.. _sec-events-available_events-settings:
|
||||||
|
|
||||||
Settings
|
Settings
|
||||||
--------
|
--------
|
||||||
|
|
||||||
SettingsUpdated
|
SettingsUpdated
|
||||||
The internal settings were updated.
|
The settings were updated via the REST API.
|
||||||
|
|
||||||
|
This event may also be triggered if calling code of :py:class:`octoprint.settings.Settings.save` or
|
||||||
|
:py:class:`octoprint.plugin.PluginSettings.save` sets the ``trigger_event`` parameter to ``True``.
|
||||||
@@ -21,12 +21,12 @@ Commands, which are admin-only.
|
|||||||
|
|
||||||
If Access Control is disabled, everything is directly accessible. **That also
|
If Access Control is disabled, everything is directly accessible. **That also
|
||||||
includes all administrative functionality as well as full control over the
|
includes all administrative functionality as well as full control over the
|
||||||
printer!**
|
printer**, and without the need for an :ref:`API key <sec-api-general-authorization>`!
|
||||||
|
|
||||||
Upon first start a configuration wizard is provided which allows configuration
|
Upon first start a configuration wizard is provided which allows configuration
|
||||||
of the first administrator account or alternatively disabling Access Control
|
of the first administrator account or alternatively disabling Access Control
|
||||||
(which is **NOT** recommended for systems that are directly accessible via the
|
(which is **NOT** recommended for systems that are directly accessible via the
|
||||||
Internet!).
|
internet or other untrusted networks!).
|
||||||
|
|
||||||
.. hint::
|
.. hint::
|
||||||
|
|
||||||
|
|||||||
@@ -157,9 +157,13 @@ The ``disable_hotends`` snippet is defined as follows:
|
|||||||
.. code-block:: jinja
|
.. code-block:: jinja
|
||||||
:caption: Default ``disable_hotends`` snippet
|
:caption: Default ``disable_hotends`` snippet
|
||||||
|
|
||||||
|
{% if printer_profile.extruder.sharedNozzle %}
|
||||||
|
M104 T0 S0
|
||||||
|
{% else %}
|
||||||
{% for tool in range(printer_profile.extruder.count) %}
|
{% for tool in range(printer_profile.extruder.count) %}
|
||||||
M104 T{{ tool }} S0
|
M104 T{{ tool }} S0
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
The ``disable_bed`` snippet is defined as follows:
|
The ``disable_bed`` snippet is defined as follows:
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@ and released under the `GNU Affero General Public License V3 <http://www.gnu.org
|
|||||||
|
|
||||||
Its website can be found at `octoprint.org <https://octoprint.org/>`_.
|
Its website can be found at `octoprint.org <https://octoprint.org/>`_.
|
||||||
|
|
||||||
The community forum is available at `discourse.octoprint.org <https://discourse.octoprint.org/>`_.
|
The community forum is available at `community.octoprint.org <https://community.octoprint.org/>`_.
|
||||||
|
|
||||||
The FAQ can be accessed by following `faq.octoprint.org <https://faq.octoprint.org/>`_.
|
The FAQ can be accessed by following `faq.octoprint.org <https://faq.octoprint.org/>`_.
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ If you enjoy OctoPrint, please consider becoming a regular supporter!
|
|||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This documentation currently focuses primarily on developers and less on end users. If you are interested in
|
This documentation currently focuses primarily on developers and less on end users. If you are interested in
|
||||||
helping to change this, please get in touch `on the forum <https://discourse.octoprint.org/>`_!
|
helping to change this, please get in touch `on the forum <https://community.octoprint.org/>`_!
|
||||||
|
|
||||||
Contents
|
Contents
|
||||||
========
|
========
|
||||||
|
|||||||
@@ -210,6 +210,64 @@
|
|||||||
:param object opts: Additional options for the request
|
:param object opts: Additional options for the request
|
||||||
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
||||||
|
|
||||||
|
.. js:function:: OctoPrintClient.printer.getChamberState(data, opts)
|
||||||
|
|
||||||
|
Retrieves the current printer chamber state/temperature information, and optionally also the temperature
|
||||||
|
history.
|
||||||
|
|
||||||
|
The ``flags`` object can be used to specify the data to retrieve further via the following
|
||||||
|
properties:
|
||||||
|
|
||||||
|
* ``history``: a boolean value to specify whether the temperature history should be included (``true``)
|
||||||
|
or not (``false``), defaults to it not being included
|
||||||
|
* ``limit``: an integer value to specify how many history entries to include
|
||||||
|
|
||||||
|
See :ref:`Retrieve the current bed state <sec-api-printer-chamberstate>` for more details.
|
||||||
|
|
||||||
|
:param object flags: Flags that further specify which data to retrieve, see above for details
|
||||||
|
: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.printer.setChamberTargetTemperature(target, opts)
|
||||||
|
|
||||||
|
Sets the given temperature on the printer's heated chamber (if available).
|
||||||
|
|
||||||
|
``target`` is expected to be the target temperature as a float value.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
Set the chamber to 50°C.
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
OctoPrint.printer.setChamberTargetTemperature(50.0);
|
||||||
|
|
||||||
|
See the ``target`` command in :ref:`Issue a chamber command <sec-api-printer-chambercommand>` for more details.
|
||||||
|
|
||||||
|
:param float target: The target to set
|
||||||
|
: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.printer.setChamberTemperatureOffset(offset, opts)
|
||||||
|
|
||||||
|
Sets the given temperature offset for the printer's heated chamber (if available).
|
||||||
|
|
||||||
|
``offset`` is expected to be the temperature offset to set.
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
Set the offset for the chamber to -5°C.
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
OctoPrint.printer.setChamberTemperatureOffset(-5);
|
||||||
|
|
||||||
|
See the ``offset`` command in :ref:`Issue a chamber command <sec-api-printer-chambercommand>` for more details.
|
||||||
|
|
||||||
|
:param object offsets: The offsets to set
|
||||||
|
: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.printer.jog(amounts, opts)
|
.. js:function:: OctoPrintClient.printer.jog(amounts, opts)
|
||||||
|
|
||||||
Jogs the specified axes by the specified ``amounts``.
|
Jogs the specified axes by the specified ``amounts``.
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
.. _sec-modules-users:
|
.. _sec-modules-users:
|
||||||
|
|
||||||
octoprint.users
|
octoprint.access.users
|
||||||
---------------
|
----------------------
|
||||||
|
|
||||||
.. automodule:: octoprint.users
|
.. automodule:: octoprint.access.users
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
|
||||||
@@ -6,4 +6,10 @@ octoprint.util
|
|||||||
.. automodule:: octoprint.util
|
.. automodule:: octoprint.util
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
.. _sec-modules-util-commandline:
|
||||||
|
|
||||||
|
octoprint.util.commandline
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
.. automodule:: octoprint.util.commandline
|
||||||
|
:members:
|
||||||
@@ -13,6 +13,7 @@ plugin subsystem about themselves. These are simple package attributes defined i
|
|||||||
# ...
|
# ...
|
||||||
|
|
||||||
__plugin_name__ = "My Plugin"
|
__plugin_name__ = "My Plugin"
|
||||||
|
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||||
def __plugin_load__():
|
def __plugin_load__():
|
||||||
# whatever you need to do to load your plugin, if anything at all
|
# whatever you need to do to load your plugin, if anything at all
|
||||||
pass
|
pass
|
||||||
@@ -52,6 +53,20 @@ The following properties are recognized:
|
|||||||
``__plugin_license__``
|
``__plugin_license__``
|
||||||
License of your plugin, optional, overrides the license specified in ``setup.py`` if provided.
|
License of your plugin, optional, overrides the license specified in ``setup.py`` if provided.
|
||||||
|
|
||||||
|
.. _sec-plugins-controlproperties-plugin_pythoncompat:
|
||||||
|
|
||||||
|
``__plugin_pythoncompat__``
|
||||||
|
Python compatibility string of your plugin, optional, defaults to ``>=2.7,<3`` if not set and thus Python 2 but no
|
||||||
|
Python 3 compatibility.
|
||||||
|
|
||||||
|
If your plugin is compatible to Python 3, you should set this to ``>=2.7,<4``, otherwise your plugin will not load
|
||||||
|
on OctoPrint instances installed under Python 3.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||||
|
|
||||||
|
|
||||||
.. _sec-plugins-controlproperties-plugin_implementation:
|
.. _sec-plugins-controlproperties-plugin_implementation:
|
||||||
|
|
||||||
``__plugin_implementation__``
|
``__plugin_implementation__``
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ We'll start at the most basic form a plugin can take - just a few simple lines o
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
__plugin_name__ = "Hello World"
|
__plugin_name__ = "Hello World"
|
||||||
__plugin_version__ = "1.0.0"
|
__plugin_version__ = "1.0.0"
|
||||||
@@ -89,8 +89,8 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t
|
|||||||
:emphasize-lines: 4-8,13
|
:emphasize-lines: 4-8,13
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -289,8 +289,8 @@ and ``__plugin_description__`` from ``__init__.py``:
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -314,8 +314,8 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the
|
|||||||
:emphasize-lines: 10
|
:emphasize-lines: 10
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -362,8 +362,8 @@ add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class:
|
|||||||
:emphasize-lines: 7
|
:emphasize-lines: 7
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -428,8 +428,8 @@ Let's take a look at how all that would look in our plugin's ``__init__.py``:
|
|||||||
:emphasize-lines: 8, 10, 12-13
|
:emphasize-lines: 8, 10, 12-13
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -462,8 +462,8 @@ Adjust your plugin's ``__init__.py`` like this:
|
|||||||
:emphasize-lines: 15-16
|
:emphasize-lines: 15-16
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -569,8 +569,8 @@ again since we don't use that anymore:
|
|||||||
:emphasize-lines: 15-19
|
:emphasize-lines: 15-19
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -666,8 +666,8 @@ like so:
|
|||||||
:emphasize-lines: 9,22-25
|
:emphasize-lines: 9,22-25
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -846,8 +846,8 @@ a reference to our CSS file:
|
|||||||
:emphasize-lines: 26
|
:emphasize-lines: 26
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
@@ -931,8 +931,8 @@ Then adjust our returned assets to include our LESS file as well:
|
|||||||
:emphasize-lines: 27
|
:emphasize-lines: 27
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
|
|||||||
+187
-47
@@ -28,6 +28,7 @@ or as ``postfix`` (after the existing lines).
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
|
from past import basestring
|
||||||
self._gcode_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts")
|
self._gcode_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts")
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
@@ -35,7 +36,7 @@ or as ``postfix`` (after the existing lines).
|
|||||||
for hook in self._gcodescript_hooks:
|
for hook in self._gcodescript_hooks:
|
||||||
try:
|
try:
|
||||||
retval = self._gcodescript_hooks[hook](self, "gcode", scriptName)
|
retval = self._gcodescript_hooks[hook](self, "gcode", scriptName)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error while processing gcodescript hook %s" % hook)
|
self._logger.exception("Error while processing gcodescript hook %s" % hook)
|
||||||
else:
|
else:
|
||||||
if retval is None:
|
if retval is None:
|
||||||
@@ -44,10 +45,8 @@ or as ``postfix`` (after the existing lines).
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
def to_list(data):
|
def to_list(data):
|
||||||
if isinstance(data, str):
|
if isinstance(data, basestring):
|
||||||
data = map(str.strip, data.split("\n"))
|
data = map(x.strip() for x in data.split("\n"))
|
||||||
elif isinstance(data, unicode):
|
|
||||||
data = map(unicode.strip, data.split("\n"))
|
|
||||||
|
|
||||||
if isinstance(data, (list, tuple)):
|
if isinstance(data, (list, tuple)):
|
||||||
return list(data)
|
return list(data)
|
||||||
@@ -201,31 +200,6 @@ Available plugin hooks
|
|||||||
.. contents::
|
.. contents::
|
||||||
:local:
|
:local:
|
||||||
|
|
||||||
.. _sec-plugins-hook-accesscontrol-appkey:
|
|
||||||
|
|
||||||
octoprint.accesscontrol.appkey
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
.. py:function:: acl_appkey_hook(*args, **kwargs)
|
|
||||||
|
|
||||||
By handling this hook plugins may register additional :ref:`App session key providers <sec-api-apps-sessionkey>`
|
|
||||||
within the system.
|
|
||||||
|
|
||||||
Overrides this to return your additional app information to be used for validating app session keys. You'll
|
|
||||||
need to return a list of 3-tuples of the format (id, version, public key).
|
|
||||||
|
|
||||||
The ``id`` should be the (unique) identifier of the app. Using a domain prefix might make sense here, e.g.
|
|
||||||
``org.octoprint.example.MyApp``.
|
|
||||||
|
|
||||||
``version`` should be a string specifying the version of the app for which the public key is valid. You can
|
|
||||||
provide the string ``any`` here, in which case the provided public key will be valid for all versions of the
|
|
||||||
app for which no specific public key is defined.
|
|
||||||
|
|
||||||
Finally, the public key is expected to be provided as a PKCS1 string without newlines.
|
|
||||||
|
|
||||||
:return: A list of 3-tuples as described above
|
|
||||||
:rtype: list
|
|
||||||
|
|
||||||
.. _sec-plugins-hook-accesscontrol-keyvalidator:
|
.. _sec-plugins-hook-accesscontrol-keyvalidator:
|
||||||
|
|
||||||
octoprint.accesscontrol.keyvalidator
|
octoprint.accesscontrol.keyvalidator
|
||||||
@@ -237,7 +211,7 @@ octoprint.accesscontrol.keyvalidator
|
|||||||
|
|
||||||
``apikey`` will be the API key as read from the request headers.
|
``apikey`` will be the API key as read from the request headers.
|
||||||
|
|
||||||
Hook handlers are expected to return a :class:`~octoprint.users.User` instance here that will then be considered that
|
Hook handlers are expected to return a :class:`~octoprint.access.users.User` instance here that will then be considered that
|
||||||
user making the request. By returning ``None`` or nothing at all, hook handlers signal that they do not handle the
|
user making the request. By returning ``None`` or nothing at all, hook handlers signal that they do not handle the
|
||||||
provided key.
|
provided key.
|
||||||
|
|
||||||
@@ -255,7 +229,7 @@ octoprint.accesscontrol.keyvalidator
|
|||||||
|
|
||||||
:param str apikey: The API key to validate
|
:param str apikey: The API key to validate
|
||||||
:return: The user in whose name the request will be processed further
|
:return: The user in whose name the request will be processed further
|
||||||
:rtype: :class:`~octoprint.users.User`
|
:rtype: :class:`~octoprint.access.users.User`
|
||||||
|
|
||||||
.. _sec-plugins-hook-cli-commands:
|
.. _sec-plugins-hook-cli-commands:
|
||||||
|
|
||||||
@@ -380,10 +354,10 @@ octoprint.cli.commands
|
|||||||
OctoPrint's CLI.
|
OctoPrint's CLI.
|
||||||
:rtype: list
|
:rtype: list
|
||||||
|
|
||||||
.. _sec-plugins-hook-comm-firmware-info:
|
.. _sec-plugins-hook-comm-protocol-firmware-info:
|
||||||
|
|
||||||
octoprint.comm.firmware.info
|
octoprint.comm.protocol.firmware.info
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. py:function:: firmware_info_hook(comm_instance, firmware_name, firmware_data, *args, **kwargs)
|
.. py:function:: firmware_info_hook(comm_instance, firmware_name, firmware_data, *args, **kwargs)
|
||||||
|
|
||||||
@@ -413,10 +387,10 @@ octoprint.comm.firmware.info
|
|||||||
:param str firmware_name: The name of the parsed capability
|
:param str firmware_name: The name of the parsed capability
|
||||||
:param dict firmware_data: All data contained in the ``M115`` report
|
:param dict firmware_data: All data contained in the ``M115`` report
|
||||||
|
|
||||||
.. _sec-plugins-hook-comm-firmware-capabilities:
|
.. _sec-plugins-hook-comm-protocol-firmware-capabilities:
|
||||||
|
|
||||||
octoprint.comm.firmware.capabilities
|
octoprint.comm.firmware.protocol.capabilities
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. py:function:: firmware_capability_hook(comm_instance, capability, enabled, already_defined, *args, **kwargs)
|
.. py:function:: firmware_capability_hook(comm_instance, capability, enabled, already_defined, *args, **kwargs)
|
||||||
|
|
||||||
@@ -762,9 +736,10 @@ octoprint.comm.protocol.scripts
|
|||||||
make sure to only proceed with returning additional scripts if the ``script_type`` and ``script_name`` match
|
make sure to only proceed with returning additional scripts if the ``script_type`` and ``script_name`` match
|
||||||
handled scripts. If not, None should be returned directly.
|
handled scripts. If not, None should be returned directly.
|
||||||
|
|
||||||
If the hook handler has something to add to the specified script, it may return a 2-tuple or a 3-tuple with the first entry
|
If the hook handler has something to add to the specified script, it may return a 2-tuple, a 3-tuple or a 4-tuple with the first entry
|
||||||
defining the prefix (what to *prepend* to the script in question), the second entry defining the postfix (what to
|
defining the prefix (what to *prepend* to the script in question), the second entry defining the postfix (what to
|
||||||
*append* to the script in question), and finally if desired a dictionary of variables to be made available to the script. Both prefix and postfix can be None to signify that nothing should be prepended
|
*append* to the script in question), and finally if desired a dictionary of variables to be made available to the script on third and additional tags to set on the
|
||||||
|
commands on fourth position. Both prefix and postfix can be None to signify that nothing should be prepended
|
||||||
respectively appended.
|
respectively appended.
|
||||||
|
|
||||||
The returned prefix and postfix entries may be either iterables of script lines or a string including newlines of the script lines (which
|
The returned prefix and postfix entries may be either iterables of script lines or a string including newlines of the script lines (which
|
||||||
@@ -903,6 +878,34 @@ octoprint.comm.transport.serial.factory
|
|||||||
:rtype: A serial instance implementing implementing the methods ``readline(...)``, ``write(...)``, ``close()`` and
|
:rtype: A serial instance implementing implementing the methods ``readline(...)``, ``write(...)``, ``close()`` and
|
||||||
optionally ``baudrate`` and ``timeout`` attributes as described above.
|
optionally ``baudrate`` and ``timeout`` attributes as described above.
|
||||||
|
|
||||||
|
.. _sec-plugins-hook-events-register_custom_events:
|
||||||
|
|
||||||
|
octoprint.events.register_custom_events
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. py:function:: register_custom_events_hook(*args, **kwargs)
|
||||||
|
|
||||||
|
Return a list of custom :ref:`events <sec-events>` to register in the system for your plugin.
|
||||||
|
|
||||||
|
Should return a list of strings which represent the custom events. Their name on the `octoprint.events.Events` object
|
||||||
|
will be the returned value transformed into upper case ``CAMEL_CASE`` and prefixed with ``PLUGIN_<IDENTIFIER>``. Their
|
||||||
|
value will be prefixed with ``plugin_<identifier>_``.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
Consider the following hook part of a plugin with the identifier ``myplugin``. It will register two custom events
|
||||||
|
in the system, ``octoprint.events.Events.PLUGIN_MYPLUGIN_MY_CUSTOM_EVENT`` with value ``plugin_myplugin_my_custom_event``
|
||||||
|
and ``octoprint.events.Events.PLUGIN_MYPLUGIN_MY_OTHER_CUSTOM_EVENT`` with value ``plugin_myplugin_my_other_custom_event``.
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
:linenos:
|
||||||
|
|
||||||
|
def register_custom_events(*args, **kwargs):
|
||||||
|
return ["my_custom_event", "my_other_custom_event"]
|
||||||
|
|
||||||
|
:return: A list of custom events to register
|
||||||
|
:rtype: list
|
||||||
|
|
||||||
.. _sec-plugins-hook-filemanager-analysis-factory:
|
.. _sec-plugins-hook-filemanager-analysis-factory:
|
||||||
|
|
||||||
octoprint.filemanager.analysis.factory
|
octoprint.filemanager.analysis.factory
|
||||||
@@ -1029,9 +1032,8 @@ octoprint.printer.factory
|
|||||||
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
||||||
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
||||||
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
||||||
* ``app_session_manager``: The :class:`~octoprint.server.util.flask.AppSessionManager`
|
|
||||||
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
||||||
* ``user_manager``: The :class:`~octoprint.users.UserManager`
|
* ``user_manager``: The :class:`~octoprint.access.users.UserManager`
|
||||||
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
||||||
|
|
||||||
If the factory returns anything but ``None``, it will be assigned to the global ``printer`` instance.
|
If the factory returns anything but ``None``, it will be assigned to the global ``printer`` instance.
|
||||||
@@ -1089,6 +1091,91 @@ octoprint.printer.estimation.factory
|
|||||||
:return: The :class:`~octoprint.printer.estimation.PrintTimeEstimator` class to use, or a factory method
|
:return: The :class:`~octoprint.printer.estimation.PrintTimeEstimator` class to use, or a factory method
|
||||||
:rtype: class or function
|
:rtype: class or function
|
||||||
|
|
||||||
|
.. _sec-plugins-hook-octoprint-printer-sdcardupload:
|
||||||
|
|
||||||
|
octoprint.printer.sdcardupload
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. py:function:: sd_card_upload_hook(printer, filename, path, start_callback, success_callback, failure_callback, *args, **kwargs)
|
||||||
|
|
||||||
|
Via this hook plugins can change the way files are being uploaded to the sd card of the printer.
|
||||||
|
|
||||||
|
Implementations **must** call the provided ``start_callback`` on start of the file transfer and either the ``success_callback``
|
||||||
|
or ``failure_callback`` on the end of the file transfer, depending on whether it was successful or not.
|
||||||
|
|
||||||
|
The ``start_callback`` has the following signature:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
def start_callback(local_filename, remote_filename):
|
||||||
|
# ...
|
||||||
|
|
||||||
|
``local_filename`` must be the name of the file on the ``local`` storage, ``remote_filename`` the name of the file
|
||||||
|
to be created on the ``sdcard`` storage.
|
||||||
|
|
||||||
|
``success_callback`` and ``failure_callback`` both have the following signature:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
def success_or_failure_callback(local_filename, remote_filename, elapsed):
|
||||||
|
# ...
|
||||||
|
|
||||||
|
``local_filename`` must be the name of the file on the ``local`` storage, ``remote_filename`` the name of the file
|
||||||
|
to be created on the ``sdcard`` storage. ``elapsed`` is the elapsed time in seconds.
|
||||||
|
|
||||||
|
If the hook is going to handle the upload, it must return the (future) remote filename of the file on the ``sdcard``
|
||||||
|
storage. If it returns ``None`` (or an otherwise falsy value), OctoPrint will interpret this as the hook not going to
|
||||||
|
handle the file upload, in which case the next hook or - if no other hook is registered - the default implementation
|
||||||
|
will be called.
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
The following example creates a dummy SD card uploader that does nothing but sleep for ten seconds when a file
|
||||||
|
is supposed to be uploaded. Note that the long running process of sleeping for ten seconds is extracted into its
|
||||||
|
own thread, which is important in order to not block the main application!
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
import threading
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
def nop_upload_to_sd(printer, filename, path, sd_upload_started, sd_upload_succeeded, sd_upload_failed, *args, **kwargs):
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
remote_name = printer._get_free_remote_name(filename)
|
||||||
|
logger.info("Starting dummy SDCard upload from {} to {}".format(filename, remote_name))
|
||||||
|
|
||||||
|
sd_upload_started(filename, remote_name)
|
||||||
|
|
||||||
|
def process():
|
||||||
|
logger.info("Sleeping 10s...")
|
||||||
|
time.sleep(10)
|
||||||
|
logger.info("And done!")
|
||||||
|
sd_upload_succeeded(filename, remote_name, 10)
|
||||||
|
|
||||||
|
thread = threading.Thread(target=process)
|
||||||
|
thread.daemon = True
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
return remote_name
|
||||||
|
|
||||||
|
__plugin_name__ = "No-op SDCard Upload Test"
|
||||||
|
__plugin_hooks__ = {
|
||||||
|
"octoprint.printer.sdcardupload": nop_upload_to_sd
|
||||||
|
}
|
||||||
|
|
||||||
|
.. versionadded:: 1.3.11
|
||||||
|
|
||||||
|
:param object printer: the :py:class:`~octoprint.printer.PrinterInterface` instance the hook was called from
|
||||||
|
:param str filename: filename on the ``local`` storage
|
||||||
|
:param str path: path of the file in the local file system
|
||||||
|
:param function sd_upload_started: callback for when the upload started
|
||||||
|
:param function sd_upload_success: callback for successful finish of upload
|
||||||
|
:param function sd_upload_failure: callback for failure of upload
|
||||||
|
:return: the name of the file on the ``sdcard`` storage or ``None``
|
||||||
|
:rtype: string or ``None``
|
||||||
|
|
||||||
.. _sec-plugins-hook-server-http-after_request:
|
.. _sec-plugins-hook-server-http-after_request:
|
||||||
|
|
||||||
octoprint.server.api.after_request
|
octoprint.server.api.after_request
|
||||||
@@ -1211,6 +1298,14 @@ octoprint.server.http.routes
|
|||||||
view of the blueprint will thus not be reachable since processing of the request will directly be handed over
|
view of the blueprint will thus not be reachable since processing of the request will directly be handed over
|
||||||
to your defined handler class.
|
to your defined handler class.
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
|
||||||
|
If you want your route to support CORS if it's enabled in OctoPrint, your `RequestHandler <http://tornado.readthedocs.org/en/branch4.0/web.html#request-handlers>`_
|
||||||
|
needs to implement the :class:`~octoprint.server.util.tornado.CorsSupportMixin` for this to work. Note that all of
|
||||||
|
:class:`~octoprint.server.util.tornado.LargeResponseHandler`, :class:`~octoprint.server.util.tornado.UrlProxyHandler`,
|
||||||
|
:class:`~octoprint.server.util.tornado.StaticDataHandler` and :class:`~octoprint.server.util.tornado.DeprecatedEndpointHandler`
|
||||||
|
already implement this mixin.
|
||||||
|
|
||||||
.. important::
|
.. important::
|
||||||
|
|
||||||
Implementing this hook will make your plugin require a restart of OctoPrint for enabling/disabling it fully.
|
Implementing this hook will make your plugin require a restart of OctoPrint for enabling/disabling it fully.
|
||||||
@@ -1238,6 +1333,20 @@ octoprint.server.http.routes
|
|||||||
:return: a list of 3-tuples with additional routes as defined above
|
:return: a list of 3-tuples with additional routes as defined above
|
||||||
:rtype: list
|
:rtype: list
|
||||||
|
|
||||||
|
.. _sec-plugins-hook-server-sockjs-authed:
|
||||||
|
|
||||||
|
octoprint.server.sockjs.authed
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. py:function:: socket_authed_hook(socket, user, *args, **kwargs):
|
||||||
|
|
||||||
|
Allows plugins to be notified that a user got authenticated or deauthenticated on the socket (e.g. due to logout).
|
||||||
|
|
||||||
|
See the bundled :ref:`Forcelogin Plugin <sec-bundledplugins-forcelogin>` for an example on how to utilize this.
|
||||||
|
|
||||||
|
:param object socket: the socket object which is about to be registered
|
||||||
|
:param object user: the user that got authenticated on the socket, or None if the user got deauthenticated
|
||||||
|
|
||||||
.. _sec-plugins-hook-server-sockjs-register:
|
.. _sec-plugins-hook-server-sockjs-register:
|
||||||
|
|
||||||
octoprint.server.sockjs.register
|
octoprint.server.sockjs.register
|
||||||
@@ -1418,12 +1527,12 @@ octoprint.ui.web.templatetypes
|
|||||||
|
|
||||||
.. _sec-plugins-hook-users-factory:
|
.. _sec-plugins-hook-users-factory:
|
||||||
|
|
||||||
octoprint.users.factory
|
octoprint.access.users.factory
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. py:function:: user_manager_factory_hook(components, settings, *args, **kwargs)
|
.. py:function:: user_manager_factory_hook(components, settings, *args, **kwargs)
|
||||||
|
|
||||||
Return a :class:`~octoprint.users.UserManager` instance to use as global user manager object. This will
|
Return a :class:`~octoprint.access.users.UserManager` instance to use as global user manager object. This will
|
||||||
be called only once during initial server startup.
|
be called only once during initial server startup.
|
||||||
|
|
||||||
The provided ``components`` is a dictionary containing the already initialized system components:
|
The provided ``components`` is a dictionary containing the already initialized system components:
|
||||||
@@ -1434,7 +1543,6 @@ octoprint.users.factory
|
|||||||
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
* ``analysis_queue``: The :class:`~octoprint.filemanager.analysis.AnalysisQueue`
|
||||||
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
* ``slicing_manager``: The :class:`~octoprint.slicing.SlicingManager`
|
||||||
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
* ``file_manager``: The :class:`~octoprint.filemanager.FileManager`
|
||||||
* ``app_session_manager``: The :class:`~octoprint.server.util.flask.AppSessionManager`
|
|
||||||
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
* ``plugin_lifecycle_manager``: The :class:`~octoprint.server.LifecycleManager`
|
||||||
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
* ``preemptive_cache``: The :class:`~octoprint.server.util.flask.PreemptiveCache`
|
||||||
|
|
||||||
@@ -1442,7 +1550,7 @@ octoprint.users.factory
|
|||||||
|
|
||||||
If none of the registered factories return a user manager instance, the class referenced by the ``config.yaml``
|
If none of the registered factories return a user manager instance, the class referenced by the ``config.yaml``
|
||||||
entry ``accessControl.userManager`` will be initialized if possible, otherwise a stock
|
entry ``accessControl.userManager`` will be initialized if possible, otherwise a stock
|
||||||
:class:`~octoprint.users.FilebasedUserManager` will be instantiated, linked to the default user storage
|
:class:`~octoprint.access.users.FilebasedUserManager` will be instantiated, linked to the default user storage
|
||||||
file ``~/.octoprint/users.yaml``.
|
file ``~/.octoprint/users.yaml``.
|
||||||
|
|
||||||
:param dict components: System components to use for user manager instance initialization
|
:param dict components: System components to use for user manager instance initialization
|
||||||
@@ -1450,3 +1558,35 @@ octoprint.users.factory
|
|||||||
:return: The ``userManager`` instance to use globally.
|
:return: The ``userManager`` instance to use globally.
|
||||||
:rtype: UserManager subclass or None
|
:rtype: UserManager subclass or None
|
||||||
|
|
||||||
|
|
||||||
|
.. _sec-plugins-hook-timelapse-capture-pre:
|
||||||
|
|
||||||
|
octoprint.timelapse.capture.pre
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. py:function:: capture_pre_hook(filename)
|
||||||
|
|
||||||
|
Perform specific actions prior to capturing a timelapse frame.
|
||||||
|
|
||||||
|
``filename`` will be the future path of the frame to be saved.
|
||||||
|
|
||||||
|
:param str filename: The future path of the frame to be saved.
|
||||||
|
:return: None
|
||||||
|
:rtype: None
|
||||||
|
|
||||||
|
.. _sec-plugins-hook-timelapse-capture-post:
|
||||||
|
|
||||||
|
octoprint.timelapse.capture.post
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. py:function:: capture_post_hook(filename, success)
|
||||||
|
|
||||||
|
Perform specific actions after capturing a timelapse frame.
|
||||||
|
|
||||||
|
``filename`` will be the path of the frame that should have been saved.
|
||||||
|
``sucesss`` indicates whether the capture was successful or not.
|
||||||
|
|
||||||
|
:param str filename: The path of the frame that should have been saved.
|
||||||
|
:param boolean success: Indicates whether the capture was successful or not.
|
||||||
|
:return: None
|
||||||
|
:rtype: None
|
||||||
@@ -41,10 +41,8 @@ An overview of these properties follows.
|
|||||||
OctoPrint's file manager, an instance of :class:`octoprint.filemanager.FileManager`.
|
OctoPrint's file manager, an instance of :class:`octoprint.filemanager.FileManager`.
|
||||||
``self._printer``
|
``self._printer``
|
||||||
OctoPrint's printer management object, an instance of :class:`octoprint.printer.PrinterInterface`.
|
OctoPrint's printer management object, an instance of :class:`octoprint.printer.PrinterInterface`.
|
||||||
``self._app_session_manager``
|
|
||||||
OctoPrint's application session manager, an instance of :class:`octoprint.server.util.flask.AppSessionManager`.
|
|
||||||
``self._user_manager``
|
``self._user_manager``
|
||||||
OctoPrint's user manager, an instance of :class:`octoprint.users.UserManager`.
|
OctoPrint's user manager, an instance of :class:`octoprint.access.users.UserManager`.
|
||||||
``self._connectivity_checker``
|
``self._connectivity_checker``
|
||||||
OctoPrint's connectivity checker, an instance of :class:`octoprint.util.ConnectivityChecker`.
|
OctoPrint's connectivity checker, an instance of :class:`octoprint.util.ConnectivityChecker`.
|
||||||
|
|
||||||
|
|||||||
+44
-9
@@ -68,11 +68,14 @@ calls are done is as follows:
|
|||||||
|
|
||||||
* Plugins with a return value that is not ``None`` for :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`
|
* Plugins with a return value that is not ``None`` for :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`
|
||||||
for the provided sorting context will be ordered among each other first. If the returned order number is equal for
|
for the provided sorting context will be ordered among each other first. If the returned order number is equal for
|
||||||
two or more implementations, the plugin's identifier will be the next sorting criteria.
|
two or more implementations, they will be sorted first by whether they come bundled with OctoPrint or not, then by
|
||||||
* After that follow plugins which returned ``None`` (the default). They are sorted by their identifier.
|
their identifier.
|
||||||
|
* After that follow plugins which returned ``None`` (the default). They are first sorted by whether they come bundled
|
||||||
|
with OctoPrint or not, then by their identifier.
|
||||||
|
|
||||||
Example: Consider three plugin implementations implementing the :class:`~octoprint.plugin.StartupPlugin` mixin, called
|
Example: Consider four plugin implementations implementing the :class:`~octoprint.plugin.StartupPlugin` mixin, called
|
||||||
``plugin_a``, ``plugin_b`` and ``plugin_c``. ``plugin_a`` doesn't override :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`.
|
``plugin_a``, ``plugin_b``, ``plugin_c`` and ``plugin_d``, the latter coming bundled with OctoPrint. ``plugin_a``
|
||||||
|
and ``plugin_d`` don't override :meth:`~octoprint.plugin.core.SortablePlugin.get_sorting_key`.
|
||||||
``plugin_b`` and ``plugin_c`` both return ``1`` for the sorting context ``StartupPlugin.on_startup``, ``None`` otherwise:
|
``plugin_b`` and ``plugin_c`` both return ``1`` for the sorting context ``StartupPlugin.on_startup``, ``None`` otherwise:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@@ -99,7 +102,7 @@ Example: Consider three plugin implementations implementing the :class:`~octopri
|
|||||||
|
|
||||||
class PluginB(octoprint.plugin.StartupPlugin):
|
class PluginB(octoprint.plugin.StartupPlugin):
|
||||||
|
|
||||||
def get_sorting_key(context):
|
def get_sorting_key(self, context):
|
||||||
if context == "StartupPlugin.on_startup":
|
if context == "StartupPlugin.on_startup":
|
||||||
return 1
|
return 1
|
||||||
return None
|
return None
|
||||||
@@ -120,7 +123,7 @@ Example: Consider three plugin implementations implementing the :class:`~octopri
|
|||||||
|
|
||||||
class PluginC(octoprint.plugin.StartupPlugin):
|
class PluginC(octoprint.plugin.StartupPlugin):
|
||||||
|
|
||||||
def get_sorting_key(context):
|
def get_sorting_key(self, context):
|
||||||
if context == "StartupPlugin.on_startup":
|
if context == "StartupPlugin.on_startup":
|
||||||
return 1
|
return 1
|
||||||
return None
|
return None
|
||||||
@@ -134,13 +137,45 @@ Example: Consider three plugin implementations implementing the :class:`~octopri
|
|||||||
|
|
||||||
__plugin_implementation__ = PluginC()
|
__plugin_implementation__ = PluginC()
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
:linenos:
|
||||||
|
:caption: plugin_d.py
|
||||||
|
|
||||||
|
# in this example this is bundled with OctoPrint
|
||||||
|
import octoprint.plugin
|
||||||
|
|
||||||
|
class PluginD(octoprint.plugin.StartupPlugin):
|
||||||
|
|
||||||
|
def on_startup(self, *args, **kwargs):
|
||||||
|
self._logger.info("PluginD starting up")
|
||||||
|
|
||||||
|
def on_after_startup(self, *args, **kwargs):
|
||||||
|
self._logger.info("PluginD started up")
|
||||||
|
|
||||||
|
__plugin_implementation__ = PluginD()
|
||||||
|
|
||||||
OctoPrint will detect that ``plugin_b`` and ``plugin_c`` define a order number, and since it's identical for both (``1``)
|
OctoPrint will detect that ``plugin_b`` and ``plugin_c`` define a order number, and since it's identical for both (``1``)
|
||||||
will order both plugins based on their plugin identifier. ``plugin_a`` doesn't define a sort key and hence will be
|
will order both plugins based first on their bundling status and then on their plugin identifier.
|
||||||
put after the other two. The execution order of the ``on_startup`` method will hence be ``plugin_b``, ``plugin_c``, ``plugin_a``.
|
``plugin_a`` and ``plugin_d`` don't define a sort key and hence will be
|
||||||
|
put after the other two, with ``plugin_d`` coming *before* ``plugin_a`` since it comes bundled with OctoPrint.
|
||||||
|
The execution order of the ``on_startup`` method will hence be ``plugin_b``, ``plugin_c``, ``plugin_d``, ``plugin_a``.
|
||||||
|
|
||||||
Now, the execution order of the ``on_after_startup`` method will be determined based on another sorting context,
|
Now, the execution order of the ``on_after_startup`` method will be determined based on another sorting context,
|
||||||
``StartupPlugin.on_after_startup`` for which all of the plugins return ``None``. Hence, the execution order of the
|
``StartupPlugin.on_after_startup`` for which all of the plugins return ``None``. Hence, the execution order of the
|
||||||
``on_after_startup`` method will be purely ordered by plugin identifier, ``plugin_a``, ``plugin_b``, ``plugin_c``.
|
``on_after_startup`` method will be ordered first by bundle status, then by plugin identifier: ``plugin_d``, ``plugin_a``, ``plugin_b``, ``plugin_c``.
|
||||||
|
|
||||||
|
This will result in the following messages to be generated:
|
||||||
|
|
||||||
|
.. code-block:: plain
|
||||||
|
|
||||||
|
Plugin B starting up
|
||||||
|
Plugin C starting up
|
||||||
|
Plugin D starting up
|
||||||
|
Plugin A starting up
|
||||||
|
Plugin D started up
|
||||||
|
Plugin A started up
|
||||||
|
Plugin B started up
|
||||||
|
Plugin C started up
|
||||||
|
|
||||||
.. _sec-plugins-mixins-injectedproperties:
|
.. _sec-plugins-mixins-injectedproperties:
|
||||||
|
|
||||||
|
|||||||
+43
-30
@@ -220,6 +220,11 @@ onUserLoggedIn(user)
|
|||||||
onUserLoggedOut()
|
onUserLoggedOut()
|
||||||
Called when a user gets logged out of the web app.
|
Called when a user gets logged out of the web app.
|
||||||
|
|
||||||
|
onUserPermissionsChanged(user)
|
||||||
|
Called when a change in the permissions of the current user is detected. The user data of the just logged in user
|
||||||
|
will be provided as only parameter. Note that this may also be triggered for not logged in guests if the guest
|
||||||
|
group is modified. In this case ``user`` will be undefined.
|
||||||
|
|
||||||
onTabChange(next, current)
|
onTabChange(next, current)
|
||||||
Called before the main tab view switches to a new tab, so `before` the new tab becomes visible. Called with the
|
Called before the main tab view switches to a new tab, so `before` the new tab becomes visible. Called with the
|
||||||
next (changed to) and current (still visible) tab's hash (e.g. ``#control``). Note that ``current`` might be undefined
|
next (changed to) and current (still visible) tab's hash (e.g. ``#control``). Note that ``current`` might be undefined
|
||||||
@@ -313,13 +318,13 @@ Web interface startup
|
|||||||
|
|
||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
participant Main
|
participant Main
|
||||||
participant onServerConnect
|
|
||||||
participant fetchSettings
|
|
||||||
participant bindViewModels
|
|
||||||
participant DataUpdater
|
participant DataUpdater
|
||||||
participant LoginStateViewModel
|
participant LoginStateViewModel
|
||||||
|
participant SettingsViewModel
|
||||||
|
participant UiStateViewModel
|
||||||
|
|
||||||
Note right of DataUpdater: connectCallback = undefined
|
Note over DataUpdater: connectCallback = undefined
|
||||||
|
Note over UiStateViewModel: loaded = false
|
||||||
|
|
||||||
activate Main
|
activate Main
|
||||||
|
|
||||||
@@ -337,52 +342,60 @@ Web interface startup
|
|||||||
Main->>+DataUpdater: connectCallback = onServerConnect
|
Main->>+DataUpdater: connectCallback = onServerConnect
|
||||||
Note right of DataUpdater: connectCallback = onServerConnect
|
Note right of DataUpdater: connectCallback = onServerConnect
|
||||||
DataUpdater-->>-Main: ok
|
DataUpdater-->>-Main: ok
|
||||||
Main->>+onServerConnect: call
|
Main->>+Main: onServerConnect
|
||||||
onServerConnect->>+LoginStateViewModel: passiveLogin
|
Main->>+LoginStateViewModel: passiveLogin
|
||||||
LoginStateViewModel-->>onServerConnect: ok
|
LoginStateViewModel-->>Main: ok
|
||||||
onServerConnect-->>Main: ok
|
Main-->>Main: ok
|
||||||
deactivate onServerConnect
|
deactivate Main
|
||||||
deactivate Main
|
deactivate Main
|
||||||
|
|
||||||
LoginStateViewModel->>+LoginStateViewModel: asynchronous passive login
|
LoginStateViewModel->>+LoginStateViewModel: asynchronous passive login
|
||||||
Note over Main,LoginStateViewModel: Session available!
|
Note over Main,UiStateViewModel: Session available!
|
||||||
LoginStateViewModel-X+onServerConnect: done
|
LoginStateViewModel-X+Main: done
|
||||||
deactivate LoginStateViewModel
|
deactivate LoginStateViewModel
|
||||||
deactivate LoginStateViewModel
|
deactivate LoginStateViewModel
|
||||||
|
|
||||||
onServerConnect->>+DataUpdater: initialized
|
Main->>+DataUpdater: initialized
|
||||||
Note right of DataUpdater: initialized = true
|
Note right of DataUpdater: initialized = true
|
||||||
DataUpdater->DataUpdater: trigger stored callbacks
|
DataUpdater->DataUpdater: trigger stored callbacks
|
||||||
DataUpdater-->>-onServerConnect: ok
|
DataUpdater-->>-Main: ok
|
||||||
onServerConnect-X+Main: done
|
|
||||||
deactivate onServerConnect
|
|
||||||
|
|
||||||
Main->>+fetchSettings: call
|
Main->>+Main: fetchSettings
|
||||||
Note right of fetchSettings: trigger onStartup
|
Note right of Main: trigger onStartup
|
||||||
|
|
||||||
fetchSettings-->>Main: ok
|
Main->>+SettingsViewModel: requestData
|
||||||
|
SettingsViewModel-->>Main: ok
|
||||||
|
deactivate Main
|
||||||
deactivate Main
|
deactivate Main
|
||||||
|
|
||||||
fetchSettings->>+fetchSettings: asynchronous settings fetch
|
SettingsViewModel->>+SettingsViewModel: asynchronous settings fetch
|
||||||
fetchSettings->>+bindViewModels: call
|
Note over Main,UiStateViewModel: Settings available!
|
||||||
|
SettingsViewModel-X+Main: done
|
||||||
|
deactivate SettingsViewModel
|
||||||
|
deactivate SettingsViewModel
|
||||||
|
|
||||||
|
Main->>+Main: bindViewModels
|
||||||
|
|
||||||
loop for each view model
|
loop for each view model
|
||||||
bindViewModels->bindViewModels: trigger onBeforeBinding
|
Main->Main: trigger onBeforeBinding
|
||||||
bindViewModels->bindViewModels: trigger onBoundTo
|
Main->Main: trigger onBoundTo
|
||||||
bindViewModels->bindViewModels: trigger onAfterBinding
|
Main->Main: trigger onAfterBinding
|
||||||
end
|
end
|
||||||
|
|
||||||
bindViewModels->bindViewModels: trigger onAllBound
|
Main->Main: trigger onAllBound
|
||||||
opt User is logged in
|
opt User is logged in
|
||||||
bindViewModels->>+LoginStateViewModel: onAllBound
|
Main->>+LoginStateViewModel: onAllBound
|
||||||
LoginStateViewModel->LoginStateViewModel: trigger onUserLoggedIn
|
LoginStateViewModel->LoginStateViewModel: trigger onUserLoggedIn
|
||||||
LoginStateViewModel-->>-bindViewModels: ok
|
LoginStateViewModel-->>-Main: ok
|
||||||
end
|
end
|
||||||
bindViewModels->bindViewModels: trigger onStartupComplete
|
|
||||||
bindViewModels-->>-fetchSettings: ok
|
|
||||||
|
|
||||||
deactivate fetchSettings
|
Main->>+UiStateViewModel: loaded
|
||||||
deactivate fetchSettings
|
Note right of UiStateViewModel: loaded = true
|
||||||
|
UiStateViewModel-->>-Main: ok
|
||||||
|
|
||||||
|
Main->Main: trigger onStartupComplete
|
||||||
|
deactivate Main
|
||||||
|
deactivate Main
|
||||||
|
|
||||||
|
|
||||||
.. _sec-plugins-viewmodels-reconnect:
|
.. _sec-plugins-viewmodels-reconnect:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||||
__license__ = 'The MIT License <http://opensource.org/licenses/MIT>'
|
__license__ = 'The MIT License <http://opensource.org/licenses/MIT>'
|
||||||
@@ -84,7 +84,7 @@ class CodeBlockExt(CodeBlock):
|
|||||||
return node
|
return node
|
||||||
|
|
||||||
# replace all created literal_blocks with literal_block_ext instances
|
# replace all created literal_blocks with literal_block_ext instances
|
||||||
return map(find_and_wrap_literal_block, code_block)
|
return list(map(find_and_wrap_literal_block, code_block))
|
||||||
|
|
||||||
def _wrap_literal_block(self, node):
|
def _wrap_literal_block(self, node):
|
||||||
literal = literal_block_ext.from_literal_block(node)
|
literal = literal_block_ext.from_literal_block(node)
|
||||||
@@ -160,10 +160,10 @@ class PygmentsBridgeExt(object):
|
|||||||
# for py3, recognize interactive sessions, but do not try parsing...
|
# for py3, recognize interactive sessions, but do not try parsing...
|
||||||
lexer = sphinx.highlighting.lexers['pycon3']
|
lexer = sphinx.highlighting.lexers['pycon3']
|
||||||
elif lang == 'guess':
|
elif lang == 'guess':
|
||||||
try:
|
# try:
|
||||||
lexer = sphinx.highlighting.guess_lexer(source)
|
lexer = sphinx.highlighting.guess_lexer(source)
|
||||||
except Exception:
|
# except Exception:
|
||||||
lexer = sphinx.highlighting.lexers['none']
|
# lexer = sphinx.highlighting.lexers['none']
|
||||||
else:
|
else:
|
||||||
if lang in sphinx.highlighting.lexers:
|
if lang in sphinx.highlighting.lexers:
|
||||||
lexer = sphinx.highlighting.lexers[lang]
|
lexer = sphinx.highlighting.lexers[lang]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||||
__license__ = 'The MIT License <http://opensource.org/licenses/MIT>'
|
__license__ = 'The MIT License <http://opensource.org/licenses/MIT>'
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[pytest]
|
||||||
|
testpaths = src tests
|
||||||
|
addopts = --doctest-modules
|
||||||
|
--doctest-repr=octoprint.util:pp
|
||||||
|
--ignore=src/octoprint/vendor
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -8,15 +10,17 @@ basedir = os.path.dirname(os.path.realpath(__file__))
|
|||||||
old = os.path.join(basedir, "octoprint")
|
old = os.path.join(basedir, "octoprint")
|
||||||
if os.path.exists(old):
|
if os.path.exists(old):
|
||||||
# rename left-overs from old file structure
|
# rename left-overs from old file structure
|
||||||
print """
|
print("""
|
||||||
Found left-overs from old file structure, renaming to
|
Found left-overs from old file structure, renaming to
|
||||||
"octoprint.backup". Please remove this manually (I don't
|
"octoprint.backup". Please remove this manually (I don't
|
||||||
dare to do so myself since you might have changes in there
|
dare to do so myself since you might have changes in there
|
||||||
I don't know anything about).
|
I don't know anything about).
|
||||||
"""
|
""")
|
||||||
os.rename(old, os.path.join(basedir, "octoprint.backup"))
|
os.rename(old, os.path.join(basedir, "octoprint.backup"))
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(basedir, "src"))
|
sys.path.insert(0, os.path.join(basedir, "src"))
|
||||||
|
|
||||||
import octoprint
|
import octoprint
|
||||||
|
if len(sys.argv) == 1:
|
||||||
|
sys.argv.append("serve")
|
||||||
octoprint.main()
|
octoprint.main()
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# init/systemd files for OctoPrint.
|
||||||
|
|
||||||
|
Assumes OctoPrint is installed under user pi at /home/pi/OctoPrint/venv/bin/octoprint. If you have a different
|
||||||
|
setup you'll need to adjust octoprint.default (init) or octoprint.service (systemd) accordingly.
|
||||||
|
|
||||||
|
## init
|
||||||
|
|
||||||
|
```
|
||||||
|
octoprint.default => /etc/default/octoprint
|
||||||
|
octoprint.init => /etc/init.d/octoprint
|
||||||
|
```
|
||||||
|
|
||||||
|
## systemd
|
||||||
|
|
||||||
|
```
|
||||||
|
octoprint.service => /etc/systemd/service/octoprint.service
|
||||||
|
```
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=The snappy web interface for your 3D printer
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=pi
|
||||||
|
ExecStart=/home/pi/OctoPrint/venv/bin/octoprint
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
license_file = LICENSE.txt
|
license_file = LICENSE.txt
|
||||||
|
|
||||||
|
[bdist_wheel]
|
||||||
|
universal = 1
|
||||||
|
|
||||||
[versioneer]
|
[versioneer]
|
||||||
VCS = git
|
VCS = git
|
||||||
style = pep440-tag
|
style = pep440-tag
|
||||||
|
|||||||
@@ -9,60 +9,71 @@ import versioneer
|
|||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "src"))
|
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "src"))
|
||||||
import octoprint_setuptools
|
import octoprint_setuptools
|
||||||
|
import setuptools
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Supported python versions
|
# Supported python versions
|
||||||
PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11
|
# we test against 2.7, 3.6 and 3.7, so that's what we'll mark as supported
|
||||||
|
PYTHON_REQUIRES = ">=2.7.9, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
|
||||||
|
|
||||||
# Requirements for our application
|
# Requirements for our application
|
||||||
INSTALL_REQUIRES = [
|
INSTALL_REQUIRES = [
|
||||||
# the following dependencies are non trivial to update since later versions introduce backwards incompatible
|
# the following dependencies are non trivial to update since later versions introduce backwards incompatible
|
||||||
# changes that might affect plugins, or due to other observed problems
|
# changes that might affect plugins, or due to other observed problems
|
||||||
|
|
||||||
"flask>=0.10.1,<0.11", # newer versions require newer Jinja versions
|
"flask>=0.12,<0.13", # newer versions require newer Jinja versions
|
||||||
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
|
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
|
||||||
# guarantee backwards compatibility for plugins and such with that
|
# guarantee backwards compatibility for plugins and such with that
|
||||||
# version, hence we need to pin to a lower version for now. See #1697
|
# version, hence we need to pin to a lower version for now. See #1697
|
||||||
"tornado==4.5.3", # a memory leak was observed in tornado >= 5, see #2585
|
"tornado==4.5.3", # a memory leak was observed in tornado >= 5, see #2585
|
||||||
"Flask-Login>=0.2.11,<0.3", # some functions changed to properties in 0.3
|
"regex!=2018.11.6", # avoid broken 2018.11.6. See #2874
|
||||||
|
|
||||||
# anything below this should be checked on releases for new versions
|
# anything below this should be checked on releases for new versions
|
||||||
|
|
||||||
|
"Flask-Login>=0.4.1,<0.5",
|
||||||
"Flask-Principal>=0.4,<0.5",
|
"Flask-Principal>=0.4,<0.5",
|
||||||
"Flask-Babel>=0.12,<0.13",
|
"Flask-Babel>=0.12,<0.13",
|
||||||
"Flask-Assets>=0.12,<0.13",
|
"Flask-Assets>=0.12,<0.13",
|
||||||
"werkzeug>=0.14.1,<0.15",
|
"werkzeug>=0.15.1,<0.16",
|
||||||
"PyYAML>=3.13,<4",
|
"cachelib>=0.1,<0.2",
|
||||||
|
"PyYAML>=5.1,<6",
|
||||||
"markdown>=3.0,<3.1",
|
"markdown>=3.0,<3.1",
|
||||||
"pyserial>=3.4,<3.5",
|
"pyserial>=3.4,<3.5",
|
||||||
"netaddr>=0.7.19,<0.8",
|
"netaddr>=0.7.19,<0.8",
|
||||||
"watchdog>=0.9.0,<0.10",
|
"watchdog>=0.9.0,<0.10",
|
||||||
"sarge==0.1.5post0",
|
"sarge==0.1.5post0",
|
||||||
"netifaces>=0.10.7,<0.11",
|
"netifaces>=0.10.9,<0.11",
|
||||||
"pylru>=1.1,<1.2",
|
"pylru>=1.2,<1.3",
|
||||||
"rsa>=4.0,<5",
|
"rsa>=4.0,<5",
|
||||||
"pkginfo>=1.4.2,<1.5",
|
"pkginfo>=1.5.0.1,<1.6",
|
||||||
"requests>=2.20.0,<3",
|
"requests>=2.21.0,<3",
|
||||||
"semantic_version>=2.6,<2.7",
|
"semantic_version>=2.6,<2.7",
|
||||||
"psutil>=5.4.8,<5.5",
|
"psutil>=5.6.1,<5.7",
|
||||||
"Click>=7,<8",
|
"Click>=7,<8",
|
||||||
"awesome-slugify>=1.6.5,<1.7",
|
"awesome-slugify>=1.6.5,<1.7",
|
||||||
"feedparser>=5.2.1,<5.3",
|
"feedparser>=5.2.1,<5.3",
|
||||||
"chainmap>=1.0.2,<1.1",
|
|
||||||
"future>=0.17,<0.18",
|
"future>=0.17,<0.18",
|
||||||
"scandir>=1.9,<1.10",
|
"websocket-client>=0.56,<0.57",
|
||||||
"websocket-client>=0.53,<0.54",
|
"wrapt>=1.11.1,<1.12",
|
||||||
"python-dateutil>=2.7.5,<2.8",
|
|
||||||
"wrapt>=1.10.11,<1.11",
|
|
||||||
"futures>=3.2,<3.3",
|
|
||||||
"emoji>=0.5.1,<0.6",
|
"emoji>=0.5.1,<0.6",
|
||||||
"monotonic>=1.5,<1.6",
|
"frozendict>=1.2,<1.3",
|
||||||
"frozendict>=1.2,<1.3"
|
"sentry-sdk==0.7.7"
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.platform == "darwin":
|
# Python 2 specific requirements
|
||||||
INSTALL_REQUIRES.append("appdirs>=1.4.0")
|
INSTALL_REQUIRES_PYTHON2 = [
|
||||||
|
"futures>=3.2,<3.3",
|
||||||
|
"monotonic>=1.5,<1.6",
|
||||||
|
"scandir>=1.10,<1.11",
|
||||||
|
"chainmap>=1.0.3,<1.1",
|
||||||
|
"typing>=3.6.6,<4"
|
||||||
|
]
|
||||||
|
|
||||||
|
# OSX specific requirements
|
||||||
|
INSTALL_REQUIRES_OSX = [
|
||||||
|
"appdirs>=1.4.0",
|
||||||
|
]
|
||||||
|
|
||||||
# Additional requirements for optional install options
|
# Additional requirements for optional install options
|
||||||
EXTRA_REQUIRES = dict(
|
EXTRA_REQUIRES = dict(
|
||||||
@@ -70,11 +81,15 @@ EXTRA_REQUIRES = dict(
|
|||||||
develop=[
|
develop=[
|
||||||
# Testing dependencies
|
# Testing dependencies
|
||||||
"mock>=2.0.0,<3",
|
"mock>=2.0.0,<3",
|
||||||
"nose>=1.3.7,<1.4",
|
"pytest>=4.2.1,<5.0",
|
||||||
|
"pytest-doctest-custom>=1.0.0,<1.1",
|
||||||
"ddt",
|
"ddt",
|
||||||
|
|
||||||
|
# linter
|
||||||
|
"flake8",
|
||||||
|
|
||||||
# Documentation dependencies
|
# Documentation dependencies
|
||||||
"sphinx>=1.8.1,<1.9",
|
"sphinx>=1.6,<1.7",
|
||||||
"sphinxcontrib-httpdomain",
|
"sphinxcontrib-httpdomain",
|
||||||
"sphinxcontrib-mermaid>=0.3",
|
"sphinxcontrib-mermaid>=0.3",
|
||||||
"sphinx_rtd_theme",
|
"sphinx_rtd_theme",
|
||||||
@@ -89,6 +104,23 @@ EXTRA_REQUIRES = dict(
|
|||||||
# Dependency links for any of the aforementioned dependencies
|
# Dependency links for any of the aforementioned dependencies
|
||||||
DEPENDENCY_LINKS = []
|
DEPENDENCY_LINKS = []
|
||||||
|
|
||||||
|
# adapted from https://hynek.me/articles/conditional-python-dependencies/
|
||||||
|
if int(setuptools.__version__.split(".", 1)[0]) < 18:
|
||||||
|
# no bdist_wheel support for setuptools < 18 since we build universal wheels and our optional dependencies
|
||||||
|
# would get lost there
|
||||||
|
assert "bdist_wheel" not in sys.argv
|
||||||
|
|
||||||
|
# add optional dependencies for setuptools versions < 18 that don't yet support environment markers
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
INSTALL_REQUIRES += INSTALL_REQUIRES_PYTHON2
|
||||||
|
|
||||||
|
if sys.platform == "darwin":
|
||||||
|
INSTALL_REQUIRES += INSTALL_REQUIRES_OSX
|
||||||
|
else:
|
||||||
|
# environment markers supported
|
||||||
|
EXTRA_REQUIRES[":python_version < '3'"] = INSTALL_REQUIRES_PYTHON2
|
||||||
|
EXTRA_REQUIRES[":sys_platform == 'darwin'"] = INSTALL_REQUIRES_OSX
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------
|
||||||
# Anything below here is just command setup and general setup configuration
|
# Anything below here is just command setup and general setup configuration
|
||||||
|
|
||||||
@@ -180,6 +212,9 @@ def params():
|
|||||||
"Programming Language :: Python",
|
"Programming Language :: Python",
|
||||||
"Programming Language :: Python :: 2",
|
"Programming Language :: Python :: 2",
|
||||||
"Programming Language :: Python :: 2.7",
|
"Programming Language :: Python :: 2.7",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.6",
|
||||||
|
"Programming Language :: Python :: 3.7",
|
||||||
"Programming Language :: Python :: Implementation :: CPython",
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
"Programming Language :: JavaScript",
|
"Programming Language :: JavaScript",
|
||||||
"Topic :: Printing",
|
"Topic :: Printing",
|
||||||
@@ -192,7 +227,7 @@ def params():
|
|||||||
keywords = "3dprinting 3dprinter 3d-printing 3d-printer octoprint"
|
keywords = "3dprinting 3dprinter 3d-printing 3d-printer octoprint"
|
||||||
|
|
||||||
project_urls={
|
project_urls={
|
||||||
"Community Forum": "https://discourse.octoprint.org",
|
"Community Forum": "https://community.octoprint.org",
|
||||||
"Bug Reports": "https://github.com/foosel/OctoPrint/issues",
|
"Bug Reports": "https://github.com/foosel/OctoPrint/issues",
|
||||||
"Source": "https://github.com/foosel/OctoPrint",
|
"Source": "https://github.com/foosel/OctoPrint",
|
||||||
"Funding": "https://donate.octoprint.org"
|
"Funding": "https://donate.octoprint.org"
|
||||||
|
|||||||
+69
-23
@@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
import logging as log
|
import logging as log
|
||||||
|
|
||||||
@@ -103,8 +104,12 @@ def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
|||||||
if callable(after_logging):
|
if callable(after_logging):
|
||||||
after_logging(**kwargs)
|
after_logging(**kwargs)
|
||||||
|
|
||||||
settings_safe_mode = settings.getBoolean(["server", "startOnceInSafeMode"])
|
settings_start_once_in_safemode = "settings" if settings.getBoolean(["server", "startOnceInSafeMode"]) else None
|
||||||
safe_mode = safe_mode or settings_safe_mode
|
settings_incomplete_startup_safemode = "incomplete_startup" \
|
||||||
|
if settings.getBoolean(["server", "incompleteStartup"]) \
|
||||||
|
and not settings.getBoolean(["server", "ignoreIncompleteStartup"]) \
|
||||||
|
else None
|
||||||
|
safe_mode = safe_mode or settings_start_once_in_safemode or settings_incomplete_startup_safemode
|
||||||
kwargs["safe_mode"] = safe_mode
|
kwargs["safe_mode"] = safe_mode
|
||||||
if callable(after_safe_mode):
|
if callable(after_safe_mode):
|
||||||
after_safe_mode(**kwargs)
|
after_safe_mode(**kwargs)
|
||||||
@@ -141,7 +146,7 @@ def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
|||||||
ignore_blacklist=ignore_blacklist,
|
ignore_blacklist=ignore_blacklist,
|
||||||
connectivity_checker=connectivity_checker)
|
connectivity_checker=connectivity_checker)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise FatalStartupError("Could not initialize settings manager", cause=ex)
|
raise FatalStartupError("Could not initialize plugin manager", cause=ex)
|
||||||
|
|
||||||
kwargs["plugin_manager"] = plugin_manager
|
kwargs["plugin_manager"] = plugin_manager
|
||||||
if callable(after_plugin_manager):
|
if callable(after_plugin_manager):
|
||||||
@@ -228,6 +233,12 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
|||||||
},
|
},
|
||||||
"serial": {
|
"serial": {
|
||||||
"format": "%(asctime)s - %(message)s"
|
"format": "%(asctime)s - %(message)s"
|
||||||
|
},
|
||||||
|
"communication": {
|
||||||
|
"format": "%(asctime)s - %(name)s - %(message)s"
|
||||||
|
},
|
||||||
|
"commdebug": {
|
||||||
|
"format": "%(asctime)s - %(threadName)s - %(message)s"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"handlers": {
|
"handlers": {
|
||||||
@@ -245,19 +256,45 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
|||||||
"backupCount": 6,
|
"backupCount": 6,
|
||||||
"filename": os.path.join(settings.getBaseFolder("logs"), "octoprint.log")
|
"filename": os.path.join(settings.getBaseFolder("logs"), "octoprint.log")
|
||||||
},
|
},
|
||||||
"serialFile": {
|
"protocolFile": {
|
||||||
"class": "octoprint.logging.handlers.SerialLogHandler",
|
"class": "octoprint.logging.handlers.CommunicationLogHandler",
|
||||||
"level": "DEBUG",
|
"level": "DEBUG",
|
||||||
"formatter": "serial",
|
"formatter": "communication",
|
||||||
"backupCount": 3,
|
"backupCount": 3,
|
||||||
"filename": os.path.join(settings.getBaseFolder("logs"), "serial.log"),
|
"filename": os.path.join(settings.getBaseFolder("logs"), "protocol.log"),
|
||||||
|
"delay": True
|
||||||
|
},
|
||||||
|
"transportFile": {
|
||||||
|
"class": "octoprint.logging.handlers.CommunicationLogHandler",
|
||||||
|
"level": "DEBUG",
|
||||||
|
"formatter": "communication",
|
||||||
|
"backupCount": 3,
|
||||||
|
"filename": os.path.join(settings.getBaseFolder("logs"), "transport.log"),
|
||||||
|
"delay": True
|
||||||
|
},
|
||||||
|
"commDebugFile": {
|
||||||
|
"class": "octoprint.logging.handlers.CommunicationLogHandler",
|
||||||
|
"level": "DEBUG",
|
||||||
|
"formatter": "commdebug",
|
||||||
|
"backupCount": 3,
|
||||||
|
"filename": os.path.join(settings.getBaseFolder("logs"), "commdebug.log"),
|
||||||
"delay": True
|
"delay": True
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"loggers": {
|
"loggers": {
|
||||||
"SERIAL": {
|
"PROTOCOL": {
|
||||||
"level": "INFO",
|
"level": "DEBUG",
|
||||||
"handlers": ["serialFile"],
|
"handlers": ["protocolFile"],
|
||||||
|
"propagate": False
|
||||||
|
},
|
||||||
|
"TRANSPORT": {
|
||||||
|
"level": "DEBUG",
|
||||||
|
"handlers": ["transportFile"],
|
||||||
|
"propagate": False
|
||||||
|
},
|
||||||
|
"COMMDEBUG": {
|
||||||
|
"level": "DEBUG",
|
||||||
|
"handlers": ["commDebugFile"],
|
||||||
"propagate": False
|
"propagate": False
|
||||||
},
|
},
|
||||||
"octoprint": {
|
"octoprint": {
|
||||||
@@ -293,7 +330,7 @@ def init_logging(settings, use_logging_file=True, logging_file=None, default_con
|
|||||||
config_from_file = {}
|
config_from_file = {}
|
||||||
if os.path.exists(logging_file) and os.path.isfile(logging_file):
|
if os.path.exists(logging_file) and os.path.isfile(logging_file):
|
||||||
import yaml
|
import yaml
|
||||||
with open(logging_file, "r") as f:
|
with io.open(logging_file, 'rt', encoding='utf-8') as f:
|
||||||
config_from_file = yaml.safe_load(f)
|
config_from_file = yaml.safe_load(f)
|
||||||
|
|
||||||
# we merge that with the default config
|
# we merge that with the default config
|
||||||
@@ -342,9 +379,12 @@ def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connecti
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# we need this so that octoprint.plugins is in sys.modules and no warnings are caused when loading bundled plugins
|
||||||
|
import octoprint.plugins
|
||||||
|
|
||||||
logger = log.getLogger(__name__ + ".startup")
|
logger = log.getLogger(__name__ + ".startup")
|
||||||
|
|
||||||
plugin_folders = [(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins")), True),
|
plugin_folders = [(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "plugins")), "octoprint.plugins", True),
|
||||||
settings.getBaseFolder("plugins")]
|
settings.getBaseFolder("plugins")]
|
||||||
plugin_entry_points = ["octoprint.plugin"]
|
plugin_entry_points = ["octoprint.plugin"]
|
||||||
plugin_disabled_list = settings.get(["plugins", "_disabled"])
|
plugin_disabled_list = settings.get(["plugins", "_disabled"])
|
||||||
@@ -363,13 +403,16 @@ def init_pluginsystem(settings, safe_mode=False, ignore_blacklist=True, connecti
|
|||||||
return True
|
return True
|
||||||
plugin_validators.append(validator)
|
plugin_validators.append(validator)
|
||||||
|
|
||||||
|
compatibility_ignored_list = settings.get(["plugins", "_forcedCompatible"])
|
||||||
|
|
||||||
from octoprint.plugin import plugin_manager
|
from octoprint.plugin import plugin_manager
|
||||||
pm = plugin_manager(init=True,
|
pm = plugin_manager(init=True,
|
||||||
plugin_folders=plugin_folders,
|
plugin_folders=plugin_folders,
|
||||||
plugin_entry_points=plugin_entry_points,
|
plugin_entry_points=plugin_entry_points,
|
||||||
plugin_disabled_list=plugin_disabled_list,
|
plugin_disabled_list=plugin_disabled_list,
|
||||||
plugin_blacklist=plugin_blacklist,
|
plugin_blacklist=plugin_blacklist,
|
||||||
plugin_validators=plugin_validators)
|
plugin_validators=plugin_validators,
|
||||||
|
compatibility_ignored_list=compatibility_ignored_list)
|
||||||
|
|
||||||
settings_overlays = dict()
|
settings_overlays = dict()
|
||||||
disabled_from_overlays = dict()
|
disabled_from_overlays = dict()
|
||||||
@@ -482,7 +525,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
|
|||||||
if os.stat(path).st_mtime + ttl < time.time():
|
if os.stat(path).st_mtime + ttl < time.time():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
with bom_aware_open(path, encoding="utf-8", mode="r") as f:
|
with bom_aware_open(path, encoding="utf-8", mode='rt') as f:
|
||||||
result = yaml.safe_load(f)
|
result = yaml.safe_load(f)
|
||||||
|
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
@@ -496,12 +539,12 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
|
|||||||
|
|
||||||
if cache is not None:
|
if cache is not None:
|
||||||
try:
|
try:
|
||||||
with bom_aware_open(cache, encoding="utf-8", mode="w") as f:
|
with bom_aware_open(cache, encoding="utf-8", mode='wt') as f:
|
||||||
yaml.safe_dump(result, f)
|
yaml.safe_dump(result, f)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.info("Fetched plugin blacklist but couldn't write it to its cache file.")
|
logger.info("Fetched plugin blacklist but couldn't write it to its cache file: %s", e)
|
||||||
except:
|
except Exception as e:
|
||||||
logger.info("Unable to fetch plugin blacklist from {}, proceeding without it.".format(url))
|
logger.info("Unable to fetch plugin blacklist from {}, proceeding without it: {}".format(url, e))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -528,7 +571,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
|
|||||||
logger.info("Blacklist processing done")
|
logger.info("Blacklist processing done")
|
||||||
|
|
||||||
return blacklist
|
return blacklist
|
||||||
except:
|
except Exception:
|
||||||
logger.exception("Something went wrong while processing the plugin blacklist. Proceeding without it.")
|
logger.exception("Something went wrong while processing the plugin blacklist. Proceeding without it.")
|
||||||
|
|
||||||
|
|
||||||
@@ -595,6 +638,9 @@ def main():
|
|||||||
# cut off stuff from the beginning
|
# cut off stuff from the beginning
|
||||||
args = args[-1 * sys_args_length:] if sys_args_length else []
|
args = args[-1 * sys_args_length:] if sys_args_length else []
|
||||||
|
|
||||||
|
from octoprint.util.fixes import patch_sarge_async_on_py2
|
||||||
|
patch_sarge_async_on_py2()
|
||||||
|
|
||||||
from octoprint.cli import octo
|
from octoprint.cli import octo
|
||||||
octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
|
octo(args=args, prog_name="octoprint", auto_envvar_prefix="OCTOPRINT")
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
#import sys
|
||||||
|
#if sys.version_info[0] >= 3:
|
||||||
|
# raise RuntimeError("Sorry, OctoPrint does not yet support Python 3")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import octoprint
|
import octoprint
|
||||||
|
|||||||
+46
-11
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
# This file helps to compute a version number in source trees obtained from
|
# This file helps to compute a version number in source trees obtained from
|
||||||
# git-archive tarball (such as those provided by githubs download-from-tag
|
# git-archive tarball (such as those provided by githubs download-from-tag
|
||||||
@@ -9,13 +11,14 @@
|
|||||||
# versioneer-0.15+dev (https://github.com/warner/python-versioneer)
|
# versioneer-0.15+dev (https://github.com/warner/python-versioneer)
|
||||||
|
|
||||||
"""Git implementation of _version.py."""
|
"""Git implementation of _version.py."""
|
||||||
from __future__ import absolute_import, division, print_function
|
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
def get_keywords():
|
def get_keywords():
|
||||||
@@ -41,7 +44,7 @@ def get_config():
|
|||||||
# _version.py
|
# _version.py
|
||||||
cfg = VersioneerConfig()
|
cfg = VersioneerConfig()
|
||||||
cfg.VCS = "git"
|
cfg.VCS = "git"
|
||||||
cfg.style = "pep440-post"
|
cfg.style = "pep440-tag"
|
||||||
cfg.tag_prefix = ""
|
cfg.tag_prefix = ""
|
||||||
cfg.parentdir_prefix = ""
|
cfg.parentdir_prefix = ""
|
||||||
cfg.versionfile_source = "src/octoprint/_version.py"
|
cfg.versionfile_source = "src/octoprint/_version.py"
|
||||||
@@ -130,7 +133,7 @@ def git_get_keywords(versionfile_abs):
|
|||||||
# _version.py.
|
# _version.py.
|
||||||
keywords = {}
|
keywords = {}
|
||||||
try:
|
try:
|
||||||
f = open(versionfile_abs, "r")
|
f = io.open(versionfile_abs, "rt", encoding="utf-8")
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if line.strip().startswith("git_refnames ="):
|
if line.strip().startswith("git_refnames ="):
|
||||||
mo = re.search(r'=\s*"(.*)"', line)
|
mo = re.search(r'=\s*"(.*)"', line)
|
||||||
@@ -156,11 +159,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
|
|||||||
if verbose:
|
if verbose:
|
||||||
print("keywords are unexpanded, not using")
|
print("keywords are unexpanded, not using")
|
||||||
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
|
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
|
||||||
refs = set([r.strip() for r in refnames.strip("()").split(",")])
|
refs = set(r.strip() for r in refnames.strip("()").split(","))
|
||||||
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
|
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
|
||||||
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
|
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
|
||||||
TAG = "tag: "
|
TAG = "tag: "
|
||||||
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
|
tags = set(r[len(TAG):] for r in refs if r.startswith(TAG))
|
||||||
if not tags:
|
if not tags:
|
||||||
# Either we're using git < 1.8.3, or there really are no tags. We use
|
# Either we're using git < 1.8.3, or there really are no tags. We use
|
||||||
# a heuristic: assume all version tags have a digit. The old git %d
|
# a heuristic: assume all version tags have a digit. The old git %d
|
||||||
@@ -169,7 +172,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
|
|||||||
# between branches and tags. By ignoring refnames without digits, we
|
# between branches and tags. By ignoring refnames without digits, we
|
||||||
# filter out many common branch names like "release" and
|
# filter out many common branch names like "release" and
|
||||||
# "stabilization", as well as "HEAD" and "master".
|
# "stabilization", as well as "HEAD" and "master".
|
||||||
tags = set([r for r in refs if re.search(r'\d', r)])
|
tags = set(r for r in refs if re.search(r'\d', r))
|
||||||
if verbose:
|
if verbose:
|
||||||
print("discarding '%s', no digits" % ",".join(refs-tags))
|
print("discarding '%s', no digits" % ",".join(refs-tags))
|
||||||
|
|
||||||
@@ -254,7 +257,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
|
|||||||
abbrev_ref_out = run_command(GITS,
|
abbrev_ref_out = run_command(GITS,
|
||||||
["rev-parse", "--abbrev-ref", "HEAD"],
|
["rev-parse", "--abbrev-ref", "HEAD"],
|
||||||
cwd=root)
|
cwd=root)
|
||||||
if abbrev_ref_out is not None:
|
if abbrev_ref_out is not None and abbrev_ref_out != "HEAD":
|
||||||
pieces["branch"] = abbrev_ref_out.strip()
|
pieces["branch"] = abbrev_ref_out.strip()
|
||||||
|
|
||||||
# now we have TAG-NUM-gHEX or HEX
|
# now we have TAG-NUM-gHEX or HEX
|
||||||
@@ -305,17 +308,18 @@ def git_parse_lookup_file(path):
|
|||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
import re
|
||||||
lookup = []
|
lookup = []
|
||||||
with open(path, "r") as f:
|
with io.open(path, "rt", encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if '#' in line:
|
if '#' in line:
|
||||||
line = line[:line.rindex("#")]
|
line = line[:line.index("#")]
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
split_line = map(lambda x: x.strip(), line.split())
|
split_line = list(map(lambda x: x.strip(), line.split()))
|
||||||
if not len(split_line):
|
if not len(split_line):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -336,7 +340,8 @@ def git_parse_lookup_file(path):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
lookup.append(entry)
|
lookup.append(entry)
|
||||||
except:
|
except Exception:
|
||||||
|
logging.getLogger(__name__).exception("Versioneer problem")
|
||||||
break
|
break
|
||||||
return lookup
|
return lookup
|
||||||
|
|
||||||
@@ -354,6 +359,9 @@ def git_pieces_from_lookup(lookup, root, verbose, run_command=run_command):
|
|||||||
raise NotThisMethod("git rev-parse --abbrev-ref HEAD failed")
|
raise NotThisMethod("git rev-parse --abbrev-ref HEAD failed")
|
||||||
|
|
||||||
current_branch = stdout.strip()
|
current_branch = stdout.strip()
|
||||||
|
if current_branch == "HEAD":
|
||||||
|
raise NotThisMethod("not on a branch")
|
||||||
|
|
||||||
for matcher, render, tag, ref_commit in lookup:
|
for matcher, render, tag, ref_commit in lookup:
|
||||||
if matcher.match(current_branch):
|
if matcher.match(current_branch):
|
||||||
if tag is None or ref_commit is None:
|
if tag is None or ref_commit is None:
|
||||||
@@ -441,6 +449,31 @@ def render_pep440(pieces):
|
|||||||
return rendered
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render_pep440_tag(pieces):
|
||||||
|
"""TAG[[.postDISTANCE].dev0+gHEX] -- Just the tag if not dirty, else more info
|
||||||
|
|
||||||
|
Useful for projects that want commit based tracking on some branches
|
||||||
|
but have the master branch only report tags, to allow for commits that
|
||||||
|
do not modify actual code (e.g. to .github/* or docs).
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. 0.postDISTANCE[.dev0]+gHEX
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".post%d" % pieces["distance"]
|
||||||
|
rendered += ".dev0"
|
||||||
|
rendered += "+g%s" % pieces["short"]
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = "0.post%d" % pieces["distance"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dev0"
|
||||||
|
rendered += "+g%s" % pieces["short"]
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
def render_pep440_pre(pieces):
|
def render_pep440_pre(pieces):
|
||||||
"""TAG[.post.devDISTANCE] -- No -dirty.
|
"""TAG[.post.devDISTANCE] -- No -dirty.
|
||||||
|
|
||||||
@@ -591,6 +624,8 @@ def render(pieces, style):
|
|||||||
rendered = render_pep440_old(pieces)
|
rendered = render_pep440_old(pieces)
|
||||||
elif style == "pep440-dev":
|
elif style == "pep440-dev":
|
||||||
rendered = render_pep440_dev(pieces)
|
rendered = render_pep440_dev(pieces)
|
||||||
|
elif style == "pep440-tag":
|
||||||
|
rendered = render_pep440_tag(pieces)
|
||||||
elif style == "git-describe":
|
elif style == "git-describe":
|
||||||
rendered = render_git_describe(pieces)
|
rendered = render_git_describe(pieces)
|
||||||
elif style == "git-describe-long":
|
elif style == "git-describe-long":
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
ADMIN_GROUP = "admins"
|
||||||
|
USER_GROUP = "users"
|
||||||
|
GUEST_GROUP = "guests"
|
||||||
|
READONLY_GROUP = "readonly"
|
||||||
@@ -0,0 +1,601 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__author__ = "Marc Hannappel <salandora@gmail.com>"
|
||||||
|
__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 io
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from past.builtins import basestring
|
||||||
|
|
||||||
|
from octoprint.settings import settings
|
||||||
|
from octoprint.util import atomic_write
|
||||||
|
from octoprint.access import ADMIN_GROUP, USER_GROUP, GUEST_GROUP, READONLY_GROUP
|
||||||
|
from octoprint.access.permissions import Permissions, OctoPrintPermission
|
||||||
|
from flask_principal import Need, Permission
|
||||||
|
|
||||||
|
DEFAULT_ADMIN_PERMISSIONS = [Permissions.ADMIN]
|
||||||
|
"""Default admin permissions are the legacy permissions from before 1.4.0"""
|
||||||
|
|
||||||
|
DEFAULT_USER_PERMISSIONS = [Permissions.STATUS,
|
||||||
|
Permissions.CONNECTION,
|
||||||
|
Permissions.WEBCAM,
|
||||||
|
Permissions.FILES_UPLOAD,
|
||||||
|
Permissions.FILES_DOWNLOAD,
|
||||||
|
Permissions.FILES_DELETE,
|
||||||
|
Permissions.FILES_SELECT,
|
||||||
|
Permissions.PRINT,
|
||||||
|
Permissions.MONITOR_TERMINAL,
|
||||||
|
Permissions.CONTROL,
|
||||||
|
Permissions.SLICE,
|
||||||
|
Permissions.TIMELAPSE_LIST,
|
||||||
|
Permissions.TIMELAPSE_ADMIN]
|
||||||
|
"""Default user permissions are the legacy permissions from before 1.4.0"""
|
||||||
|
|
||||||
|
DEFAULT_GUEST_PERMISSIONS = [Permissions.STATUS,
|
||||||
|
Permissions.WEBCAM,
|
||||||
|
Permissions.FILES_DOWNLOAD,
|
||||||
|
Permissions.TIMELAPSE_LIST,
|
||||||
|
Permissions.MONITOR_TERMINAL]
|
||||||
|
"""Default guest permissions are the legacy permissions from before 1.4.0"""
|
||||||
|
|
||||||
|
|
||||||
|
GroupNeed = partial(Need, 'group')
|
||||||
|
GroupNeed.__doc__ = """A need with the method preset to `"group"`."""
|
||||||
|
|
||||||
|
|
||||||
|
class GroupPermission(Permission):
|
||||||
|
def __init__(self, key):
|
||||||
|
need = GroupNeed(key)
|
||||||
|
super(GroupPermission, self).__init__(need)
|
||||||
|
|
||||||
|
|
||||||
|
class GroupManager(object):
|
||||||
|
@classmethod
|
||||||
|
def default_permissions_for_group(cls, group):
|
||||||
|
result = []
|
||||||
|
for permission in Permissions.all():
|
||||||
|
if group in permission.default_groups:
|
||||||
|
result.append(permission)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._group_change_listeners = []
|
||||||
|
self._init_defaults()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def groups(self):
|
||||||
|
return []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def admin_group(self):
|
||||||
|
return self.find_group(ADMIN_GROUP)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user_group(self):
|
||||||
|
return self.find_group(USER_GROUP)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def guest_group(self):
|
||||||
|
return self.find_group(GUEST_GROUP)
|
||||||
|
|
||||||
|
def _init_defaults(self):
|
||||||
|
self.add_group(ADMIN_GROUP,
|
||||||
|
"Admins",
|
||||||
|
"Administrators",
|
||||||
|
self.default_permissions_for_group(ADMIN_GROUP),
|
||||||
|
[],
|
||||||
|
changeable=False,
|
||||||
|
removable=False,
|
||||||
|
save=False)
|
||||||
|
self.add_group(USER_GROUP,
|
||||||
|
"Users",
|
||||||
|
"All logged in users",
|
||||||
|
self.default_permissions_for_group(USER_GROUP),
|
||||||
|
[],
|
||||||
|
default=True,
|
||||||
|
removable=False,
|
||||||
|
toggleable=False,
|
||||||
|
save=False)
|
||||||
|
self.add_group(GUEST_GROUP,
|
||||||
|
"Guests",
|
||||||
|
"Anyone who is not currently logged in",
|
||||||
|
self.default_permissions_for_group(GUEST_GROUP),
|
||||||
|
[],
|
||||||
|
removable=False,
|
||||||
|
toggleable=False,
|
||||||
|
save=False),
|
||||||
|
self.add_group(READONLY_GROUP,
|
||||||
|
"Read-only Access",
|
||||||
|
"Group to gain read-only access",
|
||||||
|
self.default_permissions_for_group(READONLY_GROUP),
|
||||||
|
[],
|
||||||
|
changeable=False,
|
||||||
|
removable=False,
|
||||||
|
save=False)
|
||||||
|
|
||||||
|
def register_listener(self, listener):
|
||||||
|
self._group_change_listeners.append(listener)
|
||||||
|
|
||||||
|
def unregister_listener(self, listener):
|
||||||
|
self._group_change_listeners.remove(listener)
|
||||||
|
|
||||||
|
def add_group(self, key, name, description, permissions, subgroups,
|
||||||
|
default=False, removable=True, changeable=True, toggleable=True, save=True, notify=True):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def update_group(self, key, description=None, permissions=None, subgroups=None, default=None, save=True, notify=True):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def remove_group(self, key, save=True, notify=True):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def find_group(self, key):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _to_permissions(self, *permissions):
|
||||||
|
return list(filter(lambda x: x is not None,
|
||||||
|
[Permissions.find(permission) for permission in permissions]))
|
||||||
|
|
||||||
|
def _from_permissions(self, *permissions):
|
||||||
|
return [permission.key for permission in permissions]
|
||||||
|
|
||||||
|
def _from_groups(self, *groups):
|
||||||
|
return [group.key for group in groups]
|
||||||
|
|
||||||
|
def _to_groups(self, *groups):
|
||||||
|
return filter(lambda x: x is not None,
|
||||||
|
[self._to_group(g) for g in groups])
|
||||||
|
|
||||||
|
def _to_group(self, group):
|
||||||
|
# noinspection PyCompatibility
|
||||||
|
if isinstance(group, Group):
|
||||||
|
return group
|
||||||
|
elif isinstance(group, basestring):
|
||||||
|
return self.find_group(group)
|
||||||
|
elif isinstance(group, dict):
|
||||||
|
return self.find_group(group.get("key"))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _notify_listeners(self, action, group, *args, **kwargs):
|
||||||
|
method = "on_group_{}".format(action)
|
||||||
|
for listener in self._group_change_listeners:
|
||||||
|
try:
|
||||||
|
getattr(listener, method)(group, *args, **kwargs)
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error notifying listener {!r} via {}".format(listener, method))
|
||||||
|
|
||||||
|
class GroupChangeListener(object):
|
||||||
|
|
||||||
|
def on_group_added(self, group):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_group_removed(self, group):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_group_permissions_changed(self, group, added=None, removed=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_group_subgroups_changed(self, group, added=None, removed=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FilebasedGroupManager(GroupManager):
|
||||||
|
def __init__(self, path=None):
|
||||||
|
if path is None:
|
||||||
|
path = settings().get(["accessControl", "groupfile"])
|
||||||
|
if path is None:
|
||||||
|
path = os.path.join(settings().getBaseFolder("base"), "groups.yaml")
|
||||||
|
|
||||||
|
self._groupfile = path
|
||||||
|
self._groups = dict()
|
||||||
|
self._dirty = False
|
||||||
|
|
||||||
|
GroupManager.__init__(self)
|
||||||
|
|
||||||
|
self._load()
|
||||||
|
|
||||||
|
def _load(self):
|
||||||
|
if os.path.exists(self._groupfile) and os.path.isfile(self._groupfile):
|
||||||
|
try:
|
||||||
|
with io.open(self._groupfile, 'rt', encoding='utf-8') as f:
|
||||||
|
data = yaml.safe_load(f)
|
||||||
|
|
||||||
|
if not "groups" in data:
|
||||||
|
groups = data
|
||||||
|
data = dict(groups=groups)
|
||||||
|
|
||||||
|
groups = data.get("groups", dict())
|
||||||
|
tracked_permissions = data.get("tracked", list())
|
||||||
|
|
||||||
|
for key, attributes in groups.items():
|
||||||
|
if key in self._groups:
|
||||||
|
# group is already there (from the defaults most likely)
|
||||||
|
if not self._groups[key].is_changeable():
|
||||||
|
# group may not be changed -> bail
|
||||||
|
continue
|
||||||
|
|
||||||
|
removable = self._groups[key].is_removable()
|
||||||
|
changeable = self._groups[key].is_changeable()
|
||||||
|
toggleable = self._groups[key].is_toggleable()
|
||||||
|
else:
|
||||||
|
removable = True
|
||||||
|
changeable = True
|
||||||
|
toggleable = True
|
||||||
|
|
||||||
|
permissions = self._to_permissions(*attributes.get("permissions", []))
|
||||||
|
default_permissions = self.default_permissions_for_group(key)
|
||||||
|
for permission in default_permissions:
|
||||||
|
if not permission.key in tracked_permissions and not permission in permissions:
|
||||||
|
permissions.append(permission)
|
||||||
|
|
||||||
|
subgroups = attributes.get("subgroups", [])
|
||||||
|
|
||||||
|
group = Group(key, attributes.get("name", ""),
|
||||||
|
description=attributes.get("description", ""),
|
||||||
|
permissions=permissions,
|
||||||
|
subgroups=subgroups,
|
||||||
|
default=attributes.get("default", False),
|
||||||
|
removable=removable,
|
||||||
|
changeable=changeable,
|
||||||
|
toggleable=toggleable)
|
||||||
|
self._groups[key] = group
|
||||||
|
|
||||||
|
for group in self._groups.values():
|
||||||
|
group._subgroups = self._to_groups(*group._subgroups)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error while loading groups from file {}".format(self._groupfile))
|
||||||
|
|
||||||
|
def _save(self, force=False):
|
||||||
|
if self._groupfile is None or not self._dirty and not force:
|
||||||
|
return
|
||||||
|
|
||||||
|
groups = dict()
|
||||||
|
for key in self._groups.keys():
|
||||||
|
group = self._groups[key]
|
||||||
|
groups[key] = dict(
|
||||||
|
name=group._name,
|
||||||
|
description=group._description,
|
||||||
|
permissions=self._from_permissions(*group._permissions),
|
||||||
|
subgroups=self._from_groups(*group._subgroups),
|
||||||
|
default=group._default
|
||||||
|
)
|
||||||
|
|
||||||
|
data = dict(groups=groups,
|
||||||
|
tracked=[x.key for x in Permissions.all()])
|
||||||
|
|
||||||
|
with atomic_write(self._groupfile, mode='wt', permissions=0o600, max_permissions=0o666) as f:
|
||||||
|
import yaml
|
||||||
|
yaml.safe_dump(data, f, default_flow_style=False, indent=4, allow_unicode=True)
|
||||||
|
self._dirty = False
|
||||||
|
self._load()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def groups(self):
|
||||||
|
return list(self._groups.values())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default_groups(self):
|
||||||
|
return [group for group in self._groups.values() if group.is_default()]
|
||||||
|
|
||||||
|
def find_group(self, key):
|
||||||
|
if key is None:
|
||||||
|
return None
|
||||||
|
return self._groups.get(key)
|
||||||
|
|
||||||
|
def add_group(self, key, name, description, permissions, subgroups, default=False, removable=True,
|
||||||
|
changeable=True, toggleable=True, overwrite=False, notify=True, save=True):
|
||||||
|
if key in self._groups and not overwrite:
|
||||||
|
raise GroupAlreadyExists(key)
|
||||||
|
|
||||||
|
if not permissions:
|
||||||
|
permissions = []
|
||||||
|
|
||||||
|
permissions = self._to_permissions(*permissions)
|
||||||
|
assert(all(map(lambda p: isinstance(p, OctoPrintPermission), permissions)))
|
||||||
|
|
||||||
|
subgroups = self._to_groups(*subgroups)
|
||||||
|
assert(all(map(lambda g: isinstance(g, Group), subgroups)))
|
||||||
|
|
||||||
|
group = Group(key, name,
|
||||||
|
description=description,
|
||||||
|
permissions=permissions,
|
||||||
|
subgroups=subgroups,
|
||||||
|
default=default,
|
||||||
|
changeable=changeable,
|
||||||
|
removable=removable,
|
||||||
|
toggleable=toggleable)
|
||||||
|
self._groups[key] = group
|
||||||
|
|
||||||
|
if save:
|
||||||
|
self._dirty = True
|
||||||
|
self._save()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
self._notify_listeners("added", group)
|
||||||
|
|
||||||
|
def remove_group(self, key, save=True, notify=True):
|
||||||
|
"""Removes a Group by key"""
|
||||||
|
group = self._to_group(key)
|
||||||
|
if group is None:
|
||||||
|
raise UnknownGroup(key)
|
||||||
|
|
||||||
|
if not group.is_removable():
|
||||||
|
raise GroupUnremovable(key)
|
||||||
|
|
||||||
|
del self._groups[key]
|
||||||
|
self._dirty = True
|
||||||
|
|
||||||
|
if save:
|
||||||
|
self._save()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
self._notify_listeners("removed", group)
|
||||||
|
|
||||||
|
def update_group(self, key, description=None, permissions=None, subgroups=None, default=None, save=True, notify=True):
|
||||||
|
group = self._to_group(key)
|
||||||
|
if group is None:
|
||||||
|
raise UnknownGroup(key)
|
||||||
|
|
||||||
|
if not group.is_changeable():
|
||||||
|
raise GroupCantBeChanged(key)
|
||||||
|
|
||||||
|
if description is not None and description != group.get_description():
|
||||||
|
group.change_description(description)
|
||||||
|
self._dirty = True
|
||||||
|
|
||||||
|
notifications = []
|
||||||
|
|
||||||
|
if permissions is not None:
|
||||||
|
permissions = self._to_permissions(*permissions)
|
||||||
|
assert (all(map(lambda p: isinstance(p, OctoPrintPermission), permissions)))
|
||||||
|
|
||||||
|
removed_permissions = list(set(group._permissions) - set(permissions))
|
||||||
|
added_permissions = list(set(permissions) - set(group._permissions))
|
||||||
|
|
||||||
|
if removed_permissions:
|
||||||
|
self._dirty |= group.remove_permissions_from_group(removed_permissions)
|
||||||
|
if added_permissions:
|
||||||
|
self._dirty |= group.add_permissions_to_group(added_permissions)
|
||||||
|
|
||||||
|
notifications.append((("permissions_changed", group),
|
||||||
|
dict(added=added_permissions, removed=removed_permissions)))
|
||||||
|
|
||||||
|
if subgroups is not None:
|
||||||
|
subgroups = self._to_groups(*subgroups)
|
||||||
|
assert(all(map(lambda g: isinstance(g, Group), subgroups)))
|
||||||
|
|
||||||
|
removed_subgroups = list(set(group._subgroups) - set(subgroups))
|
||||||
|
added_subgroups = list(set(subgroups) - set(group._subgroups))
|
||||||
|
|
||||||
|
if removed_subgroups:
|
||||||
|
self._dirty = group.remove_subgroups_from_group(removed_subgroups)
|
||||||
|
if added_subgroups:
|
||||||
|
self._dirty = group.add_subgroups_to_group(added_subgroups)
|
||||||
|
|
||||||
|
notifications.append((("subgroups_changed", group),
|
||||||
|
dict(added=added_subgroups, removed=removed_subgroups)))
|
||||||
|
|
||||||
|
if default is not None:
|
||||||
|
group.change_default(default)
|
||||||
|
self._dirty = True
|
||||||
|
|
||||||
|
if self._dirty:
|
||||||
|
if save:
|
||||||
|
self._save()
|
||||||
|
|
||||||
|
if notify:
|
||||||
|
for args, kwargs in notifications:
|
||||||
|
self._notify_listeners(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class GroupAlreadyExists(Exception):
|
||||||
|
def __init__(self, key):
|
||||||
|
Exception.__init__(self, "Group %s already exists" % key)
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownGroup(Exception):
|
||||||
|
def __init__(self, key):
|
||||||
|
Exception.__init__(self, "Unknown group: %s" % key)
|
||||||
|
|
||||||
|
|
||||||
|
class GroupUnremovable(Exception):
|
||||||
|
def __init__(self, key):
|
||||||
|
Exception.__init__(self, "Group can't be removed: %s" % key)
|
||||||
|
|
||||||
|
|
||||||
|
class GroupCantBeChanged(Exception):
|
||||||
|
def __init__(self, key):
|
||||||
|
Exception.__init__(self, "Group can't be changed: %s" % key)
|
||||||
|
|
||||||
|
|
||||||
|
class Group(object):
|
||||||
|
def __init__(self, key, name, description="", permissions=None, subgroups=None, default=False, removable=True, changeable=True, toggleable=True):
|
||||||
|
self._key = key
|
||||||
|
self._name = name
|
||||||
|
self._description = description
|
||||||
|
self._permissions = permissions
|
||||||
|
self._subgroups = subgroups
|
||||||
|
self._default = default
|
||||||
|
self._removable = removable
|
||||||
|
self._changeable = changeable
|
||||||
|
self._toggleable = toggleable
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
from octoprint.access.permissions import OctoPrintPermission
|
||||||
|
return dict(
|
||||||
|
key=self.key,
|
||||||
|
name=self.get_name(),
|
||||||
|
description=self._description,
|
||||||
|
permissions=list(map(lambda p: p.key, self._permissions)),
|
||||||
|
subgroups=list(map(lambda g: g.key, self._subgroups)),
|
||||||
|
needs=OctoPrintPermission.convert_needs_to_dict(self.needs),
|
||||||
|
default=self._default,
|
||||||
|
removable=self._removable,
|
||||||
|
changeable=self._changeable,
|
||||||
|
toggleable=self._toggleable
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def key(self):
|
||||||
|
return self._key
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
def get_description(self):
|
||||||
|
return self._description
|
||||||
|
|
||||||
|
def is_default(self):
|
||||||
|
return self._default
|
||||||
|
|
||||||
|
def is_changeable(self):
|
||||||
|
return self._changeable
|
||||||
|
|
||||||
|
def is_removable(self):
|
||||||
|
return self._removable
|
||||||
|
|
||||||
|
def is_toggleable(self):
|
||||||
|
return self._toggleable
|
||||||
|
|
||||||
|
def add_permissions_to_group(self, permissions):
|
||||||
|
"""Adds a list of permissions to a group"""
|
||||||
|
if not self.is_changeable():
|
||||||
|
raise GroupCantBeChanged(self.key)
|
||||||
|
|
||||||
|
# Make sure the permissions variable is of type list
|
||||||
|
if not isinstance(permissions, list):
|
||||||
|
permissions = [permissions]
|
||||||
|
|
||||||
|
assert(all(map(lambda p: isinstance(p, OctoPrintPermission), permissions)))
|
||||||
|
|
||||||
|
dirty = False
|
||||||
|
for permission in permissions:
|
||||||
|
if permissions not in self.permissions:
|
||||||
|
self._permissions.append(permission)
|
||||||
|
dirty = True
|
||||||
|
|
||||||
|
return dirty
|
||||||
|
|
||||||
|
def remove_permissions_from_group(self, permissions):
|
||||||
|
"""Removes a list of permissions from a group"""
|
||||||
|
if not self.is_changeable():
|
||||||
|
raise GroupCantBeChanged(self.key)
|
||||||
|
|
||||||
|
# Make sure the permissions variable is of type list
|
||||||
|
if not isinstance(permissions, list):
|
||||||
|
permissions = [permissions]
|
||||||
|
|
||||||
|
assert(all(map(lambda p: isinstance(p, OctoPrintPermission), permissions)))
|
||||||
|
|
||||||
|
dirty = False
|
||||||
|
for permission in permissions:
|
||||||
|
if permission in self._permissions:
|
||||||
|
self._permissions.remove(permission)
|
||||||
|
dirty = True
|
||||||
|
|
||||||
|
return dirty
|
||||||
|
|
||||||
|
def add_subgroups_to_group(self, subgroups):
|
||||||
|
"""Adds a list of subgroups to a group"""
|
||||||
|
if not self.is_changeable():
|
||||||
|
raise GroupCantBeChanged(self.key)
|
||||||
|
|
||||||
|
# Make sure the subgroups variable is of type list
|
||||||
|
if not isinstance(subgroups, list):
|
||||||
|
subgroups = [subgroups]
|
||||||
|
|
||||||
|
assert(all(map(lambda g: isinstance(g, Group), subgroups)))
|
||||||
|
|
||||||
|
dirty = False
|
||||||
|
for group in subgroups:
|
||||||
|
if group.is_toggleable() and group not in self._subgroups:
|
||||||
|
self._subgroups.append(group)
|
||||||
|
dirty = True
|
||||||
|
|
||||||
|
return dirty
|
||||||
|
|
||||||
|
def remove_subgroups_from_group(self, subgroups):
|
||||||
|
"""Removes a list of subgroups from a group"""
|
||||||
|
"""Adds a list of subgroups to a group"""
|
||||||
|
if not self.is_changeable():
|
||||||
|
raise GroupCantBeChanged(self.key)
|
||||||
|
|
||||||
|
# Make sure the subgroups variable is of type list
|
||||||
|
if not isinstance(subgroups, list):
|
||||||
|
subgroups = [subgroups]
|
||||||
|
|
||||||
|
assert (all(map(lambda g: isinstance(g, Group), subgroups)))
|
||||||
|
|
||||||
|
dirty = False
|
||||||
|
for group in subgroups:
|
||||||
|
if group.is_toggleable() and group in self._subgroups:
|
||||||
|
self._subgroups.remove(group)
|
||||||
|
dirty = True
|
||||||
|
|
||||||
|
return dirty
|
||||||
|
|
||||||
|
def change_default(self, default):
|
||||||
|
"""Changes the default flag of a Group"""
|
||||||
|
if not self.is_changeable():
|
||||||
|
raise GroupCantBeChanged(self.key)
|
||||||
|
|
||||||
|
self._default = default
|
||||||
|
|
||||||
|
def change_description(self, description):
|
||||||
|
"""Changes the description of a group"""
|
||||||
|
self._description = description
|
||||||
|
|
||||||
|
@property
|
||||||
|
def permissions(self):
|
||||||
|
if Permissions.ADMIN in self._permissions:
|
||||||
|
return Permissions.all()
|
||||||
|
|
||||||
|
return list(filter(lambda p: p is not None, self._permissions))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subgroups(self):
|
||||||
|
return filter(lambda g: g is not None, self._subgroups)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def needs(self):
|
||||||
|
needs = set()
|
||||||
|
needs.add(GroupNeed(self.key))
|
||||||
|
for p in self.permissions:
|
||||||
|
needs = needs.union(p.needs)
|
||||||
|
for g in self.subgroups:
|
||||||
|
needs = needs.union(g.needs)
|
||||||
|
|
||||||
|
return needs
|
||||||
|
|
||||||
|
def has_permission(self, permission):
|
||||||
|
if Permissions.ADMIN.get_name() in self._permissions:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return permission.needs.issubset(self.needs)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '{}("{}", "{}", description="{}", permissions={!r}, ' \
|
||||||
|
'default={}, removable={}, changeable={})'.format(self.__class__.__name__,
|
||||||
|
self._key,
|
||||||
|
self._name,
|
||||||
|
self._description,
|
||||||
|
self._permissions,
|
||||||
|
bool(self._default),
|
||||||
|
bool(self._removable),
|
||||||
|
bool(self._changeable))
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return self.key.__hash__()
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return isinstance(other, Group) and other.key == self.key
|
||||||
@@ -0,0 +1,368 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__author__ = "Marc Hannappel <salandora@gmail.com>"
|
||||||
|
__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"
|
||||||
|
|
||||||
|
from future.utils import with_metaclass
|
||||||
|
from flask import g, abort
|
||||||
|
from flask_babel import gettext
|
||||||
|
from flask_principal import Permission, PermissionDenied, RoleNeed, Need
|
||||||
|
|
||||||
|
from functools import wraps
|
||||||
|
from collections import OrderedDict, defaultdict
|
||||||
|
|
||||||
|
# noinspection PyCompatibility
|
||||||
|
from past.builtins import basestring
|
||||||
|
|
||||||
|
from octoprint.access import ADMIN_GROUP, USER_GROUP, READONLY_GROUP
|
||||||
|
|
||||||
|
|
||||||
|
class OctoPrintPermission(Permission):
|
||||||
|
@classmethod
|
||||||
|
def convert_needs_to_dict(cls, needs):
|
||||||
|
ret_needs = defaultdict(list)
|
||||||
|
for need in needs:
|
||||||
|
if need.value not in ret_needs[need.method]:
|
||||||
|
ret_needs[need.method].append(need.value)
|
||||||
|
return ret_needs
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def convert_to_needs(cls, needs):
|
||||||
|
result = []
|
||||||
|
for need in needs:
|
||||||
|
# noinspection PyCompatibility
|
||||||
|
if isinstance(need, Need):
|
||||||
|
result.append(need)
|
||||||
|
elif isinstance(need, Permission):
|
||||||
|
result += need.needs
|
||||||
|
elif isinstance(need, basestring):
|
||||||
|
result.append(RoleNeed(need))
|
||||||
|
return result
|
||||||
|
|
||||||
|
def __init__(self, name, description, *needs, **kwargs):
|
||||||
|
self._name = name
|
||||||
|
self._description = description
|
||||||
|
self._dangerous = kwargs.pop("dangerous", False)
|
||||||
|
self._default_groups = kwargs.pop("default_groups", [])
|
||||||
|
|
||||||
|
self._key = None
|
||||||
|
|
||||||
|
Permission.__init__(self, *self.convert_to_needs(needs))
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return dict(
|
||||||
|
key=self.key,
|
||||||
|
name=self.get_name(),
|
||||||
|
dangerous=self._dangerous,
|
||||||
|
default_groups=self._default_groups,
|
||||||
|
description=self.get_description(),
|
||||||
|
needs=self.convert_needs_to_dict(self.needs)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def key(self):
|
||||||
|
return self._key
|
||||||
|
|
||||||
|
@key.setter
|
||||||
|
def key(self, value):
|
||||||
|
self._key = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default_groups(self):
|
||||||
|
return self._default_groups
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
def get_description(self):
|
||||||
|
return self._description
|
||||||
|
|
||||||
|
def union(self, other):
|
||||||
|
"""Create a new OctoPrintPermission with the requirements of the union of this
|
||||||
|
and other.
|
||||||
|
|
||||||
|
:param other: The other permission
|
||||||
|
"""
|
||||||
|
p = self.__class__(self._name, self._description, *self.needs.union(other.needs))
|
||||||
|
p.excludes.update(self.excludes.union(other.excludes))
|
||||||
|
return p
|
||||||
|
|
||||||
|
def difference(self, other):
|
||||||
|
"""Create a new OctoPrintPermission consisting of requirements in this
|
||||||
|
permission and not in the other.
|
||||||
|
"""
|
||||||
|
|
||||||
|
p = self.__class__(self._name, self._description, *self.needs.difference(other.needs))
|
||||||
|
p.excludes.update(self.excludes.difference(other.excludes))
|
||||||
|
return p
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '{}({!r}, {!r}, {})'.format(self.__class__.__name__,
|
||||||
|
self.get_name(),
|
||||||
|
self.get_description(),
|
||||||
|
', '.join(map(repr, self.needs)))
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return self.get_name().__hash__()
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return isinstance(other, OctoPrintPermission) and other.get_name() == self.get_name()
|
||||||
|
|
||||||
|
|
||||||
|
class PluginOctoPrintPermission(OctoPrintPermission):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.plugin = kwargs.pop("plugin", None)
|
||||||
|
OctoPrintPermission.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = OctoPrintPermission.as_dict(self)
|
||||||
|
result["plugin"] = self.plugin
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class PluginIdentityContext(object):
|
||||||
|
"""Identity context for not initialized Permissions
|
||||||
|
|
||||||
|
Needed to support @Permissions.PLUGIN_X_Y.require()
|
||||||
|
|
||||||
|
Will search the permission when needed
|
||||||
|
"""
|
||||||
|
def __init__(self, key, http_exception=None):
|
||||||
|
self.key = key
|
||||||
|
self.http_exception = http_exception
|
||||||
|
"""The permission of this principal
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def identity(self):
|
||||||
|
"""The identity of this principal
|
||||||
|
"""
|
||||||
|
return g.identity
|
||||||
|
|
||||||
|
def can(self):
|
||||||
|
"""Whether the identity has access to the permission
|
||||||
|
"""
|
||||||
|
permission = getattr(Permissions, self.key)
|
||||||
|
if permission is None or isinstance(permission, PluginPermissionDecorator):
|
||||||
|
raise UnknownPermission(self.key)
|
||||||
|
|
||||||
|
return permission.can()
|
||||||
|
|
||||||
|
def __call__(self, f):
|
||||||
|
@wraps(f)
|
||||||
|
def _decorated(*args, **kw):
|
||||||
|
with self:
|
||||||
|
rv = f(*args, **kw)
|
||||||
|
return rv
|
||||||
|
|
||||||
|
return _decorated
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
permission = getattr(Permissions, self.key)
|
||||||
|
if permission is None or isinstance(permission, PluginPermissionDecorator):
|
||||||
|
raise UnknownPermission(self.key)
|
||||||
|
|
||||||
|
# check the permission here
|
||||||
|
if not permission.can():
|
||||||
|
if self.http_exception:
|
||||||
|
abort(self.http_exception, permission)
|
||||||
|
raise PermissionDenied(permission)
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class PluginPermissionDecorator(Permission):
|
||||||
|
"""Decorator Class for not initialized Permissions
|
||||||
|
|
||||||
|
Needed to support @Permissions.PLUGIN_X_Y.require()
|
||||||
|
"""
|
||||||
|
def __init__(self, key):
|
||||||
|
self.key = key
|
||||||
|
|
||||||
|
def require(self, http_exception=None):
|
||||||
|
return PluginIdentityContext(self.key, http_exception)
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionsMetaClass(type):
|
||||||
|
permissions = OrderedDict()
|
||||||
|
|
||||||
|
def __new__(mcs, name, bases, args):
|
||||||
|
cls = type.__new__(mcs, name, bases, args)
|
||||||
|
|
||||||
|
for key, value in args.items():
|
||||||
|
if isinstance(value, OctoPrintPermission):
|
||||||
|
value.key = key
|
||||||
|
mcs.permissions[key] = value
|
||||||
|
delattr(cls, key)
|
||||||
|
|
||||||
|
return cls
|
||||||
|
|
||||||
|
def __setattr__(cls, key, value):
|
||||||
|
if isinstance(value, OctoPrintPermission):
|
||||||
|
if key in cls.permissions:
|
||||||
|
raise PermissionAlreadyExists(key)
|
||||||
|
value.key = key
|
||||||
|
cls.permissions[key] = value
|
||||||
|
|
||||||
|
def __getattr__(cls, key):
|
||||||
|
permission = cls.permissions.get(key)
|
||||||
|
|
||||||
|
if key.startswith("PLUGIN_") and permission is None:
|
||||||
|
return PluginPermissionDecorator(key)
|
||||||
|
|
||||||
|
return permission
|
||||||
|
|
||||||
|
def all(cls):
|
||||||
|
return list(cls.permissions.values())
|
||||||
|
|
||||||
|
def filter(cls, cb):
|
||||||
|
return list(filter(cb, cls.all()))
|
||||||
|
|
||||||
|
def find(cls, p, filter=None):
|
||||||
|
key = None
|
||||||
|
if isinstance(p, OctoPrintPermission):
|
||||||
|
key = p.key
|
||||||
|
elif isinstance(p, dict):
|
||||||
|
key = p.get("key")
|
||||||
|
elif isinstance(p, basestring):
|
||||||
|
key = p
|
||||||
|
|
||||||
|
if key is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return cls.match(lambda p: p.key == key, filter=filter)
|
||||||
|
|
||||||
|
def match(cls, match, filter=None):
|
||||||
|
if callable(filter):
|
||||||
|
permissions = cls.filter(filter)
|
||||||
|
else:
|
||||||
|
permissions = cls.all()
|
||||||
|
|
||||||
|
for permission in permissions:
|
||||||
|
if match(permission):
|
||||||
|
return permission
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class Permissions(with_metaclass(PermissionsMetaClass)):
|
||||||
|
|
||||||
|
# Special permission
|
||||||
|
ADMIN = OctoPrintPermission("Admin",
|
||||||
|
gettext("Admin is allowed to do everything"),
|
||||||
|
RoleNeed("admin"),
|
||||||
|
dangerous=True,
|
||||||
|
default_groups=[ADMIN_GROUP])
|
||||||
|
|
||||||
|
STATUS = OctoPrintPermission("Status",
|
||||||
|
gettext("Allows to gather status information, e.g. job progress, "
|
||||||
|
"printer state, temperatures, ..."),
|
||||||
|
RoleNeed("status"),
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
|
||||||
|
CONNECTION = OctoPrintPermission("Connection",
|
||||||
|
gettext("Allows to connect to and disconnect from a printer"),
|
||||||
|
RoleNeed("connection"),
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
|
||||||
|
WEBCAM = OctoPrintPermission("Webcam",
|
||||||
|
gettext("Allows to watch the webcam stream"),
|
||||||
|
RoleNeed("webcam"),
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
|
||||||
|
SYSTEM = OctoPrintPermission("System",
|
||||||
|
gettext("Allows to run system commands, e.g. restart OctoPrint, "
|
||||||
|
"shutdown or reboot the system"),
|
||||||
|
RoleNeed("system"),
|
||||||
|
dangerous=True)
|
||||||
|
|
||||||
|
FILES_LIST = OctoPrintPermission("File List",
|
||||||
|
gettext("Allows to retrieve a list of all uploaded files, including"
|
||||||
|
"their metadata (e.g. date, file size, analysis results, ...)"),
|
||||||
|
RoleNeed("files_list"),
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
FILES_UPLOAD = OctoPrintPermission("File Upload",
|
||||||
|
gettext("Allows users to upload new files"),
|
||||||
|
RoleNeed("files_upload"),
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
FILES_DOWNLOAD = OctoPrintPermission("File Download",
|
||||||
|
gettext("Allows users to download files. The GCODE viewer is "
|
||||||
|
"affected by this as well."),
|
||||||
|
RoleNeed("files_download"), FILES_LIST,
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
FILES_DELETE = OctoPrintPermission("File Delete",
|
||||||
|
gettext("Allows users to delete files"),
|
||||||
|
RoleNeed("files_delete"), FILES_LIST,
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
FILES_SELECT = OctoPrintPermission("File Select",
|
||||||
|
gettext("Allows to select a file for printing"),
|
||||||
|
RoleNeed("files_select"), FILES_LIST,
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
|
||||||
|
PRINT = OctoPrintPermission("Print",
|
||||||
|
gettext("Allows to start, pause and cancel a print job. Includes the \"Select\" "
|
||||||
|
"permission"),
|
||||||
|
RoleNeed("print"), FILES_SELECT,
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
|
||||||
|
GCODE_VIEWER = OctoPrintPermission("GCODE viewer",
|
||||||
|
gettext("Allows access to the GCODE viewer. Includes the \"File Download\""
|
||||||
|
"permission."),
|
||||||
|
RoleNeed("gcodeviewer"), FILES_DOWNLOAD,
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
|
||||||
|
MONITOR_TERMINAL = OctoPrintPermission("Terminal",
|
||||||
|
gettext("Allows to watch the terminal tab but not to send commands "
|
||||||
|
"to the printer from it"),
|
||||||
|
RoleNeed("monitor_terminal"),
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
|
||||||
|
CONTROL = OctoPrintPermission("Control",
|
||||||
|
gettext("Allows to control of the printer by using the temperature controls,"
|
||||||
|
"the control tab or sending commands through the terminal."),
|
||||||
|
RoleNeed("control"),
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
|
||||||
|
SLICE = OctoPrintPermission("Slice",
|
||||||
|
gettext("Allows to slice files"),
|
||||||
|
RoleNeed("slice"),
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
|
||||||
|
TIMELAPSE_LIST = OctoPrintPermission("Timelapse List",
|
||||||
|
gettext("Allows to list timelapse videos"),
|
||||||
|
RoleNeed("timelapse_list"),
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
TIMELAPSE_DOWNLOAD = OctoPrintPermission("Timelapse Download",
|
||||||
|
gettext("Allows to download timelapse videos"),
|
||||||
|
RoleNeed("timelapse_download"),
|
||||||
|
default_groups=[USER_GROUP, READONLY_GROUP])
|
||||||
|
TIMELAPSE_DELETE = OctoPrintPermission("Timelapse Delete",
|
||||||
|
gettext("Allows to delete timelapse videos and unrendered timelapses"),
|
||||||
|
RoleNeed("timelapse_delete"),
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
TIMELAPSE_ADMIN = OctoPrintPermission("Timelapse Admin",
|
||||||
|
gettext("Allows to change the timelapse settings and delete or "
|
||||||
|
"render unrendered timelapses. Includes the \"Timelapse List\","
|
||||||
|
"\"Timelapse Delete\" and \"Timelapse Download\" permissions"),
|
||||||
|
RoleNeed("timelapse_admin"), TIMELAPSE_LIST, TIMELAPSE_DOWNLOAD,
|
||||||
|
default_groups=[USER_GROUP])
|
||||||
|
|
||||||
|
SETTINGS = OctoPrintPermission("Settings",
|
||||||
|
gettext("Allows to manage settings"),
|
||||||
|
RoleNeed("settings"),
|
||||||
|
dangerous=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionAlreadyExists(Exception):
|
||||||
|
def __init__(self, permission):
|
||||||
|
Exception.__init__(self, "Permission %s already exists" % permission)
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownPermission(Exception):
|
||||||
|
def __init__(self, permissionname):
|
||||||
|
Exception.__init__(self, "Unknown permission: %s" % permissionname)
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,12 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
import octoprint
|
import octoprint
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
|
|
||||||
#~~ "octoprint util" commands
|
#~~ "octoprint util" commands
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
import yaml
|
import yaml
|
||||||
|
from octoprint.util import monotonic_time
|
||||||
from octoprint.util.gcodeInterpreter import gcode
|
from octoprint.util.gcodeInterpreter import gcode
|
||||||
|
|
||||||
throttle_callback = None
|
throttle_callback = None
|
||||||
@@ -52,7 +54,7 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
|
|||||||
if len(offsets) < maxt:
|
if len(offsets) < maxt:
|
||||||
offsets += [(0, 0)] * (maxt - len(offsets))
|
offsets += [(0, 0)] * (maxt - len(offsets))
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = monotonic_time()
|
||||||
|
|
||||||
progress_callback = None
|
progress_callback = None
|
||||||
if progress:
|
if progress:
|
||||||
@@ -68,9 +70,9 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
|
|||||||
max_extruders=maxt,
|
max_extruders=maxt,
|
||||||
g90_extruder=g90_extruder)
|
g90_extruder=g90_extruder)
|
||||||
|
|
||||||
click.echo("DONE:{}s".format(time.time() - start_time))
|
click.echo("DONE:{}s".format(monotonic_time() - start_time))
|
||||||
click.echo("RESULTS:")
|
click.echo("RESULTS:")
|
||||||
click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=" ", allow_unicode=True))
|
click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=4, allow_unicode=True))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
gcode_command()
|
gcode_command()
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
|
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import octoprint_client
|
import octoprint_client
|
||||||
@@ -12,6 +15,7 @@ import octoprint_client
|
|||||||
from octoprint.cli import get_ctx_obj_option, bulk_options
|
from octoprint.cli import get_ctx_obj_option, bulk_options
|
||||||
from octoprint import init_settings, FatalStartupError
|
from octoprint import init_settings, FatalStartupError
|
||||||
|
|
||||||
|
from past.builtins import unicode
|
||||||
|
|
||||||
class JsonStringParamType(click.ParamType):
|
class JsonStringParamType(click.ParamType):
|
||||||
name = "json"
|
name = "json"
|
||||||
@@ -19,7 +23,7 @@ class JsonStringParamType(click.ParamType):
|
|||||||
def convert(self, value, param, ctx):
|
def convert(self, value, param, ctx):
|
||||||
try:
|
try:
|
||||||
return json.loads(value)
|
return json.loads(value)
|
||||||
except:
|
except Exception:
|
||||||
self.fail("%s is not a valid json string" % value, param, ctx)
|
self.fail("%s is not a valid json string" % value, param, ctx)
|
||||||
|
|
||||||
|
|
||||||
@@ -143,16 +147,16 @@ 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."""
|
"""POSTs JSON data to the specified server path, taking the data from the specified file."""
|
||||||
if json_flag or yaml_flag:
|
if json_flag or yaml_flag:
|
||||||
if json_flag:
|
if json_flag:
|
||||||
with open(file_path, "rb") as fp:
|
with io.open(file_path, 'rt') as fp:
|
||||||
data = json.load(fp)
|
data = json.load(fp)
|
||||||
else:
|
else:
|
||||||
import yaml
|
import yaml
|
||||||
with open(file_path, "rb") as fp:
|
with io.open(file_path, 'rt') as fp:
|
||||||
data = yaml.safe_load(fp)
|
data = yaml.safe_load(fp)
|
||||||
|
|
||||||
r = ctx.obj.client.post_json(path, data, timeout=timeout)
|
r = ctx.obj.client.post_json(path, data, timeout=timeout)
|
||||||
else:
|
else:
|
||||||
with open(file_path, "rb") as fp:
|
with io.open(file_path, 'rb') as fp:
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
|
|
||||||
r = ctx.obj.client.post(path, data, timeout=timeout)
|
r = ctx.obj.client.post(path, data, timeout=timeout)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from octoprint import init_settings, FatalStartupError
|
from octoprint import init_settings, FatalStartupError
|
||||||
@@ -17,7 +18,7 @@ import pprint
|
|||||||
|
|
||||||
def _to_settings_path(path):
|
def _to_settings_path(path):
|
||||||
if not isinstance(path, (list, tuple)):
|
if not isinstance(path, (list, tuple)):
|
||||||
path = filter(lambda x: x, map(lambda x: x.strip(), path.split(".")))
|
path = list(filter(lambda x: x, map(lambda x: x.strip(), path.split("."))))
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def _set_helper(settings, path, value, data_type=None):
|
def _set_helper(settings, path, value, data_type=None):
|
||||||
@@ -207,7 +208,7 @@ def get_command(ctx, path, as_json=False, as_yaml=False, as_raw=False):
|
|||||||
if as_json:
|
if as_json:
|
||||||
output = json.dumps(value)
|
output = json.dumps(value)
|
||||||
elif as_yaml:
|
elif as_yaml:
|
||||||
output = yaml.safe_dump(value, default_flow_style=False, indent=" ", allow_unicode=True)
|
output = yaml.safe_dump(value, default_flow_style=False, indent=4, allow_unicode=True)
|
||||||
elif as_raw:
|
elif as_raw:
|
||||||
output = value
|
output = value
|
||||||
else:
|
else:
|
||||||
@@ -232,7 +233,7 @@ def effective_command(ctx, as_json=False, as_yaml=False, as_raw=False):
|
|||||||
if as_json:
|
if as_json:
|
||||||
output = json.dumps(value)
|
output = json.dumps(value)
|
||||||
elif as_yaml:
|
elif as_yaml:
|
||||||
output = yaml.safe_dump(value, default_flow_style=False, indent=" ", allow_unicode=True)
|
output = yaml.safe_dump(value, default_flow_style=False, indent=4, allow_unicode=True)
|
||||||
elif as_raw:
|
elif as_raw:
|
||||||
output = value
|
output = value
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
@@ -7,6 +7,7 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
|||||||
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
|
|
||||||
from past.builtins import basestring
|
from past.builtins import basestring
|
||||||
|
|
||||||
@@ -116,7 +117,8 @@ class OctoPrintDevelCommands(click.MultiCommand):
|
|||||||
if key in options:
|
if key in options:
|
||||||
val = options[key]
|
val = options[key]
|
||||||
else:
|
else:
|
||||||
raw = raw if isinstance(raw, basestring) else str(raw)
|
if not isinstance(raw, basestring):
|
||||||
|
raw = str(raw)
|
||||||
val = env.from_string(raw).render(cookiecutter=cookiecutter_dict)
|
val = env.from_string(raw).render(cookiecutter=cookiecutter_dict)
|
||||||
|
|
||||||
if not no_input:
|
if not no_input:
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from octoprint.cli import pass_octoprint_ctx, OctoPrintContext, get_ctx_obj_option
|
from octoprint.cli import pass_octoprint_ctx, OctoPrintContext, get_ctx_obj_option
|
||||||
@@ -88,11 +89,12 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
|||||||
commands = hook(self, pass_octoprint_ctx)
|
commands = hook(self, pass_octoprint_ctx)
|
||||||
for command in commands:
|
for command in commands:
|
||||||
if not isinstance(command, click.Command):
|
if not isinstance(command, click.Command):
|
||||||
self._logger.warn("Plugin {} provided invalid CLI command, ignoring it: {!r}".format(name, command))
|
self._logger.warning("Plugin {} provided invalid CLI command, ignoring it: {!r}".format(name, command))
|
||||||
continue
|
continue
|
||||||
result[name + self.sep + command.name] = command
|
result[name + self.sep + command.name] = command
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error while retrieving cli commands for plugin {}".format(name))
|
self._logger.exception("Error while retrieving cli commands for plugin {}".format(name),
|
||||||
|
extra=dict(plugin=name))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
+40
-14
@@ -1,17 +1,18 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
click.disable_unicode_literals_warning = True
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from octoprint.cli import bulk_options, standard_options, set_ctx_obj_option, get_ctx_obj_option
|
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,
|
def run_server(basedir, configfile, host, port, v6_only, debug, allow_root, logging_config, verbosity, safe_mode,
|
||||||
ignore_blacklist, octoprint_daemon=None):
|
ignore_blacklist, octoprint_daemon=None):
|
||||||
"""Initializes the environment and starts up the server."""
|
"""Initializes the environment and starts up the server."""
|
||||||
|
|
||||||
@@ -26,6 +27,15 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
|||||||
logger.info("Starting OctoPrint {}".format(__display_version__))
|
logger.info("Starting OctoPrint {}".format(__display_version__))
|
||||||
if safe_mode:
|
if safe_mode:
|
||||||
logger.info("Starting in SAFE MODE. Third party plugins will be disabled!")
|
logger.info("Starting in SAFE MODE. Third party plugins will be disabled!")
|
||||||
|
if safe_mode == "flag":
|
||||||
|
reason = "command line flag"
|
||||||
|
elif safe_mode == "settings":
|
||||||
|
reason = "setting in config.yaml"
|
||||||
|
elif safe_mode == "incomplete_startup":
|
||||||
|
reason = "problem during last startup"
|
||||||
|
else:
|
||||||
|
reason = "unknown"
|
||||||
|
logger.info("Reason for safe mode: {}".format(reason))
|
||||||
|
|
||||||
if recorder and len(recorder):
|
if recorder and len(recorder):
|
||||||
logger.info(get_divider_line("-", "Logged during platform initialization:"))
|
logger.info(get_divider_line("-", "Logged during platform initialization:"))
|
||||||
@@ -101,6 +111,7 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
|||||||
environment_detector=environment_detector,
|
environment_detector=environment_detector,
|
||||||
host=host,
|
host=host,
|
||||||
port=port,
|
port=port,
|
||||||
|
v6_only=v6_only,
|
||||||
debug=debug,
|
debug=debug,
|
||||||
safe_mode=safe_mode,
|
safe_mode=safe_mode,
|
||||||
allow_root=allow_root,
|
allow_root=allow_root,
|
||||||
@@ -111,9 +122,13 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
|||||||
|
|
||||||
server_options = bulk_options([
|
server_options = bulk_options([
|
||||||
click.option("--host", type=click.STRING, callback=set_ctx_obj_option,
|
click.option("--host", type=click.STRING, callback=set_ctx_obj_option,
|
||||||
help="Specify the host on which to bind the server."),
|
help="Specify the host address on which to bind the server."),
|
||||||
click.option("--port", type=click.INT, callback=set_ctx_obj_option,
|
click.option("--port", type=click.INT, callback=set_ctx_obj_option,
|
||||||
help="Specify the port on which to bind the server."),
|
help="Specify the port on which to bind the server."),
|
||||||
|
click.option("-4", "--ipv4", "v4", is_flag=True, callback=set_ctx_obj_option,
|
||||||
|
help="Bind to IPv4 addresses only. Implies '--host 0.0.0.0'. Silently ignored if -6 is present."),
|
||||||
|
click.option("-6", "--ipv6", "v6", is_flag=True, callback=set_ctx_obj_option,
|
||||||
|
help="Bind to IPv6 addresses only. Disables dual stack when binding to any v6 addresses. Silently ignored if -4 is present."),
|
||||||
click.option("--logging", type=click.Path(), callback=set_ctx_obj_option,
|
click.option("--logging", type=click.Path(), callback=set_ctx_obj_option,
|
||||||
help="Specify the config file to use for configuring logging."),
|
help="Specify the config file to use for configuring logging."),
|
||||||
click.option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option,
|
click.option("--iknowwhatimdoing", "allow_root", is_flag=True, callback=set_ctx_obj_option,
|
||||||
@@ -123,7 +138,7 @@ server_options = bulk_options([
|
|||||||
click.option("--ignore-blacklist", "ignore_blacklist", is_flag=True, callback=set_ctx_obj_option,
|
click.option("--ignore-blacklist", "ignore_blacklist", is_flag=True, callback=set_ctx_obj_option,
|
||||||
help="Disable processing of the plugin blacklist.")
|
help="Disable processing of the plugin blacklist.")
|
||||||
])
|
])
|
||||||
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``,
|
"""Decorator to add the options shared among the server commands: ``--host``, ``--port``, ``-4``, ``-6``
|
||||||
``--logging``, ``--iknowwhatimdoing`` and ``--debug``."""
|
``--logging``, ``--iknowwhatimdoing`` and ``--debug``."""
|
||||||
|
|
||||||
daemon_options = bulk_options([
|
daemon_options = bulk_options([
|
||||||
@@ -153,7 +168,7 @@ def enable_safemode(ctx, **kwargs):
|
|||||||
click.echo(e.message, err=True)
|
click.echo(e.message, err=True)
|
||||||
click.echo("There was a fatal error initializing the settings manager.", err=True)
|
click.echo("There was a fatal error initializing the settings manager.", err=True)
|
||||||
ctx.exit(-1)
|
ctx.exit(-1)
|
||||||
|
else:
|
||||||
settings.setBoolean(["server", "startOnceInSafeMode"], True)
|
settings.setBoolean(["server", "startOnceInSafeMode"], True)
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|
||||||
@@ -172,6 +187,8 @@ def serve_command(ctx, **kwargs):
|
|||||||
|
|
||||||
host = get_value("host")
|
host = get_value("host")
|
||||||
port = get_value("port")
|
port = get_value("port")
|
||||||
|
v4 = get_value("v4")
|
||||||
|
v6 = get_value("v6")
|
||||||
logging = get_value("logging")
|
logging = get_value("logging")
|
||||||
allow_root = get_value("allow_root")
|
allow_root = get_value("allow_root")
|
||||||
debug = get_value("debug")
|
debug = get_value("debug")
|
||||||
@@ -179,10 +196,13 @@ def serve_command(ctx, **kwargs):
|
|||||||
basedir = get_value("basedir")
|
basedir = get_value("basedir")
|
||||||
configfile = get_value("configfile")
|
configfile = get_value("configfile")
|
||||||
verbosity = get_value("verbosity")
|
verbosity = get_value("verbosity")
|
||||||
safe_mode = get_value("safe_mode")
|
safe_mode = "flag" if get_value("safe_mode") else None
|
||||||
ignore_blacklist = get_value("ignore_blacklist")
|
ignore_blacklist = get_value("ignore_blacklist")
|
||||||
|
|
||||||
run_server(basedir, configfile, host, port, debug,
|
if v4 and not host:
|
||||||
|
host = "0.0.0.0"
|
||||||
|
|
||||||
|
run_server(basedir, configfile, host, port, v6, debug,
|
||||||
allow_root, logging, verbosity, safe_mode,
|
allow_root, logging, verbosity, safe_mode,
|
||||||
ignore_blacklist)
|
ignore_blacklist)
|
||||||
|
|
||||||
@@ -209,6 +229,8 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
|||||||
|
|
||||||
host = get_value("host")
|
host = get_value("host")
|
||||||
port = get_value("port")
|
port = get_value("port")
|
||||||
|
v4 = get_value("v4")
|
||||||
|
v6 = get_value("v6")
|
||||||
logging = get_value("logging")
|
logging = get_value("logging")
|
||||||
allow_root = get_value("allow_root")
|
allow_root = get_value("allow_root")
|
||||||
debug = get_value("debug")
|
debug = get_value("debug")
|
||||||
@@ -217,9 +239,12 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
|||||||
basedir = get_value("basedir")
|
basedir = get_value("basedir")
|
||||||
configfile = get_value("configfile")
|
configfile = get_value("configfile")
|
||||||
verbosity = get_value("verbosity")
|
verbosity = get_value("verbosity")
|
||||||
safe_mode = get_value("safe_mode")
|
safe_mode = "flag" if get_value("safe_mode") else None
|
||||||
ignore_blacklist = get_value("ignore_blacklist")
|
ignore_blacklist = get_value("ignore_blacklist")
|
||||||
|
|
||||||
|
if v4 and not host:
|
||||||
|
host = "0.0.0.0"
|
||||||
|
|
||||||
if pid is None:
|
if pid is None:
|
||||||
click.echo("No path to a pidfile set",
|
click.echo("No path to a pidfile set",
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
@@ -227,14 +252,15 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
|||||||
|
|
||||||
from octoprint.daemon import Daemon
|
from octoprint.daemon import Daemon
|
||||||
class OctoPrintDaemon(Daemon):
|
class OctoPrintDaemon(Daemon):
|
||||||
def __init__(self, pidfile, basedir, configfile, host, port, debug, allow_root, logging_config, verbosity,
|
def __init__(self, pidfile, basedir, configfile, host, port, v6_only, debug, allow_root, logging_config,
|
||||||
safe_mode, ignore_blacklist):
|
verbosity, safe_mode, ignore_blacklist):
|
||||||
Daemon.__init__(self, pidfile)
|
Daemon.__init__(self, pidfile)
|
||||||
|
|
||||||
self._basedir = basedir
|
self._basedir = basedir
|
||||||
self._configfile = configfile
|
self._configfile = configfile
|
||||||
self._host = host
|
self._host = host
|
||||||
self._port = port
|
self._port = port
|
||||||
|
self._v6_only = v6_only
|
||||||
self._debug = debug
|
self._debug = debug
|
||||||
self._allow_root = allow_root
|
self._allow_root = allow_root
|
||||||
self._logging_config = logging_config
|
self._logging_config = logging_config
|
||||||
@@ -243,12 +269,12 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
|||||||
self._ignore_blacklist = ignore_blacklist
|
self._ignore_blacklist = ignore_blacklist
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
run_server(self._basedir, self._configfile, self._host, self._port, self._debug,
|
run_server(self._basedir, self._configfile, self._host, self._port, self._v6_only, self._debug,
|
||||||
self._allow_root, self._logging_config, self._verbosity, self._safe_mode,
|
self._allow_root, self._logging_config, self._verbosity, self._safe_mode,
|
||||||
self._ignore_blacklist, octoprint_daemon=self)
|
self._ignore_blacklist, octoprint_daemon=self)
|
||||||
|
|
||||||
octoprint_daemon = OctoPrintDaemon(pid, basedir, configfile, host, port, debug, allow_root, logging, verbosity,
|
octoprint_daemon = OctoPrintDaemon(pid, basedir, configfile, host, port, v6, debug, allow_root, logging,
|
||||||
safe_mode, ignore_blacklist)
|
verbosity, safe_mode, ignore_blacklist)
|
||||||
|
|
||||||
if command == "start":
|
if command == "start":
|
||||||
octoprint_daemon.start()
|
octoprint_daemon.start()
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,215 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import io
|
||||||
|
|
||||||
|
try:
|
||||||
|
from os import scandir
|
||||||
|
except ImportError:
|
||||||
|
from scandir import scandir
|
||||||
|
|
||||||
|
from octoprint.settings import settings
|
||||||
|
from octoprint.util import is_hidden_path
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionProfile(object):
|
||||||
|
|
||||||
|
def __init__(self, id, name=None, printer_profile=None, protocol=None, protocol_parameters=None, transport=None, transport_parameters=None, **kwargs):
|
||||||
|
self.id = id
|
||||||
|
self.name = name if name is not None else id
|
||||||
|
self.printer_profile = printer_profile
|
||||||
|
self.protocol = protocol
|
||||||
|
self.protocol_parameters = protocol_parameters
|
||||||
|
self.transport = transport
|
||||||
|
self.transport_parameters = transport_parameters
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, data):
|
||||||
|
identifier = data.pop("id")
|
||||||
|
return ConnectionProfile(identifier, **data)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return dict(id=self.id,
|
||||||
|
name=self.name,
|
||||||
|
printer_profile=self.printer_profile,
|
||||||
|
protocol=self.protocol,
|
||||||
|
protocol_parameters=self.protocol_parameters,
|
||||||
|
transport=self.transport,
|
||||||
|
transport_parameters=self.transport_parameters)
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionProfileManager(object):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def to_profile(cls, data):
|
||||||
|
return ConnectionProfile.from_dict(data)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self._current = None
|
||||||
|
self._folder = settings().getBaseFolder("connectionProfiles")
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
def select(self, identifier):
|
||||||
|
self._current = self.get(identifier)
|
||||||
|
if self._current is None:
|
||||||
|
self._logger.error("Profile {} is invalid, cannot select".format(identifier))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def deselect(self):
|
||||||
|
self._current = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current(self):
|
||||||
|
return self._current
|
||||||
|
|
||||||
|
def get_all(self):
|
||||||
|
return self._load_all()
|
||||||
|
|
||||||
|
def get(self, identifier):
|
||||||
|
try:
|
||||||
|
if self.exists(identifier):
|
||||||
|
return self._load_from_path(self._get_profile_path(identifier))
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
except InvalidProfileError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def remove(self, identifier):
|
||||||
|
return self._remove_from_path(self._get_profile_path(identifier))
|
||||||
|
|
||||||
|
def save(self, profile, allow_overwrite=False, make_default=False):
|
||||||
|
self._save_to_path(self._get_profile_path(profile.id),
|
||||||
|
profile,
|
||||||
|
allow_overwrite=allow_overwrite)
|
||||||
|
|
||||||
|
if make_default:
|
||||||
|
self.set_default(profile.id)
|
||||||
|
|
||||||
|
return self.get(profile.id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def profile_count(self):
|
||||||
|
return len(self._load_all_identifiers())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_modified(self):
|
||||||
|
dates = [os.stat(self._folder).st_mtime]
|
||||||
|
dates += [entry.stat().st_mtime for entry in scandir(self._folder) if entry.name.endswith(".profile")]
|
||||||
|
return max(dates)
|
||||||
|
|
||||||
|
def get_default(self):
|
||||||
|
default = settings().get(["connectionProfiles", "default"])
|
||||||
|
if default is not None and self.exists(default):
|
||||||
|
profile = self.get(default)
|
||||||
|
if profile is not None:
|
||||||
|
return profile
|
||||||
|
else:
|
||||||
|
self._logger.warning("Default profile {} is invalid".format(default))
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def set_default(self, identifier):
|
||||||
|
all_identifiers = self._load_all_identifiers()
|
||||||
|
if identifier is not None and identifier not in all_identifiers:
|
||||||
|
return
|
||||||
|
|
||||||
|
settings().set(["connectionProfiles", "default"], identifier)
|
||||||
|
settings().save()
|
||||||
|
|
||||||
|
def get_current_or_default(self):
|
||||||
|
if self._current is not None:
|
||||||
|
return self._current
|
||||||
|
else:
|
||||||
|
return self.get_default()
|
||||||
|
|
||||||
|
def get_current(self):
|
||||||
|
return self._current
|
||||||
|
|
||||||
|
def exists(self, identifier):
|
||||||
|
if identifier is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
path = self._get_profile_path(identifier)
|
||||||
|
return os.path.exists(path) and os.path.isfile(path)
|
||||||
|
|
||||||
|
def _load_all(self):
|
||||||
|
all_identifiers = self._load_all_identifiers()
|
||||||
|
results = dict()
|
||||||
|
for identifier, path in all_identifiers.items():
|
||||||
|
try:
|
||||||
|
profile = self._load_from_path(path)
|
||||||
|
except InvalidProfileError:
|
||||||
|
self._logger.warning("Profile {} is invalid, skipping".format(identifier))
|
||||||
|
continue
|
||||||
|
|
||||||
|
if profile is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
results[identifier] = profile
|
||||||
|
return results
|
||||||
|
|
||||||
|
def _load_all_identifiers(self):
|
||||||
|
results = dict()
|
||||||
|
for entry in scandir(self._folder):
|
||||||
|
if is_hidden_path(entry.name) or not entry.name.endswith(".profile"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not entry.is_file():
|
||||||
|
continue
|
||||||
|
|
||||||
|
identifier = entry.name[:-len(".profile")]
|
||||||
|
results[identifier] = entry.path
|
||||||
|
return results
|
||||||
|
|
||||||
|
def _load_from_path(self, path):
|
||||||
|
if not os.path.exists(path) or not os.path.isfile(path):
|
||||||
|
return None
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
with io.open(path, 'rt', encoding='utf-8') as f:
|
||||||
|
data = yaml.safe_load(f)
|
||||||
|
|
||||||
|
if data is None or not isinstance(data, dict):
|
||||||
|
raise InvalidProfileError("Profile is None or not a dict")
|
||||||
|
|
||||||
|
return ConnectionProfile.from_dict(data)
|
||||||
|
|
||||||
|
def _save_to_path(self, path, profile, allow_overwrite=False):
|
||||||
|
if os.path.exists(path) and not allow_overwrite:
|
||||||
|
raise SaveError("Profile {} already exists and overwriting is not allowed".format(profile["id"]))
|
||||||
|
|
||||||
|
from octoprint.util import atomic_write
|
||||||
|
import yaml
|
||||||
|
try:
|
||||||
|
with atomic_write(path, mode="wt", max_permissions=0o666) as f:
|
||||||
|
yaml.safe_dump(profile.as_dict(), f,
|
||||||
|
default_flow_style=False,
|
||||||
|
indent=2,
|
||||||
|
allow_unicode=True)
|
||||||
|
except Exception as e:
|
||||||
|
self._logger.exception("Error while trying to save profile {}".format(profile["id"]))
|
||||||
|
raise SaveError("Cannot save profile {}: {}".format(profile["id"], e))
|
||||||
|
|
||||||
|
def _remove_from_path(self, path):
|
||||||
|
try:
|
||||||
|
os.remove(path)
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _get_profile_path(self, identifier):
|
||||||
|
return os.path.join(self._folder, "{}.profile".format(identifier))
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidProfileError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class SaveError(Exception):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,573 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import copy
|
||||||
|
|
||||||
|
from octoprint.comm.protocol import ProtocolListener, FileAwareProtocolListener, ProtocolState, FileManagementProtocolMixin
|
||||||
|
|
||||||
|
from octoprint.util.listener import ListenerAware
|
||||||
|
|
||||||
|
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||||
|
|
||||||
|
from octoprint.util import monotonic_time
|
||||||
|
|
||||||
|
from future.utils import with_metaclass
|
||||||
|
|
||||||
|
|
||||||
|
class LastResult(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.elapsed = None
|
||||||
|
self.clean_elapsed = None
|
||||||
|
self.progress = None
|
||||||
|
self.pos = None
|
||||||
|
self.success = None
|
||||||
|
|
||||||
|
self.available = False
|
||||||
|
|
||||||
|
|
||||||
|
class Printjob(with_metaclass(ABCMeta, ProtocolListener, ListenerAware)):
|
||||||
|
|
||||||
|
parallel = False
|
||||||
|
"""Job runs parallel to regular communication."""
|
||||||
|
|
||||||
|
exclusive = False
|
||||||
|
"""Job has exclusive claim to communication channel."""
|
||||||
|
|
||||||
|
def __init__(self, name=None, user=None, event_data=None):
|
||||||
|
if event_data is None:
|
||||||
|
event_data = dict()
|
||||||
|
|
||||||
|
super(Printjob, self).__init__()
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._start = None
|
||||||
|
self._protocol = None
|
||||||
|
self._printer_profile = None
|
||||||
|
self._name = name
|
||||||
|
self._user = user
|
||||||
|
self._event_data = event_data
|
||||||
|
|
||||||
|
self._lost_time = 0
|
||||||
|
self._last_result = LastResult()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def user(self):
|
||||||
|
return self._user
|
||||||
|
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pos(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def elapsed(self):
|
||||||
|
return monotonic_time() - self._start if self._start is not None else None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def clean_elapsed(self):
|
||||||
|
elapsed = self.elapsed
|
||||||
|
if elapsed is None:
|
||||||
|
return None
|
||||||
|
return elapsed - self._lost_time
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_result(self):
|
||||||
|
return self._last_result
|
||||||
|
|
||||||
|
@property
|
||||||
|
def progress(self):
|
||||||
|
size = self.size
|
||||||
|
pos = self.pos
|
||||||
|
if pos is None or size is None or size == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return float(pos) / float(size)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active(self):
|
||||||
|
return self._start is not None
|
||||||
|
|
||||||
|
def add_to_lost_time(self, value):
|
||||||
|
self._lost_time += value
|
||||||
|
|
||||||
|
def can_process(self, protocol):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||||
|
self._last_result = LastResult()
|
||||||
|
self._start = monotonic_time()
|
||||||
|
self._user = user
|
||||||
|
self._protocol = protocol
|
||||||
|
self._protocol.register_listener(self)
|
||||||
|
|
||||||
|
def pause(self, user=None, tags=None, **kwargs):
|
||||||
|
self.process_job_paused(user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def resume(self, user=None, tags=None, **kwargs):
|
||||||
|
self.process_job_resumed(user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def cancel(self, error=False, user=None, tags=None, **kwargs):
|
||||||
|
if error:
|
||||||
|
self.process_job_failed(**kwargs)
|
||||||
|
else:
|
||||||
|
self.process_job_cancelled(user=user, tags=tags, **kwargs)
|
||||||
|
self._protocol.unregister_listener(self)
|
||||||
|
self._protocol = None
|
||||||
|
|
||||||
|
def get_next(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def can_get_content(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_content_generator(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def event_payload(self, incl_last=False):
|
||||||
|
payload = copy.deepcopy(self._event_data)
|
||||||
|
|
||||||
|
payload["owner"] = self._user
|
||||||
|
elapsed = self.elapsed
|
||||||
|
if elapsed is None and incl_last and self.last_result.available:
|
||||||
|
elapsed = self.last_result.elapsed
|
||||||
|
if elapsed is not None:
|
||||||
|
payload["time"] = elapsed
|
||||||
|
|
||||||
|
return payload
|
||||||
|
|
||||||
|
def process_job_started(self, user=None, tags=None, **kwargs):
|
||||||
|
self.notify_listeners("on_job_started", self, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def process_job_done(self, user=None, tags=None, **kwargs):
|
||||||
|
self.notify_listeners("on_job_done", self, user=user, tags=tags, **kwargs)
|
||||||
|
self.report_stats()
|
||||||
|
self.reset_job()
|
||||||
|
|
||||||
|
def process_job_failed(self, **kwargs):
|
||||||
|
self.notify_listeners("on_job_failed", self, **kwargs)
|
||||||
|
self.report_stats()
|
||||||
|
self.reset_job(success=False)
|
||||||
|
|
||||||
|
def process_job_cancelled(self, user=None, tags=None, **kwargs):
|
||||||
|
self.notify_listeners("on_job_cancelled", self, user=user, tags=tags, **kwargs)
|
||||||
|
self.report_stats()
|
||||||
|
self.reset_job(success=False)
|
||||||
|
|
||||||
|
def process_job_paused(self, user=None, tags=None, **kwargs):
|
||||||
|
self.notify_listeners("on_job_paused", self, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def process_job_resumed(self, user=None, tags=None, **kwargs):
|
||||||
|
self.notify_listeners("on_job_resumed", self, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def process_job_progress(self):
|
||||||
|
self.notify_listeners("on_job_progress", self)
|
||||||
|
|
||||||
|
def report_stats(self):
|
||||||
|
elapsed = self.elapsed
|
||||||
|
if elapsed:
|
||||||
|
self._logger.info("Job processed in {}s".format(elapsed))
|
||||||
|
|
||||||
|
def reset_job(self, success=True):
|
||||||
|
self._last_result.progress = 1.0 if success else self.progress
|
||||||
|
self._last_result.pos = self.size if success else self.pos
|
||||||
|
self._last_result.elapsed = self.elapsed
|
||||||
|
self._last_result.clean_elapsed = self.clean_elapsed
|
||||||
|
self._last_result.success = success
|
||||||
|
self._last_result.available = True
|
||||||
|
|
||||||
|
self._start = None
|
||||||
|
self._lost_time = 0
|
||||||
|
|
||||||
|
def on_protocol_state(self, protocol, old_state, new_state, *args, **kwargs):
|
||||||
|
if new_state in (ProtocolState.DISCONNECTED, ProtocolState.DISCONNECTED_WITH_ERROR) and self.active:
|
||||||
|
self.cancel(error=True)
|
||||||
|
|
||||||
|
|
||||||
|
class StoragePrintjob(Printjob):
|
||||||
|
def __init__(self, storage, path_in_storage, *args, **kwargs):
|
||||||
|
Printjob.__init__(self, *args, **kwargs)
|
||||||
|
self._storage = storage
|
||||||
|
self._path_in_storage = path_in_storage
|
||||||
|
|
||||||
|
@property
|
||||||
|
def storage(self):
|
||||||
|
return self._storage
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_in_storage(self):
|
||||||
|
return self._path_in_storage
|
||||||
|
|
||||||
|
def event_payload(self, incl_last=False):
|
||||||
|
payload = Printjob.event_payload(self, incl_last=incl_last)
|
||||||
|
payload["name"] = self.name
|
||||||
|
payload["path"] = self.path_in_storage
|
||||||
|
payload["origin"] = self.storage
|
||||||
|
return payload
|
||||||
|
|
||||||
|
|
||||||
|
class LocalFilePrintjob(StoragePrintjob):
|
||||||
|
|
||||||
|
def __init__(self, path, *args, **kwargs):
|
||||||
|
encoding = kwargs.pop("encoding", "utf-8")
|
||||||
|
|
||||||
|
StoragePrintjob.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
if path is None or not os.path.exists(path):
|
||||||
|
raise ValueError("path must be set to a local file path")
|
||||||
|
|
||||||
|
self._path = path
|
||||||
|
self._encoding = encoding
|
||||||
|
self._size = os.stat(path).st_size
|
||||||
|
|
||||||
|
self._pos = 0
|
||||||
|
self._read_lines = 0
|
||||||
|
self._actual_lines = 0
|
||||||
|
|
||||||
|
self._cancel_pos = None
|
||||||
|
|
||||||
|
self._handle = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pos(self):
|
||||||
|
return self._pos
|
||||||
|
|
||||||
|
@property
|
||||||
|
def actual_lines(self):
|
||||||
|
return self._actual_lines
|
||||||
|
|
||||||
|
@property
|
||||||
|
def read_lines(self):
|
||||||
|
return self._read_lines
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cancel_pos(self):
|
||||||
|
return self._cancel_pos
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active(self):
|
||||||
|
return self._start is not None and self._handle is not None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
return self._path
|
||||||
|
|
||||||
|
def event_payload(self, incl_last=False):
|
||||||
|
event_data = StoragePrintjob.event_payload(self, incl_last=incl_last)
|
||||||
|
event_data["size"] = self.size
|
||||||
|
return event_data
|
||||||
|
|
||||||
|
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||||
|
Printjob.process(self, protocol, position=position, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
from octoprint.util import bom_aware_open
|
||||||
|
self._handle = bom_aware_open(self._path, encoding=self._encoding, errors="replace")
|
||||||
|
|
||||||
|
if position > 0:
|
||||||
|
self._handle.seek(position)
|
||||||
|
self._pos = position
|
||||||
|
self.process_job_started(user=user, tags=tags)
|
||||||
|
|
||||||
|
def cancel(self, error=False, user=None, tags=None, **kwargs):
|
||||||
|
self._cancel_pos = self.pos
|
||||||
|
super(LocalFilePrintjob, self).cancel(error=error, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def get_next(self):
|
||||||
|
from octoprint.util import to_unicode
|
||||||
|
|
||||||
|
if self._handle is None:
|
||||||
|
raise ValueError("File {} is not open for reading" % self._path)
|
||||||
|
|
||||||
|
try:
|
||||||
|
processed = None
|
||||||
|
while processed is None:
|
||||||
|
if self._handle is None:
|
||||||
|
# file got closed just now
|
||||||
|
self.process_job_done()
|
||||||
|
return None
|
||||||
|
line = to_unicode(self._handle.readline())
|
||||||
|
|
||||||
|
# we need to manually keep track of our pos here since
|
||||||
|
# codecs' readline will make our handle's tell not
|
||||||
|
# return the actual number of bytes read, but also the
|
||||||
|
# already buffered bytes (for detecting the newlines)
|
||||||
|
self._pos += len(line)
|
||||||
|
self._actual_lines += 1
|
||||||
|
|
||||||
|
if not line:
|
||||||
|
self.process_job_done()
|
||||||
|
return None
|
||||||
|
processed = self.process_line(line)
|
||||||
|
|
||||||
|
self._read_lines += 1
|
||||||
|
self.process_job_progress()
|
||||||
|
return processed
|
||||||
|
except Exception as e:
|
||||||
|
self.cancel(error=True)
|
||||||
|
self._logger.exception("Exception while processing line")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
def process_line(self, line):
|
||||||
|
return line
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self._handle is not None:
|
||||||
|
try:
|
||||||
|
self._handle.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self._handle = None
|
||||||
|
|
||||||
|
def can_get_content(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_content_generator(self):
|
||||||
|
from octoprint.util import bom_aware_open
|
||||||
|
with bom_aware_open(self._path, encoding=self._encoding, error="replace") as f:
|
||||||
|
for line in f.readline():
|
||||||
|
yield line
|
||||||
|
|
||||||
|
def reset_job(self, success=True):
|
||||||
|
super(LocalFilePrintjob, self).reset_job(success=success)
|
||||||
|
self.close()
|
||||||
|
self._pos = self._read_lines = 0
|
||||||
|
|
||||||
|
def report_stats(self):
|
||||||
|
elapsed = self.elapsed
|
||||||
|
lines = self._read_lines
|
||||||
|
|
||||||
|
if elapsed and lines:
|
||||||
|
self._logger.info("Job processed in {:.3f}s ({} lines)".format(elapsed, lines))
|
||||||
|
|
||||||
|
|
||||||
|
class LocalGcodeFilePrintjob(LocalFilePrintjob):
|
||||||
|
|
||||||
|
def can_process(self, protocol):
|
||||||
|
return LocalGcodeFilePrintjob in protocol.supported_jobs
|
||||||
|
|
||||||
|
def process_line(self, line):
|
||||||
|
# TODO no dependency on protocol module
|
||||||
|
from octoprint.comm.protocol.reprap.util import strip_comment
|
||||||
|
|
||||||
|
# strip line
|
||||||
|
processed = line.strip()
|
||||||
|
|
||||||
|
# strip comments
|
||||||
|
processed = strip_comment(processed)
|
||||||
|
if not len(processed):
|
||||||
|
return None
|
||||||
|
|
||||||
|
# TODO apply offsets
|
||||||
|
|
||||||
|
# return result
|
||||||
|
return processed
|
||||||
|
|
||||||
|
|
||||||
|
class CopyJobMixin(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class LocalGcodeStreamjob(LocalGcodeFilePrintjob, CopyJobMixin):
|
||||||
|
|
||||||
|
exclusive = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_job(cls, job, remote):
|
||||||
|
if not isinstance(job, LocalGcodeFilePrintjob):
|
||||||
|
raise ValueError("job must be a LocalGcodeFilePrintjob")
|
||||||
|
|
||||||
|
path = job._path
|
||||||
|
storage = job._storage
|
||||||
|
path_in_storage = job._path_in_storage
|
||||||
|
name = job._name
|
||||||
|
user = job._user
|
||||||
|
encoding = job._encoding
|
||||||
|
event_data = job._event_data
|
||||||
|
|
||||||
|
return cls(remote, path, storage, path_in_storage,
|
||||||
|
name=name, user=user, encoding=encoding, event_data=event_data)
|
||||||
|
|
||||||
|
def __init__(self, remote, *args, **kwargs):
|
||||||
|
super(LocalGcodeStreamjob, self).__init__(*args, **kwargs)
|
||||||
|
self._remote = remote
|
||||||
|
|
||||||
|
@property
|
||||||
|
def remote(self):
|
||||||
|
return self._remote
|
||||||
|
|
||||||
|
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||||
|
super(LocalGcodeStreamjob, self).process(protocol, position=position, user=user, tags=tags, **kwargs)
|
||||||
|
self._protocol.record_file(self._remote)
|
||||||
|
|
||||||
|
def process_job_done(self, user=None, tags=None, **kwargs):
|
||||||
|
self._protocol.stop_recording_file()
|
||||||
|
super(LocalGcodeStreamjob, self).process_job_done(user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def process_job_failed(self, **kwargs):
|
||||||
|
self._protocol.stop_recording_file()
|
||||||
|
super(LocalGcodeStreamjob, self).process_job_failed(**kwargs)
|
||||||
|
|
||||||
|
def process_job_cancelled(self, user=None, tags=None, **kwargs):
|
||||||
|
self._protocol.stop_recording_file()
|
||||||
|
self._protocol.delete_file(self.remote)
|
||||||
|
super(LocalGcodeStreamjob, self).process_job_cancelled(user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def can_process(self, protocol):
|
||||||
|
from octoprint.comm.protocol import FileStreamingProtocolMixin
|
||||||
|
return LocalGcodeStreamjob in protocol.supported_jobs and isinstance(protocol, FileStreamingProtocolMixin) and isinstance(protocol, FileManagementProtocolMixin)
|
||||||
|
|
||||||
|
def report_stats(self):
|
||||||
|
elapsed = self.elapsed
|
||||||
|
lines = self._read_lines
|
||||||
|
|
||||||
|
if elapsed and lines:
|
||||||
|
self._logger.info("Job processed in {:.3f}s ({} lines). Approx. {:.3f} lines/s, {:.3f} ms/line".format(elapsed,
|
||||||
|
lines,
|
||||||
|
float(lines) / float(elapsed),
|
||||||
|
float(elapsed) * 1000.0 / float(lines)))
|
||||||
|
|
||||||
|
|
||||||
|
class SDFilePrintjob(StoragePrintjob, FileAwareProtocolListener):
|
||||||
|
|
||||||
|
parallel = True
|
||||||
|
|
||||||
|
def __init__(self, path, status_interval=2.0, *args, **kwargs):
|
||||||
|
name = path
|
||||||
|
if name.startswith("/"):
|
||||||
|
name = name[1:]
|
||||||
|
|
||||||
|
StoragePrintjob.__init__(self,
|
||||||
|
"sdcard",
|
||||||
|
name,
|
||||||
|
name=name,
|
||||||
|
event_data=dict(name=name,
|
||||||
|
path=path,
|
||||||
|
origin="sdcard"))
|
||||||
|
self._filename = path
|
||||||
|
self._status_interval = status_interval
|
||||||
|
|
||||||
|
self._status_timer = None
|
||||||
|
self._active = False
|
||||||
|
|
||||||
|
self._size = None
|
||||||
|
self._last_pos = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pos(self):
|
||||||
|
return self._last_pos
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active(self):
|
||||||
|
return self._start is not None and self._active
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status_interval(self):
|
||||||
|
return self._status_interval
|
||||||
|
|
||||||
|
def can_process(self, protocol):
|
||||||
|
from octoprint.comm.protocol import FileAwareProtocolMixin
|
||||||
|
return SDFilePrintjob in protocol.supported_jobs and isinstance(protocol, FileAwareProtocolMixin)
|
||||||
|
|
||||||
|
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||||
|
Printjob.process(self, protocol, position=position, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
self._protocol.register_listener(self)
|
||||||
|
self._active = True
|
||||||
|
self._last_pos = position
|
||||||
|
|
||||||
|
self._protocol.start_file_print(self._filename,
|
||||||
|
position=position,
|
||||||
|
user=user,
|
||||||
|
tags=tags,
|
||||||
|
part_of_job=True,
|
||||||
|
**kwargs)
|
||||||
|
self._protocol.start_file_print_status_monitor()
|
||||||
|
|
||||||
|
def pause(self, user=None, tags=None, **kwargs):
|
||||||
|
super(SDFilePrintjob, self).pause(user=user, tags=tags, **kwargs)
|
||||||
|
self._protocol.pause_file_print(user=user,
|
||||||
|
tags=tags,
|
||||||
|
part_of_job=True,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
|
def resume(self, user=None, tags=None, **kwargs):
|
||||||
|
super(SDFilePrintjob, self).resume(user=user, tags=tags, **kwargs)
|
||||||
|
self._protocol.resume_file_print(user=user,
|
||||||
|
tags=tags,
|
||||||
|
part_of_job=True,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
|
def on_protocol_sd_status(self, protocol, pos, total):
|
||||||
|
self._last_pos = pos
|
||||||
|
self._size = total
|
||||||
|
self.process_job_progress()
|
||||||
|
|
||||||
|
def on_protocol_file_print_started(self, protocol, name, long_name, size, *args, **kwargs):
|
||||||
|
self._size = size
|
||||||
|
self.process_job_started(**kwargs)
|
||||||
|
|
||||||
|
def on_protocol_file_print_done(self, protocol, *args, **kwargs):
|
||||||
|
self._protocol.stop_file_print_status_monitor(**kwargs)
|
||||||
|
self.process_job_done(**kwargs)
|
||||||
|
|
||||||
|
def on_protocol_file_print_paused(self, protocol, *args, **kwargs):
|
||||||
|
self._protocol.pause_file_print(**kwargs)
|
||||||
|
|
||||||
|
def on_protocol_file_print_resumed(self, protocol, *args, **kwargs):
|
||||||
|
self._protocol.resume_file_print(**kwargs)
|
||||||
|
|
||||||
|
def reset_job(self, success=True):
|
||||||
|
super(SDFilePrintjob, self).reset_job(success=success)
|
||||||
|
self._active = False
|
||||||
|
self._last_pos = None
|
||||||
|
self._size = None
|
||||||
|
|
||||||
|
def event_payload(self, incl_last=False):
|
||||||
|
payload = Printjob.event_payload(self, incl_last=incl_last)
|
||||||
|
payload["size"] = self.size
|
||||||
|
return payload
|
||||||
|
|
||||||
|
|
||||||
|
class PrintjobListener(object):
|
||||||
|
|
||||||
|
def on_job_started(self, job, suppress_script=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_done(self, job, suppress_script=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_failed(self, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_cancelling(self, job, firmware_error=None, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_cancelled(self, job, cancel_position=None, suppress_script=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_paused(self, job, pause_position=None, suppress_script=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_resumed(self, job, suppress_script=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_progress(self, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,542 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.transport import TransportListener, TransportState
|
||||||
|
from octoprint.plugin import plugin_manager
|
||||||
|
from octoprint.util import to_unicode, CountedEvent
|
||||||
|
from octoprint.util.listener import ListenerAware
|
||||||
|
from octoprint.settings import SubSettings
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
import copy
|
||||||
|
import logging
|
||||||
|
|
||||||
|
_registry = dict()
|
||||||
|
|
||||||
|
def register_protocols():
|
||||||
|
from .reprap import ReprapGcodeProtocol
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# stock protocols
|
||||||
|
register_protocol(ReprapGcodeProtocol)
|
||||||
|
|
||||||
|
# more protocols provided by plugins
|
||||||
|
hooks = plugin_manager().get_hooks("octoprint.comm.protocol.register")
|
||||||
|
for name, hook in hooks.items():
|
||||||
|
try:
|
||||||
|
protocols = hook()
|
||||||
|
for protocol in protocols:
|
||||||
|
try:
|
||||||
|
register_protocol(protocol)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error while registering protocol class {} for plugin {}".format(protocol, name))
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error executing octoprint.comm.protocol.register hook for plugin {}".format(name))
|
||||||
|
|
||||||
|
|
||||||
|
def register_protocol(protocol_class):
|
||||||
|
if not hasattr(protocol_class, "key"):
|
||||||
|
raise ValueError("Protocol class {} is missing key".format(protocol_class))
|
||||||
|
_registry[protocol_class.key] = protocol_class
|
||||||
|
|
||||||
|
|
||||||
|
def lookup_protocol(key):
|
||||||
|
return _registry.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
def all_protocols():
|
||||||
|
return _registry.values()
|
||||||
|
|
||||||
|
|
||||||
|
class Protocol(ListenerAware, TransportListener):
|
||||||
|
|
||||||
|
name = None
|
||||||
|
key = None
|
||||||
|
|
||||||
|
supported_jobs = []
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_connection_options(cls):
|
||||||
|
return []
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_settings_defaults(cls):
|
||||||
|
return dict()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(Protocol, self).__init__()
|
||||||
|
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._protocol_logger = logging.getLogger("PROTOCOL")
|
||||||
|
self._state = ProtocolState.DISCONNECTED
|
||||||
|
self._error = None
|
||||||
|
|
||||||
|
self._printer_profile = kwargs.get("printer_profile")
|
||||||
|
self._plugin_manager = kwargs.get("plugin_manager")
|
||||||
|
self._event_bus = kwargs.get("event_bus")
|
||||||
|
self._settings = kwargs.get("settings")
|
||||||
|
if not isinstance(self._settings, ProtocolSettings):
|
||||||
|
self._settings = ProtocolSettings(self._settings, self)
|
||||||
|
|
||||||
|
self._job = None
|
||||||
|
self._transport = None
|
||||||
|
|
||||||
|
self._job_on_hold = CountedEvent()
|
||||||
|
|
||||||
|
self._args = dict()
|
||||||
|
|
||||||
|
def args(self):
|
||||||
|
return copy.deepcopy(self._args)
|
||||||
|
|
||||||
|
def set_current_args(self, **value):
|
||||||
|
self._args = copy.deepcopy(value)
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def job_put_on_hold(self, blocking=True):
|
||||||
|
if not self._job_on_hold.acquire(blocking=blocking):
|
||||||
|
raise RuntimeError("Could not acquire job_on_hold lock")
|
||||||
|
|
||||||
|
self._job_on_hold.set()
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
self._job_on_hold.clear()
|
||||||
|
if self._job_on_hold.counter == 0:
|
||||||
|
self._job_on_hold_cleared()
|
||||||
|
self._job_on_hold.release()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def job_on_hold(self):
|
||||||
|
return self._job_on_hold.counter > 0
|
||||||
|
|
||||||
|
def set_job_on_hold(self, value, blocking=True):
|
||||||
|
if not self._job_on_hold.acquire(blocking=blocking):
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
if value:
|
||||||
|
self._job_on_hold.set()
|
||||||
|
else:
|
||||||
|
self._job_on_hold.clear()
|
||||||
|
if self._job_on_hold.counter == 0:
|
||||||
|
self._job_on_hold_cleared()
|
||||||
|
finally:
|
||||||
|
self._job_on_hold.release()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def transport(self):
|
||||||
|
return self._transport
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@state.setter
|
||||||
|
def state(self, new_state):
|
||||||
|
old_state = self._state
|
||||||
|
if old_state == new_state:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._state = new_state
|
||||||
|
|
||||||
|
name = "_on_switching_state_{}".format(new_state)
|
||||||
|
method = getattr(self, name, None)
|
||||||
|
if method is not None:
|
||||||
|
method(old_state)
|
||||||
|
|
||||||
|
self.process_protocol_log("--- Protocol state changed from '{}' to '{}'".format(old_state, new_state))
|
||||||
|
self.notify_listeners("on_protocol_state", self, old_state, new_state)
|
||||||
|
|
||||||
|
name = "_on_switched_state_{}".format(new_state)
|
||||||
|
method = getattr(self, name, None)
|
||||||
|
if method is not None:
|
||||||
|
method(old_state)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def error(self):
|
||||||
|
return self._error
|
||||||
|
|
||||||
|
@error.setter
|
||||||
|
def error(self, new_error):
|
||||||
|
self._error = new_error
|
||||||
|
|
||||||
|
def connect(self, transport, transport_args=None, transport_kwargs=None):
|
||||||
|
if self.state not in (ProtocolState.DISCONNECTED, ProtocolState.DISCONNECTED_WITH_ERROR):
|
||||||
|
raise ProtocolAlreadyConnectedError("Already connected, disconnect first")
|
||||||
|
|
||||||
|
self.process_protocol_log("--- Protocol {} connecting via transport {}...".format(self,
|
||||||
|
transport))
|
||||||
|
|
||||||
|
if transport_args is None:
|
||||||
|
transport_args = []
|
||||||
|
if transport_kwargs is None:
|
||||||
|
transport_kwargs = dict()
|
||||||
|
|
||||||
|
self._transport = transport
|
||||||
|
self._transport.register_listener(self)
|
||||||
|
|
||||||
|
if self._transport.state == TransportState.DISCONNECTED:
|
||||||
|
self._transport.connect(*transport_args, **transport_kwargs)
|
||||||
|
self.state = ProtocolState.CONNECTING
|
||||||
|
|
||||||
|
def disconnect(self, error=False):
|
||||||
|
if self.state in (ProtocolState.DISCONNECTED, ProtocolState.DISCONNECTED_WITH_ERROR, ProtocolState.DISCONNECTING, ProtocolState.DISCONNECTING_WITH_ERROR):
|
||||||
|
raise ProtocolNotConnectedError("Already disconnecting or disconnected")
|
||||||
|
|
||||||
|
if error:
|
||||||
|
self.state = ProtocolState.DISCONNECTING_WITH_ERROR
|
||||||
|
else:
|
||||||
|
self.state = ProtocolState.DISCONNECTING
|
||||||
|
|
||||||
|
self.process_protocol_log("--- Protocol {} disconnecting from transport {}...".format(self,
|
||||||
|
self._transport))
|
||||||
|
|
||||||
|
self._transport.unregister_listener(self)
|
||||||
|
if self._transport.state == TransportState.CONNECTED:
|
||||||
|
try:
|
||||||
|
self._transport.disconnect()
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error while disconnecting from transport {}".format(self._transport))
|
||||||
|
error = True
|
||||||
|
|
||||||
|
if error:
|
||||||
|
self.state = ProtocolState.DISCONNECTED_WITH_ERROR
|
||||||
|
else:
|
||||||
|
self.state = ProtocolState.DISCONNECTED
|
||||||
|
|
||||||
|
def process(self, job, position=0, user=None, tags=None, **kwargs):
|
||||||
|
if not job.can_process(self):
|
||||||
|
raise ValueError("Job {} cannot be processed with protocol {}".format(job, self))
|
||||||
|
|
||||||
|
self._job = job
|
||||||
|
self._job.register_listener(self)
|
||||||
|
|
||||||
|
self.state = ProtocolState.STARTING
|
||||||
|
self.notify_listeners("on_protocol_job_starting", self, self._job, user=user, tags=tags, **kwargs)
|
||||||
|
self._job.process(self, position=position, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def pause_processing(self, user=None, tags=None, **kwargs):
|
||||||
|
if self._job is None or self.state not in ProtocolState.PROCESSING_STATES:
|
||||||
|
return
|
||||||
|
self.state = ProtocolState.PAUSING
|
||||||
|
self.notify_listeners("on_protocol_job_pausing", self, self._job, user=user, tags=tags, **kwargs)
|
||||||
|
self._job.pause(user=user, tags=tags)
|
||||||
|
|
||||||
|
def resume_processing(self, user=None, tags=None, **kwargs):
|
||||||
|
if self._job is None or self.state not in (ProtocolState.PAUSING, ProtocolState.PAUSED):
|
||||||
|
return
|
||||||
|
self.state = ProtocolState.RESUMING
|
||||||
|
self.notify_listeners("on_protocol_job_resuming", self, self._job, user=user, tags=tags, **kwargs)
|
||||||
|
self._job.resume(user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def cancel_processing(self, error=False, user=None, tags=None, **kwargs):
|
||||||
|
if self._job is not None and self.state in ProtocolState.PROCESSING_STATES + (ProtocolState.PAUSED,):
|
||||||
|
self.state = ProtocolState.CANCELLING
|
||||||
|
self.notify_listeners("on_protocol_job_cancelling", self, self._job, user=user, tags=tags, **kwargs)
|
||||||
|
self._job.cancel(error=error, user=user, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def can_send(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def send_commands(self, command_type=None, tags=None, *commands):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def send_script(self, script, context=None, user=None, tags=None):
|
||||||
|
"""
|
||||||
|
Sends the specified script/the GCODE script with the specified name.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
script (GcodeScript or unicode): Script or name of the script to send
|
||||||
|
context (dict): Additional render context
|
||||||
|
user (str): The user on whose behalf the script is being sent. May be None
|
||||||
|
tags (set): And tags to send with the script commands. May be None
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def repair(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_job_started(self, job, *args, **kwargs):
|
||||||
|
self.notify_listeners("on_protocol_job_started", self, job, *args, **kwargs)
|
||||||
|
self.state = ProtocolState.PROCESSING
|
||||||
|
|
||||||
|
def on_job_paused(self, job, *args, **kwargs):
|
||||||
|
self.notify_listeners("on_protocol_job_paused", self, job, *args, **kwargs)
|
||||||
|
self.state = ProtocolState.PAUSED
|
||||||
|
|
||||||
|
def on_job_resumed(self, job, *args, **kwargs):
|
||||||
|
self.notify_listeners("on_protocol_job_resumed", self, job, *args, **kwargs)
|
||||||
|
self.state = ProtocolState.PROCESSING
|
||||||
|
|
||||||
|
def on_job_done(self, job, *args, **kwargs):
|
||||||
|
self.notify_listeners("on_protocol_job_done", self, job, *args, **kwargs)
|
||||||
|
self._job_processed(job)
|
||||||
|
|
||||||
|
def on_job_cancelled(self, job, *args, **kwargs):
|
||||||
|
self.notify_listeners("on_protocol_job_cancelled", self, job, *args, **kwargs)
|
||||||
|
self._job_processed(job)
|
||||||
|
|
||||||
|
def on_job_failed(self, job, *args, **kwargs):
|
||||||
|
self.notify_listeners("on_protocol_job_failed", self, job, *args, **kwargs)
|
||||||
|
self._job_processed(job)
|
||||||
|
|
||||||
|
def _job_processed(self, job, *args, **kwargs):
|
||||||
|
self._job.unregister_listener(self)
|
||||||
|
self.state = ProtocolState.CONNECTED
|
||||||
|
|
||||||
|
def on_transport_disconnected(self, transport, error=None):
|
||||||
|
self.disconnect(error=error is not None)
|
||||||
|
|
||||||
|
def on_transport_log_received_data(self, transport, data):
|
||||||
|
message = "<<< {}".format(to_unicode(data, errors="replace").strip())
|
||||||
|
self.process_protocol_log(message)
|
||||||
|
|
||||||
|
def on_transport_log_sent_data(self, transport, data):
|
||||||
|
message = ">>> {}".format(to_unicode(data, errors="replace").strip())
|
||||||
|
self.process_protocol_log(message)
|
||||||
|
|
||||||
|
def on_transport_log_message(self, transport, data):
|
||||||
|
message = "--- {}".format(to_unicode(data, errors="replace").strip())
|
||||||
|
self.process_protocol_log(message)
|
||||||
|
|
||||||
|
def process_protocol_log(self, message):
|
||||||
|
self._protocol_logger.info(message)
|
||||||
|
self.notify_listeners("on_protocol_log", self, message)
|
||||||
|
|
||||||
|
def _job_on_hold_cleared(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.__class__.__name__
|
||||||
|
|
||||||
|
class ProtocolState(object):
|
||||||
|
CONNECTING = "connecting"
|
||||||
|
CONNECTED = "connected"
|
||||||
|
DISCONNECTING = "disconnecting"
|
||||||
|
DISCONNECTED = "disconnected"
|
||||||
|
STARTING = "starting"
|
||||||
|
PROCESSING = "processing"
|
||||||
|
FINISHING = "finishing"
|
||||||
|
CANCELLING = "cancelling"
|
||||||
|
PAUSING = "pausing"
|
||||||
|
RESUMING = "resuming"
|
||||||
|
PAUSED = "paused"
|
||||||
|
ERROR = "error"
|
||||||
|
DISCONNECTING_WITH_ERROR = "disconnecting_with_error"
|
||||||
|
DISCONNECTED_WITH_ERROR = "disconnected_with_error"
|
||||||
|
|
||||||
|
PROCESSING_STATES = (STARTING, PROCESSING, CANCELLING, PAUSING, RESUMING, FINISHING)
|
||||||
|
OPERATIONAL_STATES = (CONNECTED, PAUSED) + PROCESSING_STATES
|
||||||
|
|
||||||
|
class ProtocolSettings(SubSettings):
|
||||||
|
def __init__(self, settings, protocol):
|
||||||
|
SubSettings.__init__(self, settings, ["comm", "protocol", protocol.key],
|
||||||
|
defaults=protocol.get_settings_defaults())
|
||||||
|
|
||||||
|
class ProtocolAlreadyConnectedError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ProtocolNotConnectedError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ThreeAxisProtocolMixin(object):
|
||||||
|
def move(self, x=None, y=None, z=None, feedrate=None, relative=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def home(self, x=False, y=False, z=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MultiToolProtocolMixin(object):
|
||||||
|
def change_tool(self, tool, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ThreeDPrinterProtocolMixin(ThreeAxisProtocolMixin, MultiToolProtocolMixin):
|
||||||
|
def move(self, x=None, y=None, z=None, e=None, feedrate=None, relative=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_feedrate_multiplier(self, multiplier, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_extrusion_multiplier(self, multiplier, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_extruder_temperature(self, temperature, tool=None, wait=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_bed_temperature(self, temperature, wait=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_chamber_temperature(self, temperature, wait=False, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FanControlProtocolMixin(object):
|
||||||
|
def set_fan_speed(self, speed, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_fan_speed(self, speed, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MotorControlProtocolMixin(object):
|
||||||
|
def enable_motors(self, *args, **kwargs):
|
||||||
|
self.set_motor_state(True)
|
||||||
|
|
||||||
|
def disable_motors(self, *args, **kwargs):
|
||||||
|
self.set_motor_state(False)
|
||||||
|
|
||||||
|
def set_motor_state(self, enabled, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_motor_state(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PowerControlProtocolMixin(object):
|
||||||
|
def enable_power(self, *args, **kwargs):
|
||||||
|
self.set_power_state(True)
|
||||||
|
|
||||||
|
def disable_power(self, *args, **kwargs):
|
||||||
|
self.set_power_state(False)
|
||||||
|
|
||||||
|
def set_power_state(self, enabled, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_power_state(self, *args, **kwargs):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class FileAwareProtocolMixin(object):
|
||||||
|
def init_file_storage(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def eject_file_storage(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def list_files(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def start_file_print(self, name, position=0, tags=None, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def pause_file_print(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def resume_file_print(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_file_print_status(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def start_file_print_status_monitor(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def stop_file_print_status_monitor(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileManagementProtocolMixin(FileAwareProtocolMixin):
|
||||||
|
def delete_file(self, name, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileStreamingProtocolMixin(FileManagementProtocolMixin):
|
||||||
|
def record_file(self, name, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def stop_recording_file(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ProtocolListener(object):
|
||||||
|
def on_protocol_state(self, protocol, old_state, new_state, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_temperature(self, protocol, temperatures, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_log(self, protocol, message, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_reset(self, protocol, idle, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_started(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_pausing(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_paused(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_resuming(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_resumed(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_cancelling(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_cancelled(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_finishing(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_done(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_job_failed(self, protocol, job, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FileAwareProtocolListener(object):
|
||||||
|
def on_protocol_file_storage_available(self, protocol, available, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_file_list(self, protocol, files, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_file_status(self, protocol, pos, total, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_file_print_started(self, protocol, name, long_name, size, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_file_print_done(self, protocol, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_file_print_paused(self, protocol, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_file_print_resumed(self, protocol, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PositionAwareProtocolListener(object):
|
||||||
|
|
||||||
|
def on_protocol_position_all_update(self, protocol, position, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_position_z_update(self, protocol, z, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FirmwareDataAwareProtocolListener(object):
|
||||||
|
|
||||||
|
def on_protocol_firmware_info(self, protocol, info, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_protocol_firmware_capability(self, protocol, capability, enabled, capabilities, *args, **kwargs):
|
||||||
|
pass
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,93 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
import copy
|
||||||
|
import re
|
||||||
|
|
||||||
|
from future.utils import with_metaclass
|
||||||
|
|
||||||
|
from octoprint.util import pp
|
||||||
|
|
||||||
|
|
||||||
|
_compiled_regex_type = type(re.compile(r"a"))
|
||||||
|
def _is_compiled_regex(obj):
|
||||||
|
return isinstance(obj, _compiled_regex_type)
|
||||||
|
|
||||||
|
|
||||||
|
__registry = dict()
|
||||||
|
|
||||||
|
def _register_command_class(cls):
|
||||||
|
__registry[cls.__name__] = cls
|
||||||
|
|
||||||
|
|
||||||
|
def to_command(line, type=None, tags=None, **kwargs):
|
||||||
|
if isinstance(line, Command):
|
||||||
|
return line
|
||||||
|
|
||||||
|
for cls in __registry.values():
|
||||||
|
if cls.pattern:
|
||||||
|
# noinspection PyUnresolvedReferences,PyProtectedMember
|
||||||
|
if _is_compiled_regex(cls.pattern) and cls.pattern.match(line):
|
||||||
|
return cls.from_line(line, type=type, tags=tags, **kwargs)
|
||||||
|
elif callable(cls.pattern) and cls.pattern(line):
|
||||||
|
return cls.from_line(line, type=type, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
return Command.from_line(line, type=type, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class CommandMetaClass(type):
|
||||||
|
def __new__(mcs, *args, **kwargs):
|
||||||
|
c = type.__new__(mcs, *args, **kwargs)
|
||||||
|
_register_command_class(c)
|
||||||
|
return c
|
||||||
|
|
||||||
|
class Command(with_metaclass(CommandMetaClass, object)):
|
||||||
|
|
||||||
|
pattern = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_line(cls, line, type=None, tags=None, **kwargs):
|
||||||
|
return cls(line, type=type, tags=tags, **kwargs)
|
||||||
|
|
||||||
|
def __init__(self, line, type=None, tags=None, **kwargs):
|
||||||
|
if tags is None:
|
||||||
|
tags = set()
|
||||||
|
|
||||||
|
self.line = line
|
||||||
|
self.bytes = line.encode("ascii", errors="replace")
|
||||||
|
self.type = type
|
||||||
|
self.tags = tags
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "{}({!r},type={!r},tags={})".format(self.__class__.__name__, self.line, self.type, pp(self.tags))
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.line
|
||||||
|
|
||||||
|
def __bytes__(self):
|
||||||
|
return self.bytes
|
||||||
|
|
||||||
|
def __key(self):
|
||||||
|
return self.line, self.type
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.__key() == other.__key()
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(self.__key())
|
||||||
|
|
||||||
|
def with_type(self, type):
|
||||||
|
c = copy.deepcopy(self)
|
||||||
|
c.type = type
|
||||||
|
return c
|
||||||
|
|
||||||
|
def with_tags(self, tags):
|
||||||
|
if tags is None:
|
||||||
|
return self
|
||||||
|
|
||||||
|
c = copy.deepcopy(self)
|
||||||
|
c.tags |= tags
|
||||||
|
return c
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.commands import Command
|
||||||
|
|
||||||
|
from octoprint.util import pp
|
||||||
|
|
||||||
|
class AtCommand(Command):
|
||||||
|
|
||||||
|
pattern = staticmethod(lambda x: x.startswith("@"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_line(line, **kwargs):
|
||||||
|
split = line.split(None, 1)
|
||||||
|
if len(split) == 2:
|
||||||
|
atcommand = split[0]
|
||||||
|
parameters = split[1]
|
||||||
|
else:
|
||||||
|
atcommand = split[0]
|
||||||
|
parameters = ""
|
||||||
|
|
||||||
|
atcommand = atcommand[1:]
|
||||||
|
|
||||||
|
return AtCommand(line, atcommand, parameters, **kwargs)
|
||||||
|
|
||||||
|
def __init__(self, line, atcommand, parameters, **kwargs):
|
||||||
|
self.atcommand = atcommand
|
||||||
|
self.parameters = parameters
|
||||||
|
super(AtCommand, self).__init__(line, **kwargs)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "AtCommand({!r},{!r},{!r},type={!r},tags={}".format(self.line,
|
||||||
|
self.atcommand,
|
||||||
|
self.parameters,
|
||||||
|
self.type,
|
||||||
|
pp(self.tags))
|
||||||
|
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.commands import Command
|
||||||
|
|
||||||
|
import re
|
||||||
|
import string
|
||||||
|
|
||||||
|
from octoprint.util import pp
|
||||||
|
|
||||||
|
class GcodeCommand(Command):
|
||||||
|
|
||||||
|
pattern = staticmethod(lambda x: GcodeCommand.command_regex.match(x))
|
||||||
|
|
||||||
|
command_regex = re.compile(r"^\s*((?P<GM>[GM](?P<number>\d+))(\\.(?P<subcode>\d+))?|(?P<T>T(?P<tool>\d+))|(?P<F>F(?P<feedrate>\d+)))")
|
||||||
|
parameter_regex = re.compile(r"(?P<key>[A-Z])((?P<value>[-+]?[0-9]*\.?[0-9]+)(?!\d)|(\s|$))")
|
||||||
|
|
||||||
|
possible_params = tuple(string.ascii_lowercase) + ("subcode", "param", "tool", "feedrate", "original")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def from_line(line, **kwargs):
|
||||||
|
if isinstance(line, GcodeCommand):
|
||||||
|
return line
|
||||||
|
|
||||||
|
tags = kwargs.get("tags")
|
||||||
|
if tags is None:
|
||||||
|
tags = set()
|
||||||
|
|
||||||
|
command_type = kwargs.get("type")
|
||||||
|
|
||||||
|
line = line.strip()
|
||||||
|
code = ""
|
||||||
|
|
||||||
|
args = dict(original=line, type=command_type, tags=tags)
|
||||||
|
|
||||||
|
match = GcodeCommand.command_regex.match(line)
|
||||||
|
|
||||||
|
if match is None:
|
||||||
|
# not a gcode command
|
||||||
|
return Command.from_line(line, **kwargs)
|
||||||
|
|
||||||
|
if match.group("GM"):
|
||||||
|
code = match.group("GM")
|
||||||
|
|
||||||
|
if match.group("subcode"):
|
||||||
|
args["subcode"] = int(match.group("subcode"))
|
||||||
|
|
||||||
|
if match.group(0) != line:
|
||||||
|
rest = line[len(match.group(0)):]
|
||||||
|
|
||||||
|
while True:
|
||||||
|
matched_param = GcodeCommand.parameter_regex.search(rest)
|
||||||
|
if not matched_param:
|
||||||
|
break
|
||||||
|
|
||||||
|
key = matched_param.group("key").lower()
|
||||||
|
if matched_param.group("value"):
|
||||||
|
value = matched_param.group("value")
|
||||||
|
if "." in value:
|
||||||
|
value = float(value)
|
||||||
|
else:
|
||||||
|
value = int(value)
|
||||||
|
else:
|
||||||
|
value = True
|
||||||
|
args[key] = value
|
||||||
|
rest = rest[:matched_param.start()] + rest[matched_param.end():]
|
||||||
|
|
||||||
|
rest = rest.lstrip()
|
||||||
|
if rest:
|
||||||
|
args["param"] = rest
|
||||||
|
|
||||||
|
elif match.group("T"):
|
||||||
|
code = "T"
|
||||||
|
args["tool"] = int(match.group("tool"))
|
||||||
|
|
||||||
|
elif match.group("F"):
|
||||||
|
code = "F"
|
||||||
|
args["feedrate"] = int(match.group("feedrate"))
|
||||||
|
|
||||||
|
return GcodeCommand(code, **args)
|
||||||
|
|
||||||
|
def __init__(self, code, **kwargs):
|
||||||
|
self.code = code
|
||||||
|
|
||||||
|
self.subcode = kwargs.pop("subcode", None)
|
||||||
|
self.tool = kwargs.pop("tool", None)
|
||||||
|
self.feedrate = kwargs.pop("feedrate", None)
|
||||||
|
self.param = kwargs.pop("param", None)
|
||||||
|
self.original = kwargs.pop("original", None)
|
||||||
|
|
||||||
|
command_type = kwargs.pop("type", None)
|
||||||
|
tags = kwargs.pop("tags", None)
|
||||||
|
|
||||||
|
self.args = kwargs
|
||||||
|
|
||||||
|
if self.original is None:
|
||||||
|
line = self._to_line()
|
||||||
|
else:
|
||||||
|
line = self.original
|
||||||
|
|
||||||
|
super(GcodeCommand, self).__init__(line, type=command_type, tags=tags)
|
||||||
|
|
||||||
|
self._repr = self._to_repr()
|
||||||
|
|
||||||
|
def __getattr__(self, item):
|
||||||
|
if len(item) == 1:
|
||||||
|
return self.args.get(item, None)
|
||||||
|
raise AttributeError("'GcodeCommand' object has no attribute '{}'".format(item))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self._repr
|
||||||
|
|
||||||
|
def _to_line(self):
|
||||||
|
attr = []
|
||||||
|
for key in string.ascii_lowercase:
|
||||||
|
value = self.args.get(key, None)
|
||||||
|
if value is not None:
|
||||||
|
if value is True:
|
||||||
|
attr.append(key.upper())
|
||||||
|
else:
|
||||||
|
attr.append("{}{!r}".format(key.upper(), value))
|
||||||
|
attribute_str = " ".join(attr)
|
||||||
|
return "{}{}{}".format(self.code.upper(), " " + attribute_str if attribute_str else "",
|
||||||
|
" " + self.param if self.param else "")
|
||||||
|
|
||||||
|
def _to_repr(self):
|
||||||
|
args = [k + "=" + repr(getattr(self, k)) for k in self.possible_params if getattr(self, k, None) is not None]
|
||||||
|
return "GcodeCommand({!r}{},type={!r},tags={})".format(self.code,
|
||||||
|
"," + ",".join(args) if args else "",
|
||||||
|
self.type,
|
||||||
|
pp(self.tags))
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from .generic import * # noqa: F403
|
||||||
|
from .klipper import * # noqa: F403
|
||||||
|
from .marlin import * # noqa: F403
|
||||||
|
from .repetier import * # noqa: F403
|
||||||
|
from .reprapfirmware import * # noqa: F403
|
||||||
|
from .smoothieware import * # noqa: F403
|
||||||
|
|
||||||
|
from .anet import * # noqa: F403
|
||||||
|
from .malyan import * # noqa: F403
|
||||||
|
|
||||||
|
|
||||||
|
class FlavorOverride(object):
|
||||||
|
|
||||||
|
def __init__(self, flavor, overrides):
|
||||||
|
self._flavor = flavor
|
||||||
|
self._overrides = overrides
|
||||||
|
|
||||||
|
@property
|
||||||
|
def flavor(self):
|
||||||
|
return self._flavor
|
||||||
|
|
||||||
|
@flavor.setter
|
||||||
|
def flavor(self, value):
|
||||||
|
self._flavor = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def overrides(self):
|
||||||
|
return self._overrides
|
||||||
|
|
||||||
|
@overrides.setter
|
||||||
|
def overrides(self, value):
|
||||||
|
self._overrides = value
|
||||||
|
|
||||||
|
def __getattr__(self, item):
|
||||||
|
try:
|
||||||
|
return self._overrides[item]
|
||||||
|
except KeyError:
|
||||||
|
return getattr(self._flavor, item)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from .repetier import RepetierFlavor
|
||||||
|
|
||||||
|
class AnetA8RepetierFlavor(RepetierFlavor):
|
||||||
|
|
||||||
|
key = "aneta8repetier"
|
||||||
|
name = "Anet A8"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "anet_a8" in firmware_name.lower()
|
||||||
|
|
||||||
@@ -0,0 +1,706 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
import re
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.commands.gcode import GcodeCommand
|
||||||
|
from octoprint.comm.protocol.reprap.util import regex_float_pattern, regex_positive_float_pattern, regex_int_pattern
|
||||||
|
|
||||||
|
from octoprint.util import chunks, monotonic_time
|
||||||
|
|
||||||
|
from future.utils import with_metaclass
|
||||||
|
|
||||||
|
_flavor_registry = dict()
|
||||||
|
|
||||||
|
|
||||||
|
def _register_flavor(cls):
|
||||||
|
key = getattr(cls, "key", None)
|
||||||
|
if key and not key in _flavor_registry:
|
||||||
|
_flavor_registry[key] = cls
|
||||||
|
|
||||||
|
|
||||||
|
def all_flavors():
|
||||||
|
return _flavor_registry.values()
|
||||||
|
|
||||||
|
|
||||||
|
def lookup_flavor(key):
|
||||||
|
return _flavor_registry.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
class FlavorMeta(type):
|
||||||
|
def __new__(mcs, name, bases, class_dict):
|
||||||
|
cls = type.__new__(mcs, name, bases, class_dict)
|
||||||
|
_register_flavor(cls)
|
||||||
|
return cls
|
||||||
|
|
||||||
|
|
||||||
|
class GenericFlavor(with_metaclass(FlavorMeta, object)):
|
||||||
|
|
||||||
|
key = "generic"
|
||||||
|
name = "Generic Flavor"
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
unknown_requires_ack = False
|
||||||
|
unknown_with_checksum = False
|
||||||
|
|
||||||
|
always_send_checksum = False
|
||||||
|
never_send_checksum = False
|
||||||
|
|
||||||
|
detect_external_heatups = True
|
||||||
|
block_while_dwelling = False
|
||||||
|
|
||||||
|
trigger_ok_after_resend = "detect"
|
||||||
|
|
||||||
|
sd_relative_path = False
|
||||||
|
|
||||||
|
checksum_requiring_commands = ["M110"]
|
||||||
|
long_running_commands = ["G4", "G28", "G29", "G30", "G32", "M190", "M109", "M400", "M226"]
|
||||||
|
asynchronous_commands = ["G0", "G1", "G2", "G3"]
|
||||||
|
blocked_commands = ["M0", "M1"]
|
||||||
|
pausing_commands = ["M0", "M1", "M25"]
|
||||||
|
emergency_commands = ["M112", "M108", "M410"]
|
||||||
|
|
||||||
|
heatup_abortable = False
|
||||||
|
|
||||||
|
regex_resend_linenumber = re.compile(r"(N|N:)?(?P<n>%s)" % regex_int_pattern)
|
||||||
|
"""Regex to use for request line numbers in resend requests"""
|
||||||
|
|
||||||
|
regex_temp = re.compile(r"(?P<tool>B|T(?P<toolnum>\d*)):\s*(?P<actual>%s)(\s*/?\s*(?P<target>%s))?" % (
|
||||||
|
regex_positive_float_pattern, regex_positive_float_pattern))
|
||||||
|
"""Regex matching temperature entries in line.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``tool``: whole tool designator, incl. optional ``toolnum`` (str)
|
||||||
|
* ``toolnum``: tool number, if provided (int)
|
||||||
|
* ``actual``: actual temperature (float)
|
||||||
|
* ``target``: target temperature, if provided (float)
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_position = re.compile(r"(?P<axis>[XYZE]):(?P<pos>{float})\s*".format(float=regex_float_pattern))
|
||||||
|
"""Regex for matching position entries in line.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``axis``: axis designator, either ``X``, ``Y``, ``Z`` or ``E`` (str)
|
||||||
|
* ``pos``: axis position (float)
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_firmware_splitter = re.compile(r"\s*([A-Z0-9_]+):")
|
||||||
|
"""Regex to use for splitting M115 responses."""
|
||||||
|
|
||||||
|
regex_sd_file_opened = re.compile(r"file opened:\s*(?P<name>.*?)(\s+size:\s*(?P<size>[0-9]+)|$)")
|
||||||
|
|
||||||
|
regex_sd_printing_byte = re.compile(r"sd printing byte (?P<current>[0-9]*)/(?P<total>[0-9]*)")
|
||||||
|
"""Regex matching SD printing status reports.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``current``: current byte position in file being printed
|
||||||
|
* ``total``: total size of file being printed
|
||||||
|
"""
|
||||||
|
|
||||||
|
##~~ Overrides
|
||||||
|
|
||||||
|
_overrides = dict()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def with_overrides(cls, overrides):
|
||||||
|
return type(b"{}WithOverrides".format(cls.__name__), (cls,), overrides)
|
||||||
|
|
||||||
|
##~~ Identifier
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return False
|
||||||
|
|
||||||
|
##~~ Message matchers
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_timeout(cls, line, lower_line, state, flags):
|
||||||
|
now = monotonic_time()
|
||||||
|
matches = ((line == "" and now > flags["timeout"]) or (flags["expect_continous_comms"]
|
||||||
|
and not flags["job_on_hold"]
|
||||||
|
and not flags["long_running_command"]
|
||||||
|
and not flags["heating"]
|
||||||
|
and now > flags["ok_timeout"])) and \
|
||||||
|
(not cls.block_while_dwelling or not flags["dwelling_until"] or now > flags["dwelling_until"])
|
||||||
|
continue_further = line != ""
|
||||||
|
return matches, continue_further
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_ok(cls, line, lower_line, state, flags):
|
||||||
|
matches = lower_line.startswith("ok")
|
||||||
|
continue_further = not matches \
|
||||||
|
or cls.message_temperature(line, lower_line, state, flags) \
|
||||||
|
or cls.message_position(line, lower_line, state, flags) \
|
||||||
|
or cls.message_firmware_info(line, lower_line, state, flags)
|
||||||
|
return matches, continue_further
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_start(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line == "start"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_wait(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line == "wait"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_resend(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line.startswith("resend") or lower_line.startswith("rs")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_action_command(cls, line, lower_line, state, flags):
|
||||||
|
return line.startswith("//") and line[2:].strip().startswith("action:")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_error(cls, line, lower_line, state, flags):
|
||||||
|
return line.startswith("Error:") or line.startswith("!!")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_ignore_ok(cls, line, lower_line, state, flags):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def comm_busy(cls, line, lower_line, state, flags):
|
||||||
|
return line.startswith("echo:busy:") or line.startswith("busy:")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def error_multiline(cls, line, lower_line, state, flags):
|
||||||
|
return False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def error_communication(cls, line, lower_line, state, flags):
|
||||||
|
return "line number" in lower_line or "checksum" in lower_line or "format error" in lower_line or "expected line" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_temperature(cls, line, lower_line, state, flags):
|
||||||
|
return "T:" in line or "T0:" in line or "B:" in line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_position(cls, line, lower_line, state, flags):
|
||||||
|
return 'X:' in line and 'Y:' in line and 'Z:' in line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_firmware_info(cls, line, lower_line, state, flags):
|
||||||
|
return "NAME:" in line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_firmware_capability(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line.startswith("cap:")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_init_ok(cls, line, lower_line, state, flags):
|
||||||
|
return "sd card ok" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_init_fail(cls, line, lower_line, state, flags):
|
||||||
|
return "sd init fail" in lower_line or "volume.init failed" in lower_line or "openroot failed" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_file_opened(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line.startswith("file opened")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_file_selected(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line.startswith("file selected")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_begin_file_list(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line.startswith("begin file list")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_end_file_list(cls, line, lower_line, state, flags):
|
||||||
|
return lower_line.startswith("end file list")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_printing_byte(cls, line, lower_line, state, flags):
|
||||||
|
return "sd printing byte" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_not_printing(cls, line, lower_line, state, flags):
|
||||||
|
return "not sd printing" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_done_printing(cls, line, lower_line, state, flags):
|
||||||
|
return "done printing file" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_begin_writing(cls, line, lower_line, state, flags):
|
||||||
|
return "writing to file" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_end_writing(cls, line, lower_line, state, flags):
|
||||||
|
return "done saving file" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_sd_entry(cls, line, lower_line, state, flags):
|
||||||
|
return flags["sd_files_temp"] is not None
|
||||||
|
|
||||||
|
##~~ Message parsers
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_comm_error(cls, line, lower_line, state, flags):
|
||||||
|
return dict(line=line, lower_line=lower_line)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_comm_timeout(cls, line, lower_line, state, flags):
|
||||||
|
return dict(line=line, lower_line=lower_line)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_comm_action_command(cls, line, lower_line, state, flags):
|
||||||
|
action = line[2:].strip()[len("action:"):].strip()
|
||||||
|
return dict(line=line, lower_line=lower_line, action=action)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_error_communication(cls, line, lower_line, state, flags):
|
||||||
|
if "line number" in lower_line or "expected line" in lower_line:
|
||||||
|
error_type = "linenumber"
|
||||||
|
elif "checksum" in lower_line:
|
||||||
|
error_type = "checksum"
|
||||||
|
else:
|
||||||
|
error_type = "other"
|
||||||
|
|
||||||
|
flags["last_communication_error"] = error_type
|
||||||
|
return dict(error_type=error_type)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_comm_resend(cls, line, lower_line, state, flags):
|
||||||
|
line_to_resend = None
|
||||||
|
match = cls.regex_resend_linenumber.search(line)
|
||||||
|
if match is not None:
|
||||||
|
line_to_resend = int(match.group("n"))
|
||||||
|
return dict(linenumber=line_to_resend)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_temperature(cls, line, lower_line, state, flags):
|
||||||
|
"""
|
||||||
|
Parses the provided temperature line.
|
||||||
|
|
||||||
|
The result will be a dictionary mapping from the extruder or bed key to
|
||||||
|
a tuple with current and target temperature. The result will be canonicalized
|
||||||
|
with :func:`canonicalize_temperatures` before returning.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: a 2-tuple with the maximum tool number and a dict mapping from
|
||||||
|
key to (actual, target) tuples, with key either matching ``Tn`` for ``n >= 0`` or ``B``
|
||||||
|
"""
|
||||||
|
|
||||||
|
current_tool = flags["current_tool"]
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
max_tool_num = 0
|
||||||
|
for match in re.finditer(cls.regex_temp, line):
|
||||||
|
values = match.groupdict()
|
||||||
|
tool = values["tool"]
|
||||||
|
if tool == "T" and "toolnum" in values and values["toolnum"]:
|
||||||
|
tool_num = int(values["toolnum"])
|
||||||
|
if tool_num > max_tool_num:
|
||||||
|
max_tool_num = tool_num
|
||||||
|
|
||||||
|
try:
|
||||||
|
actual = float(values.get("actual", None)) if values.get("actual", None) is not None else None
|
||||||
|
target = float(values.get("target", None)) if values.get("target", None) is not None else None
|
||||||
|
result[tool] = actual, target
|
||||||
|
except ValueError:
|
||||||
|
# catch conversion issues, we'll rather just not get the temperature update instead of killing the connection
|
||||||
|
pass
|
||||||
|
|
||||||
|
heatup_detected = not lower_line.startswith("ok") and not flags["heating"] and not flags["temperature_autoreporting"]
|
||||||
|
|
||||||
|
return dict(max_tool_num=max(max_tool_num, current_tool),
|
||||||
|
temperatures=cls._canonicalize_temperatures(result, current_tool),
|
||||||
|
heatup_detected=heatup_detected)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_position(cls, line, lower_line, state, flags):
|
||||||
|
position = dict(x=None, y=None, z=None, e=None)
|
||||||
|
for match in re.finditer(cls.regex_position, line):
|
||||||
|
position[match.group("axis").lower()] = float(match.group("pos"))
|
||||||
|
return dict(position=position)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_firmware_info(cls, line, lower_line, state, flags):
|
||||||
|
data = cls._parse_firmware_line(line)
|
||||||
|
firmware_name = data.get("FIRMWARE_NAME")
|
||||||
|
|
||||||
|
if firmware_name is None:
|
||||||
|
# Malyan's "Marlin compatible firmware" isn't actually Marlin compatible and doesn't even
|
||||||
|
# report its firmware name properly in response to M115. Wonderful - why stick to established
|
||||||
|
# protocol when you can do your own thing, right?
|
||||||
|
#
|
||||||
|
# Example: NAME: Malyan VER: 2.9 MODEL: M200 HW: HA02
|
||||||
|
#
|
||||||
|
# We do a bit of manual fiddling around here to circumvent that issue and get ourselves a
|
||||||
|
# reliable firmware name (NAME + VER) out of the Malyan M115 response.
|
||||||
|
name = data.get("NAME")
|
||||||
|
ver = data.get("VER")
|
||||||
|
if "malyan" in name.lower() and ver:
|
||||||
|
firmware_name = name.strip() + " " + ver.strip()
|
||||||
|
|
||||||
|
if firmware_name is not None:
|
||||||
|
firmware_name = firmware_name.strip()
|
||||||
|
|
||||||
|
return dict(firmware_name=firmware_name,
|
||||||
|
data=data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_firmware_capability(cls, line, lower_line, state, flags):
|
||||||
|
result = cls._parse_capability_line(line)
|
||||||
|
if not result:
|
||||||
|
return
|
||||||
|
cap, enabled = result
|
||||||
|
return dict(cap=cap, enabled=enabled)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_sd_file_opened(cls, line, lower_line, state, flags):
|
||||||
|
match = cls.regex_sd_file_opened.match(lower_line)
|
||||||
|
if not match:
|
||||||
|
return
|
||||||
|
|
||||||
|
name = match.group("name")
|
||||||
|
size = int(match.group("size"))
|
||||||
|
return dict(name=name, long_name=name, size=size)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_sd_entry(cls, line, lower_line, state, flags):
|
||||||
|
fileinfo = lower_line.rsplit(None, 1)
|
||||||
|
if len(fileinfo) > 1:
|
||||||
|
# we might have extended file information here, so let's split filename and size and try to make them a bit nicer
|
||||||
|
filename, size = fileinfo
|
||||||
|
try:
|
||||||
|
size = int(size)
|
||||||
|
except ValueError:
|
||||||
|
# whatever that was, it was not an integer, so we'll just use the whole line as filename and set size to None
|
||||||
|
filename = lower_line
|
||||||
|
size = None
|
||||||
|
else:
|
||||||
|
# no extended file information, so only the filename is there and we set size to None
|
||||||
|
filename = lower_line
|
||||||
|
size = None
|
||||||
|
|
||||||
|
from octoprint.util import filter_non_ascii
|
||||||
|
|
||||||
|
if filter_non_ascii(filename):
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
if not filename.startswith("/"):
|
||||||
|
# file from the root of the sd -- we'll prepend a /
|
||||||
|
filename = "/" + filename
|
||||||
|
|
||||||
|
return dict(name=filename, long_name=filename, size=int(size) if size is not None else None)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_sd_printing_byte(cls, line, lower_line, state, flags):
|
||||||
|
match = cls.regex_sd_printing_byte.match(lower_line)
|
||||||
|
if not match:
|
||||||
|
return None
|
||||||
|
return dict(current=int(match.group("current")), total=int(match.group("total")))
|
||||||
|
|
||||||
|
##~~ Commands
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_hello(cls):
|
||||||
|
return cls.command_set_line(0)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_get_firmware_info(cls):
|
||||||
|
return GcodeCommand("M115")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_finish_moving(cls):
|
||||||
|
return GcodeCommand("M400")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_get_position(cls):
|
||||||
|
return GcodeCommand("M114")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_get_temp(cls):
|
||||||
|
return GcodeCommand("M105")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_line(cls, n):
|
||||||
|
return GcodeCommand("M110", n=n)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_emergency_stop(cls):
|
||||||
|
return GcodeCommand("M112")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_abort_heatup(cls):
|
||||||
|
return GcodeCommand("M108")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_extruder_temp(cls, temperature, tool=None, wait=False):
|
||||||
|
command = "M109" if wait else "M104"
|
||||||
|
args = dict(s=temperature)
|
||||||
|
if tool is not None:
|
||||||
|
args["t"] = tool
|
||||||
|
return GcodeCommand(command, **args)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_bed_temp(cls, temperature, wait=False):
|
||||||
|
return GcodeCommand("M190" if wait else "M140", s=temperature)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_chamber_temp(cls, temperature, wait=False):
|
||||||
|
return GcodeCommand("M191" if wait else "M141", s=temperature)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_relative_positioning(cls):
|
||||||
|
return GcodeCommand("G91")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_absolute_positioning(cls):
|
||||||
|
return GcodeCommand("G90")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_move(cls, x=None, y=None, z=None, e=None, f=None):
|
||||||
|
return GcodeCommand("G1", x=x, y=y, z=z, e=e, f=f)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_extrude(cls, e=None, f=None):
|
||||||
|
return cls.command_move(e=e, f=f)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_home(cls, x=False, y=False, z=False):
|
||||||
|
return GcodeCommand("G28", x=0 if x else None, y=0 if y else None, z=0 if z else None)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_tool(cls, tool):
|
||||||
|
return GcodeCommand("T{}".format(tool))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_feedrate_multiplier(cls, multiplier):
|
||||||
|
return GcodeCommand("M220", s=multiplier)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_extrusion_multiplier(cls, multiplier):
|
||||||
|
return GcodeCommand("M221", s=multiplier)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_fan_speed(cls, speed):
|
||||||
|
return GcodeCommand("M106", s=speed)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_set_motors(cls, enable):
|
||||||
|
return GcodeCommand("M17") if enable else GcodeCommand("M18")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_refresh(cls):
|
||||||
|
return GcodeCommand("M20")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_init(cls):
|
||||||
|
return GcodeCommand("M21")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_release(cls):
|
||||||
|
return GcodeCommand("M22")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_select_file(cls, name):
|
||||||
|
return GcodeCommand("M23", param=name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_start(cls):
|
||||||
|
return GcodeCommand("M24")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_pause(cls):
|
||||||
|
return GcodeCommand("M25")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_resume(cls):
|
||||||
|
return GcodeCommand("M24")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_set_pos(cls, pos):
|
||||||
|
return GcodeCommand("M26", s=pos)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_status(cls):
|
||||||
|
return GcodeCommand("M27")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_begin_write(cls, name):
|
||||||
|
return GcodeCommand("M28", param=name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_end_write(cls):
|
||||||
|
return GcodeCommand("M29")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_sd_delete(cls, name):
|
||||||
|
return GcodeCommand("M30", param=name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_autoreport_temperature(cls, interval):
|
||||||
|
return GcodeCommand("M155", s=interval)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_autoreport_sd_status(cls, interval):
|
||||||
|
return GcodeCommand("M27", s=interval)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def command_busy_protocol_interval(cls, interval):
|
||||||
|
return GcodeCommand("M113", s=interval)
|
||||||
|
|
||||||
|
##~~ Helpers
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _canonicalize_temperatures(cls, parsed, current):
|
||||||
|
"""
|
||||||
|
Canonicalizes the temperatures provided in parsed.
|
||||||
|
|
||||||
|
Will make sure that returned result only contains extruder keys
|
||||||
|
like Tn, so always qualified with a tool number.
|
||||||
|
|
||||||
|
The algorithm for cleaning up the parsed keys is the following:
|
||||||
|
|
||||||
|
* If ``T`` is not included with the reported extruders, return
|
||||||
|
* If more than just ``T`` is reported:
|
||||||
|
* If both ``T`` and ``T0`` are reported set ``Tc`` to ``T``, remove
|
||||||
|
``T`` from the result.
|
||||||
|
* Else set ``T0`` to ``T`` and delete ``T`` (Smoothie extra).
|
||||||
|
* If only ``T`` is reported, set ``Tc`` to ``T`` and delete ``T``
|
||||||
|
* return
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
parsed (dict): the parsed temperatures (mapping tool => (actual, target))
|
||||||
|
to canonicalize
|
||||||
|
current (int): the current active extruder
|
||||||
|
Returns:
|
||||||
|
dict: the canonicalized version of ``parsed``
|
||||||
|
"""
|
||||||
|
|
||||||
|
reported_extruders = list(filter(lambda x: x.startswith("T"), parsed.keys()))
|
||||||
|
if not "T" in reported_extruders:
|
||||||
|
# Our reported_extruders are either empty or consist purely
|
||||||
|
# of Tn keys, no need for any action
|
||||||
|
return parsed
|
||||||
|
|
||||||
|
current_tool_key = "T%d" % current
|
||||||
|
result = dict(parsed)
|
||||||
|
|
||||||
|
if len(reported_extruders) > 1:
|
||||||
|
if "T0" in reported_extruders:
|
||||||
|
# Both T and T0 are present, so T contains the current
|
||||||
|
# extruder's temperature, e.g. for current_tool == 1:
|
||||||
|
#
|
||||||
|
# T:<T1> T0:<T0> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T0:<T1> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# Same goes if Tc is already present, it will be overwritten:
|
||||||
|
#
|
||||||
|
# T:<T1> T0:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T0:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
result[current_tool_key] = result["T"]
|
||||||
|
del result["T"]
|
||||||
|
else:
|
||||||
|
# So T is there, but T0 isn't. That looks like Smoothieware which
|
||||||
|
# always reports the first extruder T0 as T:
|
||||||
|
#
|
||||||
|
# T:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T0:<T0> T1:<T1> T2:<T2> ... B:<B>
|
||||||
|
result["T0"] = result["T"]
|
||||||
|
del result["T"]
|
||||||
|
|
||||||
|
else:
|
||||||
|
# We only have T. That can mean two things:
|
||||||
|
#
|
||||||
|
# * we only have one extruder at all, or
|
||||||
|
# * we are currently parsing a response to M109/M190, which on
|
||||||
|
# some firmwares doesn't report the full M105 output while
|
||||||
|
# waiting for the target temperature to be reached but only
|
||||||
|
# reports the current tool and bed
|
||||||
|
#
|
||||||
|
# In both cases it is however safe to just move our T over
|
||||||
|
# to T<current> in the parsed data, current should always stay
|
||||||
|
# 0 for single extruder printers. E.g. for current_tool == 1:
|
||||||
|
#
|
||||||
|
# T:<T1>
|
||||||
|
#
|
||||||
|
# becomes
|
||||||
|
#
|
||||||
|
# T1:<T1>
|
||||||
|
|
||||||
|
result[current_tool_key] = result["T"]
|
||||||
|
del result["T"]
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _parse_firmware_line(cls, line):
|
||||||
|
"""
|
||||||
|
Parses the provided firmware info line.
|
||||||
|
|
||||||
|
The result will be a dictionary mapping from the contained keys to the contained
|
||||||
|
values.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
line (unicode): the line to parse
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: a dictionary with the parsed data
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = dict()
|
||||||
|
split_line = cls.regex_firmware_splitter.split(line.strip())[1:] # first entry is empty start of trimmed string
|
||||||
|
for key, value in chunks(split_line, 2):
|
||||||
|
result[key] = value
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _parse_capability_line(cls, line):
|
||||||
|
"""
|
||||||
|
Parses the provided firmware capability line.
|
||||||
|
|
||||||
|
Lines are expected to be of the format
|
||||||
|
|
||||||
|
Cap:<capability name in caps>:<0 or 1>
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
|
||||||
|
Cap:AUTOREPORT_TEMP:1
|
||||||
|
Cap:TOGGLE_LIGHTS:0
|
||||||
|
|
||||||
|
Args:
|
||||||
|
line (unicode): the line to parse
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: a 2-tuple of the parsed capability name and whether it's on (true) or off (false), or None if the line
|
||||||
|
could not be parsed
|
||||||
|
"""
|
||||||
|
|
||||||
|
line = line.lower()
|
||||||
|
if line.startswith("cap:"):
|
||||||
|
line = line[len("cap:"):]
|
||||||
|
|
||||||
|
parts = line.split(":")
|
||||||
|
if len(parts) != 2:
|
||||||
|
# wrong format, can't parse this
|
||||||
|
return None
|
||||||
|
|
||||||
|
capability, flag = parts
|
||||||
|
if not flag in ("0", "1"):
|
||||||
|
# wrong format, can't parse this
|
||||||
|
return None
|
||||||
|
|
||||||
|
return capability.upper(), flag == "1"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.flavors.generic import GenericFlavor
|
||||||
|
|
||||||
|
class ReprapFirmwareFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "klipper"
|
||||||
|
name = "Klipper"
|
||||||
|
|
||||||
|
unknown_requires_ack = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "klipper" in firmware_name.lower()
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.flavors.generic import GenericFlavor
|
||||||
|
|
||||||
|
class MalyanFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "malyan"
|
||||||
|
name = "Malyan"
|
||||||
|
|
||||||
|
always_send_checksum = False
|
||||||
|
block_while_dwelling = True
|
||||||
|
sd_always_available = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "malyan" in firmware_name.lower()
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.flavors.generic import GenericFlavor
|
||||||
|
|
||||||
|
class MarlinFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "marlin"
|
||||||
|
name = "Marlin"
|
||||||
|
|
||||||
|
emergency_commands = ["M112", "M108", "M410"]
|
||||||
|
heatup_abortable = True
|
||||||
|
|
||||||
|
|
||||||
|
class MarlinLegacyFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "marlinlegacy"
|
||||||
|
name = "Legacy Marlin"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "marlin v1" in firmware_name.lower()
|
||||||
|
|
||||||
|
|
||||||
|
class PrusaMarlinFlavor(MarlinFlavor):
|
||||||
|
|
||||||
|
key = "prusamarlin"
|
||||||
|
name = "Marlin: Prusa variant"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "prusa-firmware" in firmware_name.lower() and "marlin" in firmware_name.lower()
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.flavors import GenericFlavor
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.util import regex_positive_float_pattern
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
class RepetierFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "repetier"
|
||||||
|
name = "Repetier"
|
||||||
|
|
||||||
|
always_send_checksum = True
|
||||||
|
identical_resends_countdown = 5
|
||||||
|
block_while_dwelling = True
|
||||||
|
detect_external_heatups = False
|
||||||
|
|
||||||
|
regex_tempextr = re.compile("targetextr(?P<toolnum>\d+):(?P<target>%s)" % regex_positive_float_pattern)
|
||||||
|
"""Regex for matching target temp reporting from Repetier.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``toolnum``: number of the extruder to which the target temperature
|
||||||
|
report belongs (int)
|
||||||
|
* ``target``: new target temperature (float)
|
||||||
|
"""
|
||||||
|
|
||||||
|
regex_tempbed = re.compile("targetbed:(?P<target>%s)" % regex_positive_float_pattern)
|
||||||
|
"""Regex for matching target temp reporting from Repetier for beds.
|
||||||
|
|
||||||
|
Groups will be as follows:
|
||||||
|
|
||||||
|
* ``target``: new target temperature (float)
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "repetier" in firmware_name.lower()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def message_temperature(cls, line, lower_line, state, flags):
|
||||||
|
return GenericFlavor.message_temperature(line, lower_line, state, flags) or "targetextr" in lower_line or "targetbed" in lower_line
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def parse_message_temperature(cls, line, lower_line, state, flags):
|
||||||
|
if "targetextr" in lower_line:
|
||||||
|
match = cls.regex_tempextr.match(lower_line)
|
||||||
|
if match is not None:
|
||||||
|
tool_num = int(match.group("toolnum"))
|
||||||
|
target = float(match.group("target"))
|
||||||
|
tool = "T{}".format(tool_num)
|
||||||
|
temperatures = dict()
|
||||||
|
temperatures[tool] = (None, target)
|
||||||
|
return dict(max_tool_num=max(tool_num, flags.get("current_tool", 0)),
|
||||||
|
temperatures=temperatures,
|
||||||
|
heatup_detected=False)
|
||||||
|
elif "targetbed" in lower_line:
|
||||||
|
match = cls.regex_tempbed.match(lower_line)
|
||||||
|
if match is not None:
|
||||||
|
target = float(match.group("target"))
|
||||||
|
temperatures = dict(bed=(None, target))
|
||||||
|
return dict(max_tool_num=flags.get("current_tool", 0),
|
||||||
|
temperatures=temperatures,
|
||||||
|
heatup_detected=False)
|
||||||
|
else:
|
||||||
|
# Repetier sends temperature output on it's own line, so we can't use the
|
||||||
|
# "no ok in temperature output" metric to detected external heatups
|
||||||
|
result = GenericFlavor.parse_message_temperature(line, lower_line, state, flags)
|
||||||
|
result[b"heatup_detected"] = False
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
##~~ Preprocessors, returning True stops further processing by the protocol
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def preprocess_comm_resend(cls, linenumber, state, flags):
|
||||||
|
if flags.get("resend_swallow_repetitions", False) \
|
||||||
|
and flags.get("resend_swallow_repetitions_counter", 0) \
|
||||||
|
and linenumber == flags["resend_requested"] \
|
||||||
|
and flags["resend_swallow_repetitions_counter"] > 0:
|
||||||
|
cls.logger.debug("Ignoring resend request for line {}, that is "
|
||||||
|
"probably a repetition sent by the firmware to "
|
||||||
|
"ensure it arrives, not a real request"
|
||||||
|
.format(linenumber))
|
||||||
|
flags["resend_swallow_repetitions_counter"] -= 1
|
||||||
|
return True
|
||||||
|
|
||||||
|
flags["resend_swallow_repetitions_counter"] = cls.identical_resends_countdown
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.flavors.generic import GenericFlavor
|
||||||
|
|
||||||
|
class ReprapFirmwareFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "reprapfirmware"
|
||||||
|
name = "RepRapFirmware"
|
||||||
|
|
||||||
|
sd_relative_path = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def identifier(cls, firmware_name, firmware_info):
|
||||||
|
return "reprapfirmware" in firmware_name.lower()
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.flavors.generic import GenericFlavor
|
||||||
|
|
||||||
|
class ReprapFirmwareFlavor(GenericFlavor):
|
||||||
|
|
||||||
|
key = "smoothieware"
|
||||||
|
name = "Smoothieware"
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.scripts import Script, UnknownScript
|
||||||
|
from octoprint.comm.protocol.reprap.util import process_gcode_line
|
||||||
|
|
||||||
|
class GcodeScript(Script):
|
||||||
|
|
||||||
|
def __init__(self, settings, name, context=None):
|
||||||
|
def renderer(ctx):
|
||||||
|
lines = settings.loadScript("gcode", name, context=ctx)
|
||||||
|
if lines is None:
|
||||||
|
raise UnknownScript(name)
|
||||||
|
return lines
|
||||||
|
|
||||||
|
super(GcodeScript, self).__init__(name, renderer, context=context)
|
||||||
|
|
||||||
|
def render(self, context=None):
|
||||||
|
script = super(GcodeScript, self).render(context)
|
||||||
|
return list(filter(lambda x: x is not None and x.strip() != "",
|
||||||
|
map(lambda x: process_gcode_line(x),
|
||||||
|
script)))
|
||||||
@@ -0,0 +1,398 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.protocol.reprap.commands import Command, to_command
|
||||||
|
from octoprint.util import PrependableQueue, TypeAlreadyInQueue, CountedEvent
|
||||||
|
|
||||||
|
# noinspection PyCompatibility
|
||||||
|
from past.builtins import basestring
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
import copy
|
||||||
|
import logging
|
||||||
|
import threading
|
||||||
|
|
||||||
|
try:
|
||||||
|
# noinspection PyCompatibility
|
||||||
|
import queue
|
||||||
|
except Exception:
|
||||||
|
# noinspection PyCompatibility
|
||||||
|
import Queue as queue
|
||||||
|
|
||||||
|
regex_float_pattern = "[-+]?[0-9]*\.?[0-9]+"
|
||||||
|
regex_positive_float_pattern = "[+]?[0-9]*\.?[0-9]+"
|
||||||
|
regex_int_pattern = "\d+"
|
||||||
|
|
||||||
|
|
||||||
|
def strip_comment(line):
|
||||||
|
if not ";" in line:
|
||||||
|
# shortcut
|
||||||
|
return line
|
||||||
|
|
||||||
|
escaped = False
|
||||||
|
result = []
|
||||||
|
for c in line:
|
||||||
|
if c == ";" and not escaped:
|
||||||
|
break
|
||||||
|
result += c
|
||||||
|
escaped = (c == "\\") and not escaped
|
||||||
|
return "".join(result).strip()
|
||||||
|
|
||||||
|
|
||||||
|
def process_gcode_line(line, offsets=None, current_tool=None):
|
||||||
|
line = strip_comment(line).strip()
|
||||||
|
if not len(line):
|
||||||
|
return None
|
||||||
|
|
||||||
|
# if offsets is not None:
|
||||||
|
# line = apply_temperature_offsets(line, offsets, current_tool=current_tool)
|
||||||
|
|
||||||
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_command_handler_result(command, handler_results, tags_to_add=None):
|
||||||
|
"""
|
||||||
|
Normalizes a command handler result.
|
||||||
|
|
||||||
|
Handler results can be either ``None``, a single result entry or a list of result
|
||||||
|
entries.
|
||||||
|
|
||||||
|
``None`` results are ignored, the provided ``command``, ``command_type``,
|
||||||
|
``gcode``, ``subcode`` and ``tags`` are returned in that case (as single-entry list with
|
||||||
|
one 5-tuple as entry).
|
||||||
|
|
||||||
|
Single result entries are either:
|
||||||
|
|
||||||
|
* a single string defining a replacement ``command``
|
||||||
|
* a 1-tuple defining a replacement ``command``
|
||||||
|
* a 2-tuple defining a replacement ``command`` and ``command_type``
|
||||||
|
* a 3-tuple defining a replacement ``command`` and ``command_type`` and additional ``tags`` to set
|
||||||
|
|
||||||
|
A ``command`` that is ``None`` will lead to the entry being ignored for
|
||||||
|
the normalized result.
|
||||||
|
|
||||||
|
The method returns a list of normalized result entries. Normalized result
|
||||||
|
entries always are a 4-tuple consisting of ``command``, ``command_type``,
|
||||||
|
``gcode`` and ``subcode``, the latter three being allowed to be ``None``. The list may
|
||||||
|
be empty in which case the command is to be suppressed.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
>>> from octoprint.comm.protocol.reprap.commands.gcode import GcodeCommand
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), None) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M105',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), GcodeCommand("M110")) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), ["M110"]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), ["M110", "M117 Foobar"]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags=set()), GcodeCommand('M117',param='Foobar',original='M117 Foobar',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), [("M110",), "M117 Foobar"]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags=set()), GcodeCommand('M117',param='Foobar',original='M117 Foobar',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), [("M110", "lineno_reset"), "M117 Foobar"]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type='lineno_reset',tags=set()), GcodeCommand('M117',param='Foobar',original='M117 Foobar',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), []) # doctest: +ALLOW_UNICODE
|
||||||
|
[]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), ["M110", None]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), [("M110",), (None, "ignored")]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105"), [("M110",), ("M117 Foobar", "display_message"), ("tuple", "of", "unexpected", "length"), ("M110", "lineno_reset")]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags=set()), GcodeCommand('M117',param='Foobar',original='M117 Foobar',type='display_message',tags=set()), GcodeCommand('M110',original='M110',type='lineno_reset',tags=set())]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105",tags={"tag1", "tag2"}), ["M110", "M117 Foobar"]) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags={'tag1', 'tag2'}), GcodeCommand('M117',param='Foobar',original='M117 Foobar',type=None,tags={'tag1', 'tag2'})]
|
||||||
|
>>> normalize_command_handler_result(GcodeCommand("M105",tags={"tag1", "tag2"}), ["M110", "M117 Foobar"], tags_to_add={"tag3"}) # doctest: +ALLOW_UNICODE
|
||||||
|
[GcodeCommand('M110',original='M110',type=None,tags={'tag1', 'tag2', 'tag3'}), GcodeCommand('M117',param='Foobar',original='M117 Foobar',type=None,tags={'tag1', 'tag2', 'tag3'})]
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
command (Command): The command for which the handler result was
|
||||||
|
generated
|
||||||
|
handler_results: The handler result(s) to normalized. Can be either
|
||||||
|
a single result entry or a list of result entries.
|
||||||
|
tags_to_add (set of unicode or None): List of tags to add to expanded result
|
||||||
|
entries
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(list) - A list of normalized handler result entries, which are
|
||||||
|
``Command`` instances
|
||||||
|
"""
|
||||||
|
|
||||||
|
original = command
|
||||||
|
|
||||||
|
if handler_results is None:
|
||||||
|
# handler didn't return anything, we'll just continue
|
||||||
|
return [original]
|
||||||
|
|
||||||
|
if not isinstance(handler_results, list):
|
||||||
|
handler_results = [handler_results, ]
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for handler_result in handler_results:
|
||||||
|
# we iterate over all handler result entries and process each one
|
||||||
|
# individually here
|
||||||
|
|
||||||
|
if handler_result is None:
|
||||||
|
# entry is None, we'll ignore that entry and continue
|
||||||
|
continue
|
||||||
|
|
||||||
|
def expand_tags(tags, tags_to_add):
|
||||||
|
tags = tags.copy()
|
||||||
|
if tags_to_add and isinstance(tags_to_add, set):
|
||||||
|
tags |= tags_to_add
|
||||||
|
return tags
|
||||||
|
|
||||||
|
if isinstance(handler_result, basestring):
|
||||||
|
# entry is just a string, replace command with it
|
||||||
|
if handler_result != original.line:
|
||||||
|
# command changed, swap it
|
||||||
|
command = to_command(handler_result,
|
||||||
|
type=original.type,
|
||||||
|
tags=expand_tags(original.tags, tags_to_add))
|
||||||
|
result.append(command)
|
||||||
|
|
||||||
|
elif isinstance(handler_result, Command):
|
||||||
|
if handler_result != original:
|
||||||
|
command = copy.copy(handler_result)
|
||||||
|
command.tags = expand_tags(original.tags, tags_to_add)
|
||||||
|
result.append(command)
|
||||||
|
|
||||||
|
elif isinstance(handler_result, tuple):
|
||||||
|
# entry is a tuple, extract command and command_type
|
||||||
|
hook_result_length = len(handler_result)
|
||||||
|
|
||||||
|
command_type = original.type
|
||||||
|
command_tags = original.tags
|
||||||
|
|
||||||
|
if hook_result_length == 1:
|
||||||
|
# handler returned just the command
|
||||||
|
command_line, = handler_result
|
||||||
|
elif hook_result_length == 2:
|
||||||
|
# handler returned command and command_type
|
||||||
|
command_line, command_type = handler_result
|
||||||
|
elif hook_result_length == 3:
|
||||||
|
# handler returned command, command type and additional tags
|
||||||
|
command_line, command_type, command_tags = handler_result
|
||||||
|
else:
|
||||||
|
# handler returned a tuple of an unexpected length, ignore
|
||||||
|
# and continue
|
||||||
|
continue
|
||||||
|
|
||||||
|
if command_line is None:
|
||||||
|
# command is None, ignore it and continue
|
||||||
|
continue
|
||||||
|
|
||||||
|
if command_line != original.line or command_type != original.type:
|
||||||
|
# command or command_type changed, tags need to be rewritten
|
||||||
|
command_tags = expand_tags(command_tags, tags_to_add)
|
||||||
|
|
||||||
|
result.append(to_command(command_line, type=command_type, tags=command_tags))
|
||||||
|
|
||||||
|
# reset to original
|
||||||
|
command = original
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class SendToken(CountedEvent):
|
||||||
|
|
||||||
|
def __init__(self, value=0, maximum=None, **kwargs):
|
||||||
|
super(SendToken, self).__init__(value=value, maximum=maximum, **kwargs)
|
||||||
|
self._ignored = 0
|
||||||
|
|
||||||
|
def set(self, ignore=False):
|
||||||
|
with self._mutex:
|
||||||
|
if ignore:
|
||||||
|
self._ignored += 1
|
||||||
|
self._internal_set(self._counter + 1)
|
||||||
|
|
||||||
|
def clear(self, completely=False):
|
||||||
|
with self._mutex:
|
||||||
|
if completely:
|
||||||
|
self._internal_set(0)
|
||||||
|
self._ignored = 0
|
||||||
|
else:
|
||||||
|
if self._ignored > 0:
|
||||||
|
self._ignored -= 1
|
||||||
|
self._internal_set(self._counter - 1)
|
||||||
|
self._internal_set(self._counter - 1)
|
||||||
|
|
||||||
|
|
||||||
|
class LineHistory(object):
|
||||||
|
def __init__(self, max=None):
|
||||||
|
self.max = max
|
||||||
|
|
||||||
|
self._lines = []
|
||||||
|
self._mutex = threading.RLock()
|
||||||
|
self._line_number_lookup = dict()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def lines(self):
|
||||||
|
with self._mutex:
|
||||||
|
return [x[0] for x in self._lines]
|
||||||
|
|
||||||
|
def append(self, line, line_number=None):
|
||||||
|
with self._mutex:
|
||||||
|
self._lines.append((line, line_number))
|
||||||
|
if line_number is not None:
|
||||||
|
self._line_number_lookup[line_number] = line
|
||||||
|
self._cleanup()
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
with self._mutex:
|
||||||
|
self._lines = []
|
||||||
|
self._line_number_lookup = dict()
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
with self._mutex:
|
||||||
|
return len(self._lines)
|
||||||
|
|
||||||
|
def __getitem__(self, line_number):
|
||||||
|
with self._mutex:
|
||||||
|
return self._line_number_lookup[line_number]
|
||||||
|
|
||||||
|
def __contains__(self, line_number):
|
||||||
|
with self._mutex:
|
||||||
|
return line_number in self._line_number_lookup
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return iter(self.lines)
|
||||||
|
|
||||||
|
def _cleanup(self):
|
||||||
|
if len(self._lines) <= self.max:
|
||||||
|
return
|
||||||
|
|
||||||
|
while len(self._lines) > self.max:
|
||||||
|
_, line_number = self._lines.pop(0)
|
||||||
|
if line_number is not None:
|
||||||
|
try:
|
||||||
|
del self._line_number_lookup[line_number]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PositionRecord(object):
|
||||||
|
_standard_attrs = {"x", "y", "z", "e", "f", "t"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def valid_e(cls, attr):
|
||||||
|
if not attr.startswith("e"):
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
int(attr[1:])
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
attrs = self._standard_attrs | set([key for key in kwargs if self.valid_e(key)])
|
||||||
|
for attr in attrs:
|
||||||
|
setattr(self, attr, kwargs.get(attr))
|
||||||
|
|
||||||
|
def copy_from(self, other):
|
||||||
|
# make sure all standard attrs and attrs from other are set
|
||||||
|
attrs = self._standard_attrs | set([key for key in dir(other) if self.valid_e(key)])
|
||||||
|
for attr in attrs:
|
||||||
|
setattr(self, attr, getattr(other, attr))
|
||||||
|
|
||||||
|
# delete attrs other doesn't have
|
||||||
|
attrs = set([key for key in dir(self) if self.valid_e(key)]) - attrs
|
||||||
|
for attr in attrs:
|
||||||
|
delattr(self, attr)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
attrs = self._standard_attrs | set([key for key in dir(self) if self.valid_e(key)])
|
||||||
|
return dict((attr, getattr(self, attr)) for attr in attrs)
|
||||||
|
|
||||||
|
|
||||||
|
class TemperatureRecord(object):
|
||||||
|
def __init__(self):
|
||||||
|
self._tools = dict()
|
||||||
|
self._bed = (None, None)
|
||||||
|
self._chamber = (None, None)
|
||||||
|
|
||||||
|
def copy_from(self, other):
|
||||||
|
self._tools = other.tools
|
||||||
|
self._bed = other.bed
|
||||||
|
self._chamber = other.chamber
|
||||||
|
|
||||||
|
def set_tool(self, tool, actual=None, target=None):
|
||||||
|
current = self._tools.get(tool, (None, None))
|
||||||
|
self._tools[tool] = self._to_new_tuple(current, actual, target)
|
||||||
|
|
||||||
|
def set_bed(self, actual=None, target=None):
|
||||||
|
current = self._bed
|
||||||
|
self._bed = self._to_new_tuple(current, actual, target)
|
||||||
|
|
||||||
|
def set_chamber(self, actual=None, target=None):
|
||||||
|
current = self._chamber()
|
||||||
|
self._chamber = self._to_new_tuple(current, actual, target)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tools(self):
|
||||||
|
return dict(self._tools)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bed(self):
|
||||||
|
return self._bed
|
||||||
|
|
||||||
|
@property
|
||||||
|
def chamber(self):
|
||||||
|
return self._chamber
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = dict()
|
||||||
|
|
||||||
|
tools = self.tools
|
||||||
|
for tool, data in tools.items():
|
||||||
|
result["tool{}".format(tool)] = dict(actual=data[0],
|
||||||
|
target=data[1])
|
||||||
|
|
||||||
|
bed = self.bed
|
||||||
|
result["bed"] = dict(actual=bed[0],
|
||||||
|
target=bed[1])
|
||||||
|
|
||||||
|
chamber = self.chamber
|
||||||
|
result["chamber"] = dict(actual=chamber[0],
|
||||||
|
target=chamber[1])
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def as_script_dict(self):
|
||||||
|
result = self.as_dict()
|
||||||
|
|
||||||
|
# backwards compatibility
|
||||||
|
tools = self.tools
|
||||||
|
for tool, data in tools.items():
|
||||||
|
result[tool] = dict(actual=data[0],
|
||||||
|
target=data[1])
|
||||||
|
|
||||||
|
bed = self.bed
|
||||||
|
result["b"] = dict(actual=bed[0],
|
||||||
|
target=bed[1])
|
||||||
|
|
||||||
|
chamber = self.chamber
|
||||||
|
result["c"] = dict(actual=chamber[0],
|
||||||
|
target=chamber[1])
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _to_new_tuple(cls, current, actual, target):
|
||||||
|
if current is None or not isinstance(current, tuple) or len(current) != 2:
|
||||||
|
current = (None, None)
|
||||||
|
|
||||||
|
if actual is None and target is None:
|
||||||
|
return current
|
||||||
|
|
||||||
|
old_actual, old_target = current
|
||||||
|
|
||||||
|
if actual is None:
|
||||||
|
return old_actual, target
|
||||||
|
elif target is None:
|
||||||
|
return actual, old_target
|
||||||
|
else:
|
||||||
|
return actual, target
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.util import PrependableQueue, TypedQueue, TypeAlreadyInQueue
|
||||||
|
|
||||||
|
try:
|
||||||
|
import queue
|
||||||
|
except ImportError:
|
||||||
|
import Queue as queue
|
||||||
|
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
import logging
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
|
class ScriptQueue(PrependableQueue):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class JobQueue(PrependableQueue):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class CommandQueue(TypedQueue):
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
TypedQueue.__init__(self, *args, **kwargs)
|
||||||
|
self._unblocked = threading.Event()
|
||||||
|
self._unblocked.set()
|
||||||
|
|
||||||
|
def block(self):
|
||||||
|
self._unblocked.clear()
|
||||||
|
|
||||||
|
def unblock(self):
|
||||||
|
self._unblocked.set()
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def blocked(self):
|
||||||
|
self.block()
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
self.unblock()
|
||||||
|
|
||||||
|
def get(self, *args, **kwargs):
|
||||||
|
self._unblocked.wait()
|
||||||
|
return TypedQueue.get(self, *args, **kwargs)
|
||||||
|
|
||||||
|
def put(self, *args, **kwargs):
|
||||||
|
self._unblocked.wait()
|
||||||
|
return TypedQueue.put(self, *args, **kwargs)
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
cleared = []
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
cleared.append(TypedQueue.get(self, False))
|
||||||
|
TypedQueue.task_done(self)
|
||||||
|
except queue.Empty:
|
||||||
|
break
|
||||||
|
return cleared
|
||||||
|
|
||||||
|
|
||||||
|
class SendQueue(PrependableQueue):
|
||||||
|
|
||||||
|
def __init__(self, maxsize=0):
|
||||||
|
PrependableQueue.__init__(self, maxsize=maxsize)
|
||||||
|
|
||||||
|
self._unblocked = threading.Event()
|
||||||
|
self._unblocked.set()
|
||||||
|
|
||||||
|
self._resend_queue = PrependableQueue()
|
||||||
|
self._send_queue = PrependableQueue()
|
||||||
|
self._lookup = set()
|
||||||
|
|
||||||
|
self._resend_active = False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def resend_active(self):
|
||||||
|
return self._resend_active
|
||||||
|
|
||||||
|
@resend_active.setter
|
||||||
|
def resend_active(self, resend_active):
|
||||||
|
with self.mutex:
|
||||||
|
self._resend_active = resend_active
|
||||||
|
|
||||||
|
def block(self):
|
||||||
|
self._unblocked.clear()
|
||||||
|
|
||||||
|
def unblock(self):
|
||||||
|
self._unblocked.set()
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def blocked(self):
|
||||||
|
self.block()
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
self.unblock()
|
||||||
|
|
||||||
|
def prepend(self, item, item_type=None, target=None, block=True, timeout=None):
|
||||||
|
self._unblocked.wait()
|
||||||
|
PrependableQueue.prepend(self, (item, item_type, target), block=block, timeout=timeout)
|
||||||
|
|
||||||
|
def put(self, item, item_type=None, target=None, block=True, timeout=None):
|
||||||
|
self._unblocked.wait()
|
||||||
|
PrependableQueue.put(self, (item, item_type, target), block=block, timeout=timeout)
|
||||||
|
|
||||||
|
def get(self, block=True, timeout=None):
|
||||||
|
self._unblocked.wait()
|
||||||
|
item, _, _ = PrependableQueue.get(self, block=block, timeout=timeout)
|
||||||
|
return item
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
cleared = []
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
cleared.append(PrependableQueue.get(self, False))
|
||||||
|
PrependableQueue.task_done(self)
|
||||||
|
except queue.Empty:
|
||||||
|
break
|
||||||
|
return cleared
|
||||||
|
|
||||||
|
def _put(self, item):
|
||||||
|
_, item_type, target = item
|
||||||
|
if item_type is not None:
|
||||||
|
if item_type in self._lookup:
|
||||||
|
raise TypeAlreadyInQueue(item_type, "Type {} is already in queue".format(item_type))
|
||||||
|
else:
|
||||||
|
self._lookup.add(item_type)
|
||||||
|
|
||||||
|
if target == "resend":
|
||||||
|
self._resend_queue.put(item)
|
||||||
|
else:
|
||||||
|
self._send_queue.put(item)
|
||||||
|
|
||||||
|
def _prepend(self, item):
|
||||||
|
_, item_type, target = item
|
||||||
|
if item_type is not None:
|
||||||
|
if item_type in self._lookup:
|
||||||
|
raise TypeAlreadyInQueue(item_type, "Type {} is already in queue".format(item_type))
|
||||||
|
else:
|
||||||
|
self._lookup.add(item_type)
|
||||||
|
|
||||||
|
if target == "resend":
|
||||||
|
self._resend_queue.prepend(item)
|
||||||
|
else:
|
||||||
|
self._send_queue.prepend(item)
|
||||||
|
|
||||||
|
def _get(self):
|
||||||
|
if self.resend_active:
|
||||||
|
item = self._resend_queue.get(block=False)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
item = self._resend_queue.get(block=False)
|
||||||
|
except queue.Empty:
|
||||||
|
item = self._send_queue.get(block=False)
|
||||||
|
|
||||||
|
_, item_type, _ = item
|
||||||
|
if item_type is not None:
|
||||||
|
if item_type in self._lookup:
|
||||||
|
self._lookup.remove(item_type)
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
|
def _qsize(self, len=len):
|
||||||
|
if self.resend_active:
|
||||||
|
return self._resend_queue.qsize()
|
||||||
|
else:
|
||||||
|
return self._resend_queue.qsize() + self._send_queue.qsize()
|
||||||
|
|
||||||
|
|
||||||
|
class QueueMarker(object):
|
||||||
|
|
||||||
|
def __init__(self, callback):
|
||||||
|
self.callback = callback
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
if callable(self.callback):
|
||||||
|
try:
|
||||||
|
self.callback()
|
||||||
|
except Exception:
|
||||||
|
logging.getLogger(__name__).exception("Error while running callback of QueueMarker")
|
||||||
|
|
||||||
|
|
||||||
|
class SendQueueMarker(QueueMarker):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
class Script(object):
|
||||||
|
|
||||||
|
def __init__(self, name, renderer, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = dict()
|
||||||
|
|
||||||
|
self.name = name
|
||||||
|
self.renderer = renderer
|
||||||
|
self.context = context
|
||||||
|
|
||||||
|
def render(self, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = dict()
|
||||||
|
|
||||||
|
render_context = dict(self.context)
|
||||||
|
render_context.update(context)
|
||||||
|
|
||||||
|
content = self.renderer(render_context)
|
||||||
|
if content is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return content.split("\n")
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownScript(Exception):
|
||||||
|
def __init__(self, name, *args, **kwargs):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidScript(Exception):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,350 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.util.parameters import get_param_dict
|
||||||
|
|
||||||
|
import copy
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
from octoprint.util import monotonic_time
|
||||||
|
from octoprint.util.listener import ListenerAware
|
||||||
|
from octoprint.plugin import plugin_manager
|
||||||
|
from octoprint.settings import SubSettings
|
||||||
|
|
||||||
|
_registry = dict()
|
||||||
|
|
||||||
|
def register_transports():
|
||||||
|
from .serialtransport import SerialTransport
|
||||||
|
from .sockettransport import TcpTransport, SerialOverTcpTransport
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# stock transports
|
||||||
|
register_transport(SerialTransport)
|
||||||
|
register_transport(TcpTransport)
|
||||||
|
register_transport(SerialOverTcpTransport)
|
||||||
|
|
||||||
|
# more transports provided by plugins
|
||||||
|
hooks = plugin_manager().get_hooks("octoprint.comm.transport.register")
|
||||||
|
for name, hook in hooks.items():
|
||||||
|
try:
|
||||||
|
transports = hook()
|
||||||
|
for transport in transports:
|
||||||
|
try:
|
||||||
|
register_transport(transport)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error while registering transport class {} for plugin {}".format(transport, name))
|
||||||
|
except Exception:
|
||||||
|
logger.exception("Error executing octoprint.comm.transport.register hook for plugin {}".format(name))
|
||||||
|
|
||||||
|
|
||||||
|
def register_transport(transport_class):
|
||||||
|
if not hasattr(transport_class, "key"):
|
||||||
|
raise ValueError("Transport class {} is missing key".format(transport_class))
|
||||||
|
_registry[transport_class.key] = transport_class
|
||||||
|
|
||||||
|
|
||||||
|
def lookup_transport(key):
|
||||||
|
return _registry.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
def all_transports():
|
||||||
|
return _registry.values()
|
||||||
|
|
||||||
|
|
||||||
|
class Transport(ListenerAware):
|
||||||
|
|
||||||
|
name = None
|
||||||
|
key = None
|
||||||
|
|
||||||
|
message_integrity = False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_connection_options(cls):
|
||||||
|
return []
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_settings_defaults(cls):
|
||||||
|
return dict()
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(Transport, self).__init__()
|
||||||
|
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._state = TransportState.DISCONNECTED
|
||||||
|
self._args = dict()
|
||||||
|
|
||||||
|
self._printer_profile = kwargs.get("printer_profile")
|
||||||
|
self._plugin_manager = kwargs.get("plugin_manager")
|
||||||
|
self._event_bus = kwargs.get("event_bus")
|
||||||
|
self._settings = kwargs.get("settings")
|
||||||
|
if not isinstance(self._settings, TransportSettings):
|
||||||
|
self._settings = TransportSettings(self._settings, self)
|
||||||
|
|
||||||
|
def args(self):
|
||||||
|
return copy.deepcopy(self._args)
|
||||||
|
|
||||||
|
def set_current_args(self, **value):
|
||||||
|
self._args = copy.deepcopy(value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@state.setter
|
||||||
|
def state(self, value):
|
||||||
|
old_state = self.state
|
||||||
|
self._state = value
|
||||||
|
self.notify_listeners("on_transport_log_message", self, "Transport state changed from '{}' to '{}'".format(old_state, value))
|
||||||
|
|
||||||
|
def connect(self, **params):
|
||||||
|
if self.state == TransportState.CONNECTED:
|
||||||
|
raise TransportAlreadyConnectedError("Already connected, disconnect first")
|
||||||
|
options = self.get_connection_options()
|
||||||
|
param_dict = get_param_dict(params, options)
|
||||||
|
|
||||||
|
self.create_connection(**param_dict)
|
||||||
|
|
||||||
|
self.state = TransportState.CONNECTED
|
||||||
|
self.notify_listeners("on_transport_connected", self)
|
||||||
|
|
||||||
|
def disconnect(self, error=None):
|
||||||
|
if self.state == TransportState.DISCONNECTED:
|
||||||
|
raise TransportNotConnectedError("Already disconnected")
|
||||||
|
|
||||||
|
success = self.drop_connection()
|
||||||
|
if not success and not error:
|
||||||
|
error = "Error disconnecting transport"
|
||||||
|
|
||||||
|
if error:
|
||||||
|
self.state = TransportState.DISCONNECTED_WITH_ERROR
|
||||||
|
self.notify_listeners("on_transport_log_message", self, error)
|
||||||
|
else:
|
||||||
|
self.state = TransportState.DISCONNECTED
|
||||||
|
|
||||||
|
self.notify_listeners("on_transport_disconnected", self, error=error)
|
||||||
|
|
||||||
|
def create_connection(self, *args, **kwargs):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def drop_connection(self):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def read(self, size=None, timeout=None):
|
||||||
|
data = self.do_read(size=size, timeout=timeout)
|
||||||
|
self.notify_listeners("on_transport_log_received_data", self, data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def write(self, data):
|
||||||
|
self.do_write(data)
|
||||||
|
self.notify_listeners("on_transport_log_sent_data", self, data)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def in_waiting(self):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def do_read(self, size=None, timeout=None):
|
||||||
|
return b""
|
||||||
|
|
||||||
|
def do_write(self, data):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
|
class TransportState(object):
|
||||||
|
CONNECTED = "connected"
|
||||||
|
DISCONNECTED = "disconnected"
|
||||||
|
DISCONNECTED_WITH_ERROR = "disconnected_with_error"
|
||||||
|
|
||||||
|
|
||||||
|
class TransportSettings(SubSettings):
|
||||||
|
def __init__(self, settings, transport):
|
||||||
|
self.transport = transport.key
|
||||||
|
SubSettings.__init__(self, settings, ["comm", "transport", transport.key],
|
||||||
|
defaults=transport.get_settings_defaults())
|
||||||
|
|
||||||
|
|
||||||
|
class TransportNotConnectedError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TransportAlreadyConnectedError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TransportWrapper(ListenerAware):
|
||||||
|
|
||||||
|
unforwarded_handlers = []
|
||||||
|
"""Allows to explicitly disable certain transport listener handlers on sub classes."""
|
||||||
|
|
||||||
|
def __init__(self, transport):
|
||||||
|
ListenerAware.__init__(self)
|
||||||
|
self.transport = transport
|
||||||
|
self.transport.register_listener(self)
|
||||||
|
|
||||||
|
# make sure we forward any transport listener calls to our own registered listeners
|
||||||
|
|
||||||
|
def forward_handler(name):
|
||||||
|
def f(*args, **kwargs):
|
||||||
|
# replace references to self.transport with self
|
||||||
|
args = [self if arg == self.transport else arg for arg in args]
|
||||||
|
kwargs = dict((key, self if value == self.transport else value) for key, value in kwargs.items())
|
||||||
|
|
||||||
|
# forward
|
||||||
|
self.notify_listeners(name, *args, **kwargs)
|
||||||
|
return f
|
||||||
|
|
||||||
|
for handler in filter(lambda x: x.startswith("on_transport_"), dir(TransportListener)):
|
||||||
|
if handler not in self.__class__.unforwarded_handlers:
|
||||||
|
setattr(self, handler, forward_handler(handler))
|
||||||
|
|
||||||
|
def __getattr__(self, item):
|
||||||
|
return getattr(self.transport, item)
|
||||||
|
|
||||||
|
|
||||||
|
class SeparatorAwareTransportWrapper(TransportWrapper):
|
||||||
|
|
||||||
|
unforwarded_handlers = ["on_transport_log_received_data"]
|
||||||
|
"""We have read overwritten and hence send our own received_data notification."""
|
||||||
|
|
||||||
|
def __init__(self, transport, terminator):
|
||||||
|
TransportWrapper.__init__(self, transport)
|
||||||
|
|
||||||
|
self.terminator = terminator
|
||||||
|
|
||||||
|
self._buffered = bytearray()
|
||||||
|
|
||||||
|
def read(self, size=None, timeout=None):
|
||||||
|
start = monotonic_time()
|
||||||
|
termlen = len(self.terminator)
|
||||||
|
data = self._buffered
|
||||||
|
|
||||||
|
while True:
|
||||||
|
# make sure we always read everything that is waiting
|
||||||
|
data += bytearray(self.transport.read(self.transport.in_waiting))
|
||||||
|
|
||||||
|
# check for terminator, if it's there we have found our line
|
||||||
|
termpos = data.find(self.terminator)
|
||||||
|
if termpos >= 0:
|
||||||
|
# line: everything up to and incl. the terminator
|
||||||
|
line = data[:termpos + termlen]
|
||||||
|
|
||||||
|
# buffered: everything after the terminator
|
||||||
|
self._buffered = data[termpos + termlen:]
|
||||||
|
|
||||||
|
received = bytes(line)
|
||||||
|
self.notify_listeners("on_transport_log_received_data", self, received)
|
||||||
|
return received
|
||||||
|
|
||||||
|
# check if timeout expired
|
||||||
|
if timeout and monotonic_time() > start + timeout:
|
||||||
|
break
|
||||||
|
|
||||||
|
# if we arrive here we so far couldn't read a full line, wait for more data
|
||||||
|
c = self.transport.read(1)
|
||||||
|
if not c:
|
||||||
|
# EOF
|
||||||
|
break
|
||||||
|
|
||||||
|
# add to data and loop
|
||||||
|
data += c
|
||||||
|
|
||||||
|
self._buffered = data
|
||||||
|
|
||||||
|
raise TimeoutTransportException()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "SeparatorAwareTransportWrapper({}, separator={})".format(self.transport, self.terminator)
|
||||||
|
|
||||||
|
class LineAwareTransportWrapper(SeparatorAwareTransportWrapper):
|
||||||
|
|
||||||
|
def __init__(self, transport):
|
||||||
|
SeparatorAwareTransportWrapper.__init__(self, transport, b"\n")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "LineAwareTransportWrapper({})".format(self.transport)
|
||||||
|
|
||||||
|
class PushingTransportWrapper(TransportWrapper):
|
||||||
|
|
||||||
|
def __init__(self, transport, name=b"PushingTransportWrapper.receiver_loop", timeout=None):
|
||||||
|
super(PushingTransportWrapper, self).__init__(transport)
|
||||||
|
self.name = name
|
||||||
|
self.timeout = timeout
|
||||||
|
|
||||||
|
self._receiver_active = False
|
||||||
|
self._receiver_thread = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def active(self):
|
||||||
|
return self._receiver_active
|
||||||
|
|
||||||
|
def connect(self, **kwargs):
|
||||||
|
self.transport.connect(**kwargs)
|
||||||
|
|
||||||
|
import threading
|
||||||
|
|
||||||
|
self._receiver_active = True
|
||||||
|
self._receiver_thread = threading.Thread(target=self._receiver_loop, name=self.name)
|
||||||
|
self._receiver_thread.daemon = True
|
||||||
|
self._receiver_thread.start()
|
||||||
|
|
||||||
|
def disconnect(self):
|
||||||
|
self._receiver_active = False
|
||||||
|
self.transport.disconnect()
|
||||||
|
|
||||||
|
def wait(self):
|
||||||
|
self._receiver_thread.join()
|
||||||
|
|
||||||
|
def _receiver_loop(self):
|
||||||
|
while self._receiver_active:
|
||||||
|
try:
|
||||||
|
data = self.transport.read(timeout=self.timeout)
|
||||||
|
self.notify_listeners("on_transport_data_pushed", self, data)
|
||||||
|
except TimeoutTransportException as ex:
|
||||||
|
self.notify_listeners("on_transport_data_exception", self, ex)
|
||||||
|
except Exception:
|
||||||
|
if self._receiver_active:
|
||||||
|
raise
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "PushingTransportWrapper({})".format(self.transport)
|
||||||
|
|
||||||
|
class TransportListener(object):
|
||||||
|
|
||||||
|
def on_transport_connected(self, transport):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_transport_disconnected(self, transport, error=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_transport_log_sent_data(self, transport, data):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_transport_log_received_data(self, transport, data):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_transport_log_message(self, transport, data):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class PushingTransportWrapperListener(object):
|
||||||
|
|
||||||
|
def on_transport_data_pushed(self, transport, data):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_transport_data_exception(self, transport, exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class TransportException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class TimeoutTransportException(TransportException):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class EofTransportException(TransportException):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.transport import Transport, LineAwareTransportWrapper, PushingTransportWrapper
|
||||||
|
from octoprint.comm.util.parameters import TextType, IntegerType, ChoiceType, SuggestionType, BooleanType, Value
|
||||||
|
|
||||||
|
import serial
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class SerialTransport(Transport):
|
||||||
|
name = "Serial Connection"
|
||||||
|
key = "serial"
|
||||||
|
message_integrity = False
|
||||||
|
|
||||||
|
suggested_baudrates = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
|
||||||
|
unix_port_patterns = ["/dev/ttyUSB*", "/dev/ttyACM*", "/dev/tty.usb*",
|
||||||
|
"/dev/cu.*", "/dev/cuaU*", "/dev/rfcomm*"]
|
||||||
|
|
||||||
|
max_write_passes = 5
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def for_additional_ports_and_baudrates(cls, additional_ports, additional_baudrates):
|
||||||
|
patterns = SerialTransport.unix_port_patterns
|
||||||
|
if additional_ports:
|
||||||
|
patterns += additional_ports
|
||||||
|
|
||||||
|
baudrates = SerialTransport.suggested_baudrates
|
||||||
|
if additional_baudrates:
|
||||||
|
baudrates += additional_baudrates
|
||||||
|
|
||||||
|
return type(cls.__name__ + b"WithAdditionalPorts",
|
||||||
|
(cls,),
|
||||||
|
{b"unix_port_patterns": patterns,
|
||||||
|
b"suggested_baudrates": baudrates})
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_connection_options(cls):
|
||||||
|
return [
|
||||||
|
SuggestionType("port", "Port", cls.get_available_serial_ports(), lambda value: Value(value)),
|
||||||
|
SuggestionType("baudrate", "Baudrate", cls.get_available_baudrates(), lambda value: Value(value), default=0),
|
||||||
|
IntegerType("write_timeout", "Write Timeout (sec)", min=1, default=10, advanced=True),
|
||||||
|
BooleanType("exclusive", "Exclusive access", default=True, advanced=True),
|
||||||
|
ChoiceType("parity", "Parity",
|
||||||
|
[Value(serial.PARITY_NONE, "none"),
|
||||||
|
Value(serial.PARITY_ODD, "odd"),
|
||||||
|
Value(serial.PARITY_EVEN, "even")],
|
||||||
|
default=serial.PARITY_NONE, advanced=True)
|
||||||
|
]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_available_serial_ports(cls):
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.platform == "win32":
|
||||||
|
# windows
|
||||||
|
from serial.tools.list_ports import comports
|
||||||
|
ports = comports()
|
||||||
|
|
||||||
|
else:
|
||||||
|
# posix
|
||||||
|
import glob
|
||||||
|
|
||||||
|
devices = [device
|
||||||
|
for pattern in cls.unix_port_patterns
|
||||||
|
for device in glob.glob(pattern)]
|
||||||
|
|
||||||
|
plat = sys.platform.lower()
|
||||||
|
|
||||||
|
if plat[:5] == "linux":
|
||||||
|
# linux
|
||||||
|
from serial.tools.list_ports_linux import SysFS
|
||||||
|
ports = [info
|
||||||
|
for info in [SysFS(d) for d in devices]
|
||||||
|
if info.subsystem != "platform"]
|
||||||
|
else:
|
||||||
|
# other posix systems
|
||||||
|
from serial.tools import list_ports_common
|
||||||
|
ports = [list_ports_common.ListPortInfo(d) for d in devices]
|
||||||
|
|
||||||
|
port_values = [Value(None, title="Auto detect")] + sorted([Value(port.device, title=port.description) for port in ports], key=lambda x: x.title)
|
||||||
|
return port_values
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_available_baudrates(cls):
|
||||||
|
return [Value(0, title="Auto detect")] + \
|
||||||
|
sorted([Value(baudrate) for baudrate in cls.suggested_baudrates], key=lambda x: x.title, reverse=True)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(SerialTransport, self).__init__()
|
||||||
|
|
||||||
|
self.serial_factory = kwargs.get("serial_factory", None)
|
||||||
|
|
||||||
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._serial = None
|
||||||
|
|
||||||
|
self._closing = False
|
||||||
|
|
||||||
|
def create_connection(self, **kwargs):
|
||||||
|
factory = self.serial_factory
|
||||||
|
if self.serial_factory is None:
|
||||||
|
factory = self._default_serial_factory
|
||||||
|
|
||||||
|
self._closing = False
|
||||||
|
self._serial = factory(**kwargs)
|
||||||
|
self.set_current_args(**kwargs)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def drop_connection(self):
|
||||||
|
error = False
|
||||||
|
|
||||||
|
if self._serial is not None:
|
||||||
|
self._closing = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
if callable(getattr(self._serial, "cancel_read", None)):
|
||||||
|
self._serial.cancel_read()
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error while cancelling pending reads from the serial port")
|
||||||
|
|
||||||
|
try:
|
||||||
|
if callable(getattr(self._serial, "cancel_write", None)):
|
||||||
|
self._serial.cancel_write()
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error while cancelling pending writes to the serial port")
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._serial.close()
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error while closing the serial port")
|
||||||
|
error = True
|
||||||
|
|
||||||
|
self._serial = None
|
||||||
|
|
||||||
|
return not error
|
||||||
|
|
||||||
|
def do_read(self, size=None, timeout=None):
|
||||||
|
return self._serial.read(size=size)
|
||||||
|
|
||||||
|
def do_write(self, data):
|
||||||
|
written = 0
|
||||||
|
passes = 0
|
||||||
|
|
||||||
|
def try_to_write(d):
|
||||||
|
result = self._serial.write(d)
|
||||||
|
if result is None or not isinstance(result, int):
|
||||||
|
# probably some plugin not returning the written bytes, assuming all of them
|
||||||
|
return len(data)
|
||||||
|
else:
|
||||||
|
return result
|
||||||
|
|
||||||
|
while written < len(data):
|
||||||
|
to_send = data[written:]
|
||||||
|
old_written = written
|
||||||
|
|
||||||
|
try:
|
||||||
|
written += try_to_write(to_send)
|
||||||
|
except serial.SerialTimeoutException:
|
||||||
|
self._logger.warn("Serial timeout while writing to serial port, trying again.")
|
||||||
|
try:
|
||||||
|
# second try
|
||||||
|
written += try_to_write(to_send)
|
||||||
|
except Exception:
|
||||||
|
if not self._closing:
|
||||||
|
message = "Unexpected error while writing to serial port"
|
||||||
|
self._logger.exception(message)
|
||||||
|
self.disconnect(error=message)
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
if not self._closing:
|
||||||
|
message = "Unexpected error while writing to serial port"
|
||||||
|
self._logger.exception(message)
|
||||||
|
self.disconnect(error=message)
|
||||||
|
break
|
||||||
|
|
||||||
|
if old_written == written:
|
||||||
|
passes += 1
|
||||||
|
if passes > self.max_write_passes:
|
||||||
|
message = "Could not write anything to the serial port in {} tries, something appears to be " \
|
||||||
|
"wrong with the printer communication".format(self.max_write_passes)
|
||||||
|
self._logger.error(message)
|
||||||
|
self.disconnect(error=message)
|
||||||
|
break
|
||||||
|
|
||||||
|
@property
|
||||||
|
def in_waiting(self):
|
||||||
|
return getattr(self._serial, "in_waiting", 0)
|
||||||
|
|
||||||
|
def _default_serial_factory(self, **kwargs):
|
||||||
|
return serial.Serial(port=kwargs.get("port"),
|
||||||
|
baudrate=kwargs.get("baudrate"),
|
||||||
|
exclusive=kwargs.get("exclusive"),
|
||||||
|
parity=kwargs.get("parity"),
|
||||||
|
write_timeout=kwargs.get("write_timeout", 10) * 1000)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "SerialTransport"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# list ports
|
||||||
|
ports = SerialTransport.get_available_serial_ports()
|
||||||
|
for port in ports:
|
||||||
|
print(port.title + ": " + port.value)
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from octoprint.comm.transport import Transport, LineAwareTransportWrapper
|
||||||
|
from octoprint.comm.util.parameters import TextType, IntegerType
|
||||||
|
|
||||||
|
import socket
|
||||||
|
|
||||||
|
class TcpTransport(Transport):
|
||||||
|
|
||||||
|
name = "TCP Connection"
|
||||||
|
key = "tcpsocket"
|
||||||
|
message_integrity = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_connection_options(cls):
|
||||||
|
return [
|
||||||
|
TextType("host", "Host"),
|
||||||
|
IntegerType("port", "Port", min=1, max=65535)
|
||||||
|
]
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(TcpTransport, self).__init__()
|
||||||
|
|
||||||
|
self._socket = None
|
||||||
|
|
||||||
|
def create_connection(self, host=None, port=None):
|
||||||
|
if host is None:
|
||||||
|
raise ValueError("host must not be None")
|
||||||
|
if port is None:
|
||||||
|
raise ValueError("port must not be None")
|
||||||
|
|
||||||
|
self._socket = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||||
|
self._socket.connect((host, port))
|
||||||
|
self.set_current_args(host=host, port=port)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def drop_connection(self):
|
||||||
|
try:
|
||||||
|
self._socket.close()
|
||||||
|
return True
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Error closing socket")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def do_read(self, size=None, timeout=None):
|
||||||
|
if size is None:
|
||||||
|
size = 16
|
||||||
|
return self._socket.recv(size)
|
||||||
|
|
||||||
|
def do_write(self, data):
|
||||||
|
self._socket.sendall(data)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "TcpTransport"
|
||||||
|
|
||||||
|
class SerialOverTcpTransport(TcpTransport):
|
||||||
|
|
||||||
|
name = "Serial Connection over TCP"
|
||||||
|
key = "serialovertcpsocket"
|
||||||
|
message_integrity = False
|
||||||
Whitespace-only changes.
@@ -0,0 +1,194 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
|
from past.builtins import unicode
|
||||||
|
|
||||||
|
def get_param_dict(data, options):
|
||||||
|
options_by_name = dict((option.name, option) for option in options)
|
||||||
|
|
||||||
|
result = dict()
|
||||||
|
for key, value in data.items():
|
||||||
|
if not key in options_by_name:
|
||||||
|
continue
|
||||||
|
option = options_by_name[key]
|
||||||
|
result[key] = option.convert(value)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class ParamType(object):
|
||||||
|
type = "generic"
|
||||||
|
|
||||||
|
def __init__(self, name, title, default=None, advanced=False, help=None):
|
||||||
|
self.name = name
|
||||||
|
self.title = title
|
||||||
|
self.default = default
|
||||||
|
self.advanced = advanced
|
||||||
|
self.help = help
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return dict(name=self.name,
|
||||||
|
title=self.title,
|
||||||
|
default=self.default,
|
||||||
|
advanced=self.advanced,
|
||||||
|
help=self.help,
|
||||||
|
type=self.type)
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "{}(".format(self.__class__.__name__) \
|
||||||
|
+ ", ".join(["{}={!r}".format(key, value) for key, value in self.__dict__.items() if not key.startswith("_")]) + ")"
|
||||||
|
|
||||||
|
class TextType(ParamType):
|
||||||
|
type = "text"
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
if isinstance(value, bytes):
|
||||||
|
value = value.decode("utf-8", "replace")
|
||||||
|
return value
|
||||||
|
|
||||||
|
class IntegerType(ParamType):
|
||||||
|
type = "integer"
|
||||||
|
|
||||||
|
def __init__(self, name, title, min=None, max=None, unit=None, **kwargs):
|
||||||
|
self.min = min
|
||||||
|
self.max = max
|
||||||
|
self.unit = unit
|
||||||
|
ParamType.__init__(self, name, title, **kwargs)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = ParamType.as_dict(self)
|
||||||
|
result.update(dict(min=self.min,
|
||||||
|
max=self.max,
|
||||||
|
unit=self.unit))
|
||||||
|
return result
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
try:
|
||||||
|
value = int(value)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError("value {!r} is not a valid integer".format(value))
|
||||||
|
|
||||||
|
if self.min is not None and value < self.min:
|
||||||
|
raise ValueError("value {} is less than minimum valid value {}".format(value, self.min))
|
||||||
|
if self.max is not None and value > self.max:
|
||||||
|
raise ValueError("value {} is greater than maximum valid value {}".format(value, self.max))
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
class FloatType(ParamType):
|
||||||
|
type = "float"
|
||||||
|
|
||||||
|
def __init__(self, name, title, min=None, max=None, unit=None, **kwargs):
|
||||||
|
self.min = min
|
||||||
|
self.max = max
|
||||||
|
self.unit = unit
|
||||||
|
ParamType.__init__(self, name, title, **kwargs)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = ParamType.as_dict(self)
|
||||||
|
result.update(dict(min=self.min,
|
||||||
|
max=self.max,
|
||||||
|
unit=self.unit))
|
||||||
|
return result
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
try:
|
||||||
|
value = float(value)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError("value {!r} is not a valid float".format(value))
|
||||||
|
|
||||||
|
if self.min is not None and value < self.min:
|
||||||
|
raise ValueError("value {} is less than minimum valid value {}".format(value, self.min))
|
||||||
|
if self.max is not None and value > self.max:
|
||||||
|
raise ValueError("value {} is greater than maximum valid value {}".format(value, self.max))
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
class BooleanType(ParamType):
|
||||||
|
type = "boolean"
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
try:
|
||||||
|
value = bool(value)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError("value {!r} is not a valid boolean".format(value))
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
class ChoiceType(ParamType):
|
||||||
|
type = "choice"
|
||||||
|
|
||||||
|
def __init__(self, name, title, choices, **kwargs):
|
||||||
|
self.choices = choices
|
||||||
|
ParamType.__init__(self, name, title, **kwargs)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = ParamType.as_dict(self)
|
||||||
|
result.update(dict(choices=list(map(lambda x: x.as_dict(), self.choices))))
|
||||||
|
return result
|
||||||
|
|
||||||
|
class SmallChoiceType(ChoiceType):
|
||||||
|
type = "smallchoice"
|
||||||
|
|
||||||
|
class SuggestionType(ParamType):
|
||||||
|
type = "suggestion"
|
||||||
|
|
||||||
|
def __init__(self, name, title, suggestions, factory, **kwargs):
|
||||||
|
self.suggestions = suggestions
|
||||||
|
self.factory = factory
|
||||||
|
ParamType.__init__(self, name, title, **kwargs)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = ParamType.as_dict(self)
|
||||||
|
result.update(dict(suggestions=list(map(lambda x: x.as_dict(), self.suggestions))))
|
||||||
|
return result
|
||||||
|
|
||||||
|
class ListType(ParamType):
|
||||||
|
type = "list"
|
||||||
|
|
||||||
|
def __init__(self, name, title, factory, **kwargs):
|
||||||
|
self.factory = factory
|
||||||
|
ParamType.__init__(self, name, title, **kwargs)
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
if isinstance(value, unicode):
|
||||||
|
items = map(unicode.strip, value.split(","))
|
||||||
|
elif isinstance(value, list):
|
||||||
|
items = value
|
||||||
|
else:
|
||||||
|
raise ValueError("value {!r} must be either a comma-separated string or a list".format(value))
|
||||||
|
|
||||||
|
return list(map(self.factory, items))
|
||||||
|
|
||||||
|
class ParamGroup(ParamType):
|
||||||
|
type = "group"
|
||||||
|
|
||||||
|
def __init__(self, name, title, params, help=None, advanced=False):
|
||||||
|
ParamType.__init__(self, name, title, help=help, advanced=advanced)
|
||||||
|
self.params = params
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
result = ParamType.as_dict(self)
|
||||||
|
result["params"] = [x.as_dict() for x in self.params]
|
||||||
|
return result
|
||||||
|
|
||||||
|
def convert(self, value):
|
||||||
|
if not isinstance(value, dict):
|
||||||
|
raise ValueError("value {!r} must be a dict".format(value))
|
||||||
|
return dict((k, v.convert()) for k, v in value.items())
|
||||||
|
|
||||||
|
class Value(object):
|
||||||
|
def __init__(self, value, title=None, help=None):
|
||||||
|
self.value = value
|
||||||
|
self.title = title if title else value
|
||||||
|
self.help = help
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return dict(value=self.value,
|
||||||
|
title=self.title,
|
||||||
|
help=self.help)
|
||||||
+10
-9
@@ -1,12 +1,13 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Generic linux daemon base class
|
Generic linux daemon base class
|
||||||
|
|
||||||
Originally from http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/#c35
|
Originally from http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/#c35
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
import io, sys, os, time, signal
|
||||||
import sys, os, time, signal
|
|
||||||
|
|
||||||
class Daemon:
|
class Daemon:
|
||||||
"""
|
"""
|
||||||
@@ -60,9 +61,9 @@ class Daemon:
|
|||||||
# redirect standard file descriptors
|
# redirect standard file descriptors
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
si = open(os.devnull, 'r')
|
si = io.open(os.devnull, 'rt', encoding='utf-8')
|
||||||
so = open(os.devnull, 'a+')
|
so = io.open(os.devnull, 'at+', encoding='utf-8')
|
||||||
se = open(os.devnull, 'a+')
|
se = io.open(os.devnull, 'at+', encoding='utf-8')
|
||||||
|
|
||||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||||
@@ -133,7 +134,7 @@ class Daemon:
|
|||||||
except OSError:
|
except OSError:
|
||||||
try:
|
try:
|
||||||
self.remove_pidfile()
|
self.remove_pidfile()
|
||||||
except:
|
except Exception:
|
||||||
self.error("Daemon found not running, but could not remove stale pidfile")
|
self.error("Daemon found not running, but could not remove stale pidfile")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@@ -142,7 +143,7 @@ class Daemon:
|
|||||||
def get_pid(self):
|
def get_pid(self):
|
||||||
"""Get the pid from the pidfile."""
|
"""Get the pid from the pidfile."""
|
||||||
try:
|
try:
|
||||||
with open(self.pidfile,'r') as pf:
|
with io.open(self.pidfile,'rt', encoding='utf-8') as pf:
|
||||||
pid = int(pf.read().strip())
|
pid = int(pf.read().strip())
|
||||||
except (IOError, ValueError):
|
except (IOError, ValueError):
|
||||||
pid = None
|
pid = None
|
||||||
@@ -150,7 +151,7 @@ class Daemon:
|
|||||||
|
|
||||||
def set_pid(self, pid):
|
def set_pid(self, pid):
|
||||||
"""Write the pid to the pidfile."""
|
"""Write the pid to the pidfile."""
|
||||||
with open(self.pidfile,'w+') as f:
|
with io.open(self.pidfile,'wt+', encoding='utf-8') as f:
|
||||||
f.write(str(pid) + '\n')
|
f.write(str(pid) + '\n')
|
||||||
|
|
||||||
def remove_pidfile(self):
|
def remove_pidfile(self):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
@@ -7,7 +7,6 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms
|
|||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import yaml
|
import yaml
|
||||||
@@ -16,6 +15,7 @@ import psutil
|
|||||||
|
|
||||||
from octoprint.plugin import EnvironmentDetectionPlugin
|
from octoprint.plugin import EnvironmentDetectionPlugin
|
||||||
from octoprint.util.platform import get_os
|
from octoprint.util.platform import get_os
|
||||||
|
from octoprint.util.version import get_python_version_string
|
||||||
|
|
||||||
class EnvironmentDetector(object):
|
class EnvironmentDetector(object):
|
||||||
|
|
||||||
@@ -25,10 +25,15 @@ class EnvironmentDetector(object):
|
|||||||
self._cache = None
|
self._cache = None
|
||||||
self._cache_lock = threading.RLock()
|
self._cache_lock = threading.RLock()
|
||||||
|
|
||||||
self._environment_plugins = self._plugin_manager.get_implementations(EnvironmentDetectionPlugin)
|
|
||||||
|
|
||||||
self._logger = logging.getLogger(__name__)
|
self._logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._environment_plugins = self._plugin_manager.get_implementations(EnvironmentDetectionPlugin)
|
||||||
|
except Exception:
|
||||||
|
# just in case, see #3100...
|
||||||
|
self._logger.exception("There was an error fetching EnvironmentDetectionPlugins from the plugin manager")
|
||||||
|
self._environment_plugins = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def environment(self):
|
def environment(self):
|
||||||
with self._cache_lock:
|
with self._cache_lock:
|
||||||
@@ -54,7 +59,7 @@ class EnvironmentDetector(object):
|
|||||||
self.notify_plugins()
|
self.notify_plugins()
|
||||||
|
|
||||||
return environment
|
return environment
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Unexpected error while detecting environment")
|
self._logger.exception("Unexpected error while detecting environment")
|
||||||
with self._cache_lock:
|
with self._cache_lock:
|
||||||
self._cache = dict()
|
self._cache = dict()
|
||||||
@@ -70,22 +75,22 @@ class EnvironmentDetector(object):
|
|||||||
|
|
||||||
# determine python version
|
# determine python version
|
||||||
try:
|
try:
|
||||||
result["version"] = platform.python_version()
|
result["version"] = get_python_version_string()
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error detecting python version")
|
self._logger.exception("Error detecting python version")
|
||||||
|
|
||||||
# determine if we are running from a virtual environment
|
# determine if we are running from a virtual environment
|
||||||
try:
|
try:
|
||||||
if hasattr(sys, "real_prefix") or (hasattr(sys, "base_prefix") and os.path.realpath(sys.prefix) != os.path.realpath(sys.base_prefix)):
|
if hasattr(sys, "real_prefix") or (hasattr(sys, "base_prefix") and os.path.realpath(sys.prefix) != os.path.realpath(sys.base_prefix)):
|
||||||
result["virtualenv"] = sys.prefix
|
result["virtualenv"] = sys.prefix
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error detecting whether we are running in a virtual environment")
|
self._logger.exception("Error detecting whether we are running in a virtual environment")
|
||||||
|
|
||||||
# try to find pip version
|
# try to find pip version
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
result["pip"] = pkg_resources.get_distribution("pip").version
|
result["pip"] = pkg_resources.get_distribution("pip").version
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error detecting pip version")
|
self._logger.exception("Error detecting pip version")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -105,7 +110,7 @@ class EnvironmentDetector(object):
|
|||||||
result["freq"] = cpu_freq.max
|
result["freq"] = cpu_freq.max
|
||||||
if ram and hasattr(ram, "total"):
|
if ram and hasattr(ram, "total"):
|
||||||
result["ram"] = ram.total
|
result["ram"] = ram.total
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error while detecting hardware environment")
|
self._logger.exception("Error while detecting hardware environment")
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -118,9 +123,10 @@ class EnvironmentDetector(object):
|
|||||||
additional = implementation.get_additional_environment()
|
additional = implementation.get_additional_environment()
|
||||||
if additional is not None and isinstance(additional, dict) and len(additional):
|
if additional is not None and isinstance(additional, dict) and len(additional):
|
||||||
result[implementation._identifier] = additional
|
result[implementation._identifier] = additional
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error while fetching additional "
|
self._logger.exception("Error while fetching additional "
|
||||||
"environment data from plugin {}".format(implementation._identifier))
|
"environment data from plugin {}".format(implementation._identifier),
|
||||||
|
extra=dict(plugin=implementation._identifier))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -134,7 +140,7 @@ class EnvironmentDetector(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
_log(self._format())
|
_log(self._format())
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error logging detected environment")
|
self._logger.exception("Error logging detected environment")
|
||||||
|
|
||||||
def _format(self):
|
def _format(self):
|
||||||
@@ -145,10 +151,10 @@ class EnvironmentDetector(object):
|
|||||||
|
|
||||||
dumped_environment = yaml.safe_dump(environment,
|
dumped_environment = yaml.safe_dump(environment,
|
||||||
default_flow_style=False,
|
default_flow_style=False,
|
||||||
indent=" ",
|
indent=4,
|
||||||
allow_unicode=True).strip()
|
allow_unicode=True).strip()
|
||||||
environment_lines = "\n".join(map(lambda l: "| {}".format(l), dumped_environment.split("\n")))
|
environment_lines = "\n".join(map(lambda l: "| {}".format(l), dumped_environment.split("\n")))
|
||||||
return u"Detected environment is Python {} under {} ({}). Details:\n{}".format(environment["python"]["version"],
|
return "Detected environment is Python {} under {} ({}). Details:\n{}".format(environment["python"]["version"],
|
||||||
environment["os"]["id"].title(),
|
environment["os"]["id"].title(),
|
||||||
environment["os"]["platform"],
|
environment["os"]["platform"],
|
||||||
environment_lines)
|
environment_lines)
|
||||||
@@ -162,6 +168,6 @@ class EnvironmentDetector(object):
|
|||||||
for implementation in self._environment_plugins:
|
for implementation in self._environment_plugins:
|
||||||
try:
|
try:
|
||||||
implementation.on_environment_detected(environment)
|
implementation.on_environment_detected(environment)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error while sending environment "
|
self._logger.exception("Error while sending environment "
|
||||||
"detection result to plugin {}".format(implementation._identifier))
|
"detection result to plugin {}".format(implementation._identifier))
|
||||||
+60
-33
@@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__author__ = "Gina Häußge <osd@foosel.net>, Lars Norpchen"
|
__author__ = "Gina Häußge <osd@foosel.net>, Lars Norpchen"
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
@@ -14,6 +14,7 @@ except ImportError:
|
|||||||
import Queue as queue
|
import Queue as queue
|
||||||
import threading
|
import threading
|
||||||
import collections
|
import collections
|
||||||
|
import re
|
||||||
|
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
@@ -23,7 +24,7 @@ _instance = None
|
|||||||
|
|
||||||
|
|
||||||
def all_events():
|
def all_events():
|
||||||
return [getattr(Events, name) for name in Events.__dict__ if not name.startswith("__")]
|
return [getattr(Events, name) for name in Events.__dict__ if not name.startswith("_") and not name in ("register_event",)]
|
||||||
|
|
||||||
|
|
||||||
class Events(object):
|
class Events(object):
|
||||||
@@ -119,6 +120,23 @@ class Events(object):
|
|||||||
# Settings
|
# Settings
|
||||||
SETTINGS_UPDATED = "SettingsUpdated"
|
SETTINGS_UPDATED = "SettingsUpdated"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def register_event(cls, event, prefix=None):
|
||||||
|
name = cls._to_identifier(event)
|
||||||
|
if prefix:
|
||||||
|
event = prefix + event
|
||||||
|
name = cls._to_identifier(prefix) + name
|
||||||
|
setattr(cls, name, event)
|
||||||
|
return name, event
|
||||||
|
|
||||||
|
# based on https://stackoverflow.com/a/1176023
|
||||||
|
_first_cap_re = re.compile('(.)([A-Z][a-z]+)')
|
||||||
|
_all_cap_re = re.compile('([a-z0-9])([A-Z])')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _to_identifier(cls, name):
|
||||||
|
s1 = cls._first_cap_re.sub(r'\1_\2', name)
|
||||||
|
return cls._all_cap_re.sub(r'\1_\2', s1).upper()
|
||||||
|
|
||||||
def eventManager():
|
def eventManager():
|
||||||
global _instance
|
global _instance
|
||||||
@@ -135,6 +153,7 @@ class EventManager(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._registeredListeners = collections.defaultdict(list)
|
self._registeredListeners = collections.defaultdict(list)
|
||||||
self._logger = logging.getLogger(__name__)
|
self._logger = logging.getLogger(__name__)
|
||||||
|
self._logger_fire = logging.getLogger("{}.fire".format(__name__))
|
||||||
|
|
||||||
self._startup_signaled = False
|
self._startup_signaled = False
|
||||||
self._shutdown_signaled = False
|
self._shutdown_signaled = False
|
||||||
@@ -156,21 +175,20 @@ class EventManager(object):
|
|||||||
self._shutdown_signaled = True
|
self._shutdown_signaled = True
|
||||||
|
|
||||||
eventListeners = self._registeredListeners[event]
|
eventListeners = self._registeredListeners[event]
|
||||||
self._logger.debug("Firing event: %s (Payload: %r)" % (event, payload))
|
self._logger_fire.debug("Firing event: {} (Payload: {!r})".format(event, payload))
|
||||||
|
|
||||||
for listener in eventListeners:
|
for listener in eventListeners:
|
||||||
self._logger.debug("Sending action to %r" % listener)
|
self._logger.debug("Sending action to {!r}".format(listener))
|
||||||
try:
|
try:
|
||||||
listener(event, payload)
|
listener(event, payload)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Got an exception while sending event %s (Payload: %r) to %s" % (event, payload, listener))
|
self._logger.exception("Got an exception while sending event {} (Payload: {!r}) to {}".format(event, payload, listener))
|
||||||
|
|
||||||
octoprint.plugin.call_plugin(octoprint.plugin.types.EventHandlerPlugin,
|
octoprint.plugin.call_plugin(octoprint.plugin.types.EventHandlerPlugin,
|
||||||
"on_event",
|
"on_event",
|
||||||
args=(event, payload),
|
args=(event, payload))
|
||||||
initialized=True)
|
|
||||||
self._logger.info("Event loop shut down")
|
self._logger.info("Event loop shut down")
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Ooops, the event bus worker loop crashed")
|
self._logger.exception("Ooops, the event bus worker loop crashed")
|
||||||
|
|
||||||
def fire(self, event, payload=None):
|
def fire(self, event, payload=None):
|
||||||
@@ -211,7 +229,7 @@ class EventManager(object):
|
|||||||
|
|
||||||
if event == Events.UPDATED_FILES and "type" in payload and payload["type"] == "printables":
|
if event == Events.UPDATED_FILES and "type" in payload and payload["type"] == "printables":
|
||||||
# when sending UpdatedFiles with type "printables", also send another event with deprecated type "gcode"
|
# when sending UpdatedFiles with type "printables", also send another event with deprecated type "gcode"
|
||||||
# TODO v1.3.0 Remove again
|
# TODO v1.4.0 Remove again
|
||||||
import copy
|
import copy
|
||||||
legacy_payload = copy.deepcopy(payload)
|
legacy_payload = copy.deepcopy(payload)
|
||||||
legacy_payload["type"] = "gcode"
|
legacy_payload["type"] = "gcode"
|
||||||
@@ -227,19 +245,18 @@ class EventManager(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._registeredListeners[event].append(callback)
|
self._registeredListeners[event].append(callback)
|
||||||
self._logger.debug("Subscribed listener %r for event %s" % (callback, event))
|
self._logger.debug("Subscribed listener {!r} for event {}".format(callback, event))
|
||||||
|
|
||||||
def unsubscribe (self, event, callback):
|
def unsubscribe (self, event, callback):
|
||||||
"""
|
"""
|
||||||
Unsubscribe a listener from an event -- pass in the event name (as string) and the callback object
|
Unsubscribe a listener from an event -- pass in the event name (as string) and the callback object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not callback in self._registeredListeners[event]:
|
try:
|
||||||
# callback not subscribed to event, just return
|
|
||||||
return
|
|
||||||
|
|
||||||
self._registeredListeners[event].remove(callback)
|
self._registeredListeners[event].remove(callback)
|
||||||
self._logger.debug("Unsubscribed listener %r for event %s" % (callback, event))
|
except ValueError:
|
||||||
|
# not registered
|
||||||
|
pass
|
||||||
|
|
||||||
def join(self, timeout=None):
|
def join(self, timeout=None):
|
||||||
self._worker.join(timeout)
|
self._worker.join(timeout)
|
||||||
@@ -282,7 +299,7 @@ class DebugEventListener(GenericEventListener):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
GenericEventListener.__init__(self)
|
GenericEventListener.__init__(self)
|
||||||
|
|
||||||
events = filter(lambda x: not x.startswith("__"), dir(Events))
|
events = list(filter(lambda x: not x.startswith("__"), dir(Events)))
|
||||||
self.subscribe(events)
|
self.subscribe(events)
|
||||||
|
|
||||||
def eventCallback(self, event, payload):
|
def eventCallback(self, event, payload):
|
||||||
@@ -316,25 +333,32 @@ class CommandTrigger(GenericEventListener):
|
|||||||
self._logger.info("Invalid subscription definition, not a dictionary: {!r}".format(subscription))
|
self._logger.info("Invalid subscription definition, not a dictionary: {!r}".format(subscription))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not "event" in subscription.keys() or not "command" in subscription.keys() \
|
if not "event" in subscription or not "command" in subscription \
|
||||||
or not "type" in subscription.keys() or not subscription["type"] in ["system", "gcode"]:
|
or not "type" in subscription or not subscription["type"] in ["system", "gcode"]:
|
||||||
self._logger.info("Invalid command trigger, missing either event, type or command or type is invalid: {!r}".format(subscription))
|
self._logger.info("Invalid command trigger, missing either event, type or command or type is invalid: {!r}".format(subscription))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if "enabled" in subscription.keys() and not subscription["enabled"]:
|
if "enabled" in subscription and not subscription["enabled"]:
|
||||||
self._logger.info("Disabled command trigger: {!r}".format(subscription))
|
self._logger.info("Disabled command trigger: {!r}".format(subscription))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
event = subscription["event"]
|
events = subscription["event"]
|
||||||
command = subscription["command"]
|
command = subscription["command"]
|
||||||
commandType = subscription["type"]
|
commandType = subscription["type"]
|
||||||
debug = subscription["debug"] if "debug" in subscription else False
|
debug = subscription["debug"] if "debug" in subscription else False
|
||||||
|
|
||||||
if not event in self._subscriptions.keys():
|
# "event" in the configuration can be a string, or
|
||||||
|
# a list of strings. If it's the former, convert it
|
||||||
|
# into the latter.
|
||||||
|
if not isinstance(events, (tuple, list, set)):
|
||||||
|
events = [events]
|
||||||
|
|
||||||
|
for event in events:
|
||||||
|
if event not in self._subscriptions:
|
||||||
self._subscriptions[event] = []
|
self._subscriptions[event] = []
|
||||||
self._subscriptions[event].append((command, commandType, debug))
|
self._subscriptions[event].append((command, commandType, debug))
|
||||||
|
|
||||||
if not event in eventsToSubscribe:
|
if event not in eventsToSubscribe:
|
||||||
eventsToSubscribe.append(event)
|
eventsToSubscribe.append(event)
|
||||||
|
|
||||||
self.subscribe(eventsToSubscribe)
|
self.subscribe(eventsToSubscribe)
|
||||||
@@ -355,12 +379,12 @@ class CommandTrigger(GenericEventListener):
|
|||||||
if isinstance(command, (tuple, list, set)):
|
if isinstance(command, (tuple, list, set)):
|
||||||
processedCommand = []
|
processedCommand = []
|
||||||
for c in command:
|
for c in command:
|
||||||
processedCommand.append(self._processCommand(c, payload))
|
processedCommand.append(self._processCommand(c, event, payload))
|
||||||
else:
|
else:
|
||||||
processedCommand = self._processCommand(command, payload)
|
processedCommand = self._processCommand(command, event, payload)
|
||||||
self.executeCommand(processedCommand, commandType, debug=debug)
|
self.executeCommand(processedCommand, commandType, debug=debug)
|
||||||
except KeyError as e:
|
except KeyError:
|
||||||
self._logger.warn("There was an error processing one or more placeholders in the following command: %s" % command)
|
self._logger.warning("There was an error processing one or more placeholders in the following command: %s" % command)
|
||||||
|
|
||||||
def executeCommand(self, command, commandType, debug=False):
|
def executeCommand(self, command, commandType, debug=False):
|
||||||
if commandType == "system":
|
if commandType == "system":
|
||||||
@@ -388,10 +412,10 @@ class CommandTrigger(GenericEventListener):
|
|||||||
commandExecutioner(command)
|
commandExecutioner(command)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
if debug:
|
if debug:
|
||||||
self._logger.warn("Command failed with return code {}: {}".format(e.returncode, str(e)))
|
self._logger.warning("Command failed with return code {}: {}".format(e.returncode, str(e)))
|
||||||
else:
|
else:
|
||||||
self._logger.warn("Command failed with return code {}, enable debug logging on target 'octoprint.events' for details".format(e.returncode))
|
self._logger.warning("Command failed with return code {}, enable debug logging on target 'octoprint.events' for details".format(e.returncode))
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Command failed")
|
self._logger.exception("Command failed")
|
||||||
|
|
||||||
t = threading.Thread(target=process)
|
t = threading.Thread(target=process)
|
||||||
@@ -406,13 +430,14 @@ class CommandTrigger(GenericEventListener):
|
|||||||
self._logger.info("Executing GCode commands: %r" % command)
|
self._logger.info("Executing GCode commands: %r" % command)
|
||||||
self._printer.commands(commands)
|
self._printer.commands(commands)
|
||||||
|
|
||||||
def _processCommand(self, command, payload):
|
def _processCommand(self, command, event, payload):
|
||||||
"""
|
"""
|
||||||
Performs string substitutions in the command string based on a few current parameters.
|
Performs string substitutions in the command string based on a few current parameters.
|
||||||
|
|
||||||
The following substitutions are currently supported:
|
The following substitutions are currently supported:
|
||||||
|
|
||||||
- {__currentZ} : current Z position of the print head, or -1 if not available
|
- {__currentZ} : current Z position of the print head, or -1 if not available
|
||||||
|
- {__eventname} : the name of the event hook being triggered
|
||||||
- {__filename} : name of currently selected file, or "NO FILE" if no file is selected
|
- {__filename} : name of currently selected file, or "NO FILE" if no file is selected
|
||||||
- {__filepath} : path in origin location of currently selected file, or "NO FILE" if no file is selected
|
- {__filepath} : path in origin location of currently selected file, or "NO FILE" if no file is selected
|
||||||
- {__fileorigin} : origin of currently selected file, or "NO FILE" if no file is selected
|
- {__fileorigin} : origin of currently selected file, or "NO FILE" if no file is selected
|
||||||
@@ -429,11 +454,13 @@ class CommandTrigger(GenericEventListener):
|
|||||||
import json
|
import json
|
||||||
try:
|
try:
|
||||||
json_string = json.dumps(payload)
|
json_string = json.dumps(payload)
|
||||||
except:
|
except Exception:
|
||||||
|
self._logger.exception("JSON: Cannot dump %r", payload)
|
||||||
json_string = ""
|
json_string = ""
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
"__currentZ": "-1",
|
"__currentZ": "-1",
|
||||||
|
"__eventname": event,
|
||||||
"__filename": "NO FILE",
|
"__filename": "NO FILE",
|
||||||
"__filepath": "NO PATH",
|
"__filepath": "NO PATH",
|
||||||
"__progress": "0",
|
"__progress": "0",
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__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"
|
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
@@ -15,11 +16,11 @@ from octoprint.events import eventManager, Events
|
|||||||
|
|
||||||
from .destinations import FileDestinations
|
from .destinations import FileDestinations
|
||||||
from .analysis import QueueEntry, AnalysisQueue
|
from .analysis import QueueEntry, AnalysisQueue
|
||||||
from .storage import LocalFileStorage
|
|
||||||
from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
|
from .util import AbstractFileWrapper, StreamWrapper, DiskFileWrapper
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# noinspection PyCompatibility
|
||||||
from past.builtins import basestring
|
from past.builtins import basestring
|
||||||
|
|
||||||
ContentTypeMapping = namedtuple("ContentTypeMapping", "extensions, content_type")
|
ContentTypeMapping = namedtuple("ContentTypeMapping", "extensions, content_type")
|
||||||
@@ -30,10 +31,6 @@ extensions = dict(
|
|||||||
|
|
||||||
def full_extension_tree():
|
def full_extension_tree():
|
||||||
result = dict(
|
result = dict(
|
||||||
# extensions for 3d model files
|
|
||||||
model=dict(
|
|
||||||
stl=ContentTypeMapping(["stl"], "application/sla")
|
|
||||||
),
|
|
||||||
# extensions for printable machine code
|
# extensions for printable machine code
|
||||||
machinecode=dict(
|
machinecode=dict(
|
||||||
gcode=ContentTypeMapping(["gcode", "gco", "g"], "text/plain")
|
gcode=ContentTypeMapping(["gcode", "gco", "g"], "text/plain")
|
||||||
@@ -74,6 +71,18 @@ def full_extension_tree():
|
|||||||
else:
|
else:
|
||||||
return merged
|
return merged
|
||||||
|
|
||||||
|
slicer_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.SlicerPlugin)
|
||||||
|
for plugin in slicer_plugins:
|
||||||
|
try:
|
||||||
|
plugin_result = plugin.get_slicer_extension_tree()
|
||||||
|
if plugin_result is None or not isinstance(plugin_result, dict):
|
||||||
|
continue
|
||||||
|
result = octoprint.util.dict_merge(result, plugin_result, leaf_merger=leaf_merger)
|
||||||
|
except Exception:
|
||||||
|
logging.getLogger(__name__).exception("Exception while retrieving additional extension "
|
||||||
|
"tree entries from SlicerPlugin {name}".format(name=plugin._identifier),
|
||||||
|
extra=dict(plugin=plugin._identifier))
|
||||||
|
|
||||||
extension_tree_hooks = octoprint.plugin.plugin_manager().get_hooks("octoprint.filemanager.extension_tree")
|
extension_tree_hooks = octoprint.plugin.plugin_manager().get_hooks("octoprint.filemanager.extension_tree")
|
||||||
for name, hook in extension_tree_hooks.items():
|
for name, hook in extension_tree_hooks.items():
|
||||||
try:
|
try:
|
||||||
@@ -81,13 +90,15 @@ def full_extension_tree():
|
|||||||
if hook_result is None or not isinstance(hook_result, dict):
|
if hook_result is None or not isinstance(hook_result, dict):
|
||||||
continue
|
continue
|
||||||
result = octoprint.util.dict_merge(result, hook_result, leaf_merger=leaf_merger)
|
result = octoprint.util.dict_merge(result, hook_result, leaf_merger=leaf_merger)
|
||||||
except:
|
except Exception:
|
||||||
logging.getLogger(__name__).exception("Exception while retrieving additional extension tree entries from hook {name}".format(name=name))
|
logging.getLogger(__name__).exception("Exception while retrieving additional extension "
|
||||||
|
"tree entries from hook {name}".format(name=name),
|
||||||
|
extra=dict(plugin=name))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def get_extensions(type, subtree=None):
|
def get_extensions(type, subtree=None):
|
||||||
if not subtree:
|
if subtree is None:
|
||||||
subtree = full_extension_tree()
|
subtree = full_extension_tree()
|
||||||
|
|
||||||
for key, value in subtree.items():
|
for key, value in subtree.items():
|
||||||
@@ -101,7 +112,7 @@ def get_extensions(type, subtree=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_all_extensions(subtree=None):
|
def get_all_extensions(subtree=None):
|
||||||
if not subtree:
|
if subtree is None:
|
||||||
subtree = full_extension_tree()
|
subtree = full_extension_tree()
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
@@ -120,7 +131,7 @@ def get_all_extensions(subtree=None):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def get_path_for_extension(extension, subtree=None):
|
def get_path_for_extension(extension, subtree=None):
|
||||||
if not subtree:
|
if subtree is None:
|
||||||
subtree = full_extension_tree()
|
subtree = full_extension_tree()
|
||||||
|
|
||||||
for key, value in subtree.items():
|
for key, value in subtree.items():
|
||||||
@@ -136,7 +147,7 @@ def get_path_for_extension(extension, subtree=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_content_type_mapping_for_extension(extension, subtree=None):
|
def get_content_type_mapping_for_extension(extension, subtree=None):
|
||||||
if not subtree:
|
if subtree is None:
|
||||||
subtree = full_extension_tree()
|
subtree = full_extension_tree()
|
||||||
|
|
||||||
for key, value in subtree.items():
|
for key, value in subtree.items():
|
||||||
@@ -331,21 +342,21 @@ class FileManager(object):
|
|||||||
gcode_location=dest_location))
|
gcode_location=dest_location))
|
||||||
else:
|
else:
|
||||||
source_meta = self.get_metadata(source_location, source_path)
|
source_meta = self.get_metadata(source_location, source_path)
|
||||||
hash = source_meta["hash"]
|
hash = source_meta.get("hash", "n/a")
|
||||||
|
|
||||||
import io
|
import io
|
||||||
links = [("model", dict(name=source_path))]
|
links = [("model", dict(name=source_path))]
|
||||||
_, stl_name = self.split_path(source_location, source_path)
|
_, stl_name = self.split_path(source_location, source_path)
|
||||||
file_obj = StreamWrapper(os.path.basename(dest_path),
|
file_obj = StreamWrapper(os.path.basename(dest_path),
|
||||||
io.BytesIO(u";Generated from {stl_name} {hash}\n".format(**locals()).encode("ascii", "replace")),
|
io.BytesIO(";Generated from {stl_name} (hash: {hash})\n".format(**locals()).encode("ascii", "replace")),
|
||||||
io.FileIO(tmp_path, "rb"))
|
io.FileIO(tmp_path, 'rb'))
|
||||||
|
|
||||||
printer_profile = self._printer_profile_manager.get(printer_profile_id)
|
printer_profile = self._printer_profile_manager.get(printer_profile_id)
|
||||||
self.add_file(dest_location, dest_path, file_obj,
|
self.add_file(dest_location, dest_path, file_obj,
|
||||||
display=display, links=links, allow_overwrite=True,
|
display=display, links=links, allow_overwrite=True,
|
||||||
printer_profile=printer_profile, analysis=_analysis)
|
printer_profile=printer_profile, analysis=_analysis)
|
||||||
|
|
||||||
end_time = time.time()
|
end_time = octoprint.util.monotonic_time()
|
||||||
eventManager().fire(Events.SLICING_DONE, dict(stl=source_path,
|
eventManager().fire(Events.SLICING_DONE, dict(stl=source_path,
|
||||||
stl_location=source_location,
|
stl_location=source_location,
|
||||||
gcode=dest_path,
|
gcode=dest_path,
|
||||||
@@ -370,8 +381,7 @@ class FileManager(object):
|
|||||||
|
|
||||||
slicer = self._slicing_manager.get_slicer(slicer_name)
|
slicer = self._slicing_manager.get_slicer(slicer_name)
|
||||||
|
|
||||||
import time
|
start_time = octoprint.util.monotonic_time()
|
||||||
start_time = time.time()
|
|
||||||
eventManager().fire(Events.SLICING_STARTED, {"stl": source_path,
|
eventManager().fire(Events.SLICING_STARTED, {"stl": source_path,
|
||||||
"stl_location": source_location,
|
"stl_location": source_location,
|
||||||
"gcode": dest_path,
|
"gcode": dest_path,
|
||||||
@@ -415,16 +425,19 @@ class FileManager(object):
|
|||||||
if self._last_slicing_progress != progress_int:
|
if self._last_slicing_progress != progress_int:
|
||||||
self._last_slicing_progress = progress_int
|
self._last_slicing_progress = progress_int
|
||||||
for callback in self._slicing_progress_callbacks:
|
for callback in self._slicing_progress_callbacks:
|
||||||
try: callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
try:
|
||||||
except: self._logger.exception("Exception while pushing slicing progress")
|
callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
||||||
|
except Exception:
|
||||||
|
self._logger.exception("Exception while pushing slicing progress")
|
||||||
|
|
||||||
if progress_int:
|
if progress_int:
|
||||||
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
|
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
|
||||||
for plugin in self._progress_plugins:
|
for plugin in self._progress_plugins:
|
||||||
try:
|
try:
|
||||||
plugin.on_slicing_progress(slicer, source_location, source_path, dest_location, dest_path, progress)
|
plugin.on_slicing_progress(slicer, source_location, source_path, dest_location, dest_path, progress)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Exception while sending slicing progress to plugin %s" % plugin._identifier)
|
self._logger.exception("Exception while sending slicing progress to plugin %s" % plugin._identifier,
|
||||||
|
extra=dict(plugin=plugin._identifier))
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
thread = threading.Thread(target=call_plugins, args=(slicer, source_location, source_path, dest_location, dest_path, progress_int))
|
thread = threading.Thread(target=call_plugins, args=(slicer, source_location, source_path, dest_location, dest_path, progress_int))
|
||||||
@@ -446,8 +459,8 @@ class FileManager(object):
|
|||||||
|
|
||||||
def list_files(self, destinations=None, path=None, filter=None, recursive=None):
|
def list_files(self, destinations=None, path=None, filter=None, recursive=None):
|
||||||
if not destinations:
|
if not destinations:
|
||||||
destinations = self._storage_managers.keys()
|
destinations = list(self._storage_managers.keys())
|
||||||
if isinstance(destinations, (str, unicode, basestring)):
|
if isinstance(destinations, basestring):
|
||||||
destinations = [destinations]
|
destinations = [destinations]
|
||||||
|
|
||||||
result = dict()
|
result = dict()
|
||||||
@@ -459,11 +472,11 @@ class FileManager(object):
|
|||||||
if printer_profile is None:
|
if printer_profile is None:
|
||||||
printer_profile = self._printer_profile_manager.get_current_or_default()
|
printer_profile = self._printer_profile_manager.get_current_or_default()
|
||||||
|
|
||||||
for hook in self._preprocessor_hooks.values():
|
for name, hook in self._preprocessor_hooks.items():
|
||||||
try:
|
try:
|
||||||
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error when calling preprocessor hook {}, ignoring".format(hook))
|
self._logger.exception("Error when calling preprocessor hook for plugin {}, ignoring".format(name), extra=dict(plugin=name))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if hook_file_object is not None:
|
if hook_file_object is not None:
|
||||||
@@ -589,6 +602,9 @@ class FileManager(object):
|
|||||||
name=dst_name))
|
name=dst_name))
|
||||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||||
|
|
||||||
|
def create_print_job(self, destination, path, user=None):
|
||||||
|
return self._storage(destination).create_print_job(path, user=user)
|
||||||
|
|
||||||
def has_analysis(self, destination, path):
|
def has_analysis(self, destination, path):
|
||||||
return self._storage(destination).has_analysis(path)
|
return self._storage(destination).has_analysis(path)
|
||||||
|
|
||||||
@@ -602,11 +618,14 @@ class FileManager(object):
|
|||||||
self._storage(destination).remove_link(path, rel, data)
|
self._storage(destination).remove_link(path, rel, data)
|
||||||
|
|
||||||
def log_print(self, destination, path, timestamp, print_time, success, printer_profile):
|
def log_print(self, destination, path, timestamp, print_time, success, printer_profile):
|
||||||
|
try:
|
||||||
try:
|
try:
|
||||||
if success:
|
if success:
|
||||||
self._storage(destination).add_history(path, dict(timestamp=timestamp, printTime=print_time, success=success, printerProfile=printer_profile))
|
self._storage(destination).add_history(path, dict(timestamp=timestamp, printTime=print_time, success=success, printerProfile=printer_profile))
|
||||||
else:
|
else:
|
||||||
self._storage(destination).add_history(path, dict(timestamp=timestamp, success=success, printerProfile=printer_profile))
|
self._storage(destination).add_history(path, dict(timestamp=timestamp, success=success, printerProfile=printer_profile))
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
eventManager().fire(Events.METADATA_STATISTICS_UPDATED, dict(storage=destination, path=path))
|
eventManager().fire(Events.METADATA_STATISTICS_UPDATED, dict(storage=destination, path=path))
|
||||||
except NoSuchStorage:
|
except NoSuchStorage:
|
||||||
# if there's no storage configured where to log the print, we'll just not log it
|
# if there's no storage configured where to log the print, we'll just not log it
|
||||||
@@ -622,9 +641,9 @@ class FileManager(object):
|
|||||||
pos=pos,
|
pos=pos,
|
||||||
date=time.time())
|
date=time.time())
|
||||||
try:
|
try:
|
||||||
with atomic_write(self._recovery_file, max_permissions=0o666) as f:
|
with atomic_write(self._recovery_file, mode='wt', max_permissions=0o666) as f:
|
||||||
yaml.safe_dump(data, stream=f, default_flow_style=False, indent=" ", allow_unicode=True)
|
yaml.safe_dump(data, stream=f, default_flow_style=False, indent=2, allow_unicode=True)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Could not write recovery data to file {}".format(self._recovery_file))
|
self._logger.exception("Could not write recovery data to file {}".format(self._recovery_file))
|
||||||
|
|
||||||
def delete_recovery_data(self):
|
def delete_recovery_data(self):
|
||||||
@@ -633,7 +652,7 @@ class FileManager(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(self._recovery_file)
|
os.remove(self._recovery_file)
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Error deleting recovery data file {}".format(self._recovery_file))
|
self._logger.exception("Error deleting recovery data file {}".format(self._recovery_file))
|
||||||
|
|
||||||
def get_recovery_data(self):
|
def get_recovery_data(self):
|
||||||
@@ -642,10 +661,10 @@ class FileManager(object):
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
try:
|
try:
|
||||||
with open(self._recovery_file) as f:
|
with io.open(self._recovery_file, 'rt', encoding='utf-8') as f:
|
||||||
data = yaml.safe_load(f)
|
data = yaml.safe_load(f)
|
||||||
return data
|
return data
|
||||||
except:
|
except Exception:
|
||||||
self._logger.exception("Could not read recovery data from file {}".format(self._recovery_file))
|
self._logger.exception("Could not read recovery data from file {}".format(self._recovery_file))
|
||||||
self.delete_recovery_data()
|
self.delete_recovery_data()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
@@ -18,6 +18,7 @@ import time
|
|||||||
|
|
||||||
from octoprint.events import Events, eventManager
|
from octoprint.events import Events, eventManager
|
||||||
from octoprint.settings import settings
|
from octoprint.settings import settings
|
||||||
|
from octoprint.util import monotonic_time
|
||||||
|
|
||||||
|
|
||||||
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
|
class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")):
|
||||||
@@ -95,16 +96,16 @@ class AnalysisQueue(object):
|
|||||||
self._queues[entry.type].dequeue(entry.location, entry.path)
|
self._queues[entry.type].dequeue(entry.location, entry.path)
|
||||||
|
|
||||||
def dequeue_folder(self, destination, path):
|
def dequeue_folder(self, destination, path):
|
||||||
for queue in self._queues.values():
|
for q in self._queues.values():
|
||||||
queue.dequeue_folder(destination, path)
|
q.dequeue_folder(destination, path)
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
for queue in self._queues.values():
|
for q in self._queues.values():
|
||||||
queue.pause()
|
q.pause()
|
||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
for queue in self._queues.values():
|
for q in self._queues.values():
|
||||||
queue.resume()
|
q.resume()
|
||||||
|
|
||||||
def _analysis_finished(self, entry, result):
|
def _analysis_finished(self, entry, result):
|
||||||
for callback in self._callbacks:
|
for callback in self._callbacks:
|
||||||
@@ -249,7 +250,7 @@ class AbstractAnalysisQueue(object):
|
|||||||
self._current_progress = 0
|
self._current_progress = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
start_time = time.time()
|
start_time = monotonic_time()
|
||||||
self._logger.info("Starting analysis of {}".format(entry))
|
self._logger.info("Starting analysis of {}".format(entry))
|
||||||
eventManager().fire(Events.METADATA_ANALYSIS_STARTED, {"name": entry.name,
|
eventManager().fire(Events.METADATA_ANALYSIS_STARTED, {"name": entry.name,
|
||||||
"path": entry.path,
|
"path": entry.path,
|
||||||
@@ -262,7 +263,7 @@ class AbstractAnalysisQueue(object):
|
|||||||
result = self._do_analysis(high_priority=high_priority)
|
result = self._do_analysis(high_priority=high_priority)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
result = self._do_analysis()
|
result = self._do_analysis()
|
||||||
self._logger.info("Analysis of entry {} finished, needed {:.2f}s".format(entry, time.time() - start_time))
|
self._logger.info("Analysis of entry {} finished, needed {:.2f}s".format(entry, monotonic_time() - start_time))
|
||||||
self._finished_callback(self._current, result)
|
self._finished_callback(self._current, result)
|
||||||
finally:
|
finally:
|
||||||
self._current = None
|
self._current = None
|
||||||
@@ -382,7 +383,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
|||||||
|
|
||||||
if not p.commands[0].process:
|
if not p.commands[0].process:
|
||||||
# the process might have been set to None in case of any exception
|
# 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)))
|
raise RuntimeError("Error while trying to run command {}".format(" ".join(command)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# let's wait for stuff to finish
|
# let's wait for stuff to finish
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# coding=utf-8
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||||
|
|
||||||
class FileDestinations(object):
|
class FileDestinations(object):
|
||||||
|
|||||||
Loaded 100 of 421 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user