Compare commits
282
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fe43d38c8 | ||
|
|
cd3b24e3e4 | ||
|
|
73d944ba68 | ||
|
|
a0c8c9f84f | ||
|
|
ee4a4b1c92 | ||
|
|
b324da152b | ||
|
|
0a3e19a342 | ||
|
|
3e94574a9b | ||
|
|
aa02750458 | ||
|
|
4040c4fd8a | ||
|
|
a2e5558165 | ||
|
|
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-*
|
||||
*.iml
|
||||
Printrun
|
||||
=======
|
||||
.idea
|
||||
.vscode
|
||||
.DS_Store
|
||||
|
||||
@@ -158,6 +158,7 @@ date of first contribution):
|
||||
* [Christian Würthner](https://github.com/crysxd)
|
||||
* [Maciej Urbański](https://github.com/rooterkyberian)
|
||||
* [Adam Wolf](https://github.com/adamwolf)
|
||||
* [Carey Metcalfe](https://github.com/pR0Ps)
|
||||
* [Didi Kohen](https://github.com/kohend)
|
||||
* [Taylor Talkington](https://github.com/The-EG)
|
||||
* [Carey Metcalfe](https://github.com/pR0Ps)
|
||||
@@ -181,6 +182,7 @@ date of first contribution):
|
||||
* [Jatin Saini](https://github.com/jatin-47)
|
||||
* [Martin Bartsch](https://github.com/kaenguruhs)
|
||||
* [Matthias Weis](https://github.com/mad73923)
|
||||
* [Rob Emery](https://github.com/mintsoft)
|
||||
|
||||
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
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
* [css-element-queries](https://github.com/marcj/css-element-queries): MIT
|
||||
* [Detect Mobile Browser](http://detectmobilebrowsers.com/): Public Domain
|
||||
* [Flot](http://www.flotcharts.org/): MIT
|
||||
* [Flot Crosshair Plugin](http://www.flotcharts.org/): MIT
|
||||
* [Flot Dashes Plugin](https://github.com/cquartier/flot.dashes): Unlicense
|
||||
* [Flot Resize Plugin](http://www.flotcharts.org/): MIT
|
||||
* [Flot Time Plugin](http://www.flotcharts.org/): MIT
|
||||
* [HLS.js](https://github.com/video-dev/hls.js): Apache License 2.0
|
||||
* [JavaScript MD5](https://github.com/blueimp/JavaScript-MD5): MIT
|
||||
* [JQuery](http://jquery.com/): MIT
|
||||
|
||||
+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
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
@@ -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
|
||||
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:
|
||||
.. figure:: ../images/settings-user-api-key.png
|
||||
: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:
|
||||
|
||||
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
|
||||
|
||||
.. 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:
|
||||
|
||||
.. code-block:: none
|
||||
@@ -96,12 +102,6 @@ Then:
|
||||
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:
|
||||
|
||||
Windows
|
||||
@@ -112,20 +112,19 @@ location, please substitute accordingly.
|
||||
|
||||
First download & install:
|
||||
|
||||
* `Git for Windows <https://git-for-windows.github.io/>`_
|
||||
|
||||
* `Latest *stable* Python 3 release from python.org <https://www.python.org/downloads/windows/>`_
|
||||
* `The current Python 3.8 Windows x86 executable installer <https://www.python.org/downloads/windows/>`_
|
||||
|
||||
* 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
|
||||
different install locations please substitute accordingly
|
||||
* 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
|
||||
"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:
|
||||
|
||||
@@ -150,7 +149,6 @@ Optional but recommended tools
|
||||
These are some tools that are recommended but not required to have on hand:
|
||||
|
||||
* `Visual Studio Code <https://code.visualstudio.com/download>`_
|
||||
|
||||
* `Windows Terminal <https://github.com/microsoft/terminal>`_
|
||||
|
||||
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"
|
||||
* 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.
|
||||
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
|
||||
a GCODE script including user input.
|
||||
|
||||
.. code-block-ext:: yaml
|
||||
.. code-block:: yaml
|
||||
|
||||
controls:
|
||||
- name: Fan
|
||||
@@ -181,7 +181,7 @@ Controls
|
||||
additional input fields. ``command``/``commands`` may contain placeholders to be replaced by the values obtained
|
||||
from the user for the defined input fields:
|
||||
|
||||
.. code-block-ext:: yaml
|
||||
.. code-block:: yaml
|
||||
|
||||
name: Enable Fan
|
||||
command: M106 S%(speed)s
|
||||
@@ -253,7 +253,7 @@ Examples
|
||||
Parameterized GCODE Script
|
||||
..........................
|
||||
|
||||
.. code-block-ext:: yaml
|
||||
.. code-block:: yaml
|
||||
:caption: Control definition in ~/.octoprint/config.yaml
|
||||
:name: code-features-custom_controls-example-gcode_script-config_yaml
|
||||
|
||||
@@ -268,7 +268,7 @@ Parameterized GCODE Script
|
||||
min: 1
|
||||
step: 1
|
||||
|
||||
.. code-block-ext:: jinja
|
||||
.. code-block:: jinja
|
||||
:caption: ~/.octoprint/scripts/gcode/custom/dance.gco
|
||||
:name: code-features-custom_controls-example-gcode_script-dance_gco
|
||||
|
||||
|
||||
@@ -270,6 +270,6 @@ def setup(app):
|
||||
|
||||
# custom node type
|
||||
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"}
|
||||
@@ -117,4 +117,4 @@ def setup(app):
|
||||
app.add_directive("onlineinclude", OnlineIncludeDirective)
|
||||
|
||||
handler = (visit_onlineinclude, depart_onlineinclude)
|
||||
app.add_node(OnlineIncludeDirective, html=handler, latex=handler, text=handler)
|
||||
app.add_node(OnlineIncludeDirective, html=handler)
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import logging as log
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
if __name__ == "__main__":
|
||||
import octoprint
|
||||
|
||||
|
||||
@@ -62,8 +62,10 @@ class UserManager(GroupChangeListener):
|
||||
def anonymous_user_factory(self):
|
||||
return AnonymousUser([self._group_manager.guest_group])
|
||||
|
||||
def api_user_factory(self):
|
||||
return ApiUser([self._group_manager.admin_group, self._group_manager.user_group])
|
||||
def cli_user_factory(self):
|
||||
return LocalCliUser(
|
||||
[self._group_manager.admin_group, self._group_manager.user_group]
|
||||
)
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
@@ -1102,11 +1104,6 @@ class MethodReplacedByBooleanProperty:
|
||||
return self._attr != other
|
||||
|
||||
def __bool__(self):
|
||||
# Python 3
|
||||
return self._attr
|
||||
|
||||
def __nonzero__(self):
|
||||
# Python 2
|
||||
return self._attr
|
||||
|
||||
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):
|
||||
User.__init__(self, "_api", "", True, [], groups)
|
||||
User.__init__(self, "_cli", "", True, [], groups)
|
||||
@@ -151,7 +151,6 @@ def gcode_command(
|
||||
"happened"
|
||||
)
|
||||
sys.exit(-1)
|
||||
|
||||
click.echo("RESULTS:")
|
||||
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"
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
import click
|
||||
|
||||
@@ -33,18 +34,23 @@ def create_client(
|
||||
https=False,
|
||||
prefix=None,
|
||||
):
|
||||
assert host 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
|
||||
|
||||
if not host:
|
||||
host = settings.get(["server", "host"])
|
||||
host = host if host != "0.0.0.0" else "127.0.0.1"
|
||||
host = "127.0.0.1"
|
||||
if not port:
|
||||
port = settings.getInt(["server", "port"])
|
||||
|
||||
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(
|
||||
https=https,
|
||||
@@ -79,7 +85,7 @@ def cli(ctx, apikey, host, port, httpuser, httppass, https, prefix):
|
||||
"""Basic API client."""
|
||||
try:
|
||||
settings = None
|
||||
if not host or not port or not apikey:
|
||||
if not port or not apikey:
|
||||
settings = init_settings(
|
||||
get_ctx_obj_option(ctx, "basedir", 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"
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
@@ -439,8 +440,6 @@ class FileManager:
|
||||
source_meta = self.get_metadata(source_location, source_path)
|
||||
hash = source_meta.get("hash", "n/a")
|
||||
|
||||
import io
|
||||
|
||||
links = [("model", {"name": source_path})]
|
||||
_, stl_name = self.split_path(source_location, source_path)
|
||||
file_obj = StreamWrapper(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from typing import Union
|
||||
|
||||
from octoprint.logging import filters # 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
|
||||
|
||||
|
||||
def prefix_multilines(text: str, prefix: str = ": ") -> str:
|
||||
def prefix_multilines(text: Union[str, bytes], prefix: str = ": ") -> str:
|
||||
from octoprint.util import to_unicode
|
||||
|
||||
lines = text.splitlines()
|
||||
|
||||
@@ -322,7 +322,7 @@ class AchievementsPlugin(
|
||||
**a.dict(),
|
||||
)
|
||||
for a in Achievements.all()
|
||||
# if not a.hidden or self._has_achievement(a)
|
||||
if not a.hidden or self._has_achievement(a)
|
||||
]
|
||||
achievements.sort(key=lambda a: a.name)
|
||||
|
||||
@@ -406,9 +406,7 @@ class AchievementsPlugin(
|
||||
if self._has_achievement(achievement):
|
||||
return
|
||||
|
||||
self._data.achievements[achievement.key] = int(
|
||||
datetime.datetime.now().timestamp()
|
||||
)
|
||||
self._data.achievements[achievement.key] = int(self._now().timestamp())
|
||||
if write:
|
||||
self._write_data_file()
|
||||
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
<!--
|
||||
<button class="btn" data-bind="click: () => {triggerTestAchievement()}">Trigger</button>
|
||||
<button class="btn" data-bind="click: () => {triggerTestAchievement(true)}">Trigger w/ nag</button>
|
||||
-->
|
||||
|
||||
<h3>{{ _('Achievements') }} (<span data-bind="text: achievedAchievements"></span>/<span data-bind="text: totalAchievements"></span>)</h3>
|
||||
|
||||
<div class="achievement-list" data-bind="foreach: achievements">
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import datetime
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import copy
|
||||
import datetime
|
||||
import hashlib
|
||||
import logging
|
||||
import logging.handlers
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/bin/env python
|
||||
|
||||
__author__ = "Gina Haeussge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
@@ -250,6 +250,7 @@ class VirtualPrinter:
|
||||
|
||||
self._sdCardReady = True
|
||||
self._sdPrinting = False
|
||||
self._sdCacnelled = False
|
||||
if self._sdPrinter:
|
||||
self._sdPrinting = False
|
||||
self._sdPrintingSemaphore.set()
|
||||
@@ -682,6 +683,10 @@ class VirtualPrinter:
|
||||
if file is not None:
|
||||
self._send(file["name"])
|
||||
|
||||
def _gcode_M524(self, data: str) -> None:
|
||||
if self._sdCardReady:
|
||||
self._cancelSdPrint()
|
||||
|
||||
def _gcode_M113(self, data: str) -> None:
|
||||
matchS = re.search(r"S([0-9]+)", data)
|
||||
if matchS is not None:
|
||||
@@ -930,9 +935,9 @@ class VirtualPrinter:
|
||||
|
||||
_timeout = 0
|
||||
if matchP:
|
||||
_timeout = float(matchP.group(1)) / 1000
|
||||
_timeout = int(matchP.group(1)) / 1000
|
||||
elif matchS:
|
||||
_timeout = float(matchS.group(1))
|
||||
_timeout = int(matchS.group(1))
|
||||
|
||||
if self._sendBusy and self._busyInterval > 0:
|
||||
until = time.monotonic() + _timeout
|
||||
@@ -1566,7 +1571,9 @@ class VirtualPrinter:
|
||||
|
||||
def _startSdPrint(self):
|
||||
if self._selectedSdFile is not None:
|
||||
self._sdPrinting = False
|
||||
if self._sdPrinter is None:
|
||||
self._sdCancelled = False
|
||||
self._sdPrinting = True
|
||||
self._sdPrinter = threading.Thread(target=self._sdPrintingWorker)
|
||||
self._sdPrinter.start()
|
||||
@@ -1575,11 +1582,17 @@ class VirtualPrinter:
|
||||
def _pauseSdPrint(self):
|
||||
self._sdPrintingSemaphore.clear()
|
||||
|
||||
def _cancelSdPrint(self):
|
||||
self._sdCancelled = True
|
||||
self._sdPrinting = False
|
||||
self._sdPrintingSemaphore.set() # just in case it was cleared before
|
||||
self._sdPrinter.join()
|
||||
|
||||
def _setSdPos(self, pos):
|
||||
self._newSdFilePos = pos
|
||||
|
||||
def _reportSdStatus(self):
|
||||
if self._sdPrinter is not None and self._sdPrintingSemaphore.is_set:
|
||||
if self._sdPrinter is not None:
|
||||
self._send(
|
||||
f"SD printing byte {self._selectedSdFilePos}/{self._selectedSdFileSize}"
|
||||
)
|
||||
@@ -1684,11 +1697,11 @@ class VirtualPrinter:
|
||||
return
|
||||
|
||||
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:
|
||||
if support_r:
|
||||
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
|
||||
except Exception:
|
||||
pass
|
||||
@@ -1704,11 +1717,11 @@ class VirtualPrinter:
|
||||
|
||||
only_wait_if_higher = True
|
||||
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:
|
||||
if support_r:
|
||||
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
|
||||
except Exception:
|
||||
pass
|
||||
@@ -1724,11 +1737,11 @@ class VirtualPrinter:
|
||||
|
||||
only_wait_if_higher = True
|
||||
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:
|
||||
if support_r:
|
||||
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
|
||||
except Exception:
|
||||
pass
|
||||
@@ -1975,12 +1988,12 @@ class VirtualPrinter:
|
||||
self._finishSdPrint()
|
||||
|
||||
def _finishSdPrint(self):
|
||||
if not self._killed:
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._selectedSdFilePos = 0
|
||||
self._sdPrinting = False
|
||||
self._sdPrinter = None
|
||||
if not self._killed and not self._sdCancelled:
|
||||
self._send("Done printing file")
|
||||
self._selectedSdFilePos = 0
|
||||
self._sdPrinting = False
|
||||
self._sdPrinter = None
|
||||
|
||||
def _waitForHeatup(self, heater: str, only_wait_if_higher: bool) -> None:
|
||||
delta = 1
|
||||
|
||||
@@ -42,7 +42,7 @@ class PrintTimeEstimator:
|
||||
# by that divided by the sd status polling interval
|
||||
interval = settings().getFloat(["serial", "timeout", "sdStatus"])
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
interval = 1
|
||||
rolling_window = int(15 // interval)
|
||||
if rolling_window < 1:
|
||||
rolling_window = 1
|
||||
|
||||
@@ -173,6 +173,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
eventManager().subscribe(
|
||||
Events.METADATA_STATISTICS_UPDATED, self._on_event_MetadataStatisticsUpdated
|
||||
)
|
||||
eventManager().subscribe(Events.CONNECTED, self._on_event_Connected)
|
||||
eventManager().subscribe(Events.DISCONNECTED, self._on_event_Disconnected)
|
||||
eventManager().subscribe(Events.CHART_MARKED, self._on_event_ChartMarked)
|
||||
|
||||
self._handle_connect_hooks = plugin_manager().get_hooks(
|
||||
@@ -321,6 +323,18 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._selectedFile["user"],
|
||||
)
|
||||
|
||||
# ~~ connection events
|
||||
|
||||
def _on_event_Connected(self, event, data):
|
||||
self._markings.append(
|
||||
{"type": "connected", "label": "Connected", "time": time.time()}
|
||||
)
|
||||
|
||||
def _on_event_Disconnected(self, event, data):
|
||||
self._markings.append(
|
||||
{"type": "disconnected", "label": "Disconnected", "time": time.time()}
|
||||
)
|
||||
|
||||
# ~~ chart marking insertions
|
||||
|
||||
def _on_event_ChartMarked(self, event, data):
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
__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"
|
||||
|
||||
from typing import Dict, Optional
|
||||
|
||||
from octoprint.schema import BaseModel
|
||||
from octoprint.vendor.with_attrs_docs import with_attrs_docs
|
||||
|
||||
|
||||
@with_attrs_docs
|
||||
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
|
||||
"""Whether to allow cross origin access to the API or not."""
|
||||
@@ -96,6 +96,8 @@ jsonDecoder = None
|
||||
connectivityChecker = None
|
||||
environmentDetector = None
|
||||
|
||||
cli_key = None
|
||||
|
||||
|
||||
class OctoPrintAnonymousIdentity(AnonymousIdentity):
|
||||
def __init__(self):
|
||||
@@ -201,8 +203,8 @@ def load_user(id):
|
||||
if id is None:
|
||||
return None
|
||||
|
||||
if id == "_api":
|
||||
return userManager.api_user_factory()
|
||||
if id == "_cli":
|
||||
return userManager.cli_user_factory()
|
||||
|
||||
if session and "usersession.id" in session:
|
||||
sessionid = session["usersession.id"]
|
||||
@@ -335,6 +337,7 @@ class Server:
|
||||
global environmentDetector
|
||||
global debug
|
||||
global safe_mode
|
||||
global cli_key
|
||||
|
||||
from tornado.ioloop import IOLoop
|
||||
from tornado.web import Application
|
||||
@@ -381,6 +384,7 @@ class Server:
|
||||
util.tornado.fix_websocket_check_origin()
|
||||
util.tornado.enable_per_message_deflate_extension()
|
||||
|
||||
cli_key = self._setup_cli_key()
|
||||
self._setup_mimetypes()
|
||||
|
||||
# setup app
|
||||
@@ -1999,7 +2003,7 @@ class Server:
|
||||
)
|
||||
except 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},
|
||||
)
|
||||
|
||||
@@ -2100,6 +2104,16 @@ class Server:
|
||||
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):
|
||||
# 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.
|
||||
@@ -2252,6 +2266,7 @@ class Server:
|
||||
"js/lib/jquery/jquery.flot.js",
|
||||
"js/lib/jquery/jquery.flot.time.js",
|
||||
"js/lib/jquery/jquery.flot.crosshair.js",
|
||||
"js/lib/jquery/jquery.flot.dashes.js",
|
||||
"js/lib/jquery/jquery.flot.resize.js",
|
||||
"js/lib/jquery/jquery.iframe-transport.js",
|
||||
"js/lib/jquery/jquery.fileupload.js",
|
||||
|
||||
@@ -12,7 +12,7 @@ import octoprint.plugin
|
||||
import octoprint.util
|
||||
from octoprint.access.permissions import Permissions
|
||||
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.settings import settings, valid_boolean_trues
|
||||
from octoprint.timelapse import configure_timelapse
|
||||
@@ -118,7 +118,6 @@ def getSettings():
|
||||
|
||||
data = {
|
||||
"api": {
|
||||
"key": s.get(["api", "key"]) if Permissions.ADMIN.can() else None,
|
||||
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"]),
|
||||
},
|
||||
"appearance": {
|
||||
@@ -456,22 +455,6 @@ def setSettings():
|
||||
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"])
|
||||
@no_firstrun_access
|
||||
@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_login
|
||||
import netaddr
|
||||
|
||||
import octoprint.server
|
||||
import octoprint.timelapse
|
||||
@@ -66,7 +67,8 @@ def loginUserFromApiKey():
|
||||
if not apikey:
|
||||
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:
|
||||
# invalid API key = no API key
|
||||
raise InvalidApiKeyException("Invalid API key")
|
||||
@@ -219,11 +221,16 @@ def optionsAllowOrigin(request):
|
||||
return resp
|
||||
|
||||
|
||||
def get_user_for_apikey(apikey):
|
||||
def get_user_for_apikey(apikey, remote_address=None):
|
||||
if apikey is not None:
|
||||
if apikey == settings().get(["api", "key"]):
|
||||
# master key was used
|
||||
return octoprint.server.userManager.api_user_factory()
|
||||
if apikey == octoprint.server.cli_key and remote_address:
|
||||
try:
|
||||
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)
|
||||
if user is not None:
|
||||
|
||||
@@ -1541,9 +1541,12 @@ def get_flask_user_from_request(request):
|
||||
user = None
|
||||
|
||||
apikey = octoprint.server.util.get_api_key(request)
|
||||
remote_address = get_remote_address(request)
|
||||
if apikey is not None:
|
||||
# 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:
|
||||
# user still None -> current session user
|
||||
|
||||
@@ -172,7 +172,7 @@ _PLUGIN_BUNDLE_WRAPPER_PREFIX = """// JS assets for plugin {plugin}
|
||||
"""
|
||||
_PLUGIN_BUNDLE_WRAPPER_SUFFIX = """
|
||||
}} 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,
|
||||
dict_merge,
|
||||
fast_deepcopy,
|
||||
generate_api_key,
|
||||
is_hidden_path,
|
||||
time_this,
|
||||
yaml,
|
||||
@@ -555,10 +554,6 @@ class Settings:
|
||||
self._configfile = os.path.join(self._basedir, "config.yaml")
|
||||
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.sanity_check_folders(
|
||||
@@ -2105,16 +2100,6 @@ class Settings:
|
||||
with atomic_write(filename, mode="wt", max_permissions=0o666) as f:
|
||||
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):
|
||||
# taken from http://stackoverflow.com/questions/1084697/how-do-i-store-desktop-application-data-in-a-cross-platform-way-for-python
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn,.btn-link,ul.dropdown-menu li a{cursor:pointer}#files .gcode_files .entry:hover,.btn{background-color:#f5f5f5}.btn,.btn-danger,.btn-info,.btn-inverse,.btn-primary,.btn-success,.btn-warning{filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x}.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);*background-color:#e6e6e6;border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-color:#ccc\9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-primary,.slider .slider-selection{text-shadow:0 -1px 0 rgba(0,0,0,.25);background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c)}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small [class*=" icon-"],.btn-small [class^=icon-],table td.timelapse_files_checkbox input[type=checkbox],table td.timelapse_unrendered_checkbox input[type=checkbox],table th.timelapse_files_checkbox input[type=checkbox],table th.timelapse_unrendered_checkbox input[type=checkbox]{margin-top:0}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.border_box,.input-block-level{-webkit-box-sizing:border-box;-moz-box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-danger.active,.btn-info.active,.btn-inverse.active,.btn-primary.active,.btn-success.active,.btn-warning.active{color:rgba(255,255,255,.75)}.btn-primary{color:#fff;background-color:#006dcc;background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039\9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{bLine truncated
|
||||
.btn,.btn-link,ul.dropdown-menu li a{cursor:pointer}#files .gcode_files .entry:hover,.btn{background-color:#f5f5f5}.btn,.btn-danger,.btn-info,.btn-inverse,.btn-primary,.btn-success,.btn-warning{filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x}.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);*background-color:#e6e6e6;border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-color:#ccc\9;background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-primary,.slider .slider-selection{text-shadow:0 -1px 0 rgba(0,0,0,.25);background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c)}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small [class*=" icon-"],.btn-small [class^=icon-],table td.timelapse_files_checkbox input[type=checkbox],table td.timelapse_unrendered_checkbox input[type=checkbox],table th.timelapse_files_checkbox input[type=checkbox],table th.timelapse_unrendered_checkbox input[type=checkbox]{margin-top:0}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.border_box,.input-block-level{-webkit-box-sizing:border-box;-moz-box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-danger.active,.btn-info.active,.btn-inverse.active,.btn-primary.active,.btn-success.active,.btn-warning.active{color:rgba(255,255,255,.75)}.btn-primary{color:#fff;background-color:#006dcc;background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039\9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{bLine truncated
|
||||
@@ -1367,7 +1367,7 @@ function setOnViewModelIf(viewModel, key, value, condition) {
|
||||
"on view model",
|
||||
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",
|
||||
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",
|
||||
viewModel.constructor.name,
|
||||
":",
|
||||
exc.stack || exc
|
||||
`${exc.message}\n${exc.stack || exc}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +506,12 @@ $(function () {
|
||||
if (typeof Sentry !== "undefined") {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -794,7 +799,7 @@ $(function () {
|
||||
"Error calling onBeforeBinding on view model",
|
||||
viewModel.constructor.name,
|
||||
":",
|
||||
exc.stack || exc
|
||||
`${exc.message}\n${exc.stack || exc}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -829,7 +834,7 @@ $(function () {
|
||||
"of view model",
|
||||
viewModel.constructor.name,
|
||||
":",
|
||||
exc.stack || exc
|
||||
`${exc.message}\n${exc.stack || exc}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -887,7 +892,7 @@ $(function () {
|
||||
"to target",
|
||||
target,
|
||||
":",
|
||||
exc.stack || exc
|
||||
`${exc.message}\n${exc.stack || exc}`
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -911,7 +916,7 @@ $(function () {
|
||||
"Error while processing view model",
|
||||
name,
|
||||
"for binding:",
|
||||
exc.stack || exc
|
||||
`${exc.message}\n${exc.stack || exc}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -506,7 +506,9 @@ $(function () {
|
||||
});
|
||||
return result;
|
||||
};
|
||||
self.folderList(["/"].concat(createFolderList(files)));
|
||||
const folders = createFolderList(files);
|
||||
folders.sort();
|
||||
self.folderList(["/"].concat(folders));
|
||||
|
||||
// Sanity check file list - see #2572
|
||||
var nonrecursive = false;
|
||||
|
||||
@@ -252,8 +252,8 @@ $(function () {
|
||||
|
||||
self.userString = ko.pureComputed(function () {
|
||||
var user = self.user();
|
||||
if (user === "_api") {
|
||||
user = "API client";
|
||||
if (user === "_cli") {
|
||||
user = "CLI";
|
||||
}
|
||||
|
||||
var file = self.filename();
|
||||
|
||||
@@ -124,7 +124,6 @@ $(function () {
|
||||
);
|
||||
self.locale_languages = _.keys(AVAILABLE_LOCALES);
|
||||
|
||||
self.api_key = ko.observable(undefined);
|
||||
self.api_allowCrossOrigin = ko.observable(undefined);
|
||||
|
||||
self.appearance_name = ko.observable(undefined);
|
||||
@@ -687,26 +686,6 @@ $(function () {
|
||||
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.translationManagerDialog.modal();
|
||||
return false;
|
||||
@@ -741,7 +720,7 @@ $(function () {
|
||||
"Error calling settings callback",
|
||||
callback,
|
||||
":",
|
||||
exc.stack || exc.stacktrace || exc
|
||||
`${exc.message}\n${exc.stack || exc}`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ $(function () {
|
||||
self.loginState = parameters[0];
|
||||
self.settingsViewModel = parameters[1];
|
||||
self.access = parameters[2];
|
||||
self.printerState = parameters[3];
|
||||
|
||||
self._createToolEntry = function () {
|
||||
var entry = {
|
||||
@@ -116,6 +117,8 @@ $(function () {
|
||||
self._currentTemperatureDataBacklog = [];
|
||||
self._historyTemperatureDataBacklog = [];
|
||||
|
||||
self._graphUpdater = undefined;
|
||||
|
||||
self._printerProfileUpdated = function () {
|
||||
var graphColors = ["red", "orange", "green", "brown", "purple"];
|
||||
var heaterOptions = {};
|
||||
@@ -528,7 +531,9 @@ $(function () {
|
||||
gettext("Done"),
|
||||
gettext("Cancel"),
|
||||
gettext("Pause"),
|
||||
gettext("Resume")
|
||||
gettext("Resume"),
|
||||
gettext("Connected"),
|
||||
gettext("Disconnected")
|
||||
];
|
||||
|
||||
self._initializePlot = function (force, plotInfo) {
|
||||
@@ -664,7 +669,8 @@ $(function () {
|
||||
": " +
|
||||
targetTemp,
|
||||
color: pusher.color(heaterOptions[type].color).tint(0.5).html(),
|
||||
data: targets.length ? targets : [[now, undefined]]
|
||||
data: targets.length ? targets : [[now, undefined]],
|
||||
dashes: {show: true}
|
||||
});
|
||||
|
||||
maxTemps.push(self.getMaxTemp(actuals, targets));
|
||||
@@ -1112,6 +1118,24 @@ $(function () {
|
||||
}
|
||||
|
||||
self.changeOffsetDialog = $("#change_offset_dialog");
|
||||
|
||||
self._graphUpdater = setInterval(() => {
|
||||
if (self.printerState.isOperational()) return;
|
||||
|
||||
const now = Date.now() / 1000;
|
||||
const entry = {};
|
||||
_.each(_.keys(self.heaterOptions()), (type) => {
|
||||
entry[type] = {actual: undefined, target: undefined};
|
||||
});
|
||||
entry["time"] = now;
|
||||
|
||||
self.temperatures = self._processTemperatureData(
|
||||
now,
|
||||
[entry],
|
||||
self.temperatures
|
||||
);
|
||||
self.updatePlot();
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
self.onStartupComplete = function () {
|
||||
@@ -1129,7 +1153,12 @@ $(function () {
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: TemperatureViewModel,
|
||||
dependencies: ["loginStateViewModel", "settingsViewModel", "accessViewModel"],
|
||||
dependencies: [
|
||||
"loginStateViewModel",
|
||||
"settingsViewModel",
|
||||
"accessViewModel",
|
||||
"printerStateViewModel"
|
||||
],
|
||||
elements: ["#temp", "#temp_link", "#change_offset_dialog"]
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* jQuery.flot.dashes
|
||||
*
|
||||
* options = {
|
||||
* series: {
|
||||
* dashes: {
|
||||
*
|
||||
* // show
|
||||
* // default: false
|
||||
* // Whether to show dashes for the series.
|
||||
* show: <boolean>,
|
||||
*
|
||||
* // lineWidth
|
||||
* // default: 2
|
||||
* // The width of the dashed line in pixels.
|
||||
* lineWidth: <number>,
|
||||
*
|
||||
* // dashLength
|
||||
* // default: 10
|
||||
* // Controls the length of the individual dashes and the amount of
|
||||
* // space between them.
|
||||
* // If this is a number, the dashes and spaces will have that length.
|
||||
* // If this is an array, it is read as [ dashLength, spaceLength ]
|
||||
* dashLength: <number> or <array[2]>
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
(function($){
|
||||
|
||||
function init(plot) {
|
||||
plot.hooks.drawSeries.push(function(plot, ctx, series) {
|
||||
if (!series.dashes.show) return;
|
||||
|
||||
var plotOffset = plot.getPlotOffset(),
|
||||
axisx = series.xaxis,
|
||||
axisy = series.yaxis;
|
||||
|
||||
function plotDashes(xoffset, yoffset) {
|
||||
|
||||
var points = series.datapoints.points,
|
||||
ps = series.datapoints.pointsize,
|
||||
prevx = null,
|
||||
prevy = null,
|
||||
dashRemainder = 0,
|
||||
dashOn = true,
|
||||
dashOnLength,
|
||||
dashOffLength;
|
||||
|
||||
if (series.dashes.dashLength[0]) {
|
||||
dashOnLength = series.dashes.dashLength[0];
|
||||
if (series.dashes.dashLength[1]) {
|
||||
dashOffLength = series.dashes.dashLength[1];
|
||||
} else {
|
||||
dashOffLength = dashOnLength;
|
||||
}
|
||||
} else {
|
||||
dashOffLength = dashOnLength = series.dashes.dashLength;
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
|
||||
for (var i = ps; i < points.length; i += ps) {
|
||||
|
||||
var x1 = points[i - ps],
|
||||
y1 = points[i - ps + 1],
|
||||
x2 = points[i],
|
||||
y2 = points[i + 1];
|
||||
|
||||
if (x1 == null || x2 == null) continue;
|
||||
|
||||
// clip with ymin
|
||||
if (y1 <= y2 && y1 < axisy.min) {
|
||||
if (y2 < axisy.min) continue; // line segment is outside
|
||||
// compute new intersection point
|
||||
x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
|
||||
y1 = axisy.min;
|
||||
} else if (y2 <= y1 && y2 < axisy.min) {
|
||||
if (y1 < axisy.min) continue;
|
||||
x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1;
|
||||
y2 = axisy.min;
|
||||
}
|
||||
|
||||
// clip with ymax
|
||||
if (y1 >= y2 && y1 > axisy.max) {
|
||||
if (y2 > axisy.max) continue;
|
||||
x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
|
||||
y1 = axisy.max;
|
||||
} else if (y2 >= y1 && y2 > axisy.max) {
|
||||
if (y1 > axisy.max) continue;
|
||||
x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1;
|
||||
y2 = axisy.max;
|
||||
}
|
||||
|
||||
// clip with xmin
|
||||
if (x1 <= x2 && x1 < axisx.min) {
|
||||
if (x2 < axisx.min) continue;
|
||||
y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
|
||||
x1 = axisx.min;
|
||||
} else if (x2 <= x1 && x2 < axisx.min) {
|
||||
if (x1 < axisx.min) continue;
|
||||
y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1;
|
||||
x2 = axisx.min;
|
||||
}
|
||||
|
||||
// clip with xmax
|
||||
if (x1 >= x2 && x1 > axisx.max) {
|
||||
if (x2 > axisx.max) continue;
|
||||
y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
|
||||
x1 = axisx.max;
|
||||
} else if (x2 >= x1 && x2 > axisx.max) {
|
||||
if (x1 > axisx.max) continue;
|
||||
y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1;
|
||||
x2 = axisx.max;
|
||||
}
|
||||
|
||||
if (x1 != prevx || y1 != prevy) {
|
||||
ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset);
|
||||
}
|
||||
|
||||
var ax1 = axisx.p2c(x1) + xoffset,
|
||||
ay1 = axisy.p2c(y1) + yoffset,
|
||||
ax2 = axisx.p2c(x2) + xoffset,
|
||||
ay2 = axisy.p2c(y2) + yoffset,
|
||||
dashOffset;
|
||||
|
||||
function lineSegmentOffset(segmentLength) {
|
||||
|
||||
var c = Math.sqrt(Math.pow(ax2 - ax1, 2) + Math.pow(ay2 - ay1, 2));
|
||||
|
||||
if (c <= segmentLength) {
|
||||
return {
|
||||
deltaX: ax2 - ax1,
|
||||
deltaY: ay2 - ay1,
|
||||
distance: c,
|
||||
remainder: segmentLength - c
|
||||
}
|
||||
} else {
|
||||
var xsign = ax2 > ax1 ? 1 : -1,
|
||||
ysign = ay2 > ay1 ? 1 : -1;
|
||||
return {
|
||||
deltaX: xsign * Math.sqrt(Math.pow(segmentLength, 2) / (1 + Math.pow((ay2 - ay1)/(ax2 - ax1), 2))),
|
||||
deltaY: ysign * Math.sqrt(Math.pow(segmentLength, 2) - Math.pow(segmentLength, 2) / (1 + Math.pow((ay2 - ay1)/(ax2 - ax1), 2))),
|
||||
distance: segmentLength,
|
||||
remainder: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
//-end lineSegmentOffset
|
||||
|
||||
do {
|
||||
|
||||
dashOffset = lineSegmentOffset(
|
||||
dashRemainder > 0 ? dashRemainder :
|
||||
dashOn ? dashOnLength : dashOffLength);
|
||||
|
||||
if (dashOffset.deltaX != 0 || dashOffset.deltaY != 0) {
|
||||
if (dashOn) {
|
||||
ctx.lineTo(ax1 + dashOffset.deltaX, ay1 + dashOffset.deltaY);
|
||||
} else {
|
||||
ctx.moveTo(ax1 + dashOffset.deltaX, ay1 + dashOffset.deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
dashOn = !dashOn;
|
||||
dashRemainder = dashOffset.remainder;
|
||||
ax1 += dashOffset.deltaX;
|
||||
ay1 += dashOffset.deltaY;
|
||||
|
||||
} while (dashOffset.distance > 0);
|
||||
|
||||
prevx = x2;
|
||||
prevy = y2;
|
||||
}
|
||||
|
||||
ctx.stroke();
|
||||
}
|
||||
//-end plotDashes
|
||||
|
||||
ctx.save();
|
||||
ctx.translate(plotOffset.left, plotOffset.top);
|
||||
ctx.lineJoin = 'round';
|
||||
|
||||
var lw = series.dashes.lineWidth,
|
||||
sw = series.shadowSize;
|
||||
|
||||
// FIXME: consider another form of shadow when filling is turned on
|
||||
if (lw > 0 && sw > 0) {
|
||||
// draw shadow as a thick and thin line with transparency
|
||||
ctx.lineWidth = sw;
|
||||
ctx.strokeStyle = "rgba(0,0,0,0.1)";
|
||||
// position shadow at angle from the mid of line
|
||||
var angle = Math.PI/18;
|
||||
plotDashes(Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2));
|
||||
ctx.lineWidth = sw/2;
|
||||
plotDashes(Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4));
|
||||
}
|
||||
|
||||
ctx.lineWidth = lw;
|
||||
ctx.strokeStyle = series.color;
|
||||
|
||||
if (lw > 0) {
|
||||
plotDashes(0, 0);
|
||||
}
|
||||
|
||||
ctx.restore();
|
||||
|
||||
});
|
||||
//-end draw hook
|
||||
}
|
||||
//-end init
|
||||
|
||||
$.plot.plugins.push({
|
||||
init: init,
|
||||
options: {
|
||||
series: {
|
||||
dashes: {
|
||||
show: false,
|
||||
lineWidth: 2,
|
||||
dashLength: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
name: 'dashes',
|
||||
version: '0.1'
|
||||
});
|
||||
|
||||
})(jQuery)
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
/*! loglevel - v1.7.0 - https://github.com/pimterry/loglevel - (c) 2020 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});
|
||||
/*! 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&&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});
|
||||
@@ -608,6 +608,12 @@ table {
|
||||
.temperature-mark-type-done {
|
||||
background-color: #1b72f9;
|
||||
}
|
||||
.temperature-mark-type-connected {
|
||||
background-color: #666666;
|
||||
}
|
||||
.temperature-mark-type-disconnected {
|
||||
background-color: #333333;
|
||||
}
|
||||
|
||||
/** Various */
|
||||
|
||||
|
||||
@@ -9,37 +9,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
@@ -882,9 +882,9 @@ class ZTimelapse(Timelapse):
|
||||
and payload["old"] is not None
|
||||
and payload["new"] is not None
|
||||
):
|
||||
diff = round(abs(payload["new"] - payload["old"]), 3)
|
||||
zhop = round(self._retraction_zhop, 3)
|
||||
if diff == zhop:
|
||||
diff = abs(payload["new"] - payload["old"])
|
||||
zhop = self._retraction_zhop
|
||||
if abs(diff - zhop) < 0.001:
|
||||
return
|
||||
|
||||
# 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",
|
||||
)(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 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):
|
||||
if not isinstance(line, (str, bytes)):
|
||||
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
|
||||
)
|
||||
)
|
||||
@@ -1004,6 +1010,7 @@ def atomic_write(
|
||||
yield fd
|
||||
finally:
|
||||
fd.close()
|
||||
|
||||
os.chmod(fd.name, permissions)
|
||||
shutil.move(fd.name, filename)
|
||||
finally:
|
||||
|
||||
@@ -51,10 +51,7 @@ from octoprint.util.platform import get_os, set_close_exec
|
||||
try:
|
||||
import winreg
|
||||
except ImportError:
|
||||
try:
|
||||
import _winreg as winreg # type: ignore
|
||||
except ImportError:
|
||||
pass
|
||||
pass
|
||||
|
||||
_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.
|
||||
"""
|
||||
|
||||
__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
|
||||
scale = 25.4
|
||||
elif gcode == "G21": # Units are mm
|
||||
scale = 1.0
|
||||
scale = 1
|
||||
elif gcode == "G28": # Home
|
||||
x = getCodeFloat(line, "X")
|
||||
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
|
||||
~~~~~~~~~~~~~~~
|
||||
@@ -10,8 +9,6 @@
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
__version__ = '0.4.0'
|
||||
|
||||
import sys
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
try:
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
||||
except ImportError:
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
from .router import SockJSRouter
|
||||
from .conn import SockJSConnection
|
||||
@@ -1,6 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
"""
|
||||
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"
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import unittest
|
||||
|
||||
from ddt import data, ddt, unpack
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
Unit tests for ``octoprint.server.api``.
|
||||
"""
|
||||
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__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"
|
||||
@@ -2,7 +2,6 @@
|
||||
Unit tests for ``octoprint.server.api`` system.
|
||||
"""
|
||||
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__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"
|
||||
|
||||
@@ -11,11 +11,11 @@ import unittest
|
||||
|
||||
from ddt import data, ddt, unpack
|
||||
|
||||
##~~ _parse_header
|
||||
|
||||
|
||||
@ddt
|
||||
class ParseHeaderTest(unittest.TestCase):
|
||||
"""Tests for _parse_header"""
|
||||
|
||||
@data(
|
||||
("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)
|
||||
|
||||
|
||||
##~~ _strip_value_quotes
|
||||
|
||||
|
||||
@ddt
|
||||
class StripValueQuotesTest(unittest.TestCase):
|
||||
"""Tests for _strip_value_quotes"""
|
||||
|
||||
@data(
|
||||
("", ""),
|
||||
(None, None),
|
||||
@@ -78,11 +77,10 @@ class StripValueQuotesTest(unittest.TestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
||||
##~~ _extended_header_value
|
||||
|
||||
|
||||
@ddt
|
||||
class ExtendedHeaderValueTest(unittest.TestCase):
|
||||
"""Tests for _extended_header_value"""
|
||||
|
||||
@data(
|
||||
("", ""),
|
||||
(None, None),
|
||||
|
||||
@@ -58,11 +58,13 @@ class SettingsTest(unittest.TestCase):
|
||||
with self.mocked_basedir() as basedir:
|
||||
# construct settings
|
||||
settings = octoprint.settings.Settings()
|
||||
settings.set(["appearance", "name"], "unit test")
|
||||
settings.save()
|
||||
|
||||
# verify
|
||||
self.assertTrue(os.path.isdir(basedir))
|
||||
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):
|
||||
with self.mocked_basedir() as basedir:
|
||||
@@ -95,7 +97,9 @@ class SettingsTest(unittest.TestCase):
|
||||
my_basedir = tempfile.mkdtemp("octoprint-settings-test-custom")
|
||||
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(
|
||||
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_exists.return_value = False
|
||||
|
||||
umask = 0o026
|
||||
|
||||
# test
|
||||
with octoprint.util.atomic_write(targetpath) as f:
|
||||
f.write("test")
|
||||
with mock.patch("octoprint.util.UMASK", umask):
|
||||
with octoprint.util.atomic_write(targetpath) as f:
|
||||
f.write("test")
|
||||
|
||||
# assert
|
||||
mock_ntf.assert_called_once_with(
|
||||
@@ -227,7 +230,7 @@ class TestAtomicWrite(unittest.TestCase):
|
||||
def test_atomic_write_rel_path_aware(
|
||||
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
|
||||
tmpdirpath = "../test"
|
||||
@@ -240,9 +243,12 @@ class TestAtomicWrite(unittest.TestCase):
|
||||
mock_ntf.return_value = mock_file
|
||||
mock_exists.return_value = False
|
||||
|
||||
umask = 0o026
|
||||
|
||||
# test
|
||||
with octoprint.util.atomic_write(targetpath) as f:
|
||||
f.write("test")
|
||||
with mock.patch("octoprint.util.UMASK", umask):
|
||||
with octoprint.util.atomic_write(targetpath) as f:
|
||||
f.write("test")
|
||||
|
||||
# assert
|
||||
mock_ntf.assert_called_once_with(
|
||||
|
||||
Reference in new issue
Block a user