Compare commits

...
47 Commits
Author SHA1 Message Date
Gina Häußge f430257d70 Merge branch 'rc/maintenance' 2022-05-16 14:58:38 +02:00
Gina Häußge d2a9aaceda 🔖 Preparing release of 1.8.0 2022-05-16 14:55:05 +02:00
Gina Häußge 8ca327669c 🔒️ XSS in webcam stream URL test in Chrome
Apparently Chrome will happily create URL objects from
what is actually HTML tags. So now we will also
URI encode the stream URL prior to embedding in the page.
2022-05-12 18:58:16 +02:00
Gina Häußge d1fca86636 🥅 Better error handling 2022-05-12 10:58:08 +02:00
Gina Häußge 4d9e86ca0f 🐛 We also recognize webrtcs: for webcam streams
Thanks for the heads-up, @cp2004
2022-05-12 10:57:39 +02:00
Gina Häußge 6d259d7e6f 🔒️ Fix XSS in webcam stream test 2022-05-11 16:40:07 +02:00
Gina Häußge 5ef16773c8 🔒️ Escape requested user id
Fixes an XSS issue.
2022-05-11 13:03:40 +02:00
Gina Häußge 8087528e4a 🔒️ Sanitize and validate login redirect
Fixes an XSS and an open redirect issue.
2022-05-11 13:02:52 +02:00
Gina Häußge 700034d028 🔒️ Set remember_me cookie http only 2022-05-10 20:56:48 +02:00
Gina Häußge 885ca31168 👷‍♂️ Fix nightly merge
The action needed an upgrade due to a behaviour change in latest git.
2022-05-04 11:28:25 +02:00
Billy Richardson 64c21ba8f0 ✏️ Documentation spelling fixes (#4497) 2022-04-24 17:21:13 +01:00
Gina Häußge 53dbde2ef9 🔖 staging/maintenance is now 1.8.0rc6.dev 2022-04-12 16:21:41 +02:00
Gina Häußge 45598764e6 🔖 Preparing release of 1.8.0rc5 2022-04-12 15:30:56 +02:00
Gina Häußge 2ecc1c944f 🥅 Only use the first value pair for a temp sensor
This protects against lines from the printer like

  T:210.04 /210.00 B:52.00 /52.00 @:85 B:1234.0 /1234.0

We've seen *so* much weird stuff out there in firmware, let's better
be safe rather than sorry and rule out latter values from overwriting
former values just in case.
2022-04-12 14:26:55 +02:00
Gina Häußge d81504c12e 🐛 Fix folder saving & config migration
Settings._config has been turned into a read-only view by the
recent refactoring of the settings hierarchy. Refactored our use
as needed to still function and added deprecated decorator to
getter and setter property to communicate this change in behaviour.

_config wasn't documented, so it is not part of the official API and
thus this doesn't qualify as a breaking change, however there might
be plugins there that went beyond the documented API and use it in
some way (possibly even stuff I have written in the past), so
best give them a heads-up.

Closes #4486
2022-04-11 16:51:22 +02:00
Gina Häußge 302ccc087b 🔖 staging/maintenance is now 1.8.0rc5.dev 2022-04-05 14:49:48 +02:00
Gina Häußge c5b095a8b9 🔖 Preparing release of 1.8.0rc4 2022-04-05 13:25:05 +02:00
Gina Häußge f4b4f50cfd 🐛 Fix handling of invalid intermittend values
We not only ignore None values on our subkey paths, we ignore
anything that isn't a dict we can further level down in.

Closes #4479
2022-04-04 19:02:44 +02:00
Gina Häußge 9faec6e982 🔖 staging/maintenance is now 1.8.0rc4.dev 2022-03-29 14:05:23 +02:00
Gina Häußge 3c478036ae Merge branch 'master' into staging/maintenance 2022-03-29 11:19:35 +02:00
Gina Häußge 76e87ba813 💚 Pin click in pre-commit black
See psf/black#2964

To be replaced by an update of black et al in dev branches.
2022-03-29 11:19:16 +02:00
Gina Häußge ad32bbfdb8 🐛 Add back accidentally removed flask-login req 2022-03-29 10:55:15 +02:00
Gina Häußge ccd5fa56a2 📌 Pin werkzeug to 2.0.x for now
Apparently werkzeug removes stuff on minor releases and that just
broke flask-login 0.5. A newer version isn't out yet, so we pin to
a lower version of werkzeug for 1.8.0 and will then see what to do
with this situation for 1.9 and later (potentially even vendor
flask-login as it appears pretty dead currently).
2022-03-29 10:38:04 +02:00
Gina Häußge 24b5b3a857 🐛 Fix potential race condition in webassets
Could trigger when reloading page while preliminary cache
was being done, causing an internal server error
on page load, immediately fixed by a second reload.

Seems to be caused by the change in webasset handling
in 1.8.0, hence considering this a regression.

Fix consists of switching to a thread-safe in-memory
manifest storage.
2022-03-28 16:42:46 +02:00
Gina Häußge 3be85646cd 🔖 Preparing release of 1.8.0rc3 2022-03-28 14:27:38 +02:00
Gina Häußge 54207abbe1 ⬆️ Require latest version of the PiSupport plugin 2022-03-28 11:23:35 +02:00
Gina Häußge 4c4721518c Merge branch 'master' into staging/maintenance 2022-03-23 10:24:02 +01:00
Gina Häußge 772f9f95da 📌 pre-commit: Pin flake8 bugbear
The new version will cause pre-commit to fail, we need to fix
the newly detected issues but not on frozen code (like master
or to a degree the RCs).
2022-03-23 10:23:18 +01:00
Gina Häußge 6728a17448 🚸 Re-enable connect dialog w/ no serial ports
Apparently disabling it if no serial ports are currently
known to the client breaks certain workflows for people.

So this is a short-term solution to fix things for them, while
technically non-sensical (why offer to connect if we don't see
anything to connect to?) So in 1.9.0 this should rather be
solved by adding some form of platform agnostic (!) auto-refresh,
either regular polling while no port is detected, or even
watchdog enabled event based refresh. See #4473.
2022-03-22 12:07:59 +01:00
Zack Lewis 7bc2a79642 ✏️ Spelling correction in software update docs (#4466)
* Spelling Correction

supplyting -> supplying

* Update AUTHORS.md
2022-03-17 22:32:24 +00:00
Gina Häußge 8c9536f323 🐛 GCV: Send the final layer to the UI as well
Closes #4463
2022-03-17 14:28:16 +01:00
Charlie Powell 594b660bb6 :pencil2 2022-03-16 21:44:03 +00:00
Gina Häußge 23f90060c6 🔖 staging/maintenance is now 1.8.0rc3.dev 2022-03-16 11:53:23 +01:00
Gina Häußge 76c5924532 ⬆️ Force upgrade PiSupport to 2022.3.1+
Not 2021.3.1... 🤦‍♀️
2022-03-16 10:45:52 +01:00
Gina Häußge 6fc2edcc1f 🚸 Expose serial.ignoreEmptyPorts on UI
Closes #4460
2022-03-15 19:30:41 +01:00
Gina Häußge 056eb122f3 🐛 Fix some more less 4 incompatibilities 2022-03-15 18:27:06 +01:00
Gina Häußge 33cef57551 🐛 GCV: Fix layer transmission logic
Only ever send *completed* layers to the frontend. Otherwise in case of
zHops and such we risk sending incomplete layers and missing whole
command segments in the process.

Closes #4459
2022-03-15 17:42:01 +01:00
Gina Häußge 9563e898ba 🐛 GCV: Don't try to iterate empty models 2022-03-15 17:39:51 +01:00
Gina Häußge 3816c95678 🐛 Fix get_by_path for empty default dicts & local keys
Closes #4458
2022-03-15 14:36:55 +01:00
Gina Häußge df3b3420ab 🐛 Fix custom temperature handling
* Fix too broad regex
  * Fix lack of error handling in case of reserved identifier

All of these got already introduced in 1.4.1, but now with #4388
they are WAY more likely to pop up (e.g. in garbage lines too) and
completely nuke the connection.

Closes #4456
2022-03-15 12:38:11 +01:00
Gina Häußge 6cd87d1c84 🔖 Preparing of 1.8.0rc2 2022-03-14 18:08:40 +01:00
Gina Häußge fd125e3569 ⬆️ Upgrade outdated sentry-sdk 2022-03-14 18:08:03 +01:00
Gina Häußge 6033ca9a8f 📝 appkeys: Add docs for new auth dialog workflow 2022-03-14 16:26:25 +01:00
Gina Häußge 091edac818 🔖 make staging/maintenance actually be 1.8.0rc2.dev 2022-03-14 15:59:07 +01:00
Gina Häußge e59fab10f8 🥅 More resilience against template plugin bugs
* Don't crash if template is set to None
  * In general catch any error while processing plugin template
    configs and ignore plugin completely.

Closes #4453
2022-03-14 15:17:34 +01:00
Gina Häußge 7f348146cb 🐛 Fix handling of integer keys in the settings
Closes #4454
2022-03-14 14:46:55 +01:00
Gina Häußge 4a3b50cd3e 🔖 staging/maintenance is now 1.8.0rc2.dev 2022-03-14 12:29:32 +01:00
47 changed files with 2761 additions and 2299 deletions

No files matched your search

+2 -2
View File
@@ -15,7 +15,7 @@ jobs:
fetch-depth: 0
- name: 🔀 Merge master into maintenance
uses: robotology/gh-action-nightly-merge@v1.3.2
uses: robotology/gh-action-nightly-merge@v1.3.3
with:
stable_branch: "master"
development_branch: "maintenance"
@@ -24,7 +24,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🔀 Merge maintenance into devel
uses: robotology/gh-action-nightly-merge@v1.3.2
uses: robotology/gh-action-nightly-merge@v1.3.3
with:
stable_branch: "maintenance"
development_branch: "devel"
+3 -1
View File
@@ -47,12 +47,14 @@ repos:
hooks:
- id: black
args: ["--config", "black.toml"]
additional_dependencies:
- click==8.0.4
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-bugbear==22.1.11
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
+3 -3
View File
@@ -29,10 +29,10 @@ improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev
staging/bugfix 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev
bug/.* 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.7.0rc4
# staging/maintenance is currently the branch for preparation of 1.8.0rc6
# so is regressionfix/...
staging/maintenance 1.7.0rc4 f31194f75365787f3eb5da61a24f2f8620111f4f pep440-dev
regressionfix/.* 1.7.0rc4 f31194f75365787f3eb5da61a24f2f8620111f4f pep440-dev
staging/maintenance 1.8.0rc6 45598764e6c7f6257de87a98d15964209ddc9e09 pep440-dev
regressionfix/.* 1.8.0rc6 45598764e6c7f6257de87a98d15964209ddc9e09 pep440-dev
# staging/devel is currently inactive (but has the 1.4.1rc4 namespace)
staging/devel 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
+1
View File
@@ -164,6 +164,7 @@ date of first contribution):
* [Shell M. Shrader](https://github.com/synman)
* [Johan Verrept](https://github.com/JoveToo)
* [Nicu Surdu](https://github.com/surdu)
* [Zack Lewis](https://github.com/lima3w)
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
+8 -4
View File
@@ -8,6 +8,7 @@ thanks to everyone who contributed!
* 3D-TECH
* 3DPrinterOS
* Al Mucci
* Arnljot Arntsen
* Artillery 3D
* Ash King
@@ -20,6 +21,7 @@ thanks to everyone who contributed!
* Christian Wolf
* Christian Würthner
* Christoph Sigrist
* Craig Parker
* Creality3D
* David Bounds
* DeltaMaker 3D Printers
@@ -34,7 +36,9 @@ thanks to everyone who contributed!
* Hog Duske
* Itay Shem-tov
* James Mackay
* Jeff Green
* Jeff Moe
* jeffiel
* Jeremy Cole
* Joshua Wills
* Julian Melo
@@ -45,16 +49,15 @@ thanks to everyone who contributed!
* Kurt Wubbels
* Kyle Menigoz
* Lachlan Bell
* Lee Dohm
* Lefteris Lertas
* LulzBot
* Makespace Madrid
* Mark Walker
* Matt Van Itallie
* Michael Aumock
* Mike Kershaw
* Miles Flavel
* Mosaic Manufacturing
* Nat Friedman
* Norman Jaffe
* Peopoly
* Pete Barnwell
@@ -66,6 +69,7 @@ thanks to everyone who contributed!
* Richard Stocks
* Robert Gusek
* Ronald Griehsler
* Sean Jensen-Grey
* Sebastien Andrivet
* Stefan Krister
* Steve Dougherty
@@ -74,7 +78,7 @@ thanks to everyone who contributed!
* The Spaghetti Detective
* TJ Horner
* Trent Shumay
* Ulderico Cirello
* Ulrich Kempken
* Yehuda Katz
and 2298 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
and 2279 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
+2 -2
View File
@@ -2,11 +2,11 @@
[jinja2: src/octoprint/templates/**.jinja2]
silent=false
extensions=jinja2.ext.autoescape, jinja2.ext.with_, webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch
extensions=webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch
[jinja2: src/octoprint/plugins/**.jinja2]
silent=false
extensions=jinja2.ext.autoescape, jinja2.ext.with_, webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch
extensions=webassets.ext.jinja2.AssetsExtension, jinja2.ext.do, octoprint.util.jinja.trycatch
[javascript: src/octoprint/static/js/app/**.js]
extract_messages = gettext, ngettext
+1 -1
View File
@@ -649,7 +649,7 @@ Permission record
* - ``dangerous``
- 1
- boolean
- Whether the permission should be considered dangerous due to a high reponsibility (true) or not (false).
- Whether the permission should be considered dangerous due to a high responsibility (true) or not (false).
* - ``default_groups``
- 1
- List of string
+126 -7
View File
@@ -45,10 +45,11 @@ of the following steps:
2. The App :ref:`probes for workflow support <sec-bundledplugins-appkeys-api-probe>` on the Server. If this request
doesn't get an HTTP :http:statuscode:`204` the App needs to direct the user to an alternative manual workflow
(copy-paste API key) and abort this one. Otherwise it proceeds to the next step.
3. The App sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
3. The App sends an :ref:`Authorization request <sec-bundledplugins-appkey-datamodel-authrequest>` to the Server to start the
authorization process.
4. The Server triggers a confirmation dialog for the User on the Webinterface and returns an endpoint to the
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`.
4. The Server triggers a confirmation dialog for the User on the Webinterface (unused here) and returns an endpoint to the
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`
and an :ref:`Authorization response <sec-bundledplugins-appkey-datamodel-authresponse>` (unused here).
5. The App uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
signals that no decision has been made yet.
6. The User either accepts or denies the access request which makes the Webinterface send a
@@ -116,6 +117,98 @@ of the following steps:
end
.. _sec-bundledplugins-appkeys-workflow-authdialog:
Workflow with redirect to auth dialog
-------------------------------------
.. versionadded:: 1.8.0
Instead of asking the user to open the full blown OctoPrint interface to confirm the request,
since OctoPrint 1.8.0 there also exists the alternative of redirecting the user to a
basic auth dialog that allows logging in and confirming the request in a light-weight
dialog. To implementat that, follow these steps:
1. The User opens the App and gets prompted to enter or select an instance URL. Optionally (recommended!) the User also
enters their username which is also their user ID into the App.
2. The App :ref:`probes for workflow support <sec-bundledplugins-appkeys-api-probe>` on the Server. If this request
doesn't get an HTTP :http:statuscode:`204` the App needs to direct the user to an alternative manual workflow
(copy-paste API key) and abort this one. Otherwise it proceeds to the next step.
3. The App sends an :ref:`Authorization request <sec-bundledplugins-appkey-datamodel-authrequest>` to the Server to start the
authorization process.
4. The Server triggers a confirmation dialog for the User on the Webinterface (unused here) and returns an endpoint to the
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`
and an :ref:`Authorization response <sec-bundledplugins-appkey-datamodel-authresponse>`.
5. The App opens a browser window with the provided `auth_dialog` URL for the user to log in and confirm the request. At the
same time the App also uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
signals that no decision has been made yet.
6. The User logs in and either accepts or denies the access request which makes the auth dialog send a
:ref:`decision request <sec-bundledplugins-appkey-datamodel-decisionrequest>` to the Server.
7. If the User accepted the request, the App receives an HTTP :http:statuscode:`200` with an attached
:ref:`API key response <sec-bundledplugins-appkey-datamodel-keyresponse>`. If they deny it, the App will receive
an HTTP :http:statuscode:`404`.
.. mermaid::
sequenceDiagram
participant User
participant App
participant Auth Dialog
participant Server
note over User, Server: Step 1, 2 & 3
User->>App: enters URL of instance to connect to and optional user_id
App->>Server: GET /plugin/appkeys/probe
alt Workflow unsupported
Server->>App: 404
App->>User: alternative workflow, copy-paste key manually
else Workflow supported
App->>Server: POST /plugin/appkeys/request, (app_name, user_id)
note over User, Server: Step 4
Server->>App: 201, Location: /plugin/appkeys/request/<app_token>, auth_dialog: <auth_dialog>
note over User, Server: Step 5
App-->>Auth Dialog: open new browser window with auth_dialog URL
loop Poll for decision
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 202
end
note over User, Server: Step 6 & 7
User->>Auth Dialog: Logs in
alt User accepts
User-->>Auth Dialog: Allow access
Auth Dialog->>Server: POST /plugin/appkeys/decision/<user_token>, (True)
Server->>Auth Dialog: 204
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 200, api_key
else User denies
User-->>Auth Dialog: Deny access
Auth Dialog->>Server: POST /plugin/appkeys/decision/<user_token>, (False)
Server->>Auth Dialog: 204
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 404
end
end
.. _sec-bundledplugins-appkeys-api:
API
@@ -144,7 +237,7 @@ Start authorization process
Starts the authorization process.
Expects a :ref:`Key request <sec-bundledplugins-appkey-datamodel-keyrequest>` as request body.
Expects a :ref:`Authorization request <sec-bundledplugins-appkey-datamodel-authrequest>` as request body.
The ``app`` parameter should be a human readable identifier to use
for the application requesting access. It will be displayed to the user. Internally it will be used case insensitively,
@@ -156,6 +249,9 @@ Start authorization process
it in the ``user`` parameter. OctoPrint will then only display the authorization request on browsers the user ``me``
is logged in on.
Returns a :ref:`Authorization response <sec-bundledplugins-appkey-datamodel-authresponse>`
and HTTP :http:statuscode:`201` with the ``Location`` header set to the endpoint to poll for a decision.
:json app: application identifier to use for the request, case insensitive
:json user: optional user id to restrict the decision to the specified user
:status 201: authorization process started, polling URL to query can be found in ``Location`` header
@@ -287,10 +383,10 @@ Issue an application key command
Data model
----------
.. _sec-bundledplugins-appkey-datamodel-keyrequest:
.. _sec-bundledplugins-appkey-datamodel-authrequest:
Key request
...........
Authorization request
.....................
.. list-table::
:widths: 15 5 10 30
@@ -309,6 +405,29 @@ Key request
- str
- User identifier/name to restrict the request to
.. _sec-bundledplugins-appkey-datamodel-authresponse:
Authorization response
......................
.. list-table::
:widths: 15 5 10 30
:header-rows: 1
* - Name
- Multiplicity
- Type
- Description
* - ``app_token``
- 1
- str
- Application token to use to poll for the decision.
* - ``auth_dialog``
- 1
- str
- An URL with which a dedicated auth dialog can be used for the user to log into
and authorize the request.
.. _sec-bundledplugins-appkey-datamodel-keyresponse:
Key response
+1 -1
View File
@@ -560,7 +560,7 @@ Global credentials
.. versionadded:: 1.5.0
Starting with OctoPrint 1.5.0, the Software Update Plugin supports supplyting a GitHub
Starting with OctoPrint 1.5.0, the Software Update Plugin supports supplying a GitHub
API token to use for the ``github_release`` and ``github_commit`` version check types,
to work around possible rate limit problems if a lot of checks are to be made from a single
external IP. You may create a `personal access token <https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token>`_
+5
View File
@@ -451,6 +451,11 @@ Use the following settings to enable or disable OctoPrint features:
# whether G90/G91 also influence absolute/relative mode of extruders
g90InfluencesExtruder: false
# Replace all special characters and spaces with text equivalent to make them universally compatible.
# Most OS filesystems work fine with unicode characters, but just in case you can revert to the
# older behaviour by setting this to true.
enforceReallyUniversalFilenames: false
.. _sec-configuration-config_yaml-folder:
+1 -1
View File
@@ -216,7 +216,7 @@ There many configuration options via ``config.yaml`` for the virtual printer tha
# Enable virtual EEPROM
# If enabled, a file `eeprom.json` will be created in the plugin data folder
# to enable settings persistence across connections. Enables M500/1/2/4 commmands
# to enable settings persistence across connections. Enables M500/1/2/4 commands
# And a selection of other settings commands. Responses modeled on Marlin 2.0
enable_eeprom: true
+1 -1
View File
@@ -133,7 +133,7 @@ Example: Your PC has an IP address of ``192.168.23.42`` and a subnet mask of
The easy way: Using the OctoPrint-AutoLoginConfig plugin
........................................................
The easist way to configure AutoLogin is to install the
The easiest way to configure AutoLogin is to install the
`OctoPrint-AutoLoginConfig plugin <https://plugins.octoprint.org/plugins/autologin_config/>`_
via the plugin manager.
+1 -1
View File
@@ -1938,7 +1938,7 @@ octoprint.timelapse.capture.post
Perform specific actions after capturing a timelapse frame.
``filename`` will be the path of the frame that should have been saved.
``sucesss`` indicates whether the capture was successful or not.
``success`` indicates whether the capture was successful or not.
:param str filename: The path of the frame that should have been saved.
:param boolean success: Indicates whether the capture was successful or not.
+1 -1
View File
@@ -336,7 +336,7 @@ As a summary, follow this checklist to migrate your plugin to be compatible to b
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
* Thorougly test your plugin under Python 3. Pay special attention to any kind of string handling issues, integer
* Thoroughly test your plugin under Python 3. Pay special attention to any kind of string handling issues, integer
division, relative imports from your plugin package and how the results of ``map``, ``filter`` and ``zip`` are
used in your code, as those have proven to be the biggest issues during past migrations.
* Once everything works under both Python versions and you've prepared a new release of your plugin (don't forget to
+3 -2
View File
@@ -31,7 +31,7 @@ SETUP_REQUIRES = []
bundled_plugins = [
"OctoPrint-FileCheck>=2021.2.23",
"OctoPrint-FirmwareCheck>=2021.10.11",
"OctoPrint-PiSupport>=2021.3.1",
"OctoPrint-PiSupport>=2022.3.28",
]
core_deps = [
"cachelib>=0.2,<0.3",
@@ -58,10 +58,11 @@ core_deps = [
"requests>=2.26.0,<3",
"sarge==0.1.6",
"semantic_version>=2.8.5,<3",
"sentry-sdk>=1.3.1,<2",
"sentry-sdk>=1.5.7,<2",
"tornado>=6.0.4,<7",
"watchdog>=1,<2",
"websocket-client>=1.2.1,<2",
"werkzeug>=2.0,<2.1", # breaking changes can happen on minor version increases, flask-login 0.5 is incompatible with 2.1
"wrapt>=1.13.3,<1.14",
"zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases
"zipstream-ng>=1.3.4,<2.0.0",
@@ -18,10 +18,10 @@ from octoprint.util.version import (
)
SENTRY_URL_SERVER = (
"https://87d311e64fdc40f096a1049d99307bf5@o118517.ingest.sentry.io/1373987"
"https://0d173c8b74b945e1bdc73443e543ddee@o118517.ingest.sentry.io/1373987"
)
SENTRY_URL_COREUI = (
"https://91516ad9a76c47409b02734cbe8492c5@o118517.ingest.sentry.io/1374096"
"https://f38a3d0ad2694f7f8672b1a2485c3820@o118517.ingest.sentry.io/1374096"
)
SETTINGS_DEFAULTS = {
@@ -1,2 +1,3 @@
/*! @sentry/browser 5.18.1 (b1261aab) | https://github.com/getsentry/sentry-javascript */
var Sentry=function(t){var n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(t,r)};function r(t,r){function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}var e=function(){return(e=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var i in n=arguments[r])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)};function i(t){var n="function"==typeof Symbol&&t[Symbol.iterator],r=0;return n?n.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function o(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,i,o=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=o.next()).done;)u.push(e.value)}catch(t){i={error:t}}finally{try{e&&!e.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}function u(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(o(arguments[n]));return t}var c,a,s;!function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Debug=2]="Debug",t[t.Verbose=3]="Verbose"}(c||(c={})),(a=t.Severity||(t.Severity={})).Fatal="fatal",a.Error="error",a.Warning="warning",a.Log="log",a.Info="info",a.Debug="debug",a.Critical="critical",function(t){t.fromString=function(n){switch(n){case"debug":return t.Debug;case"info":return t.Info;case"warn":case"warning":return t.Warning;case"error":return t.Error;case"fatal":return t.Fatal;case"critical":return t.Critical;case"log":default:return t.Log}}}(t.Severity||(t.Severity={})),(s=t.Status||(t.Status={})).Unknown="unknown",s.Skipped="skipped",s.Success="success",s.RateLimit="rate_limit",s.Invalid="invalid",s.Failed="failed",function(t){t.fromHttpCode=function(n){return n>=200&&n<300?t.Success:429===n?t.RateLimit:n>=400&&n<500?t.Invalid:n>=500?t.Failed:t.Unknown}}(t.Status||(t.Status={}));var f=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){return t.__proto__=n,t}:function(t,n){for(var r in n)t.hasOwnProperty(r)||(t[r]=n[r]);return t});var h=function(t){function n(n){var r=this.constructor,e=t.call(this,n)||this;return e.message=n,e.name=r.prototype.constructor.name,f(e,r.prototype),e}return r(n,t),n}(Error);function v(t){switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return E(t,Error)}}function l(t){return"[object ErrorEvent]"===Object.prototype.toString.call(t)}function d(t){return"[object DOMError]"===Object.prototype.toString.call(t)}function p(t){return"[object String]"===Object.prototype.toString.call(t)}function y(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function m(t){return"[object Object]"===Object.prototype.toString.call(t)}function b(t){return"undefined"!=typeof Event&&E(t,Event)}function w(t){return"undefined"!=typeof Element&&E(t,Element)}function g(t){return Boolean(t&&t.then&&"function"==typeof t.then)}function E(t,n){try{return t instanceof n}catch(t){return!1}}function x(t,n){return void 0===n&&(n=0),"string"!=typeof t||0===n?t:t.length<=n?t:t.substr(0,n)+"..."}function j(t,n){if(!Array.isArray(t))return"";for(var r=[],e=0;e<t.length;e++){var i=t[e];try{r.push(String(i))}catch(t){r.push("[value cannot be serialized]")}}return r.join(n)}function k(t,n){return!!p(t)&&(r=n,"[object RegExp]"===Object.prototype.toString.call(r)?n.test(t):"string"==typeof n&&-1!==t.indexOf(n));var r}function S(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}var T={};function O(){return S()?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:T}function _(){var t=O(),n=t.crypto||t.msCrypto;if(void 0!==n&&n.getRandomValues){var r=new Uint16Array(8);n.getRandomValues(r),r[3]=4095&r[3]|16384,r[4]=16383&r[4]|32768;var e=function(t){for(var n=t.toString(16);n.length<4;)n="0"+n;return n};return e(r[0])+e(r[1])+e(r[2])+e(r[3])+e(r[4])+e(r[5])+e(r[6])+e(r[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}function D(t){if(!t)return{};var n=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!n)return{};var r=n[6]||"",e=n[8]||"";return{host:n[4],path:n[5],protocol:n[2],relative:n[5]+r+e}}function R(t){if(t.message)return t.message;if(t.exception&&t.exception.values&&t.exception.values[0]){var n=t.exception.values[0];return n.type&&n.value?n.type+": "+n.value:n.type||n.value||t.event_id||"<unknown>"}return t.event_id||"<unknown>"}function I(t){var n=O();if(!("console"in n))return t();var r=n.console,e={};["debug","info","warn","error","log","assert"].forEach(function(t){t in n.console&&r[t].__sentry_original__&&(e[t]=r[t],r[t]=r[t].__sentry_original__)});var i=t();return Object.keys(e).forEach(function(t){r[t]=e[t]}),i}function N(t,n,r){t.exception=t.exception||{},t.exception.values=t.exLine truncated
/*! @sentry/browser 6.18.2 (22f518e) | https://github.com/getsentry/sentry-javascript */
var Sentry=function(t){var n=function(t,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},n(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}var i,e=function(){return e=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++)for(var e in n=arguments[r])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t},e.apply(this,arguments)};function o(t){var n="function"==typeof Symbol&&Symbol.iterator,r=n&&t[n],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,e,o=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(i=o.next()).done;)u.push(i.value)}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return u}function a(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(u(arguments[n]));return t}t.Severity=void 0,(i=t.Severity||(t.Severity={})).Fatal="fatal",i.Error="error",i.Warning="warning",i.Log="log",i.Info="info",i.Debug="debug",i.Critical="critical";var c={};function s(){return"undefined"!=typeof window?window:"undefined"!=typeof self?self:c}var f=Object.prototype.toString;function h(t){switch(f.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return x(t,Error)}}function v(t,n){return f.call(t)==="[object "+n+"]"}function d(t){return v(t,"ErrorEvent")}function l(t){return v(t,"DOMError")}function p(t){return v(t,"String")}function y(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function m(t){return v(t,"Object")}function b(t){return"undefined"!=typeof Event&&x(t,Event)}function w(t){return"undefined"!=typeof Element&&x(t,Element)}function g(t){return Boolean(t&&t.then&&"function"==typeof t.then)}function x(t,n){try{return t instanceof n}catch(t){return!1}}function E(t,n){try{for(var r=t,i=[],e=0,o=0,u=" > ".length,a=void 0;r&&e++<5&&!("html"===(a=_(r,n))||e>1&&o+i.length*u+a.length>=80);)i.push(a),o+=a.length,r=r.parentNode;return i.reverse().join(" > ")}catch(t){return"<unknown>"}}function _(t,n){var r,i,e,o,u,a=t,c=[];if(!a||!a.tagName)return"";c.push(a.tagName.toLowerCase());var s=n&&n.length?n.filter((function(t){return a.getAttribute(t)})).map((function(t){return[t,a.getAttribute(t)]})):null;if(s&&s.length)s.forEach((function(t){c.push("["+t[0]+'="'+t[1]+'"]')}));else if(a.id&&c.push("#"+a.id),(r=a.className)&&p(r))for(i=r.split(/\s+/),u=0;u<i.length;u++)c.push("."+i[u]);var f=["type","name","title","alt"];for(u=0;u<f.length;u++)e=f[u],(o=a.getAttribute(e))&&c.push("["+e+'="'+o+'"]');return c.join("")}var j=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){return t.__proto__=n,t}:function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(t,r)||(t[r]=n[r]);return t});var k=function(t){function n(n){var r=this.constructor,i=t.call(this,n)||this;return i.message=n,i.name=r.prototype.constructor.name,j(i,r.prototype),i}return r(n,t),n}(Error),S=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;function O(t,n){void 0===n&&(n=!1);var r=t.host,i=t.path,e=t.pass,o=t.port,u=t.projectId;return t.protocol+"://"+t.publicKey+(n&&e?":"+e:"")+"@"+r+(o?":"+o:"")+"/"+(i?i+"/":i)+u}function T(t){return"user"in t&&!("publicKey"in t)&&(t.publicKey=t.user),{user:t.publicKey||"",protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function D(t){var n="string"==typeof t?function(t){var n=S.exec(t);if(!n)throw new k("Invalid Sentry Dsn: "+t);var r=u(n.slice(1),6),i=r[0],e=r[1],o=r[2],a=void 0===o?"":o,c=r[3],s=r[4],f=void 0===s?"":s,h="",v=r[5],d=v.split("/");if(d.length>1&&(h=d.slice(0,-1).join("/"),v=d.pop()),v){var l=v.match(/^\d+/);l&&(v=l[0])}return T({host:c,pass:a,path:h,projectId:v,port:f,protocol:i,publicKey:e})}(t):T(t);return n}var R=["fatal","error","warning","log","info","debug","critical"],N=s(),I="Sentry Logger ";function M(t){var n=s();if(!("console"in n))return t();var r=n.console,i={};["debug","info","warn","error","log","assert"].forEach((function(t){t in n.console&&r[t].__sentry_original__&&(i[t]=r[t],r[t]=r[t].__sentry_original__)}));var e=t();return Object.keys(i).forEach((function(t){r[t]=i[t]})),e}var q=function(){function t(){this.t=!1}return t.prototype.disable=function(){this.t=!1},t.prototype.enable=function(){this.t=!0},t.prototype.log=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this.t&&M((function(){var n;(n=N.console).log.apply(n,a([I+"[Log]:Line truncated
//# sourceMappingURL=bundle.min.js.map
@@ -138,28 +138,31 @@ GCODE.gCodeReader = (function () {
var rebuildLayerPercentageLookup = function (m) {
var result = [];
for (var i = 0; i < m.length - 1; i++) {
// start is first command of current layer
var start = m[i].length ? m[i][0].percentage : -1;
var end = -1;
for (var j = i + 1; j < m.length; j++) {
// end is percentage of first command that follows our start, might
// be later layers if the next layer is empty!
if (m[j].length) {
end = m[j][0].percentage;
break;
if (m && m.length > 0) {
for (var i = 0; i < m.length - 1; i++) {
// start is first command of current layer
var start = m[i].length ? m[i][0].percentage : -1;
var end = -1;
for (var j = i + 1; j < m.length; j++) {
// end is percentage of first command that follows our start, might
// be later layers if the next layer is empty!
if (m[j].length) {
end = m[j][0].percentage;
break;
}
}
result[i] = [start, end];
}
result[i] = [start, end];
// final start-end-pair is start percentage of last layer and 100%
result[m.length - 1] = m[m.length - 1].length
? [m[m.length - 1][0].percentage, 100]
: [-1, -1];
}
// final start-end-pair is start percentage of last layer and 100%
result[m.length - 1] = m[m.length - 1].length
? [m[m.length - 1][0].percentage, 100]
: [-1, -1];
layerPercentageLookup = result;
};
@@ -303,6 +303,7 @@ var analyzeModel = function () {
var doParse = function () {
var argChar, numSlice;
var activeLayer = undefined;
var sendLayer = undefined;
var sendMultiLayer = [];
var lastSend = 0;
@@ -599,7 +600,6 @@ var doParse = function () {
}
layer = model.length;
sendLayer = layer;
prevZ = z;
}
@@ -634,49 +634,62 @@ var doParse = function () {
};
if (zLift) {
// Insert zLift moves for later processing
// Insert zLift moves for later processing - they might be part of
// the active layer still
zLiftMoves.push({
command: command,
layer: layer
});
} else if (zLiftMoves.length > 0) {
// there's something to be checked in the Z-lift cache
if (prevZ < maxLiftZ) {
zLiftMoves.forEach(function (zLiftMove) {
// move command from move layer...
model[zLiftMove.layer].splice(
model[layer].indexOf(zLiftMove.command),
1
);
// ... to z-lift layer
model[zLiftLayer].push(zLiftMove.command);
});
} else {
if (zLiftMoves.length > 0) {
// there's something to be checked in the Z-lift cache
if (prevZ < maxLiftZ) {
zLiftMoves.forEach(function (zLiftMove) {
// move command from move layer...
model[zLiftMove.layer].splice(
model[layer].indexOf(zLiftMove.command),
1
);
// ... to z-lift layer
model[zLiftLayer].push(zLiftMove.command);
});
// clean up empty layers at the end of the model
var spliceFrom = undefined;
for (var l = model.length - 1; l > 0; l--) {
if (model[l].length > 0) break;
spliceFrom = l;
}
if (spliceFrom !== undefined) {
model.splice(spliceFrom, model.length - spliceFrom);
// clean up empty layers at the end of the model
var spliceFrom = undefined;
for (var l = model.length - 1; l > 0; l--) {
if (model[l].length > 0) break;
spliceFrom = l;
}
if (spliceFrom !== undefined) {
model.splice(spliceFrom, model.length - spliceFrom);
}
// finally determine the new active layer
if (prevZ === zLiftZ) {
// initial lifted on layer if we are back at a prior height
layer = zLiftLayer;
} else {
// new layer if this a new z, just lower than max z-lift
model[model.length] = [];
layer = model.length - 1;
}
}
// finally determine the new active layer
if (prevZ === zLiftZ) {
// initial lifted on layer if we are back at a prior height
layer = zLiftLayer;
} else {
// new layer if this a new z, just lower than max z-lift
model[model.length] = [];
layer = model.length - 1;
}
// clear up cached Z-lift moves
zLiftMoves = [];
zLiftZ = undefined;
maxLiftZ = undefined;
zLiftLayer = undefined;
}
// have we progressed a layer?
if (activeLayer === undefined || layer > activeLayer) {
// the formerly active layer is now done and can be sent
sendLayer = activeLayer;
// the current layer is the new active layer
activeLayer = layer;
}
// clear up cached Z-lift moves
zLiftMoves = [];
zLiftZ = undefined;
maxLiftZ = undefined;
zLiftLayer = undefined;
}
model[layer].push(command);
@@ -694,10 +707,19 @@ var doParse = function () {
sendMultiLayer = [];
sendMultiLayerZ = [];
}
sendMultiLayer[sendMultiLayer.length] = sendLayer;
if (sendMultiLayer.indexOf(sendLayer) === -1) {
sendMultiLayer.push(sendLayer);
}
sendLayer = undefined;
}
}
// we are done, send the final layer
if (sendMultiLayer.indexOf(activeLayer) === -1) {
sendMultiLayer.push(activeLayer);
}
sendLayersToParent(sendMultiLayer, 100);
};
+6 -2
View File
@@ -1352,6 +1352,7 @@ class Server:
app.config["TEMPLATES_AUTO_RELOAD"] = True
app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False
app.config["REMEMBER_COOKIE_HTTPONLY"] = True
# we must not set this before TEMPLATES_AUTO_RELOAD is set to True or that won't take
app.debug = self._debug
@@ -1944,6 +1945,8 @@ class Server:
global assets
global pluginManager
from octoprint.server.util.webassets import MemoryManifest # noqa: F401
util.flask.fix_webassets_filtertool()
base_folder = self._settings.getBaseFolder("generated")
@@ -1955,7 +1958,8 @@ class Server:
for entry, recreate in (
("webassets", True),
(".webassets-cache", False), # no longer used, but clean up just in case
# no longer used, but clean up just in case
(".webassets-cache", False),
(".webassets-manifest.json", False),
):
path = os.path.join(base_folder, entry)
@@ -2042,7 +2046,7 @@ class Server:
# few seconds for regeneration in development, if it means we can get rid of
# a whole monkey patch and in internal use of pickle with non-tamperproof files
assets.cache = False
assets.manifest = "json:.webassets-manifest.json"
assets.manifest = "memory"
UpdaterType = type(util.flask.SettingsCheckUpdater)(
util.flask.SettingsCheckUpdater.__name__,
+1
View File
@@ -490,6 +490,7 @@ def _saveSettings(data):
s.setBaseFolder(folder, future[folder])
except Exception:
logger.exception("Something went wrong while saving a folder path")
abort(400, description="At least one of the configured folders is invalid")
if "api" in data:
+18
View File
@@ -6,6 +6,7 @@ import gzip
import logging
import os
import re
import threading
from urllib import parse as urlparse
import webassets.filter.cssrewrite.urlpath as urlpath
@@ -14,6 +15,7 @@ from webassets.filter import Filter
from webassets.filter.cssrewrite.base import PatternRewriter
from webassets.filter.rjsmin import rjsmin
from webassets.merge import BaseHunk, MemoryHunk
from webassets.version import Manifest
def replace_url(source_url, output_url, url):
@@ -207,3 +209,19 @@ class JsPluginBundle(Bundle):
(hunk, lambda x: x.replace("\n", "\n ")),
MemoryHunk(_PLUGIN_BUNDLE_WRAPPER_SUFFIX.format(plugin=self.plugin)),
)
class MemoryManifest(Manifest):
id = "memory"
def __init__(self, *args, **kwargs):
self.manifest = {}
self._lock = threading.RLock()
def remember(self, bundle, ctx, version):
with self._lock:
self.manifest[bundle.output] = version
def query(self, bundle, ctx):
with self._lock:
return self.manifest.get(bundle.output, None)
+29 -8
View File
@@ -8,6 +8,7 @@ import logging
import os
import re
from collections import defaultdict
from urllib.parse import urlparse
from flask import (
Response,
@@ -170,7 +171,16 @@ def _add_additional_assets(hook):
def login():
from flask_login import current_user
redirect_url = request.args.get("redirect", request.script_root + url_for("index"))
default_redirect_url = request.script_root + url_for("index")
redirect_url = request.args.get("redirect", default_redirect_url)
parsed = urlparse(redirect_url) # check if redirect url is valid
if parsed.scheme != "" or parsed.netloc != "":
_logger.warning(
f"Got an invalid redirect URL with the login attempt, misconfiguration or attack attempt: {redirect_url}"
)
redirect_url = default_redirect_url
permissions = sorted(
filter(
lambda x: x is not None and isinstance(x, OctoPrintPermission),
@@ -1223,9 +1233,17 @@ def fetch_template_data(refresh=False):
for var_name, var_value in vars.items():
plugin_vars["plugin_" + name + "_" + var_name] = var_value
includes = _process_template_configs(
name, implementation, configs, template_rules
)
try:
includes = _process_template_configs(
name, implementation, configs, template_rules
)
except Exception:
_logger.exception(
"Error while processing template configs for plugin {}, ignoring it".format(
name
),
extra={"plugin": name},
)
if not wizard_required or wizard_ignored:
includes["wizard"] = list()
@@ -1483,11 +1501,14 @@ def _process_template_config(name, implementation, rule, config=None, counter=1)
)
return None
if "template" not in data:
data["template"] = rule["template"](name)
data["template"] = implementation.template_folder_key + "/" + data["template"]
if data.get("template"):
data["template"] = implementation.template_folder_key + "/" + data["template"]
else:
data["template"] = (
implementation.template_folder_key + "/" + rule["template"](name)
)
if "template_header" in data:
if data.get("template_header"):
data["template_header"] = (
implementation.template_folder_key + "/" + data["template_header"]
)
+61 -35
View File
@@ -34,6 +34,7 @@ from yaml import YAMLError
from octoprint.util import (
CaseInsensitiveSet,
atomic_write,
deprecated,
dict_merge,
fast_deepcopy,
generate_api_key,
@@ -563,7 +564,7 @@ class HierarchicalChainMap:
items = []
for k, v in d.items():
new_key = parent_key + _CHAINMAP_SEP + k if parent_key else k
new_key = parent_key + _CHAINMAP_SEP + str(k) if parent_key else str(k)
if v and isinstance(v, dict):
items.extend(HierarchicalChainMap._flatten(v, new_key).items())
else:
@@ -577,16 +578,30 @@ class HierarchicalChainMap:
if d is None:
return {}
result = dict()
result = {}
for key, value in d.items():
if not key.startswith(prefix):
continue
subkeys = key[len(prefix) :].split(_CHAINMAP_SEP)
current = result
path = []
for subkey in subkeys[:-1]:
if subkey not in current or current[subkey] is None:
# we only need that for logging in case of data weirdness below
path.append(subkey)
# make sure the subkey is in the current dict, and that it is a dict
if subkey not in current:
current[subkey] = {}
elif not isinstance(current[subkey], dict):
logging.getLogger(__name__).warning(
f"There is a non-dict value on the path to {key} at {path!r}, ignoring."
)
current[subkey] = {}
# go down a level
current = current[subkey]
current[subkeys[-1]] = value
return result
@@ -631,27 +646,26 @@ class HierarchicalChainMap:
current = self._chainmap
key = self._path_to_key(path)
prefix = key + _CHAINMAP_SEP
if key in current:
if key in current and not any(k.startswith(prefix) for k in current.keys()):
# found it, return
return current[key]
# if we arrived here we might be trying to grab a dict, look for children
key = key + _CHAINMAP_SEP
# TODO 2.0.0 remove this & make 'merged' the default
if not merged and hasattr(current, "maps"):
# we do something a bit odd here: if merged is not true, we don't include the
# full contents of the key. Instead, we only include the contents of the key
# on the first level where we find the value.
for layer in current.maps:
if any(k.startswith(key) for k in layer):
if any(k.startswith(prefix) for k in layer):
current = layer
break
result = self._unflatten(
{k: v for k, v in current.items() if k.startswith(key)}, prefix=key
{k: v for k, v in current.items() if k.startswith(prefix)}, prefix=prefix
)
if not result:
raise KeyError("Could not find entry for " + str(path))
@@ -849,7 +863,6 @@ class Settings:
self._map = HierarchicalChainMap({}, default_settings)
self.load_overlays(overlays)
self._config = None
self._dirty = False
self._dirty_time = 0
self._last_config_hash = None
@@ -1112,7 +1125,7 @@ class Settings:
@property
def config_yaml(self):
return yaml.dump(self._config)
return yaml.dump(self.config)
@property
def config_hash(self):
@@ -1127,10 +1140,28 @@ class Settings:
return self._last_config_hash
@property
def _config(self):
def config(self):
"""
A view of the local config as stored in config.yaml
Does not support modifications, they will be thrown away silently. If you need to
modify anything in the settings, utilize the provided set and remove methods.
"""
return self._map.top_map
@property
@deprecated(
"Settings._config has been deprecated and is a read-only view. Please use Settings.config or the set & remove methods instead.",
since="1.8.0",
)
def _config(self):
return self.config
@_config.setter
@deprecated(
"Setting of Settings._config has been deprecated. Please use the set & remove methods instead and get in touch if you have a usecase they don't cover.",
since="1.8.0",
)
def _config(self, value):
self._map.top_map = value
@@ -1161,11 +1192,14 @@ class Settings:
# ~~ load and save
def load(self, migrate=False):
config = None
mtime = None
if os.path.exists(self._configfile) and os.path.isfile(self._configfile):
with open(self._configfile, encoding="utf-8", errors="replace") as f:
try:
self._config = yaml.load_from_file(file=f)
self._mtime = self.last_modified
config = yaml.load_from_file(file=f)
mtime = self.last_modified
except YAMLError as e:
details = str(e)
@@ -1185,8 +1219,11 @@ class Settings:
)
# changed from else to handle cases where the file exists, but is empty / 0 bytes
if not self._config or not isinstance(self._config, dict):
self._config = {}
if not config or not isinstance(config, dict):
config = {}
self._map.top_map = config
self._mtime = mtime
if migrate:
self._migrate_config()
@@ -1280,7 +1317,7 @@ class Settings:
def _migrate_config(self, config=None, persist=False):
if config is None:
config = self._config
config = self._map.top_map
persist = True
dirty = False
@@ -1302,6 +1339,9 @@ class Settings:
dirty = migrate(config) or dirty
if dirty and persist:
self._map.top_map = (
config # we need to write it back here or the changes will be lost
)
self.save(force=True)
def _migrate_gcode_scripts(self, config):
@@ -1820,7 +1860,7 @@ class Settings:
permissions=0o600,
max_permissions=0o666,
) as configFile:
yaml.save_to_file(self._config, file=configFile)
yaml.save_to_file(self._map.top_map, file=configFile)
self._dirty = False
except Exception:
self._logger.exception("Error while saving config.yaml!")
@@ -2059,10 +2099,7 @@ class Settings:
folder = default_folder
try:
del self._config["folder"][type]
if not len(self._config["folder"]):
del self._config["folder"]
self._mark_dirty()
self.remove(["folder", type])
self.save()
except KeyError:
pass
@@ -2257,23 +2294,12 @@ class Settings:
currentPath = self.getBaseFolder(type)
defaultPath = self._get_default_folder(type)
if (
(path is None or path == defaultPath)
and "folder" in self._config
and type in self._config["folder"]
):
del self._config["folder"][type]
if not self._config["folder"]:
del self._config["folder"]
self._mark_dirty()
if path is None or path == defaultPath:
self.remove(["folder", type])
elif (path != currentPath and path != defaultPath) or force:
if validate:
_validate_folder(path, check_writable=True, deep_check_writable=True)
if "folder" not in self._config:
self._config["folder"] = {}
self._config["folder"][type] = path
self._mark_dirty()
self.set(["folder", type], path, force=force)
def saveScript(self, script_type, name, script):
script_folder = self.getBaseFolder("scripts")
+1 -1
View File
@@ -1 +1 @@
.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;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,0.75);background-color:#f5f5f5;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-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);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:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{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:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{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 / 100;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.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{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.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}.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-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;background-image:-moz-linear-gradient(top, #08c, #04c);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#04c));background-image:-webkit-linear-gradient(top, #08c, #04c);background-image:-o-linear-gradient(top, #08c, #04c);background-image:linear-gradient(to bottom, #08c, #04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.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,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);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)Line truncated
.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;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,0.75);background-color:#f5f5f5;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-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);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:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{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:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{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-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{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.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}.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-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;background-image:-moz-linear-gradient(top, #08c, #04c);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#04c));background-image:-webkit-linear-gradient(top, #08c, #04c);background-image:-o-linear-gradient(top, #08c, #04c);background-image:linear-gradient(to bottom, #08c, #04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.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,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);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btnLine truncated
+64 -30
View File
@@ -1542,41 +1542,75 @@ var copyToClipboard = function (text) {
temp.remove();
};
var determineWebcamStreamType = function (streamUrl) {
if (streamUrl) {
if (streamUrl.startsWith("webrtc")) {
return "webrtc";
}
var getExternalHostUrl = function () {
var loc = window.location;
var port = "";
if (
(loc.protocol === "http:" && loc.port !== "80") ||
(loc.protocol === "https:" && loc.port !== "443")
) {
port = ":" + loc.port;
}
return loc.protocol + "//" + loc.hostname + port;
};
var lastDotPosition = streamUrl.lastIndexOf(".");
var firstQuotationSignPosition = streamUrl.indexOf("?");
if (
lastDotPosition != -1 &&
firstQuotationSignPosition != -1 &&
lastDotPosition >= firstQuotationSignPosition
) {
throw "Malformed URL. Cannot determine stream type.";
}
var validateWebcamUrl = function (streamUrl) {
if (!streamUrl) {
return false;
}
// If we have found a dot, try to extract the extension.
if (lastDotPosition > -1) {
if (firstQuotationSignPosition > -1) {
var extension = streamUrl.slice(
lastDotPosition + 1,
firstQuotationSignPosition - 1
);
} else {
var extension = streamUrl.slice(lastDotPosition + 1);
}
if (extension.toLowerCase() == "m3u8") {
return "hls";
}
}
// By default, 'mjpg' is the stream type.
return "mjpg";
var lower = streamUrl.toLowerCase();
var toParse = streamUrl;
if (lower.startsWith("//")) {
// protocol relative
toParse = window.location.protocol + streamUrl;
} else if (lower.startsWith("/")) {
// host relative
toParse = getExternalHostUrl() + streamUrl;
} else if (
lower.startsWith("http:") ||
lower.startsWith("https:") ||
lower.startsWith("webrtc:") ||
lower.startsWith("webrtcs:")
) {
// absolute & supported protocol
toParse = streamUrl;
} else {
return false;
}
try {
return new URL(toParse);
} catch (e) {
return false;
}
};
var determineWebcamStreamType = function (streamUrl) {
if (!streamUrl) {
throw "Empty streamUrl. Cannot determine stream type.";
}
var parsed = validateWebcamUrl(streamUrl);
if (!parsed) {
throw "Invalid streamUrl. Cannot determine stream type.";
}
if (parsed.protocol === "webrtc:" || parsed.protocol === "webrtcs:") {
return "webrtc";
}
var lastDotPosition = parsed.pathname.lastIndexOf(".");
if (lastDotPosition !== -1) {
var extension = parsed.pathname.substring(lastDotPosition + 1);
if (extension.toLowerCase() === "m3u8") {
return "hls";
}
}
// By default, 'mjpg' is the stream type.
return "mjpg";
};
var saveToLocalStorage = function (key, data) {
@@ -40,7 +40,8 @@ $(function () {
self.isLoading = ko.observable(undefined);
self.enableConnect = ko.pureComputed(function () {
return self.enablePort() || !self.isErrorOrClosed();
//return self.enablePort() || !self.isErrorOrClosed();
return true; // enable always for now, until we have an auto refresh in 1.9.0
});
self.buttonText = ko.pureComputed(function () {
@@ -573,7 +573,7 @@ $(function () {
}
// Determine stream type and switch to corresponding webcam.
var streamType = determineWebcamStreamType(self.settings.webcam_streamUrl());
var streamType = self.settings.webcam_streamType();
if (streamType == "mjpg") {
self._switchToMjpgWebcam();
} else if (streamType == "hls") {
@@ -760,7 +760,7 @@ $(function () {
return;
}
var newSrc = self.settings.webcam_streamUrl();
var newSrc = self.settings.webcam_streamUrlEscaped();
if (currentSrc != newSrc) {
if (self.settings.webcam_cacheBuster()) {
if (newSrc.lastIndexOf("?") > -1) {
@@ -797,10 +797,10 @@ $(function () {
typeof video.canPlayType != undefined &&
video.canPlayType("application/vnd.apple.mpegurl") == "probably"
) {
video.src = self.settings.webcam_streamUrl();
video.src = self.settings.webcam_streamUrlEscaped();
} else if (Hls.isSupported()) {
self.hls = new Hls();
self.hls.loadSource(self.settings.webcam_streamUrl());
self.hls.loadSource(self.settings.webcam_streamUrlEscaped());
self.hls.attachMedia(video);
}
@@ -836,7 +836,7 @@ $(function () {
if (self.webRTCPeerConnection == null) {
self.webRTCPeerConnection = startWebRTC(
video,
self.settings.webcam_streamUrl(),
self.settings.webcam_streamUrlEscaped(),
self.settings.webcam_streamWebrtcIceServers()
);
}
@@ -250,6 +250,7 @@ $(function () {
self.serial_ackMax = ko.observable(undefined);
self.serial_resendRatioThreshold = ko.observable(100);
self.serial_resendRatioStart = ko.observable(100);
self.serial_ignoreEmptyPorts = ko.observable(undefined);
self.serial_enableShutdownActionCommand = ko.observable(undefined);
self.folder_uploads = ko.observable(undefined);
@@ -311,13 +312,20 @@ $(function () {
self.webcam_ffmpegPathOk(false);
self.webcam_ffmpegPathBroken(false);
};
self.webcam_streamUrlEscaped = ko.pureComputed(function () {
return encodeURI(self.webcam_streamUrl());
});
self.webcam_streamType = ko.pureComputed(function () {
try {
return determineWebcamStreamType(self.webcam_streamUrl());
return determineWebcamStreamType(self.webcam_streamUrlEscaped());
} catch (e) {
return "";
}
});
self.webcam_streamValid = ko.pureComputed(function () {
var url = self.webcam_streamUrlEscaped();
return !url || validateWebcamUrl(url);
});
self.server_onlineCheckText = ko.observable();
self.server_onlineCheckOk = ko.observable(false);
@@ -438,7 +446,8 @@ $(function () {
self.testWebcamStreamUrlBusy = ko.observable(false);
self.testWebcamStreamUrl = function () {
if (!self.webcam_streamUrl()) {
var url = self.webcam_streamUrlEscaped();
if (!url) {
return;
}
@@ -449,24 +458,31 @@ $(function () {
var text = gettext(
"If you see your webcam stream below, the entered stream URL is ok."
);
var streamType = self.webcam_streamType();
var streamType;
try {
streamType = self.webcam_streamType();
} catch (e) {
streamType = "";
}
var webcam_element;
var webrtc_peer_connection;
if (streamType == "mjpg") {
webcam_element = $('<img src="' + self.webcam_streamUrl() + '">');
} else if (streamType == "hls") {
if (streamType === "mjpg") {
webcam_element = $('<img src="' + url + '">');
} else if (streamType === "hls") {
webcam_element = $(
'<video id="webcam_hls" muted autoplay style="width: 100%"/>'
);
video_element = webcam_element[0];
if (video_element.canPlayType("application/vnd.apple.mpegurl")) {
video_element.src = self.webcam_streamUrl();
video_element.src = url;
} else if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(self.webcam_streamUrl());
hls.loadSource(url);
hls.attachMedia(video_element);
}
} else if (isWebRTCAvailable() && streamType == "webrtc") {
} else if (isWebRTCAvailable() && streamType === "webrtc") {
webcam_element = $(
'<video id="webcam_webrtc" muted autoplay playsinline controls style="width: 100%"/>'
);
@@ -474,7 +490,7 @@ $(function () {
webrtc_peer_connection = startWebRTC(
video_element,
self.webcam_streamUrl(),
url,
self.webcam_streamWebrtcIceServers()
);
} else {
+2 -2
View File
@@ -21,8 +21,8 @@
// Optional: Group multiple button groups together for a toolbar
.btn-toolbar {
font-size: 0; // Hack to remove whitespace that results from using inline-block
margin-top: @baseLineHeight / 2;
margin-bottom: @baseLineHeight / 2;
margin-top: (@baseLineHeight / 2);
margin-bottom: (@baseLineHeight / 2);
> .btn + .btn,
> .btn-group + .btn,
> .btn + .btn-group {
+2 -2
View File
@@ -24,8 +24,8 @@ code {
// Blocks of code
pre {
display: block;
padding: (@baseLineHeight - 1) / 2;
margin: 0 0 @baseLineHeight / 2;
padding: ((@baseLineHeight - 1) / 2);
margin: 0 0 (@baseLineHeight / 2);
font-size: @baseFontSize - 1; // 14px to 13px
line-height: @baseLineHeight;
word-break: break-all;
+5 -5
View File
@@ -81,7 +81,7 @@ input[type="color"],
display: inline-block;
height: @baseLineHeight;
padding: 4px 6px;
margin-bottom: @baseLineHeight / 2;
margin-bottom: (@baseLineHeight / 2);
font-size: @baseFontSize;
line-height: @baseLineHeight;
color: @gray;
@@ -399,7 +399,7 @@ select:focus:invalid {
.help-block {
display: block; // account for any element using help-block
margin-bottom: @baseLineHeight / 2;
margin-bottom: (@baseLineHeight / 2);
}
.help-inline {
@@ -416,7 +416,7 @@ select:focus:invalid {
.input-append,
.input-prepend {
display: inline-block;
margin-bottom: @baseLineHeight / 2;
margin-bottom: (@baseLineHeight / 2);
vertical-align: middle;
font-size: 0; // white space collapse hack
white-space: nowrap; // Prevent span and input from separating
@@ -617,7 +617,7 @@ input.search-query {
// Margin to space out fieldsets
.control-group {
margin-bottom: @baseLineHeight / 2;
margin-bottom: (@baseLineHeight / 2);
}
// Legend collapses margin, so next element is responsible for spacing
@@ -666,7 +666,7 @@ legend + .control-group {
.input-prepend,
.input-append {
+ .help-block {
margin-top: @baseLineHeight / 2;
margin-top: (@baseLineHeight / 2);
}
}
// Move over buttons in .form-actions to align with .controls
+2 -2
View File
@@ -376,7 +376,7 @@
// Opacity
.opacity(@opacity) {
opacity: @opacity / 100;
opacity: (@opacity / 100);
filter: ~"alpha(opacity=@{opacity})";
}
@@ -679,7 +679,7 @@
// Vertically center elements in the navbar.
// Example: an element has a height of 30px, so write out `.navbarVerticalAlign(30px);` to calculate the appropriate top margin.
.navbarVerticalAlign(@elementHeight) {
margin-top: (@navbarHeight - @elementHeight) / 2;
margin-top: ((@navbarHeight - @elementHeight) / 2);
}
// Grid System
+3 -3
View File
@@ -6,7 +6,7 @@
// -------------------------
p {
margin: 0 0 @baseLineHeight / 2;
margin: 0 0 (@baseLineHeight / 2);
}
.lead {
margin-bottom: @baseLineHeight;
@@ -160,7 +160,7 @@ h4 small {
ul,
ol {
padding: 0;
margin: 0 0 @baseLineHeight / 2 25px;
margin: 0 0 (@baseLineHeight / 2) 25px;
}
ul ul,
ul ol,
@@ -204,7 +204,7 @@ dt {
font-weight: bold;
}
dd {
margin-left: @baseLineHeight / 2;
margin-left: (@baseLineHeight / 2);
}
// Horizontal layout (like forms)
.dl-horizontal {
@@ -92,6 +92,19 @@
</label>
</div>
</div>
<div>
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_general_connection .hide' }"><i class="fas fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_ignoreEmptyPorts" id="settings-serialIgnoreEmptyPorts"> {{ _('Ignore empty ports') }}
<span class="help-block">{{ _('By checking this you\'ll disable OctoPrint warning you if no serial ports to connect to were found.') }}</span>
</label>
</div>
</div>
</div>
</div>
</fieldset>
<fieldset id="settings_serial_general_logging">
<legend>{{ _('Serial logging') }}</legend>
+2 -2
View File
@@ -69,12 +69,12 @@
<div id="login-offline" class="alert alert-error">{{ _('Server is currently offline.') }} <a id="login-reconnect" href="javascript:void(0)">{{ _('Reconnect...') }}</a></div>
{% if user_id %}<p>
{{ _('The following account is required:') }} {{ user_id }}
{{ _('The following account is required:') }} {{ user_id|e }}
</p>{% elif logged_in %}<p>
{{ _('An account with the following permissions is required:') }} {{ permission_names|join(", ") }}
</p>{% endif %}
<input type="text" id="login-user" data-test-id="login-username" class="input-block-level" placeholder="{{ _('Username')|edq }}" {% if user_id %}value="{{ user_id }}" disabled{% endif %} autofocus autocapitalize="none">
<input type="text" id="login-user" data-test-id="login-username" class="input-block-level" placeholder="{{ _('Username')|edq }}" {% if user_id %}value="{{ user_id|edq }}" disabled{% endif %} autofocus autocapitalize="none">
<input type="password" id="login-password" data-test-id="login-password" class="input-block-level" placeholder="{{ _('Password')|edq }}">
<span class="pull-right"><small><a href="https://faq.octoprint.org/forgotten-password" id="login-forgotpassword" target="_blank" tabindex="-1">{{ _('Forgot password?') }}</a></small></span>
<label class="checkbox">
@@ -1,9 +1,9 @@
<div class="control-group" title="{{ _('URL to embed into the UI for live viewing of the webcam stream')|edq }}">
<div class="control-group" title="{{ _('URL to embed into the UI for live viewing of the webcam stream')|edq }}" data-bind="css: { error: !webcam_streamValid() }">
<label class="control-label" for="settings-webcamStreamUrl">{{ _('Stream URL') }}</label>
<div class="controls">
<div class="input-append">
<input type="text" class="input-block-level" data-bind="value: webcam_streamUrl, valueUpdate: 'afterkeydown'" id="settings-webcamStreamUrl">
<button class="btn" type="button" data-bind="click: testWebcamStreamUrl, enable: webcam_streamUrl() && !testWebcamStreamUrlBusy(), css: {disabled: !webcam_streamUrl() || testWebcamStreamUrlBusy()}"><i class="fas fa-spinner fa-spin" data-bind="visible: testWebcamStreamUrlBusy"></i> {{ _('Test') }}</button>
<button class="btn" type="button" data-bind="click: testWebcamStreamUrl, enable: !testWebcamStreamUrlBusy() && webcam_streamValid(), css: {disabled: testWebcamStreamUrlBusy() || !webcam_streamValid()}"><i class="fas fa-spinner fa-spin" data-bind="visible: testWebcamStreamUrlBusy"></i> {{ _('Test') }}</button>
</div>
<span class="help-block">
<p>{% trans %}Needs to be reachable from the browser displaying the OctoPrint UI, used to embed the webcam stream into the page.{% endtrans %}</p>
File diff suppressed because it is too large. Load diff
+17 -8
View File
@@ -113,7 +113,7 @@ Groups will be as follows:
"""
regex_temp = re.compile(
r"(?P<sensor>B|C|T(?P<toolnum>\d*)|([\w]+)):\s*(?P<actual>%s)(\s*\/?\s*(?P<target>%s))?"
r"(^|\s)(?P<sensor>B|C|T(?P<toolnum>\d*)|([\w]+)):\s*(?P<actual>%s)(\s*\/?\s*(?P<target>%s))?"
% (regex_float_pattern, regex_float_pattern)
)
"""Regex matching temperature entries in line.
@@ -341,7 +341,7 @@ class PositionRecord:
class TemperatureRecord:
RESERVED_IDENTIFIER_REGEX = re.compile("[0-9]+|[bc]")
RESERVED_IDENTIFIER_REGEX = re.compile(r"B|C|T\d*")
def __init__(self):
self._tools = {}
@@ -366,7 +366,7 @@ class TemperatureRecord:
self._chamber = self._to_new_tuple(current, actual, target)
def set_custom(self, identifier, actual=None, target=None):
if self.RESERVED_IDENTIFIER_REGEX.match(identifier):
if self.RESERVED_IDENTIFIER_REGEX.fullmatch(identifier):
raise ValueError(f"{identifier} is a reserved identifier")
current = self._custom.get(identifier, (None, None))
self._custom[identifier] = self._to_new_tuple(current, actual, target)
@@ -2103,7 +2103,7 @@ class MachineCom:
def _processTemperatures(self, line):
current_tool = self._currentTool if self._currentTool is not None else 0
current_tool_key = "T%d" % current_tool
current_tool_key = f"T{current_tool}"
maxToolNum, parsedTemps = parse_temperature_line(line, current_tool)
maxToolNum = max(
@@ -2159,10 +2159,15 @@ class MachineCom:
del parsedTemps["C"]
self.last_temperature.set_chamber(actual=actual, target=target)
# all other injected temperatures
for key in parsedTemps.keys():
actual, target = parsedTemps[key]
self.last_temperature.set_custom(key, actual=actual, target=target)
# all other injected temperatures or temperature-like entries
for key, data in parsedTemps.items():
try:
actual, target = data
self.last_temperature.set_custom(key, actual=actual, target=target)
except Exception as ex:
self._logger.warning(
f"Could not add custom temperature record {key}: {ex}"
)
##~~ Serial monitor processing received messages
@@ -6263,6 +6268,10 @@ def parse_temperature_line(line, current):
for match in re.finditer(regex_temp, line):
values = match.groupdict()
sensor = values["sensor"]
if sensor in result:
# sensor already seen, let's not overwrite stuff
continue
toolnum = values.get("toolnum", None)
tool_number = int(toolnum) if toolnum is not None and len(toolnum) else None
if tool_number and tool_number > max_tool_num:
+11
View File
@@ -7,6 +7,17 @@ serial:
additionalPorts:
- /dev/portA
- /dev/portB
plugins:
foo:
bar:
a: 1
b: 2
c: 3
fnord:
bar:
a: 1
b: 2
c: 3
server:
port: 8080
devel:
+6
View File
@@ -5,6 +5,12 @@ devel:
waitInterval: 1.0
repetierStyleResends: false
capabilities: {}
plugins:
foo:
bar: {}
fnord:
bar:
d: 4
test:
b:
b1: 1
+32 -7
View File
@@ -507,11 +507,14 @@ class SettingsTest(unittest.TestCase):
def test_get_preprocessor(self):
with self.settings() as settings:
config = {}
defaults = {"test": "some string"}
preprocessors = {"test": lambda x: x.upper()}
defaults = {"test_preprocessor": "some string"}
preprocessors = {"test_preprocessor": lambda x: x.upper()}
value = settings.get(
["test"], config=config, defaults=defaults, preprocessors=preprocessors
["test_preprocessor"],
config=config,
defaults=defaults,
preprocessors=preprocessors,
)
self.assertEqual("SOME STRING", value)
@@ -519,18 +522,18 @@ class SettingsTest(unittest.TestCase):
def test_set_preprocessor(self):
with self.settings() as settings:
config = {}
defaults = {"foo": {"bar": "fnord"}}
preprocessors = {"foo": {"bar": lambda x: x.upper()}}
defaults = {"foo_preprocessor": {"bar": "fnord"}}
preprocessors = {"foo_preprocessor": {"bar": lambda x: x.upper()}}
settings.set(
["foo", "bar"],
["foo_preprocessor", "bar"],
"value",
config=config,
defaults=defaults,
preprocessors=preprocessors,
)
self.assertEqual("VALUE", config["foo"]["bar"])
self.assertEqual("VALUE", config["foo_preprocessor"]["bar"])
def test_set_external_modification(self):
with self.settings() as settings:
@@ -675,6 +678,7 @@ class ChainmapTest(unittest.TestCase):
self.assertTrue(self.chainmap.has_path(["devel"]))
self.assertTrue(self.chainmap.has_path(["devel", "virtualPrinter"]))
self.assertTrue(self.chainmap.has_path(["devel", "virtualPrinter", "enabled"]))
self.assertTrue(self.chainmap.has_path(["plugins", "foo", "bar"]))
self.assertFalse(self.chainmap.has_path(["api", "lock"]))
@@ -697,6 +701,23 @@ class ChainmapTest(unittest.TestCase):
self.chainmap.get_by_path(["test"], merged=True),
)
self.assertEqual(
self.config["plugins"]["foo"]["bar"],
self.chainmap.get_by_path(["plugins", "foo", "bar"]),
)
self.assertEqual(
self.config["plugins"]["fnord"]["bar"],
self.chainmap.get_by_path(["plugins", "fnord", "bar"]),
)
self.assertEqual(
dict_merge(
self.overlay["plugins"]["fnord"]["bar"],
self.config["plugins"]["fnord"]["bar"],
),
self.chainmap.get_by_path(["plugins", "fnord", "bar"], merged=True),
)
def test_set_by_path(self):
self.chainmap.set_by_path(["devel", "virtualPrinter", "sendWait"], False)
@@ -770,6 +791,10 @@ class ChainmapTest(unittest.TestCase):
{_key("a"): None, _key("a", "b"): "b"},
{"a": {"b": "b"}},
),
(
{_key("a"): "", _key("a", "b"): "b"},
{"a": {"b": "b"}},
),
)
@ddt.unpack
def test_unflatten(self, value, expected):
+82
View File
@@ -284,6 +284,62 @@ class TestCommHelpers(unittest.TestCase):
{"T0": (-55.7, 0), "T1": (150.0, 210.0)},
1,
),
(
"T:210.04 /210.00 B:52.00 /52.00 @:85 B@:31pS_XYZ:5",
0,
{
"T0": (210.04, 210.0),
"B": (52.00, 52.0),
},
0,
),
(
"T:210.04 /210.00 B:52.00 /52.00 @:85 31pS_XYZ:5",
0,
{
"T0": (210.04, 210.0),
"B": (52.00, 52.0),
"31pS_XYZ": (5, None),
},
0,
),
(
"T:210.04 /210.00 B:52.00 /52.00 @:85 F0:255.0 /255.0",
0,
{
"T0": (210.04, 210.0),
"B": (52.00, 52.0),
"F0": (255.0, 255.0),
},
0,
),
(
"T:210.04 /210.00 @B:52.00 /52.00",
0,
{
"T0": (210.04, 210.0),
},
0,
),
(
"T:210.04 /210.00 @B:52.00 /52.00 TXYZ:2",
0,
{
"T0": (210.04, 210.0),
"TXYZ": (2, None),
},
0,
),
(
# Only first occurrence of a sensor should be used, second B gets ignored
"T:210.04 /210.00 B:52.00 /52.00 @:85 B:1234.0 /1234.0",
0,
{
"T0": (210.04, 210.0),
"B": (52.00, 52.0),
},
0,
),
)
@unpack
def test_process_temperature_line(self, line, current, expected_result, expected_max):
@@ -533,3 +589,29 @@ class TestPositionRecord(unittest.TestCase):
from octoprint.util.comm import PositionRecord
return PositionRecord(**kwargs)
@ddt
class TestTemperatureRecord(unittest.TestCase):
@data("TX", "B2", "BX", "SOMETHING_CUSTOM", "1234B456", "blub", "fnord", "C1", "CX")
def test_set_custom(self, identifier):
temperature = self._create_temperature()
temperature.set_custom(identifier, 1, 2)
self.assertTrue(identifier in temperature.custom)
@data("T", "T1", "T42", "B", "C")
def test_set_custom_reserved(self, identifier):
temperature = self._create_temperature()
try:
temperature.set_custom(identifier, 1, 2)
self.fail(f"Expected ValueError for reserved identifier {identifier}")
except ValueError as ex:
self.assertTrue("is a reserved identifier" in str(ex))
def _create_temperature(self, **kwargs):
from octoprint.util.comm import TemperatureRecord
return TemperatureRecord(**kwargs)
Binary file not shown.
File diff suppressed because it is too large. Load diff
+713 -702
View File
File diff suppressed because it is too large. Load diff