Compare commits
275
Commits
maintenance
...
devel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fe43d38c8 | ||
|
|
73d944ba68 | ||
|
|
b324da152b | ||
|
|
4040c4fd8a | ||
|
|
57b18a3427 | ||
|
|
80e637de8c | ||
|
|
fc5d2cb5d9 | ||
|
|
01e9bc959a | ||
|
|
02939367da | ||
|
|
8082c11571 | ||
|
|
38ae0c9ac5 | ||
|
|
1763f31bda | ||
|
|
12a6f8ec42 | ||
|
|
5e9f0caa75 | ||
|
|
8c8442055e | ||
|
|
17b371c4a0 | ||
|
|
1b9a4fb8a6 | ||
|
|
8a9a541862 | ||
|
|
159df4c3f7 | ||
|
|
5f38635843 | ||
|
|
5e40b5106b | ||
|
|
445d2dc600 | ||
|
|
c5db904012 | ||
|
|
b83c978579 | ||
|
|
27021b5255 | ||
|
|
261f06c34e | ||
|
|
b2e37cd73e | ||
|
|
87d6ddb7ee | ||
|
|
38af40a212 | ||
|
|
403b4ed51b | ||
|
|
85b1442c53 | ||
|
|
b827d87e73 | ||
|
|
3f9d1e3867 | ||
|
|
4c47329b6d | ||
|
|
913ef0bbf5 | ||
|
|
bb8a7d6ec3 | ||
|
|
9719054888 | ||
|
|
b1793d19e8 | ||
|
|
5ee83611b0 | ||
|
|
5c7e9e42fb | ||
|
|
59b17eb380 | ||
|
|
7af6be5253 | ||
|
|
938a74003b | ||
|
|
b150cb07ed | ||
|
|
a94061a10c | ||
|
|
354d07883f | ||
|
|
6c5f288995 | ||
|
|
f3b5f35c1c | ||
|
|
a1e2904530 | ||
|
|
a768f4cafe | ||
|
|
d8dd36302b | ||
|
|
10516511ef | ||
|
|
6638e9aebf | ||
|
|
c1570d088b | ||
|
|
650d2b5489 | ||
|
|
f89e10a561 | ||
|
|
4febdd6800 | ||
|
|
2ba74a1117 | ||
|
|
5118088ad6 | ||
|
|
628df9e8cd | ||
|
|
eb336bce31 | ||
|
|
c3c555330c | ||
|
|
bba932242f | ||
|
|
894985ef8f | ||
|
|
ae62e85f0d | ||
|
|
f75f763538 | ||
|
|
daf5881962 | ||
|
|
ffa6e978a4 | ||
|
|
8879a0eb04 | ||
|
|
4b11098eef | ||
|
|
eba158d53d | ||
|
|
63ec0d5bca | ||
|
|
6cbd1df8e0 | ||
|
|
0ed259e1a8 | ||
|
|
fa750bf971 | ||
|
|
67b075836a | ||
|
|
a2fb012067 | ||
|
|
118e6f762e | ||
|
|
9a153bf133 | ||
|
|
a8e9105769 | ||
|
|
7f11c4c769 | ||
|
|
659f08ce71 | ||
|
|
f993ab05af | ||
|
|
cdde1bbc07 | ||
|
|
6fd26a5b75 | ||
|
|
26ad4f7269 | ||
|
|
c1a2c0ef7a | ||
|
|
a9d0856b3d | ||
|
|
7bc15efc13 | ||
|
|
c33f8c2d08 | ||
|
|
c76fee7804 | ||
|
|
5ad1ae91a0 | ||
|
|
952946c3ee | ||
|
|
e8cbe8396c | ||
|
|
7510a20d0f | ||
|
|
1b9c92bbc5 | ||
|
|
20c60d6c1a | ||
|
|
801be9c77d | ||
|
|
2712412c66 | ||
|
|
ac61ed6bb7 | ||
|
|
8bf68fae87 | ||
|
|
d837648b9a | ||
|
|
c7d9a4b7b5 | ||
|
|
4ae5ef037c | ||
|
|
e524da88d6 | ||
|
|
378839891e | ||
|
|
1056e454bd | ||
|
|
8a7cc67e11 | ||
|
|
0f42545db0 | ||
|
|
eb26009782 | ||
|
|
22d42d4864 | ||
|
|
f36c773291 | ||
|
|
655df5937a | ||
|
|
294140d938 | ||
|
|
d281b17d67 | ||
|
|
0e5b1ec1d3 | ||
|
|
026ea53145 | ||
|
|
df37e6296d | ||
|
|
49bc29fca3 | ||
|
|
4d12707f07 | ||
|
|
fe1db28bdf | ||
|
|
06db48c560 | ||
|
|
32bc6f84ca | ||
|
|
938149b65e | ||
|
|
26f032a5b6 | ||
|
|
0fd1f53230 | ||
|
|
5cdfc14cb6 | ||
|
|
23a186ebe8 | ||
|
|
71116c3641 | ||
|
|
04bc60bd8a | ||
|
|
385a7b6bc8 | ||
|
|
c0c9bf0ea5 | ||
|
|
977e30c174 | ||
|
|
e552ca9f97 | ||
|
|
33dbf409b6 | ||
|
|
94903b4a75 | ||
|
|
ac28eadf03 | ||
|
|
fc1c4da261 | ||
|
|
35a86650fc | ||
|
|
145482d581 | ||
|
|
e711ffd4c0 | ||
|
|
30739dd375 | ||
|
|
caa8962c36 | ||
|
|
21b2dde2c3 | ||
|
|
5f47af505a | ||
|
|
e83adf3978 | ||
|
|
fcc4bc7d03 | ||
|
|
5e7ccce736 | ||
|
|
581ce02504 | ||
|
|
fe719623ed | ||
|
|
53995cca88 | ||
|
|
2598625805 | ||
|
|
1697287693 | ||
|
|
30161e98b5 | ||
|
|
ff494fad8f | ||
|
|
8505a977d6 | ||
|
|
c28629bb40 | ||
|
|
eb61020395 | ||
|
|
8153d70da7 | ||
|
|
0dba51181c | ||
|
|
c2842694ce | ||
|
|
43a62bf6f3 | ||
|
|
bcea4839f6 | ||
|
|
54454deaf3 | ||
|
|
e3df0ea934 | ||
|
|
b3affac9e5 | ||
|
|
6026f066e0 | ||
|
|
6a697e9013 | ||
|
|
75ec0c887e | ||
|
|
9b0f60da05 | ||
|
|
3e6e7d3a6a | ||
|
|
4156ccc08f | ||
|
|
28ec474ed4 | ||
|
|
7f5700e0f9 | ||
|
|
e41b8e3090 | ||
|
|
635156cf7a | ||
|
|
cbe72cc1ec | ||
|
|
b202c6db54 | ||
|
|
3778bcc423 | ||
|
|
49621a65b0 | ||
|
|
d80f67df9a | ||
|
|
6cb550e9f4 | ||
|
|
55158bdef9 | ||
|
|
a34202fdec | ||
|
|
944441ec7d | ||
|
|
beef176ac0 | ||
|
|
f97db4465f | ||
|
|
262983840a | ||
|
|
bb2c3273c0 | ||
|
|
d8fa8e3029 | ||
|
|
ed21f75acf | ||
|
|
d2452c007e | ||
|
|
9625695467 | ||
|
|
7668afcff7 | ||
|
|
fd2ece0f13 | ||
|
|
a71f6fcd40 | ||
|
|
ca3b78d140 | ||
|
|
5b7bc6cb91 | ||
|
|
0fd00ef5fc | ||
|
|
2a6f7478c3 | ||
|
|
5e620bcdfe | ||
|
|
dcd3592fd4 | ||
|
|
7f56d47dbc | ||
|
|
d041e1ce97 | ||
|
|
ad0c0ddfe1 | ||
|
|
0308150048 | ||
|
|
35e35d92a6 | ||
|
|
95441dafd4 | ||
|
|
f7ad7d93a5 | ||
|
|
9c8691eeb7 | ||
|
|
a89d03b794 | ||
|
|
7810a622a9 | ||
|
|
bb8fafaacb | ||
|
|
977e021b36 | ||
|
|
00fb7daecf | ||
|
|
f66b318022 | ||
|
|
97ec0493d1 | ||
|
|
669660c2fb | ||
|
|
1b5d24cb9d | ||
|
|
d60bb43e07 | ||
|
|
86db7d8ec4 | ||
|
|
43541ceebc | ||
|
|
8ef57e2ab7 | ||
|
|
4b0c1fe63c | ||
|
|
90c0675234 | ||
|
|
b8bbdbdc64 | ||
|
|
5325b32cf2 | ||
|
|
29994cd63f | ||
|
|
718f89fdbd | ||
|
|
c02c1452e6 | ||
|
|
55ddfdd314 | ||
|
|
d5e4cf3a1a | ||
|
|
b73f62b433 | ||
|
|
5102c3b5e0 | ||
|
|
fe87062768 | ||
|
|
21a30001fa | ||
|
|
e1d55e00af | ||
|
|
d98a6da7b2 | ||
|
|
f510cc4218 | ||
|
|
ac347c4e06 | ||
|
|
d2298a8092 | ||
|
|
e45e97f9ac | ||
|
|
292aa99543 | ||
|
|
61a08d26b2 | ||
|
|
9f0ae77f95 | ||
|
|
100764b03e | ||
|
|
c715751bc6 | ||
|
|
18e6bfc7f8 | ||
|
|
0bdedffac3 | ||
|
|
86e6cd595f | ||
|
|
5faff84a9d | ||
|
|
656b0edb90 | ||
|
|
7f042b1c55 | ||
|
|
c574947e93 | ||
|
|
0949975fcd | ||
|
|
a24dad6bdb | ||
|
|
025fb23fed | ||
|
|
46beea8972 | ||
|
|
67378e1d55 | ||
|
|
95ab458677 | ||
|
|
49b40a4af3 | ||
|
|
99293b9ccf | ||
|
|
c6155e9279 | ||
|
|
9897fc2d56 | ||
|
|
35ae4af868 | ||
|
|
95c8902d96 | ||
|
|
1afd7d532c | ||
|
|
eba336221e | ||
|
|
2bb0e0edfc | ||
|
|
248352ae5c | ||
|
|
7ee8c5d284 | ||
|
|
54b3d770e7 | ||
|
|
288f6ac900 | ||
|
|
08b48e92d3 | ||
|
|
fcf60b2a9a |
No files matched your search
@@ -19,7 +19,6 @@ win32-Cura-*
|
|||||||
linux-Cura-*
|
linux-Cura-*
|
||||||
*.iml
|
*.iml
|
||||||
Printrun
|
Printrun
|
||||||
=======
|
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ date of first contribution):
|
|||||||
* [Christian Würthner](https://github.com/crysxd)
|
* [Christian Würthner](https://github.com/crysxd)
|
||||||
* [Maciej Urbański](https://github.com/rooterkyberian)
|
* [Maciej Urbański](https://github.com/rooterkyberian)
|
||||||
* [Adam Wolf](https://github.com/adamwolf)
|
* [Adam Wolf](https://github.com/adamwolf)
|
||||||
|
* [Carey Metcalfe](https://github.com/pR0Ps)
|
||||||
* [Didi Kohen](https://github.com/kohend)
|
* [Didi Kohen](https://github.com/kohend)
|
||||||
* [Taylor Talkington](https://github.com/The-EG)
|
* [Taylor Talkington](https://github.com/The-EG)
|
||||||
* [Carey Metcalfe](https://github.com/pR0Ps)
|
* [Carey Metcalfe](https://github.com/pR0Ps)
|
||||||
|
|||||||
+2
-17
@@ -12,11 +12,11 @@ Authorization
|
|||||||
=============
|
=============
|
||||||
|
|
||||||
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
|
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
|
||||||
key can be either the globally configured one, a user specific one or an app and user specific one as generated by the
|
key can be either a user specific one or an app and user specific one as generated 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 API key must either be supplied in the custom HTTP header ``X-Api-Key``, e.g.
|
The API key must either be supplied in the custom HTTP header ``X-Api-Key``, e.g.
|
||||||
|
|
||||||
@@ -52,21 +52,6 @@ will be denied with a :http:statuscode:`403`.
|
|||||||
If :ref:`Access Control <sec-features-access_control>` is disabled, OctoPrint will treat any unauthenticated anonymous requests and thus also requests
|
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!
|
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:
|
|
||||||
.. figure:: ../images/settings-global-api-key.png
|
|
||||||
:align: center
|
|
||||||
:alt: Global API key in the API settings
|
|
||||||
|
|
||||||
The global API key can be found in the "API" settings
|
|
||||||
|
|
||||||
.. _fig-api-general-userapikey:
|
.. _fig-api-general-userapikey:
|
||||||
.. figure:: ../images/settings-user-api-key.png
|
.. figure:: ../images/settings-user-api-key.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|||||||
@@ -71,23 +71,6 @@ Save settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.. _sec-api-settings-generateapikey:
|
|
||||||
|
|
||||||
Regenerate the system wide API key
|
|
||||||
==================================
|
|
||||||
|
|
||||||
.. http:post:: /api/settings/apikey
|
|
||||||
|
|
||||||
Generates a new system wide API key.
|
|
||||||
|
|
||||||
Does not expect a body. Will return the generated API key as ``apikey``
|
|
||||||
property in the JSON object contained in the response body.
|
|
||||||
|
|
||||||
Requires admin rights.
|
|
||||||
|
|
||||||
:status 200: No error
|
|
||||||
:status 403: No admin rights
|
|
||||||
|
|
||||||
.. _sec-api-settings-fetchtemplaatedata:
|
.. _sec-api-settings-fetchtemplaatedata:
|
||||||
|
|
||||||
Fetch template data
|
Fetch template data
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ installed:
|
|||||||
|
|
||||||
sudo apt-get install python3 python3-pip python3-dev python3-setuptools python3-virtualenv git libyaml-dev build-essential
|
sudo apt-get install python3 python3-pip python3-dev python3-setuptools python3-virtualenv git libyaml-dev build-essential
|
||||||
|
|
||||||
|
.. todo::
|
||||||
|
|
||||||
|
Using a Linux distribution that doesn't use ``apt``? Please send a
|
||||||
|
`Pull Request <https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md#pull-requests>`_ to get the necessary
|
||||||
|
steps into this guide!
|
||||||
|
|
||||||
Then:
|
Then:
|
||||||
|
|
||||||
.. code-block:: none
|
.. code-block:: none
|
||||||
@@ -96,12 +102,6 @@ Then:
|
|||||||
git config blame.ignoreRevsFile .git-blame-ignore-revs
|
git config blame.ignoreRevsFile .git-blame-ignore-revs
|
||||||
|
|
||||||
|
|
||||||
.. todo::
|
|
||||||
|
|
||||||
Using a Linux distribution that doesn't use ``apt``? Please send a
|
|
||||||
`Pull Request <https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md#pull-requests>`_ to get the necessary
|
|
||||||
steps into this guide!
|
|
||||||
|
|
||||||
.. _sec-development-environment-windows:
|
.. _sec-development-environment-windows:
|
||||||
|
|
||||||
Windows
|
Windows
|
||||||
@@ -112,20 +112,19 @@ location, please substitute accordingly.
|
|||||||
|
|
||||||
First download & install:
|
First download & install:
|
||||||
|
|
||||||
* `Git for Windows <https://git-for-windows.github.io/>`_
|
* `The current Python 3.8 Windows x86 executable installer <https://www.python.org/downloads/windows/>`_
|
||||||
|
|
||||||
* `Latest *stable* Python 3 release from python.org <https://www.python.org/downloads/windows/>`_
|
|
||||||
|
|
||||||
* 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
|
||||||
* it's recommended to install Python 3 into ``C:\Python3`` - if you select
|
* it's recommended to install Python 3 into ``C:\Python3`` - if you select
|
||||||
different install locations please substitute accordingly
|
different install locations please substitute accordingly
|
||||||
* it's also recommended to install for all users
|
* it's also recommended to install for all users
|
||||||
|
|
||||||
* `Build Tools For Visual Studio 2019 <https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019>`_
|
* `Build Tools for Visual Studio 2019 <https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019>`_
|
||||||
|
|
||||||
* install "C++ build tools" and ensure the latest versions of "MSVCv142 - VS 2019 C++ x64/x86 build tools" and
|
* install "C++ build tools" and ensure the latest versions of "MSVCv142 - VS 2019 C++ x64/x86 build tools" and
|
||||||
"Windows 10 SDK" are checked under individual components.
|
"Windows 10 SDK" are checked.
|
||||||
|
|
||||||
|
* `Git for Windows <https://git-scm.com/downloads>`_
|
||||||
|
|
||||||
Open the Git Bash you just installed and in that:
|
Open the Git Bash you just installed and in that:
|
||||||
|
|
||||||
@@ -150,7 +149,6 @@ Optional but recommended tools
|
|||||||
These are some tools that are recommended but not required to have on hand:
|
These are some tools that are recommended but not required to have on hand:
|
||||||
|
|
||||||
* `Visual Studio Code <https://code.visualstudio.com/download>`_
|
* `Visual Studio Code <https://code.visualstudio.com/download>`_
|
||||||
|
|
||||||
* `Windows Terminal <https://github.com/microsoft/terminal>`_
|
* `Windows Terminal <https://github.com/microsoft/terminal>`_
|
||||||
|
|
||||||
Add the following profile to ``profiles.list`` in the settings, that will allow you to
|
Add the following profile to ``profiles.list`` in the settings, that will allow you to
|
||||||
@@ -306,7 +304,7 @@ PyCharm
|
|||||||
* disable "Auto-save edited files to trigger the watched"
|
* disable "Auto-save edited files to trigger the watched"
|
||||||
* enable "Trigger the watched on external changes"
|
* enable "Trigger the watched on external changes"
|
||||||
|
|
||||||
To switch between virtual environments (e.g. Python 3.7 and 3.8), all you need to do now is change the Project Default Interpreter and restart
|
To switch between virtual environments (e.g. various Python 3 versions), all you need to do now is change the Project Default Interpreter and restart
|
||||||
OctoPrint. On current PyCharm versions you can do that right from a small selection field in the footer of the IDE.
|
OctoPrint. On current PyCharm versions you can do that right from a small selection field in the footer of the IDE.
|
||||||
Otherwise go through Settings.
|
Otherwise go through Settings.
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ The following example defines a control for enabling the cooling fan with a vari
|
|||||||
feedback evaluation for the result of the M114 "Get Position" gcode inside a section named "Reporting" and finally
|
feedback evaluation for the result of the M114 "Get Position" gcode inside a section named "Reporting" and finally
|
||||||
a GCODE script including user input.
|
a GCODE script including user input.
|
||||||
|
|
||||||
.. code-block-ext:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
controls:
|
controls:
|
||||||
- name: Fan
|
- name: Fan
|
||||||
@@ -181,7 +181,7 @@ Controls
|
|||||||
additional input fields. ``command``/``commands`` may contain placeholders to be replaced by the values obtained
|
additional input fields. ``command``/``commands`` may contain placeholders to be replaced by the values obtained
|
||||||
from the user for the defined input fields:
|
from the user for the defined input fields:
|
||||||
|
|
||||||
.. code-block-ext:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
name: Enable Fan
|
name: Enable Fan
|
||||||
command: M106 S%(speed)s
|
command: M106 S%(speed)s
|
||||||
@@ -253,7 +253,7 @@ Examples
|
|||||||
Parameterized GCODE Script
|
Parameterized GCODE Script
|
||||||
..........................
|
..........................
|
||||||
|
|
||||||
.. code-block-ext:: yaml
|
.. code-block:: yaml
|
||||||
:caption: Control definition in ~/.octoprint/config.yaml
|
:caption: Control definition in ~/.octoprint/config.yaml
|
||||||
:name: code-features-custom_controls-example-gcode_script-config_yaml
|
:name: code-features-custom_controls-example-gcode_script-config_yaml
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ Parameterized GCODE Script
|
|||||||
min: 1
|
min: 1
|
||||||
step: 1
|
step: 1
|
||||||
|
|
||||||
.. code-block-ext:: jinja
|
.. code-block:: jinja
|
||||||
:caption: ~/.octoprint/scripts/gcode/custom/dance.gco
|
:caption: ~/.octoprint/scripts/gcode/custom/dance.gco
|
||||||
:name: code-features-custom_controls-example-gcode_script-dance_gco
|
:name: code-features-custom_controls-example-gcode_script-dance_gco
|
||||||
|
|
||||||
|
|||||||
@@ -270,6 +270,6 @@ def setup(app):
|
|||||||
|
|
||||||
# custom node type
|
# custom node type
|
||||||
handler = (visit_literal_block_ext, depart_literal_block_ext)
|
handler = (visit_literal_block_ext, depart_literal_block_ext)
|
||||||
app.add_node(literal_block_ext, html=handler, latex=handler, text=handler)
|
app.add_node(literal_block_ext, html=handler)
|
||||||
|
|
||||||
return {"version": "0.1"}
|
return {"version": "0.1"}
|
||||||
@@ -117,4 +117,4 @@ def setup(app):
|
|||||||
app.add_directive("onlineinclude", OnlineIncludeDirective)
|
app.add_directive("onlineinclude", OnlineIncludeDirective)
|
||||||
|
|
||||||
handler = (visit_onlineinclude, depart_onlineinclude)
|
handler = (visit_onlineinclude, depart_onlineinclude)
|
||||||
app.add_node(OnlineIncludeDirective, html=handler, latex=handler, text=handler)
|
app.add_node(OnlineIncludeDirective, html=handler)
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import logging as log
|
import logging as log
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import octoprint
|
import octoprint
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,10 @@ class UserManager(GroupChangeListener):
|
|||||||
def anonymous_user_factory(self):
|
def anonymous_user_factory(self):
|
||||||
return AnonymousUser([self._group_manager.guest_group])
|
return AnonymousUser([self._group_manager.guest_group])
|
||||||
|
|
||||||
def api_user_factory(self):
|
def cli_user_factory(self):
|
||||||
return ApiUser([self._group_manager.admin_group, self._group_manager.user_group])
|
return LocalCliUser(
|
||||||
|
[self._group_manager.admin_group, self._group_manager.user_group]
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
@@ -1102,11 +1104,6 @@ class MethodReplacedByBooleanProperty:
|
|||||||
return self._attr != other
|
return self._attr != other
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
# Python 3
|
|
||||||
return self._attr
|
|
||||||
|
|
||||||
def __nonzero__(self):
|
|
||||||
# Python 2
|
|
||||||
return self._attr
|
return self._attr
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
@@ -1495,9 +1492,9 @@ class SessionUser(wrapt.ObjectProxy):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
##~~ User object to use when global api key is used to access the API
|
##~~ User object to use when CLI key is used
|
||||||
|
|
||||||
|
|
||||||
class ApiUser(User):
|
class LocalCliUser(User):
|
||||||
def __init__(self, groups):
|
def __init__(self, groups):
|
||||||
User.__init__(self, "_api", "", True, [], groups)
|
User.__init__(self, "_cli", "", True, [], groups)
|
||||||
@@ -151,7 +151,6 @@ def gcode_command(
|
|||||||
"happened"
|
"happened"
|
||||||
)
|
)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
click.echo("RESULTS:")
|
click.echo("RESULTS:")
|
||||||
click.echo(yaml.dump(interpreter.get_result(), pretty=True))
|
click.echo(yaml.dump(interpreter.get_result(), pretty=True))
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
|
|||||||
__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 json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@@ -33,18 +34,23 @@ def create_client(
|
|||||||
https=False,
|
https=False,
|
||||||
prefix=None,
|
prefix=None,
|
||||||
):
|
):
|
||||||
assert host is not None or settings is not None
|
|
||||||
assert port is not None or settings is not None
|
assert port is not None or settings is not None
|
||||||
assert apikey is not None or settings is not None
|
assert apikey is not None or settings is not None
|
||||||
|
|
||||||
if not host:
|
if not host:
|
||||||
host = settings.get(["server", "host"])
|
host = "127.0.0.1"
|
||||||
host = host if host != "0.0.0.0" else "127.0.0.1"
|
|
||||||
if not port:
|
if not port:
|
||||||
port = settings.getInt(["server", "port"])
|
port = settings.getInt(["server", "port"])
|
||||||
|
|
||||||
if not apikey:
|
if not apikey:
|
||||||
apikey = settings.get(["api", "key"])
|
cli_key_file = os.path.join(settings.getBaseFolder("generated"), "cli.key")
|
||||||
|
try:
|
||||||
|
with open(cli_key_file, encoding="utf8") as f:
|
||||||
|
apikey = f.readline()
|
||||||
|
except Exception:
|
||||||
|
raise FatalStartupError(
|
||||||
|
f"Can not authenticate with server at {host}:{port}, no key"
|
||||||
|
)
|
||||||
|
|
||||||
baseurl = octoprint_client.build_base_url(
|
baseurl = octoprint_client.build_base_url(
|
||||||
https=https,
|
https=https,
|
||||||
@@ -79,7 +85,7 @@ def cli(ctx, apikey, host, port, httpuser, httppass, https, prefix):
|
|||||||
"""Basic API client."""
|
"""Basic API client."""
|
||||||
try:
|
try:
|
||||||
settings = None
|
settings = None
|
||||||
if not host or not port or not apikey:
|
if not port or not apikey:
|
||||||
settings = init_settings(
|
settings = init_settings(
|
||||||
get_ctx_obj_option(ctx, "basedir", None),
|
get_ctx_obj_option(ctx, "basedir", None),
|
||||||
get_ctx_obj_option(ctx, "configfile", None),
|
get_ctx_obj_option(ctx, "configfile", None),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ __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 io
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@@ -439,8 +440,6 @@ class FileManager:
|
|||||||
source_meta = self.get_metadata(source_location, source_path)
|
source_meta = self.get_metadata(source_location, source_path)
|
||||||
hash = source_meta.get("hash", "n/a")
|
hash = source_meta.get("hash", "n/a")
|
||||||
|
|
||||||
import io
|
|
||||||
|
|
||||||
links = [("model", {"name": source_path})]
|
links = [("model", {"name": source_path})]
|
||||||
_, stl_name = self.split_path(source_location, source_path)
|
_, stl_name = self.split_path(source_location, source_path)
|
||||||
file_obj = StreamWrapper(
|
file_obj = StreamWrapper(
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Union
|
||||||
|
|
||||||
from octoprint.logging import filters # noqa: F401
|
from octoprint.logging import filters # noqa: F401
|
||||||
from octoprint.logging import handlers # noqa: F401
|
from octoprint.logging import handlers # noqa: F401
|
||||||
|
|
||||||
@@ -142,7 +144,7 @@ def get_divider_line(c, message=None, length=78, indent=3):
|
|||||||
return c * indent + " " + message
|
return c * indent + " " + message
|
||||||
|
|
||||||
|
|
||||||
def prefix_multilines(text: str, prefix: str = ": ") -> str:
|
def prefix_multilines(text: Union[str, bytes], prefix: str = ": ") -> str:
|
||||||
from octoprint.util import to_unicode
|
from octoprint.util import to_unicode
|
||||||
|
|
||||||
lines = text.splitlines()
|
lines = text.splitlines()
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import datetime
|
|
||||||
|
|
||||||
__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 copy
|
import copy
|
||||||
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#!/bin/env python
|
#!/bin/env python
|
||||||
|
|
||||||
__author__ = "Gina Haeussge <osd@foosel.net>"
|
__author__ = "Gina Haeussge <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"
|
||||||
|
|||||||
@@ -935,9 +935,9 @@ class VirtualPrinter:
|
|||||||
|
|
||||||
_timeout = 0
|
_timeout = 0
|
||||||
if matchP:
|
if matchP:
|
||||||
_timeout = float(matchP.group(1)) / 1000
|
_timeout = int(matchP.group(1)) / 1000
|
||||||
elif matchS:
|
elif matchS:
|
||||||
_timeout = float(matchS.group(1))
|
_timeout = int(matchS.group(1))
|
||||||
|
|
||||||
if self._sendBusy and self._busyInterval > 0:
|
if self._sendBusy and self._busyInterval > 0:
|
||||||
until = time.monotonic() + _timeout
|
until = time.monotonic() + _timeout
|
||||||
@@ -1697,11 +1697,11 @@ class VirtualPrinter:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.targetTemp[tool] = float(re.search(r"S([0-9]+)", line).group(1))
|
self.targetTemp[tool] = int(re.search(r"S([0-9]+)", line).group(1))
|
||||||
except Exception:
|
except Exception:
|
||||||
if support_r:
|
if support_r:
|
||||||
try:
|
try:
|
||||||
self.targetTemp[tool] = float(re.search(r"R([0-9]+)", line).group(1))
|
self.targetTemp[tool] = int(re.search(r"R([0-9]+)", line).group(1))
|
||||||
only_wait_if_higher = False
|
only_wait_if_higher = False
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
@@ -1717,11 +1717,11 @@ class VirtualPrinter:
|
|||||||
|
|
||||||
only_wait_if_higher = True
|
only_wait_if_higher = True
|
||||||
try:
|
try:
|
||||||
self.bedTargetTemp = float(re.search(r"S([0-9]+)", line).group(1))
|
self.bedTargetTemp = int(re.search(r"S([0-9]+)", line).group(1))
|
||||||
except Exception:
|
except Exception:
|
||||||
if support_r:
|
if support_r:
|
||||||
try:
|
try:
|
||||||
self.bedTargetTemp = float(re.search(r"R([0-9]+)", line).group(1))
|
self.bedTargetTemp = int(re.search(r"R([0-9]+)", line).group(1))
|
||||||
only_wait_if_higher = False
|
only_wait_if_higher = False
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
@@ -1737,11 +1737,11 @@ class VirtualPrinter:
|
|||||||
|
|
||||||
only_wait_if_higher = True
|
only_wait_if_higher = True
|
||||||
try:
|
try:
|
||||||
self.chamberTargetTemp = float(re.search("S([0-9]+)", line).group(1))
|
self.chamberTargetTemp = int(re.search("S([0-9]+)", line).group(1))
|
||||||
except Exception:
|
except Exception:
|
||||||
if support_r:
|
if support_r:
|
||||||
try:
|
try:
|
||||||
self.chamberTargetTemp = float(re.search("R([0-9]+)", line).group(1))
|
self.chamberTargetTemp = int(re.search("R([0-9]+)", line).group(1))
|
||||||
only_wait_if_higher = False
|
only_wait_if_higher = False
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class PrintTimeEstimator:
|
|||||||
# by that divided by the sd status polling interval
|
# by that divided by the sd status polling interval
|
||||||
interval = settings().getFloat(["serial", "timeout", "sdStatus"])
|
interval = settings().getFloat(["serial", "timeout", "sdStatus"])
|
||||||
if interval <= 0:
|
if interval <= 0:
|
||||||
interval = 1.0
|
interval = 1
|
||||||
rolling_window = int(15 // interval)
|
rolling_window = int(15 // interval)
|
||||||
if rolling_window < 1:
|
if rolling_window < 1:
|
||||||
rolling_window = 1
|
rolling_window = 1
|
||||||
|
|||||||
@@ -1,18 +1,11 @@
|
|||||||
__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) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|
||||||
from typing import Dict, Optional
|
|
||||||
|
|
||||||
from octoprint.schema import BaseModel
|
from octoprint.schema import BaseModel
|
||||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||||
|
|
||||||
|
|
||||||
@with_attrs_docs
|
@with_attrs_docs
|
||||||
class ApiConfig(BaseModel):
|
class ApiConfig(BaseModel):
|
||||||
key: Optional[str] = None
|
|
||||||
"""Global API key, deprecated, use User API keys instead. Unset by default, will be generated on first run."""
|
|
||||||
|
|
||||||
apps: Dict[str, str] = {}
|
|
||||||
|
|
||||||
allowCrossOrigin: bool = False
|
allowCrossOrigin: bool = False
|
||||||
"""Whether to allow cross origin access to the API or not."""
|
"""Whether to allow cross origin access to the API or not."""
|
||||||
@@ -96,6 +96,8 @@ jsonDecoder = None
|
|||||||
connectivityChecker = None
|
connectivityChecker = None
|
||||||
environmentDetector = None
|
environmentDetector = None
|
||||||
|
|
||||||
|
cli_key = None
|
||||||
|
|
||||||
|
|
||||||
class OctoPrintAnonymousIdentity(AnonymousIdentity):
|
class OctoPrintAnonymousIdentity(AnonymousIdentity):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -201,8 +203,8 @@ def load_user(id):
|
|||||||
if id is None:
|
if id is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if id == "_api":
|
if id == "_cli":
|
||||||
return userManager.api_user_factory()
|
return userManager.cli_user_factory()
|
||||||
|
|
||||||
if session and "usersession.id" in session:
|
if session and "usersession.id" in session:
|
||||||
sessionid = session["usersession.id"]
|
sessionid = session["usersession.id"]
|
||||||
@@ -335,6 +337,7 @@ class Server:
|
|||||||
global environmentDetector
|
global environmentDetector
|
||||||
global debug
|
global debug
|
||||||
global safe_mode
|
global safe_mode
|
||||||
|
global cli_key
|
||||||
|
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
from tornado.web import Application
|
from tornado.web import Application
|
||||||
@@ -381,6 +384,7 @@ class Server:
|
|||||||
util.tornado.fix_websocket_check_origin()
|
util.tornado.fix_websocket_check_origin()
|
||||||
util.tornado.enable_per_message_deflate_extension()
|
util.tornado.enable_per_message_deflate_extension()
|
||||||
|
|
||||||
|
cli_key = self._setup_cli_key()
|
||||||
self._setup_mimetypes()
|
self._setup_mimetypes()
|
||||||
|
|
||||||
# setup app
|
# setup app
|
||||||
@@ -1999,7 +2003,7 @@ class Server:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self._logger.exception(
|
self._logger.exception(
|
||||||
f"Error while registering blueprint of plugin {plugin}, ignoring it",
|
f"Error while registering assets of plugin {plugin}, ignoring it",
|
||||||
extra={"plugin": plugin},
|
extra={"plugin": plugin},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -2100,6 +2104,16 @@ class Server:
|
|||||||
extra={"plugin": name},
|
extra={"plugin": name},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _setup_cli_key(self):
|
||||||
|
from octoprint.util import generate_api_key
|
||||||
|
|
||||||
|
cli_key_file = os.path.join(self._settings.getBaseFolder("generated"), "cli.key")
|
||||||
|
cli_key = generate_api_key()
|
||||||
|
with open(cli_key_file, "w", encoding="utf8") as f:
|
||||||
|
f.write(cli_key)
|
||||||
|
|
||||||
|
return cli_key
|
||||||
|
|
||||||
def _setup_mimetypes(self):
|
def _setup_mimetypes(self):
|
||||||
# Safety measures for Windows... apparently the mimetypes module takes its translation from the windows
|
# Safety measures for Windows... apparently the mimetypes module takes its translation from the windows
|
||||||
# registry, and if for some weird reason that gets borked the reported MIME types can be all over the place.
|
# registry, and if for some weird reason that gets borked the reported MIME types can be all over the place.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import octoprint.plugin
|
|||||||
import octoprint.util
|
import octoprint.util
|
||||||
from octoprint.access.permissions import Permissions
|
from octoprint.access.permissions import Permissions
|
||||||
from octoprint.server import pluginManager, printer, userManager
|
from octoprint.server import pluginManager, printer, userManager
|
||||||
from octoprint.server.api import NO_CONTENT, api
|
from octoprint.server.api import api
|
||||||
from octoprint.server.util.flask import no_firstrun_access, with_revalidation_checking
|
from octoprint.server.util.flask import no_firstrun_access, with_revalidation_checking
|
||||||
from octoprint.settings import settings, valid_boolean_trues
|
from octoprint.settings import settings, valid_boolean_trues
|
||||||
from octoprint.timelapse import configure_timelapse
|
from octoprint.timelapse import configure_timelapse
|
||||||
@@ -118,7 +118,6 @@ def getSettings():
|
|||||||
|
|
||||||
data = {
|
data = {
|
||||||
"api": {
|
"api": {
|
||||||
"key": s.get(["api", "key"]) if Permissions.ADMIN.can() else None,
|
|
||||||
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"]),
|
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"]),
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
@@ -456,22 +455,6 @@ def setSettings():
|
|||||||
return getSettings()
|
return getSettings()
|
||||||
|
|
||||||
|
|
||||||
@api.route("/settings/apikey", methods=["POST"])
|
|
||||||
@no_firstrun_access
|
|
||||||
@Permissions.SETTINGS.require(403)
|
|
||||||
def generateApiKey():
|
|
||||||
apikey = settings().generateApiKey()
|
|
||||||
return jsonify(apikey=apikey)
|
|
||||||
|
|
||||||
|
|
||||||
@api.route("/settings/apikey", methods=["DELETE"])
|
|
||||||
@no_firstrun_access
|
|
||||||
@Permissions.SETTINGS.require(403)
|
|
||||||
def deleteApiKey():
|
|
||||||
settings().deleteApiKey()
|
|
||||||
return NO_CONTENT
|
|
||||||
|
|
||||||
|
|
||||||
@api.route("/settings/templates", methods=["GET"])
|
@api.route("/settings/templates", methods=["GET"])
|
||||||
@no_firstrun_access
|
@no_firstrun_access
|
||||||
@Permissions.SETTINGS.require(403)
|
@Permissions.SETTINGS.require(403)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ PY3 = sys.version_info >= (3, 0) # should now always be True, kept for plugins
|
|||||||
|
|
||||||
import flask as _flask
|
import flask as _flask
|
||||||
import flask_login
|
import flask_login
|
||||||
|
import netaddr
|
||||||
|
|
||||||
import octoprint.server
|
import octoprint.server
|
||||||
import octoprint.timelapse
|
import octoprint.timelapse
|
||||||
@@ -66,7 +67,8 @@ def loginUserFromApiKey():
|
|||||||
if not apikey:
|
if not apikey:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
user = get_user_for_apikey(apikey)
|
remote_address = flask.get_remote_address(_flask.request)
|
||||||
|
user = get_user_for_apikey(apikey, remote_address=remote_address)
|
||||||
if user is None:
|
if user is None:
|
||||||
# invalid API key = no API key
|
# invalid API key = no API key
|
||||||
raise InvalidApiKeyException("Invalid API key")
|
raise InvalidApiKeyException("Invalid API key")
|
||||||
@@ -219,11 +221,16 @@ def optionsAllowOrigin(request):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
def get_user_for_apikey(apikey):
|
def get_user_for_apikey(apikey, remote_address=None):
|
||||||
if apikey is not None:
|
if apikey is not None:
|
||||||
if apikey == settings().get(["api", "key"]):
|
if apikey == octoprint.server.cli_key and remote_address:
|
||||||
# master key was used
|
try:
|
||||||
return octoprint.server.userManager.api_user_factory()
|
remote_address = netaddr.IPAddress(remote_address)
|
||||||
|
if remote_address.is_loopback():
|
||||||
|
# CLI key was used on loopback
|
||||||
|
return octoprint.server.userManager.cli_user_factory()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
user = octoprint.server.userManager.find_user(apikey=apikey)
|
user = octoprint.server.userManager.find_user(apikey=apikey)
|
||||||
if user is not None:
|
if user is not None:
|
||||||
|
|||||||
@@ -1541,9 +1541,12 @@ def get_flask_user_from_request(request):
|
|||||||
user = None
|
user = None
|
||||||
|
|
||||||
apikey = octoprint.server.util.get_api_key(request)
|
apikey = octoprint.server.util.get_api_key(request)
|
||||||
|
remote_address = get_remote_address(request)
|
||||||
if apikey is not None:
|
if apikey is not None:
|
||||||
# user from api key?
|
# user from api key?
|
||||||
user = octoprint.server.util.get_user_for_apikey(apikey)
|
user = octoprint.server.util.get_user_for_apikey(
|
||||||
|
apikey, remote_address=remote_address
|
||||||
|
)
|
||||||
|
|
||||||
if user is None:
|
if user is None:
|
||||||
# user still None -> current session user
|
# user still None -> current session user
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ _PLUGIN_BUNDLE_WRAPPER_PREFIX = """// JS assets for plugin {plugin}
|
|||||||
"""
|
"""
|
||||||
_PLUGIN_BUNDLE_WRAPPER_SUFFIX = """
|
_PLUGIN_BUNDLE_WRAPPER_SUFFIX = """
|
||||||
}} catch (error) {{
|
}} catch (error) {{
|
||||||
log.error("Error in JS assets for plugin {plugin}:", (error.stack || error));
|
log.error("Error in JS assets for plugin {plugin}:", `${{exc.message}}\n${{exc.stack || exc}}`);
|
||||||
}}
|
}}
|
||||||
}})();
|
}})();
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ from octoprint.util import (
|
|||||||
deprecated,
|
deprecated,
|
||||||
dict_merge,
|
dict_merge,
|
||||||
fast_deepcopy,
|
fast_deepcopy,
|
||||||
generate_api_key,
|
|
||||||
is_hidden_path,
|
is_hidden_path,
|
||||||
time_this,
|
time_this,
|
||||||
yaml,
|
yaml,
|
||||||
@@ -555,10 +554,6 @@ class Settings:
|
|||||||
self._configfile = os.path.join(self._basedir, "config.yaml")
|
self._configfile = os.path.join(self._basedir, "config.yaml")
|
||||||
self.load(migrate=True)
|
self.load(migrate=True)
|
||||||
|
|
||||||
apikey = self.get(["api", "key"])
|
|
||||||
if not apikey or apikey == "n/a":
|
|
||||||
self.generateApiKey()
|
|
||||||
|
|
||||||
self._script_env = self._init_script_templating()
|
self._script_env = self._init_script_templating()
|
||||||
|
|
||||||
self.sanity_check_folders(
|
self.sanity_check_folders(
|
||||||
@@ -2105,16 +2100,6 @@ class Settings:
|
|||||||
with atomic_write(filename, mode="wt", max_permissions=0o666) as f:
|
with atomic_write(filename, mode="wt", max_permissions=0o666) as f:
|
||||||
f.write(script)
|
f.write(script)
|
||||||
|
|
||||||
def generateApiKey(self):
|
|
||||||
apikey = generate_api_key()
|
|
||||||
self.set(["api", "key"], apikey)
|
|
||||||
self.save(force=True)
|
|
||||||
return apikey
|
|
||||||
|
|
||||||
def deleteApiKey(self):
|
|
||||||
self.set(["api", "key"], None)
|
|
||||||
self.save(force=True)
|
|
||||||
|
|
||||||
|
|
||||||
def _default_basedir(applicationName):
|
def _default_basedir(applicationName):
|
||||||
# taken from http://stackoverflow.com/questions/1084697/how-do-i-store-desktop-application-data-in-a-cross-platform-way-for-python
|
# taken from http://stackoverflow.com/questions/1084697/how-do-i-store-desktop-application-data-in-a-cross-platform-way-for-python
|
||||||
|
|||||||
@@ -1367,7 +1367,7 @@ function setOnViewModelIf(viewModel, key, value, condition) {
|
|||||||
"on view model",
|
"on view model",
|
||||||
viewModel.constructor.name,
|
viewModel.constructor.name,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1392,7 +1392,7 @@ function callViewModelsIf(allViewModels, method, condition, callback) {
|
|||||||
"on view model",
|
"on view model",
|
||||||
viewModel.constructor.name,
|
viewModel.constructor.name,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1476,7 +1476,7 @@ function callViewModelIf(viewModel, method, condition, callback, raiseErrors) {
|
|||||||
"on view model",
|
"on view model",
|
||||||
viewModel.constructor.name,
|
viewModel.constructor.name,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -506,7 +506,12 @@ $(function () {
|
|||||||
if (typeof Sentry !== "undefined") {
|
if (typeof Sentry !== "undefined") {
|
||||||
Sentry.captureException(exc);
|
Sentry.captureException(exc);
|
||||||
}
|
}
|
||||||
log.error("Error instantiating", viewModel.name, ":", exc.stack || exc);
|
log.error(
|
||||||
|
"Error instantiating",
|
||||||
|
viewModel.name,
|
||||||
|
":",
|
||||||
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,7 +799,7 @@ $(function () {
|
|||||||
"Error calling onBeforeBinding on view model",
|
"Error calling onBeforeBinding on view model",
|
||||||
viewModel.constructor.name,
|
viewModel.constructor.name,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -829,7 +834,7 @@ $(function () {
|
|||||||
"of view model",
|
"of view model",
|
||||||
viewModel.constructor.name,
|
viewModel.constructor.name,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -887,7 +892,7 @@ $(function () {
|
|||||||
"to target",
|
"to target",
|
||||||
target,
|
target,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -911,7 +916,7 @@ $(function () {
|
|||||||
"Error while processing view model",
|
"Error while processing view model",
|
||||||
name,
|
name,
|
||||||
"for binding:",
|
"for binding:",
|
||||||
exc.stack || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -252,8 +252,8 @@ $(function () {
|
|||||||
|
|
||||||
self.userString = ko.pureComputed(function () {
|
self.userString = ko.pureComputed(function () {
|
||||||
var user = self.user();
|
var user = self.user();
|
||||||
if (user === "_api") {
|
if (user === "_cli") {
|
||||||
user = "API client";
|
user = "CLI";
|
||||||
}
|
}
|
||||||
|
|
||||||
var file = self.filename();
|
var file = self.filename();
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ $(function () {
|
|||||||
);
|
);
|
||||||
self.locale_languages = _.keys(AVAILABLE_LOCALES);
|
self.locale_languages = _.keys(AVAILABLE_LOCALES);
|
||||||
|
|
||||||
self.api_key = ko.observable(undefined);
|
|
||||||
self.api_allowCrossOrigin = ko.observable(undefined);
|
self.api_allowCrossOrigin = ko.observable(undefined);
|
||||||
|
|
||||||
self.appearance_name = ko.observable(undefined);
|
self.appearance_name = ko.observable(undefined);
|
||||||
@@ -687,26 +686,6 @@ $(function () {
|
|||||||
self.settingsDialog.modal("hide");
|
self.settingsDialog.modal("hide");
|
||||||
};
|
};
|
||||||
|
|
||||||
self.generateApiKey = function () {
|
|
||||||
if (!CONFIG_ACCESS_CONTROL) return;
|
|
||||||
|
|
||||||
showConfirmationDialog(
|
|
||||||
gettext(
|
|
||||||
"This will generate a new API Key. The old API Key will cease to function immediately."
|
|
||||||
),
|
|
||||||
function () {
|
|
||||||
OctoPrint.settings.generateApiKey().done(function (response) {
|
|
||||||
self.api_key(response.apikey);
|
|
||||||
self.requestData();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.copyApiKey = function () {
|
|
||||||
copyToClipboard(self.api_key());
|
|
||||||
};
|
|
||||||
|
|
||||||
self.showTranslationManager = function () {
|
self.showTranslationManager = function () {
|
||||||
self.translationManagerDialog.modal();
|
self.translationManagerDialog.modal();
|
||||||
return false;
|
return false;
|
||||||
@@ -741,7 +720,7 @@ $(function () {
|
|||||||
"Error calling settings callback",
|
"Error calling settings callback",
|
||||||
callback,
|
callback,
|
||||||
":",
|
":",
|
||||||
exc.stack || exc.stacktrace || exc
|
`${exc.message}\n${exc.stack || exc}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
/*! loglevel - v1.7.0 - https://github.com/pimterry/loglevel - (c) 2020 Tim Perry - licensed MIT */
|
/*! loglevel - v1.8.1 - https://github.com/pimterry/loglevel - (c) 2022 Tim Perry - licensed MIT */
|
||||||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";function a(a,b){var c=a[b];if("function"==typeof c.bind)return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch(b){return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(c){return"debug"===c&&(c="log"),typeof console!==i&&("trace"===c&&j?b:void 0!==console[c]?a(console,c):void 0!==console.log?a(console,"log"):h)}function d(a,b){for(var c=0;c<k.length;c++){var d=k[c];this[d]=c<a?h:this.methodFactory(d,a,b)}this.log=this.debug}function e(a,b,c){return function(){typeof console!==i&&(d.call(this,b,c),this[a].apply(this,arguments))}}function f(a,b,d){return c(a)||e.apply(this,arguments)}function g(a,b,c){function e(a){var b=(k[a]||"silent").toUpperCase();if(typeof window!==i&&l){try{return void(window.localStorage[l]=b)}catch(a){}try{window.document.cookie=encodeURIComponent(l)+"="+b+";"}catch(a){}}}function g(){var a;if(typeof window!==i&&l){try{a=window.localStorage[l]}catch(a){}if(typeof a===i)try{var b=window.document.cookie,c=b.indexOf(encodeURIComponent(l)+"=");-1!==c&&(a=/^([^;]+)/.exec(b.slice(c))[1])}catch(a){}return void 0===j.levels[a]&&(a=void 0),a}}var h,j=this,l="loglevel";"string"==typeof a?l+=":"+a:"symbol"==typeof a&&(l=void 0),j.name=a,j.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},j.methodFactory=c||f,j.getLevel=function(){return h},j.setLevel=function(b,c){if("string"==typeof b&&void 0!==j.levels[b.toUpperCase()]&&(b=j.levels[b.toUpperCase()]),!("number"==typeof b&&b>=0&&b<=j.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;if(h=b,!1!==c&&e(b),d.call(j,b,a),typeof console===i&&b<j.levels.SILENT)return"No console available for logging"},j.setDefaultLevel=function(a){g()||j.setLevel(a,!1)},j.enableAll=function(a){j.setLevel(j.levels.TRACE,a)},j.disableAll=function(a){j.setLevel(j.levels.SILENT,a)};var m=g();null==m&&(m=null==b?"WARN":b),j.setLevel(m,!1)}var h=function(){},i="undefined",j=typeof window!==i&&typeof window.navigator!==i&&/Trident\/|MSIE /.test(window.navigator.userAgent),k=["trace","debug","info","warn","error"],l=new g,m={};l.getLogger=function(a){if("symbol"!=typeof a&&"string"!=typeof a||""===a)throw new TypeError("You must supply a name when creating a logger.");var b=m[a];return b||(b=m[a]=new g(a,l.getLevel(),l.methodFactory)),b};var n=typeof window!==i?window.log:void 0;return l.noConflict=function(){return typeof window!==i&&window.log===l&&(window.log=n),l},l.getLoggers=function(){return m},l.default=l,l});
|
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(b):"object"==typeof module&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";function a(a,b){var c=a[b];if("function"==typeof c.bind)return c.bind(a);try{return Function.prototype.bind.call(c,a)}catch(b){return function(){return Function.prototype.apply.apply(c,[a,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(c){return"debug"===c&&(c="log"),typeof console!==i&&("trace"===c&&j?b:void 0!==console[c]?a(console,c):void 0!==console.log?a(console,"log"):h)}function d(a,b){for(var c=0;c<k.length;c++){var d=k[c];this[d]=c<a?h:this.methodFactory(d,a,b)}this.log=this.debug}function e(a,b,c){return function(){typeof console!==i&&(d.call(this,b,c),this[a].apply(this,arguments))}}function f(a,b,d){return c(a)||e.apply(this,arguments)}function g(a,b,c){function e(a){var b=(k[a]||"silent").toUpperCase();if(typeof window!==i&&m){try{return void(window.localStorage[m]=b)}catch(a){}try{window.document.cookie=encodeURIComponent(m)+"="+b+";"}catch(a){}}}function g(){var a;if(typeof window!==i&&m){try{a=window.localStorage[m]}catch(a){}if(typeof a===i)try{var b=window.document.cookie,c=b.indexOf(encodeURIComponent(m)+"=");-1!==c&&(a=/^([^;]+)/.exec(b.slice(c))[1])}catch(a){}return void 0===l.levels[a]&&(a=void 0),a}}function h(){if(typeof window!==i&&m){try{return void window.localStorage.removeItem(m)}catch(a){}try{window.document.cookie=encodeURIComponent(m)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(a){}}}var j,l=this;b=null==b?"WARN":b;var m="loglevel";"string"==typeof a?m+=":"+a:"symbol"==typeof a&&(m=void 0),l.name=a,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=c||f,l.getLevel=function(){return j},l.setLevel=function(b,c){if("string"==typeof b&&void 0!==l.levels[b.toUpperCase()]&&(b=l.levels[b.toUpperCase()]),!("number"==typeof b&&b>=0&&b<=l.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;if(j=b,!1!==c&&e(b),d.call(l,b,a),typeof console===i&&b<l.levels.SILENT)return"No console available for logging"},l.setDefaultLevel=function(a){b=a,g()||l.setLevel(a,!1)},l.resetLevel=function(){l.setLevel(b,!1),h()},l.enableAll=function(a){l.setLevel(l.levels.TRACE,a)},l.disableAll=function(a){l.setLevel(l.levels.SILENT,a)};var n=g();null==n&&(n=b),l.setLevel(n,!1)}var h=function(){},i="undefined",j=typeof window!==i&&typeof window.navigator!==i&&/Trident\/|MSIE /.test(window.navigator.userAgent),k=["trace","debug","info","warn","error"],l=new g,m={};l.getLogger=function(a){if("symbol"!=typeof a&&"string"!=typeof a||""===a)throw new TypeError("You must supply a name when creating a logger.");var b=m[a];return b||(b=m[a]=new g(a,l.getLevel(),l.methodFactory)),b};var n=typeof window!==i?window.log:void 0;return l.noConflict=function(){return typeof window!==i&&window.log===l&&(window.log=n),l},l.getLoggers=function(){return m},l.default=l,l});
|
||||||
@@ -9,37 +9,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
|
||||||
<h3>{{ _('Global API Key') }}</h3>
|
|
||||||
<div class="alert">
|
|
||||||
<p>{% trans %}
|
|
||||||
It is recommended to no longer use the global API key as it's one single key that gives full admin access
|
|
||||||
to your whole OctoPrint instance. <strong>It will be removed in OctoPrint 2.0</strong>.
|
|
||||||
Instead of using the global key you should create individual Application Keys for
|
|
||||||
your third party clients. That way they get permissions matching the user account used for key
|
|
||||||
creation and you can also revoke access to one app without having to change the keys for all other apps.
|
|
||||||
It's also recommended to create a user account without admin access and use that for third
|
|
||||||
party clients where possible.
|
|
||||||
{% endtrans %}</p>
|
|
||||||
<p><a href="javascript:void(0)" data-bind="click: function() { $root.selectTab('#settings_plugin_appkeys') }">{{ _('Access Application Keys') }}</a></p>
|
|
||||||
</div>
|
|
||||||
<div class="control-group">
|
|
||||||
<label class="control-label" for="settings-apikey">{{ _('Global API Key') }}</label>
|
|
||||||
<div class="controls">
|
|
||||||
<div class="input-append input-block-level">
|
|
||||||
<input type="text" readonly="readonly" id="settings-apikey" data-bind="value: api_key, attr: {placeholder: '{{ _('N/A')|esq }}'}">
|
|
||||||
<a class="btn add-on" title="Copy API Key to clipboard" data-bind="click: copyApiKey, css: {'disabled': !api_key()}"><i class="fas fa-copy"></i></a>
|
|
||||||
<a class="btn add-on" title="Generate new API Key" data-bind="click: generateApiKey"><i class="fas fa-sync"></i></a>
|
|
||||||
</div>
|
|
||||||
<span class="help-block">{{ _('Please note that changes to the API key are applied immediately, without having to "Save" first.') }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="control-group" data-bind="visible: api_key">
|
|
||||||
<label class="control-label">{{ _('QR Code') }}</label>
|
|
||||||
<div class="controls">
|
|
||||||
<div data-bind="qrcode: {text: api_key, size: 180}"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
@@ -882,9 +882,9 @@ class ZTimelapse(Timelapse):
|
|||||||
and payload["old"] is not None
|
and payload["old"] is not None
|
||||||
and payload["new"] is not None
|
and payload["new"] is not None
|
||||||
):
|
):
|
||||||
diff = round(abs(payload["new"] - payload["old"]), 3)
|
diff = abs(payload["new"] - payload["old"])
|
||||||
zhop = round(self._retraction_zhop, 3)
|
zhop = self._retraction_zhop
|
||||||
if diff == zhop:
|
if abs(diff - zhop) < 0.001:
|
||||||
return
|
return
|
||||||
|
|
||||||
# check if last picture has been less than min_delay ago, if so don't take a picture (anti vase mode...)
|
# check if last picture has been less than min_delay ago, if so don't take a picture (anti vase mode...)
|
||||||
|
|||||||
@@ -320,6 +320,12 @@ to_str = deprecated(
|
|||||||
since="1.3.11",
|
since="1.3.11",
|
||||||
)(to_bytes)
|
)(to_bytes)
|
||||||
|
|
||||||
|
to_native_str = deprecated(
|
||||||
|
"to_native_str is no longer needed",
|
||||||
|
includedoc="to_native_str is no longer needed, use to_unicode",
|
||||||
|
since="2.0.0",
|
||||||
|
)(to_unicode)
|
||||||
|
|
||||||
|
|
||||||
to_native_str = deprecated(
|
to_native_str = deprecated(
|
||||||
"to_native_str is no longer needed, use to_unicode instead",
|
"to_native_str is no longer needed, use to_unicode instead",
|
||||||
@@ -468,7 +474,7 @@ def get_exception_string(fmt="{type}: '{message}' @ {file}:{function}:{line}"):
|
|||||||
def sanitize_ascii(line):
|
def sanitize_ascii(line):
|
||||||
if not isinstance(line, (str, bytes)):
|
if not isinstance(line, (str, bytes)):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Expected str but got {} instead".format(
|
"Expected either str or bytes but got {} instead".format(
|
||||||
line.__class__.__name__ if line is not None else None
|
line.__class__.__name__ if line is not None else None
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -1004,6 +1010,7 @@ def atomic_write(
|
|||||||
yield fd
|
yield fd
|
||||||
finally:
|
finally:
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
os.chmod(fd.name, permissions)
|
os.chmod(fd.name, permissions)
|
||||||
shutil.move(fd.name, filename)
|
shutil.move(fd.name, filename)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -51,10 +51,7 @@ from octoprint.util.platform import get_os, set_close_exec
|
|||||||
try:
|
try:
|
||||||
import winreg
|
import winreg
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
pass
|
||||||
import _winreg as winreg # type: ignore
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
"""
|
"""
|
||||||
This module contains a functions that monkey patch third party dependencies in the one or other way.
|
This module contains a functions that monkey patch third party dependencies in the one or other way.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__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"
|
||||||
@@ -655,7 +655,7 @@ class gcode:
|
|||||||
elif gcode == "G20": # Units are inches
|
elif gcode == "G20": # Units are inches
|
||||||
scale = 25.4
|
scale = 25.4
|
||||||
elif gcode == "G21": # Units are mm
|
elif gcode == "G21": # Units are mm
|
||||||
scale = 1.0
|
scale = 1
|
||||||
elif gcode == "G28": # Home
|
elif gcode == "G28": # Home
|
||||||
x = getCodeFloat(line, "X")
|
x = getCodeFloat(line, "X")
|
||||||
y = getCodeFloat(line, "Y")
|
y = getCodeFloat(line, "Y")
|
||||||
|
|||||||
Vendored
-2
@@ -1,2 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
-3
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
"""
|
||||||
flask_principal
|
flask_principal
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
@@ -10,8 +9,6 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import with_statement
|
|
||||||
|
|
||||||
__version__ = '0.4.0'
|
__version__ = '0.4.0'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
-3
@@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
__import__('pkg_resources').declare_namespace(__name__)
|
__import__('pkg_resources').declare_namespace(__name__)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -1,5 +1,2 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
|
|
||||||
from .router import SockJSRouter
|
from .router import SockJSRouter
|
||||||
from .conn import SockJSConnection
|
from .conn import SockJSConnection
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
sockjs.tornado.periodic
|
sockjs.tornado.periodic
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ __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 unittest
|
import unittest
|
||||||
|
|
||||||
from ddt import data, ddt, unpack
|
from ddt import data, ddt, unpack
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
Unit tests for ``octoprint.server.api``.
|
Unit tests for ``octoprint.server.api``.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
__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) 2016 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
__copyright__ = "Copyright (C) 2016 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
Unit tests for ``octoprint.server.api`` system.
|
Unit tests for ``octoprint.server.api`` system.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
__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) 2016 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
__copyright__ = "Copyright (C) 2016 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import unittest
|
|||||||
|
|
||||||
from ddt import data, ddt, unpack
|
from ddt import data, ddt, unpack
|
||||||
|
|
||||||
##~~ _parse_header
|
|
||||||
|
|
||||||
|
|
||||||
@ddt
|
@ddt
|
||||||
class ParseHeaderTest(unittest.TestCase):
|
class ParseHeaderTest(unittest.TestCase):
|
||||||
|
"""Tests for _parse_header"""
|
||||||
|
|
||||||
@data(
|
@data(
|
||||||
("form-data; filename=test.gco", "form-data", {"filename": "test.gco"}),
|
("form-data; filename=test.gco", "form-data", {"filename": "test.gco"}),
|
||||||
('form-data; filename="test.gco"', "form-data", {"filename": "test.gco"}),
|
('form-data; filename="test.gco"', "form-data", {"filename": "test.gco"}),
|
||||||
@@ -56,11 +56,10 @@ class ParseHeaderTest(unittest.TestCase):
|
|||||||
self.assertDictEqual(expected_dict, actual_dict)
|
self.assertDictEqual(expected_dict, actual_dict)
|
||||||
|
|
||||||
|
|
||||||
##~~ _strip_value_quotes
|
|
||||||
|
|
||||||
|
|
||||||
@ddt
|
@ddt
|
||||||
class StripValueQuotesTest(unittest.TestCase):
|
class StripValueQuotesTest(unittest.TestCase):
|
||||||
|
"""Tests for _strip_value_quotes"""
|
||||||
|
|
||||||
@data(
|
@data(
|
||||||
("", ""),
|
("", ""),
|
||||||
(None, None),
|
(None, None),
|
||||||
@@ -78,11 +77,10 @@ class StripValueQuotesTest(unittest.TestCase):
|
|||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|
||||||
|
|
||||||
##~~ _extended_header_value
|
|
||||||
|
|
||||||
|
|
||||||
@ddt
|
@ddt
|
||||||
class ExtendedHeaderValueTest(unittest.TestCase):
|
class ExtendedHeaderValueTest(unittest.TestCase):
|
||||||
|
"""Tests for _extended_header_value"""
|
||||||
|
|
||||||
@data(
|
@data(
|
||||||
("", ""),
|
("", ""),
|
||||||
(None, None),
|
(None, None),
|
||||||
|
|||||||
@@ -58,11 +58,13 @@ class SettingsTest(unittest.TestCase):
|
|||||||
with self.mocked_basedir() as basedir:
|
with self.mocked_basedir() as basedir:
|
||||||
# construct settings
|
# construct settings
|
||||||
settings = octoprint.settings.Settings()
|
settings = octoprint.settings.Settings()
|
||||||
|
settings.set(["appearance", "name"], "unit test")
|
||||||
|
settings.save()
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
self.assertTrue(os.path.isdir(basedir))
|
self.assertTrue(os.path.isdir(basedir))
|
||||||
self.assertTrue(os.path.isfile(os.path.join(basedir, "config.yaml")))
|
self.assertTrue(os.path.isfile(os.path.join(basedir, "config.yaml")))
|
||||||
self.assertIsNotNone(settings.get(["api", "key"]))
|
self.assertIsNotNone(settings.get(["appearance", "name"]))
|
||||||
|
|
||||||
def test_basedir_folder_creation(self):
|
def test_basedir_folder_creation(self):
|
||||||
with self.mocked_basedir() as basedir:
|
with self.mocked_basedir() as basedir:
|
||||||
@@ -95,7 +97,9 @@ class SettingsTest(unittest.TestCase):
|
|||||||
my_basedir = tempfile.mkdtemp("octoprint-settings-test-custom")
|
my_basedir = tempfile.mkdtemp("octoprint-settings-test-custom")
|
||||||
self.assertNotEqual(my_basedir, default_basedir)
|
self.assertNotEqual(my_basedir, default_basedir)
|
||||||
|
|
||||||
octoprint.settings.Settings(basedir=my_basedir)
|
settings = octoprint.settings.Settings(basedir=my_basedir)
|
||||||
|
settings.set(["appearance", "name"], "unit test")
|
||||||
|
settings.save()
|
||||||
|
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
os.path.isfile(os.path.join(default_basedir, "config.yaml"))
|
os.path.isfile(os.path.join(default_basedir, "config.yaml"))
|
||||||
|
|||||||
@@ -206,9 +206,12 @@ class TestAtomicWrite(unittest.TestCase):
|
|||||||
mock_ntf.return_value = mock_file
|
mock_ntf.return_value = mock_file
|
||||||
mock_exists.return_value = False
|
mock_exists.return_value = False
|
||||||
|
|
||||||
|
umask = 0o026
|
||||||
|
|
||||||
# test
|
# test
|
||||||
with octoprint.util.atomic_write(targetpath) as f:
|
with mock.patch("octoprint.util.UMASK", umask):
|
||||||
f.write("test")
|
with octoprint.util.atomic_write(targetpath) as f:
|
||||||
|
f.write("test")
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
mock_ntf.assert_called_once_with(
|
mock_ntf.assert_called_once_with(
|
||||||
@@ -227,7 +230,7 @@ class TestAtomicWrite(unittest.TestCase):
|
|||||||
def test_atomic_write_rel_path_aware(
|
def test_atomic_write_rel_path_aware(
|
||||||
self, mock_exists, mock_chmod, mock_ntf, mock_move
|
self, mock_exists, mock_chmod, mock_ntf, mock_move
|
||||||
):
|
):
|
||||||
"""Tests whether the tempoary file is to created in the same directory as the target file. This time submitting a relative path."""
|
"""Tests whether the temporary file is to created in the same directory as the target file. This time submitting a relative path."""
|
||||||
|
|
||||||
# setup
|
# setup
|
||||||
tmpdirpath = "../test"
|
tmpdirpath = "../test"
|
||||||
@@ -240,9 +243,12 @@ class TestAtomicWrite(unittest.TestCase):
|
|||||||
mock_ntf.return_value = mock_file
|
mock_ntf.return_value = mock_file
|
||||||
mock_exists.return_value = False
|
mock_exists.return_value = False
|
||||||
|
|
||||||
|
umask = 0o026
|
||||||
|
|
||||||
# test
|
# test
|
||||||
with octoprint.util.atomic_write(targetpath) as f:
|
with mock.patch("octoprint.util.UMASK", umask):
|
||||||
f.write("test")
|
with octoprint.util.atomic_write(targetpath) as f:
|
||||||
|
f.write("test")
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
mock_ntf.assert_called_once_with(
|
mock_ntf.assert_called_once_with(
|
||||||
|
|||||||
Reference in new issue
Block a user