Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2022-08-09 15:03:28 +02:00
commit c7d9a4b7b5
79 files changed
+459 -337

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
managable
commitish
matchs
medias
+6 -24
View File
@@ -1,31 +1,14 @@
parserOptions:
ecmaVersion: 2018
overrides:
- files:
- "src/octoprint/static/js/app/**"
- "src/octoprint/static/js/**.js"
- "src/octoprint/plugins/**.js"
env:
browser: true
jquery: true
parserOptions:
ecmaVersion: 5
rules:
es5/no-arrow-functions: error
es5/no-binary-and-octal-literals: error
es5/no-block-scoping: error
es5/no-classes: error
es5/no-computed-properties: error
es5/no-default-parameters: error
es5/no-destructuring: error
es5/no-exponentiation-operator: error
es5/no-for-of: error
es5/no-generators: error
es5/no-modules: error
es5/no-object-super: error
es5/no-rest-parameters: error
es5/no-shorthand-properties: error
es5/no-spread: error
es5/no-template-literals: error
es5/no-typeof-symbol: error
es5/no-unicode-code-point-escape: error
es5/no-unicode-regex: error
es6: true
- files:
- "tests/cypress/**"
env:
@@ -36,5 +19,4 @@ overrides:
- "plugin:cypress/recommended"
plugins:
- eslint-plugin-es5
- cypress
+6 -2
View File
@@ -1,4 +1,4 @@
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/|versioneer.py|.*\.css|.*\.svg)
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|scripts/|translations/|versioneer.py|.*\.css|.*\.svg)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
@@ -54,6 +54,7 @@ repos:
- id: flake8
additional_dependencies:
- flake8-bugbear==22.3.20
exclude: ^(docs/)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.5.1
hooks:
@@ -64,7 +65,10 @@ repos:
- id: eslint
additional_dependencies:
- eslint@7.19.0
- eslint-plugin-es5@v1.3.0
- eslint-plugin-cypress@2.11.2
files: \.js$
exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/)
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
+2 -2
View File
@@ -26,8 +26,8 @@ improve/.* 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev
# staging/bugfix is the branch for preparation of the 1.8.1 bugfix release
# so are any bug/... branches
staging/bugfix 1.8.1 d2a9aacedacf2b582faca462d6e915f88676a3d5 pep440-dev
bug/.* 1.8.1 d2a9aacedacf2b582faca462d6e915f88676a3d5 pep440-dev
staging/bugfix 1.8.2 260a1aef11432c421246019e25b6b744abbaed60 pep440-dev
bug/.* 1.8.2 260a1aef11432c421246019e25b6b744abbaed60 pep440-dev
# staging/maintenance is currently the branch for preparation of 1.8.0rc6
# so is regressionfix/...
+2
View File
@@ -169,6 +169,8 @@ date of first contribution):
* [Billy Richardson](https://github.com/richardsondev)
* [Christian Bianchini](https://github.com/max246)
* [Kestin Goforth](https://github.com/kforth)
* [Dawid Pieper](https://github.com/dawidpieper)
* ["arrdem"](https://github.com/arrdem)
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
+5 -13
View File
@@ -10,37 +10,29 @@ thanks to everyone who contributed!
* 3DPrinterOS
* Al Mucci
* Arnljot Arntsen
* Artillery 3D
* Ash King
* BigTreeTech
* Boris Hussein
* Brad Jackson
* BuildBee
* Calvin Vette
* Christian Petropolis
* Christian Wolf
* Christian Würthner
* Christoph Sigrist
* Craig Parker
* Creality3D
* David Bounds
* DeltaMaker 3D Printers
* Dennis Breining
* Douglas Floyd
* Dr. Frank Wester
* Eric Betts
* Ernesto Martinez
* Franziska Kunsmann
* George Robles
* Greg Holloway
* Hog Duske
* Itay Shem-tov
* James Mackay
* Jeff Green
* Jeff Moe
* jeffiel
* Jeremy Cole
* Joshua Wills
* Julian Melo
* Justin Kaufman
* Kaile Riser
@@ -52,13 +44,15 @@ thanks to everyone who contributed!
* Lefteris Lertas
* LulzBot
* Makespace Madrid
* Mark Greenwald
* Mark Walker
* Matt Van Itallie
* Michael Aumock
* Mike Kershaw
* Miles Flavel
* Mosaic Manufacturing
* Norman Jaffe
* Obico
* Ory Weaver
* Peopoly
* Pete Barnwell
* Raise3D
@@ -68,17 +62,15 @@ thanks to everyone who contributed!
* Richard Michaud
* Richard Stocks
* Robert Gusek
* Ronald Griehsler
* Sean Jensen-Grey
* Sebastien Andrivet
* SimplyPrint
* Stefan Krister
* Steve Dougherty
* Steve Thompson
* TH3D
* The Spaghetti Detective
* TJ Horner
* Trent Shumay
* Ulrich Kempken
* Yehuda Katz
and 2279 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
and 2209 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
-1
View File
@@ -908,4 +908,3 @@ Upload response
- (File only) Whether the file that was just uploaded was started to print (``true``) or not (``false``). If this
is ``false`` but was requested to be ``true`` in the upload request, the user lacked permissions, the printer was not
operational or already printing and thus the request could not be fulfilled.
-1
View File
@@ -644,4 +644,3 @@ Profile
- Tuple of (x, y) values describing the offsets of the other extruders relative to the first extruder. E.g. for a
printer with two extruders, if the second extruder is offset by 20mm in the X and 25mm in the Y direction, this
array will read ``[ [0.0, 0.0], [20.0, 25.0] ]``
+1 -2
View File
@@ -30,7 +30,7 @@ Delete a timelapse
.. http:delete:: /api/timelapse/(string:name)
Delete the timelapse ``name``.
Returns a :ref:`timelapse list <sec-api-timelapse-datamodel-list>` in the
response body with the updated information.
@@ -283,4 +283,3 @@ For timelapse type ``timed``.
- 1
- int
- Seconds between individual shots
+5 -3
View File
@@ -1,3 +1,4 @@
#
# OctoPrint documentation build configuration file, created by
# sphinx-quickstart on Mon Dec 02 17:08:50 2013.
#
@@ -9,8 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -18,9 +19,10 @@ import os
sys.path.insert(0, os.path.abspath("../src/"))
sys.path.append(os.path.abspath("sphinxext"))
import octoprint._version
from datetime import date
import octoprint._version
year_since = 2013
year_current = date.today().year
@@ -40,7 +42,7 @@ extensions = [
"sphinx.ext.napoleon",
"sphinxcontrib.mermaid",
"sphinx.ext.intersphinx",
"sphinx_rtd_theme"
"sphinx_rtd_theme",
]
todo_include_todos = True
intersphinx_mapping = {
+1 -1
View File
@@ -451,7 +451,7 @@ 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.
+1 -1
View File
@@ -221,4 +221,4 @@ clearer (whitespace again made visible to help track indentation):
Just make sure you follow a consistent way of indenting your files -- YAML is not as strict as Python when it comes to
differing indentation variants within the same file (as long as it's still valid), but consistency will help you as
a lot as a human. Ideally you'll use a text editor which highlights white space characters for you (most editors can
be configured this way), this will help tremendously when editing whitespace sensitive syntax such as YAML.
be configured this way), this will help tremendously when editing whitespace sensitive syntax such as YAML.
+1 -2
View File
@@ -57,6 +57,7 @@ When the virtual environment is activated you can then:
* run the test suite from the checked out source folder via ``pytest``
* trigger the pre-commit check suite manually from the checked out source folder via
``pre-commit run --hook-stage manual --all-files``
* rebuild ``.css`` files from ``.less`` sources. See ``octoprint dev css:build --help``
* build the documentation running ``sphinx-build -b html . _build`` in the ``docs``
folder -- the documentation will be available in the newly created ``_build``
directory. You can simply browse it locally by opening ``index.html``
@@ -403,5 +404,3 @@ Visual Studio Code (vscode)
* Saving a file will run an auto formatter and import sort
* ``Ctrl+Shift+B`` can be used to run the ``build docs`` task to rebuild the documentation
+5 -5
View File
@@ -200,29 +200,29 @@ There many configuration options via ``config.yaml`` for the virtual printer tha
# Simulated ambient temperature in °C
ambientTemperature: 21.3
# Response to M105 when there is a target
# Placeholders:
# - heater: The heater id (eg. T0, T1, B)
# - actual: The actual temperature of the heater
# - target: The target temperature of heater
m105TargetFormatString: {heater}:{actual:.2f}/ {target:.2f}
# Response to M105 when there is no target
# Placeholders:
# - heater: The heater id (eg. T0, T1, B)
# - actual: The actual temperature of the heater
m105NoTargetFormatString: {heater}:{actual:.2f}
# 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 commands
# And a selection of other settings commands. Responses modeled on Marlin 2.0
enable_eeprom: true
# Support M503
support_m503: true
# Resend ratio to simulate noise on the line
resend_ratio: 0
-1
View File
@@ -870,4 +870,3 @@ PrinterProfileModified
* ``identifier``: the identifier of the modified printer profile
.. versionadded:: 1.3.12
+1 -1
View File
@@ -306,4 +306,4 @@
<use xlink:href="#8eaa88f76ee748fdbb66142e124db376" xmlns:xlink="http://www.w3.org/1999/xlink" transform="translate(1, 1)" p:filter="url(#f3a0f53acfa3492abf13b69eb2bf8e75)" style="opacity: 0.6; visibility: hidden; display: none;" p:heavy="true" p:name="bgCopy" id="e7a7687af8d14f2888d588636e0cd333"/>
<use xlink:href="#8eaa88f76ee748fdbb66142e124db376" xmlns:xlink="http://www.w3.org/1999/xlink"/>
<foreignObject x="7.84" y="7" width="180.32" height="50" p:name="text" id="cdcded6607b7463ea18aa393da7520bc" style="font-family: &quot;Liberation Sans&quot;,Arial,sans-serif; font-size: 13px; font-weight: normal; font-style: normal; text-decoration: none; fill: rgb(0, 0, 0); fill-opacity: 1; color: rgb(0, 0, 0); opacity: 1; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml"><span style="font-family: Consolas;">data_bind<br />styles<br />classes</span><br /></div></foreignObject>
</g></g></Content></Page></Pages></Document>
</g></g></Content></Page></Pages></Document>
-1
View File
@@ -40,4 +40,3 @@ Contents
plugins/index.rst
modules/index.rst
jsclientlib/index.rst
-1
View File
@@ -54,4 +54,3 @@
:param object parameters: Template parameters
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
-1
View File
@@ -79,4 +79,3 @@
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
+2 -2
View File
@@ -30,7 +30,7 @@
.. code-block:: javascript
OctoPrint.util.testPath("/som/path/to/a/file")
OctoPrint.util.testPath("/some/path/to/a/file")
.done(function(response) {
if (response.result) {
// check passed
@@ -45,7 +45,7 @@
.. code-block:: javascript
OctoPrint.util.testPath("/som/path/to/a/file", {"check_type": "file", "check_access": ["r", "x"]})
OctoPrint.util.testPath("/some/path/to/a/file", {"check_type": "file", "check_access": ["r", "x"]})
.done(function(response) {
if (response.result) {
// check passed
+1 -1
View File
@@ -36,4 +36,4 @@ octoprint.filemanager.util
--------------------------
.. automodule:: octoprint.filemanager.util
:members:
:members:
-3
View File
@@ -37,6 +37,3 @@ octoprint.server.util.tornado
.. automodule:: octoprint.server.util.tornado
:members:
-2
View File
@@ -5,5 +5,3 @@ octoprint.access.users
.. automodule:: octoprint.access.users
:members:
+9 -9
View File
@@ -64,18 +64,18 @@ plugin.
Version management after the official plugin repository release
---------------------------------------------------------------
Once your plugin is available in the official plugin repository, you probably want to create and distribute new versions.
For "beta" users you can use the manual file distribution method, or a more elegant release channels (see below).
After you finalized a new plugin version, don't forget to actually update the version in the ``setup.py``,
and `submit a new release on github <https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository#creating-a-release>`_.
Once your plugin is available in the official plugin repository, you probably want to create and distribute new versions.
For "beta" users you can use the manual file distribution method, or a more elegant release channels (see below).
After you finalized a new plugin version, don't forget to actually update the version in the ``setup.py``,
and `submit a new release on github <https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository#creating-a-release>`_.
After you published the new release, you can verify it on your installed octoprint,
with force checking the updates under the advanced options (in the software updates menu in the settings).
After you published the new release, you can verify it on your installed octoprint,
with force checking the updates under the advanced options (in the software updates menu in the settings).
The new versions will appear to the plugin users in the next 24 hours (it depends on their cache refreshes).
The `Software Update Plugin <https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html#>`_ has options to define multiple release channels,
The `Software Update Plugin <https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html#>`_ has options to define multiple release channels,
and you can let the users decide if they want to test your pre-releases or not.
This can be achieved with defining ``stable_branch`` and ``prerelease_branches`` in the ``get_update_information`` function,
This can be achieved with defining ``stable_branch`` and ``prerelease_branches`` in the ``get_update_information`` function,
and creating github releases to the newly configured branches too.
For more information you can check the `Software Update Plugin documentation <https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html#version-checks>`_
For more information you can check the `Software Update Plugin documentation <https://docs.octoprint.org/en/master/bundledplugins/softwareupdate.html#version-checks>`_
or read a more step-by-step writeup `here <https://github.com/cp2004/OctoPrint-Knowledge/blob/main/release-channels.md>`_.
-1
View File
@@ -71,4 +71,3 @@ them as (hopefully) documented.
browsing_enabled=True,
growl_instances=growl_instances
))
-1
View File
@@ -53,4 +53,3 @@ An overview of these properties follows.
:ref:`Available Mixins <sec-plugins-mixins-available>`
Some mixin types trigger the injection of additional properties.
-2
View File
@@ -373,5 +373,3 @@ Further reading
`Migrating plugins to Python 2 & 3 compatibility - experiences? <https://community.octoprint.org/t/migrating-plugins-to-python-2-3-compatibility-experiences/16294?u=foosel>`__
Forum topic collecting experiences by plugin developers in migrating their plugins to achieve Python 2 & 3
compatibility.
+7 -11
View File
@@ -4,22 +4,18 @@ __author__ = "Gina Häußge <osd@foosel.net>"
__license__ = "The MIT License <http://opensource.org/licenses/MIT>"
__copyright__ = "Copyright (C) 2015 Gina Häußge - Released under terms of the MIT License"
from sphinx.directives.code import CodeBlock
from typing import Any
import sphinx.highlighting
from sphinx.ext import doctest
from docutils import nodes
from docutils.parsers.rst import directives
from six import text_type
from pygments import highlight
from pygments.filters import VisibleWhitespaceFilter, ErrorToken
from pygments.filters import ErrorToken, VisibleWhitespaceFilter
from pygments.lexers.python import PythonConsoleLexer
from pygments.util import ClassNotFound
from typing import Any
from six import text_type
from sphinx.directives.code import CodeBlock
from sphinx.ext import doctest
def _merge_dict(a, b):
@@ -161,7 +157,7 @@ class PygmentsBridgeExt:
# implementation of sphinx.highlighting.PygmentsBridge, released under the Simplified BSD License, the copyright
# lies with the respective authors.
if not isinstance(source, text_type):
if not isinstance(source, str):
source = source.decode()
# find out which lexer to use
@@ -202,7 +198,7 @@ class PygmentsBridgeExt:
else:
lexer.add_filter("raiseonerror")
if not isinstance(source, text_type):
if not isinstance(source, str):
source = source.decode()
# trim doctest options if wanted
+7 -8
View File
@@ -6,22 +6,21 @@ __copyright__ = "Copyright (C) 2015 Gina Häußge - Released under terms of the
import codecs
import requests
from contextlib import closing
from typing import Any
import requests
from sphinx.directives.code import (
LiteralIncludeReader,
LiteralInclude,
LiteralIncludeReader,
container_wrapper,
dedent_lines,
logger,
nodes,
parselinenos,
logger,
container_wrapper,
)
from sphinx.util.nodes import set_source_info
from typing import Any
cache = {}
@@ -42,8 +41,8 @@ class OnlineIncludeReader(LiteralIncludeReader):
lines = [line.expandtabs(self.options["tab-width"]) for line in lines]
return lines
except (IOError, OSError):
raise IOError("Include file %r not found or reading it failed" % filename)
except OSError:
raise OSError("Include file %r not found or reading it failed" % filename)
except UnicodeError:
raise UnicodeError(
"Encoding %r used for reading included file %r seems to "
+6
View File
@@ -33,3 +33,9 @@ known_first_party =
octoprint
octoprint_setuptools
octoprint_client
[codespell]
skip = *.po,*.min.js,.git,*/vendor/*,*/lib/*,*/bootstrap/*,*/node_modules/*,*/translations/*,*/venv*,*/.*,*/build/*,*/_build/*,setup.cfg,AUTHORS.md
ignore-words = .codespell_ignore_words
quiet-level = 3
count =
+2 -2
View File
@@ -43,7 +43,7 @@ core_deps = [
"Flask-Assets>=2.0,<3",
"Flask-Babel>=2.0,<3",
"Flask-Login>=0.6,<0.7", # breaking changes can happen on minor version increases
"flask>=2,<3",
"flask>=2.2,<2.3", # breaking changes can happen on minor version increases (with deprecation warnings)
"frozendict>=2.0,<3",
"future>=0.18.2,<1", # not really needed anymore, but leaving in for py2/3 compat plugins
"markdown>=3.2.2,<4",
@@ -62,7 +62,7 @@ core_deps = [
"tornado>=6.0.4,<7",
"watchdog>=1,<2",
"websocket-client>=1.2.1,<2",
"werkzeug>=2.1,<2.2", # breaking changes can happen on minor version increases
"werkzeug>=2.2,<2.3", # breaking changes can happen on minor version increases
"wrapt>=1.14,<1.15",
"zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases
"zipstream-ng>=1.3.4,<2.0.0",
+1 -1
View File
@@ -288,7 +288,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
# TAG-NUM-gHEX
mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe)
if not mo:
# unparseable. Maybe git-describe is misbehaving?
# unparsable. Maybe git-describe is misbehaving?
pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out
return pieces
+1 -1
View File
@@ -740,7 +740,7 @@ class LocalFileStorage(StorageInterface):
):
raise StorageError(
f"{destination_name} does already exist in {destination_path}",
code=StorageError.INVALID_DESTINATION,
code=StorageError.ALREADY_EXISTS,
)
source_meta = self._get_metadata_entry(source_path, source_name)
@@ -1,11 +1,11 @@
<div class="accordion-heading-button btn-group" data-bind="visible: loginState.hasPermission(access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_CLEAR) && notifications().length > 0">
<a href="javascript:void(0)" data-bind="click: clear" title="{{ _('Clear notifications')|edq }}">
<a href="javascript:void(0)" data-bind="click: clear" title="{{ _('Clear notifications')|edq }}" aria-label="{{ _('Clear notifications')|edq }}">
<i class="far fa-trash-alt"></i>
</a>
</div>
<div class="accordion-heading-button btn-group" data-bind="visible: notifications().length > 0">
<a href="javascript:void(0)" data-bind="click: toggleSorting" title="{{ _('Change sorting')|edq }}">
<a href="javascript:void(0)" data-bind="click: toggleSorting" title="{{ _('Change sorting')|edq }}" aria-label="{{ _('Change sorting')|edq }}">
<i class="fas" data-bind="css: {'fa-sort-amount-up': sortDesc, 'fa-sort-amount-down': !sortDesc()}"></i>
</a>
</div>
@@ -1,3 +1,3 @@
<a id="navbar_show_prompt" class="pull-right" style="display: none" href="javascript:void(0)" data-bind="click: function() { showPrompt(); }, visible: active() && !visible()" title="{{ _('Message from your printer')|edq }}">
<a id="navbar_show_prompt" class="pull-right" style="display: none" href="javascript:void(0)" data-bind="click: function() { showPrompt(); }, visible: active() && !visible()" title="{{ _('Message from your printer')|edq }}" aria-label="{{ _('Message from your printer')|edq }}">
<i class="far fa-comment-dots"></i>
</a>
@@ -1,3 +1,3 @@
<a id="navbar_show_announcements" class="pull-right" href="javascript:void(0)" data-bind="click: function() { showAnnouncementDialog(); }" title="{{ _('Announcements')|edq }}">
<a id="navbar_show_announcements" class="pull-right" href="javascript:void(0)" data-bind="click: function() { showAnnouncementDialog(); }" title="{{ _('Announcements')|edq }}" aria-label="{{ _('Announcements')|edq }}">
<i class="fa-bell" data-bind="css: {'far': !unread(), 'fas': unread()}"></i>
</a>
@@ -18,10 +18,10 @@ from octoprint.util.version import (
)
SENTRY_URL_SERVER = (
"https://f4265899b96044f3a31e6414c315a0d1@o118517.ingest.sentry.io/1373987"
"https://32fedab787cf4ef0abb9f4fb9060f7c5@o118517.ingest.sentry.io/1373987"
)
SENTRY_URL_COREUI = (
"https://2f33808cb0cb4027afd005c35eebfeb4@o118517.ingest.sentry.io/1374096"
"https://09c57ca82d4047b5a37bb0655ce14187@o118517.ingest.sentry.io/1374096"
)
SETTINGS_DEFAULTS = {
@@ -17,7 +17,7 @@ class GcodeviewerPlugin(
"js/viewer/ui.js",
"js/viewer/reader.js",
"js/viewer/renderer.js",
"js/viewer/pako.js",
"js/lib/pako.js",
]
return {
@@ -41,7 +41,7 @@ var percentageByLayer = [];
var mustCompress = false;
importScripts("pako.js");
importScripts("../lib/pako.js");
var compress = function (data) {
if (!mustCompress) return data;
@@ -3,9 +3,12 @@
<div class="control-group" title="{{ _('Skip/hide gcode until this string')}}">
<label class="control-label" for="settings-gcodeviewer-skipUntilThis">{{ _('Skip to this') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.gcodeviewer.skipUntilThis" id="settings-gcodeviewer-skipUntilThis" placeholder="; layer 1">
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.gcodeviewer.skipUntilThis" id="settings-gcodeviewer-skipUntilThis" placeholder="; some comment at the start of your GCODE">
<span class="help-block">
{% trans %}If provided, the GCode Viewer will search for a line beginning with this string. If found, all GCode up to that point will be skipped. This can be used to skip "purge/nozzle wipe" GCode in the viewer. Note the search is case sensitive. Example: <code>; layer 1</code>{% endtrans %}
{% trans %}If provided, the GCode Viewer will search for a line beginning with this string. If found, all GCode up to that point will be skipped. This can be used to skip "purge/nozzle wipe" GCode in the viewer. Note the search is case sensitive.{% endtrans %}
</span>
<span class="help-block">
{% trans %}<strong>Important!</strong> Make sure that any setup codes (especially things like <code>G20</code>/<code>G21</code>, <code>G90</code>/<code>G91</code>, <code>M82</code>/<code>M83</code>) are <strong>not</strong> skipped, or your files might not get rendered correctly! If things look broken with a skip configuration, you are skipping too much.{% endtrans %}
</span>
</div>
</div>
@@ -1,3 +1,3 @@
<a href="https://faq.octoprint.org/plugintimings-log" target="_blank" title="{{ _('plugintimings.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: pluginTimingsLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>plugintimings.log</code> is enabled')|esq }}', html: true, content: pluginTimingsLogPopoverContent, trigger: 'hover' }" style="display: none">
<a href="https://faq.octoprint.org/plugintimings-log" target="_blank" title="{{ _('plugintimings.log is enabled') }}" aria-label="{{ _('plugintimings.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: pluginTimingsLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>plugintimings.log</code> is enabled')|esq }}', html: true, content: pluginTimingsLogPopoverContent, trigger: 'hover' }" style="display: none">
<i class="fas fa-file-alt"></i>
</a>
@@ -1,3 +1,3 @@
<a href="https://faq.octoprint.org/serial-log" target="_blank" title="{{ _('serial.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: serialLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>serial.log</code> is enabled')|esq }}', html: true, content: serialLogPopoverContent, trigger: 'hover' }" style="display: none">
<a href="https://faq.octoprint.org/serial-log" target="_blank" title="{{ _('serial.log is enabled') }}" aria-label="{{ _('serial.log is enabled') }}" rel="noopener noreferrer" data-bind="visible: serialLogEnabled(), popover: { placement: 'bottom', title: '{{ _('<code>serial.log</code> is enabled')|esq }}', html: true, content: serialLogPopoverContent, trigger: 'hover' }" style="display: none">
<i class="fas fa-file-alt"></i>
</a>
@@ -85,7 +85,7 @@
</select>
</div>
<div class="span1">
<a title="{{ _('Remove')|edq }}" class="btn btn-danger" data-bind="click: $parent.removeLogger"><i class="icon-trash"></i></a>
<a title="{{ _('Remove')|edq }}" aria-label="{{ _('Remove')|edq }}" class="btn btn-danger" data-bind="click: $parent.removeLogger"><i class="icon-trash"></i></a>
</div>
</div>
</div>
@@ -63,8 +63,8 @@
<div class="pull-right">
<button class="btn btn-small" data-bind="click: $root.showRepository"><i class="fas fa-plus"></i> {{ _('Get More') }}</button>
<a class="btn btn-small" href="{{ url_for('index') }}plugin/pluginmanager/export"><i class="fas fa-download"></i> {{ _('Export') }}</a>
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
<a class="btn btn-small" data-toggle="collapse" href="#pluginmanager_info" title="{{ _('Info') }}"><i class="fas fa-lg fa-info-circle text-info" data-bind="css: {'text-error': noticeCount() > 0, 'text-info': noticeCount() <=0 }"></i></a>
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}" aria-label="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
<a class="btn btn-small" data-toggle="collapse" href="#pluginmanager_info" title="{{ _('Info') }}" aria-label="{{ _('Info') }}"><i class="fas fa-lg fa-info-circle text-info" data-bind="css: {'text-error': noticeCount() > 0, 'text-info': noticeCount() <=0 }"></i></a>
</div>
<div id="pluginmanager_info" class="collapse" data-bind="css: {'in': noticeCount() > 0}">
<div class="muted" data-bind="visible: pipAvailable()">
@@ -118,14 +118,14 @@
</ul>
</div>
<div class="btn-group">
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('bundled'); plugins.removeFilter('3rdparty'); }, css: {active: !_.contains(plugins.currentFilters(), 'bundled') && !_.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show both bundled and third-party plugins')|edq }}">All</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('bundled') }, css: {active: _.contains(plugins.currentFilters(), 'bundled')}" title="{{ _('Show only bundled plugins')|edq }}">{{ _('Bundled') }}</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('3rdparty') }, css: {active: _.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show only third-party plugins')|edq }}">{{ _('3rd party') }}</button>
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('bundled'); plugins.removeFilter('3rdparty'); }, css: {active: !_.contains(plugins.currentFilters(), 'bundled') && !_.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show both bundled and third-party plugins')|edq }}" aria-label="{{ _('Show both bundled and third-party plugins')|edq }}">All</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('bundled') }, css: {active: _.contains(plugins.currentFilters(), 'bundled')}" title="{{ _('Show only bundled plugins')|edq }}" aria-label="{{ _('Show only bundled plugins')|edq }}">{{ _('Bundled') }}</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('3rdparty') }, css: {active: _.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show only third-party plugins')|edq }}" aria-label="{{ _('Show only third-party plugins')|edq }}">{{ _('3rd party') }}</button>
</div>
<div class="btn-group">
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('enabled'); plugins.removeFilter('disabled'); }, css: {active: !_.contains(plugins.currentFilters(), 'enabled') && !_.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show both enabled and disabled plugins')|edq }}">All</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('enabled') }, css: {active: _.contains(plugins.currentFilters(), 'enabled')}" title="{{ _('Show only enabled plugins')|edq }}">{{ _('Enabled') }}</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('disabled') }, css: {active: _.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show only disabled plugins')|edq }}">{{ _('Disabled') }}</button>
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('enabled'); plugins.removeFilter('disabled'); }, css: {active: !_.contains(plugins.currentFilters(), 'enabled') && !_.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show both enabled and disabled plugins')|edq }}" aria-label="{{ _('Show both enabled and disabled plugins')|edq }}">All</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('enabled') }, css: {active: _.contains(plugins.currentFilters(), 'enabled')}" title="{{ _('Show only enabled plugins')|edq }}" aria-label="{{ _('Show only enabled plugins')|edq }}">{{ _('Enabled') }}</button>
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('disabled') }, css: {active: _.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show only disabled plugins')|edq }}" aria-label="{{ _('Show only disabled plugins')|edq }}">{{ _('Disabled') }}</button>
</div>
</div>
</div>
@@ -143,7 +143,7 @@
<tbody data-bind="foreach: plugins.paginatedItems">
<tr>
<td class="settings_plugin_plugin_manager_plugins_checkbox">
<input type="checkbox" data-bind="value: key, checked: $root.selectedPlugins, enable: $root.enableBulk($data)" title="{{ _('Bundled and incompatible plugins do not support bulk operations') | edq }}">
<input type="checkbox" data-bind="value: key, checked: $root.selectedPlugins, enable: $root.enableBulk($data)" title="{{ _('Bundled and incompatible plugins do not support bulk operations') | edq }}" aria-label="{{ _('Bundled and incompatible plugins do not support bulk operations') | edq }}">
</td>
<td class="settings_plugin_plugin_manager_plugins_name">
<div data-bind="css: {muted: !enabled}"><span data-bind="text: name"></span> <span data-bind="visible: version">(<span data-bind="text: version"></span>)</span> <i title="{{ _('Bundled with OctoPrint')|edq }}" class="fas fa-th-large" data-bind="visible: bundled"></i> <i class="fas fa-lock" title="{{ _('Cannot be uninstalled through OctoPrint')|edq }}" data-bind="visible: !managable"></i> <i class="fas fa-bolt" title="{{ _('Incompatible to OctoPrint or the underlying Python environment')|edq }}" data-bind="visible: incompatible"></i> <i title="{{ _('Restart of OctoPrint needed for changes to take effect')|edq }}" class="fas fa-sync" data-bind="visible: pending_enable || pending_disable || pending_install || pending_uninstall"></i> <i title="{{ _('Pending install')|edq }}" class="fas fa-plus" data-bind="visible: pending_install"></i> <i title="{{ _('Pending uninstall')|edq }}" class="fas fa-minus" data-bind="visible: pending_uninstall"></i> <i title="{{ _('Disabled due to safe mode')|edq }}" class="fas fa-medkit" data-bind="visible: safe_mode_victim"></i> <i class="fas fa-exclamation-triangle" title="{{ _('There are notices available regarding this plugin')|edq }}" data-bind="visible: notifications && notifications.length"></i> <i class="fas fa-ban" title="{{ _('This plugin is blacklisted')|edq }}" data-bind="visible: blacklisted"></i></div>
@@ -160,7 +160,7 @@
</div>
</td>
<td class="settings_plugin_plugin_manager_plugins_actions">
<a href="#" data-bind="css: $root.toggleButtonCss($data), attr: {title: $root.toggleButtonTitle($data)}, enable: $root.enableToggle($data), click: function() { $root.togglePlugin($data) }"></a>&nbsp;|&nbsp;<a href="#" class="fas fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" data-bind="css: {disabled: !$root.enableCleanup($data)}, enable: $root.enableCleanup($data), click: function() { $root.cleanupPlugin($data) }"></a>&nbsp;|&nbsp;<a href="#" class="far fa-trash-alt" title="{{ _('Uninstall Plugin')|edq }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
<a href="#" data-bind="css: $root.toggleButtonCss($data), attr: {title: $root.toggleButtonTitle($data)}, enable: $root.enableToggle($data), click: function() { $root.togglePlugin($data) }"></a>&nbsp;|&nbsp;<a href="#" class="fas fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" aria-label="{{ _('Cleanup Plugin Data')|edq }}" data-bind="css: {disabled: !$root.enableCleanup($data)}, enable: $root.enableCleanup($data), click: function() { $root.cleanupPlugin($data) }"></a>&nbsp;|&nbsp;<a href="#" class="far fa-trash-alt" title="{{ _('Uninstall Plugin')|edq }}" aria-label="{{ _('Uninstall Plugin')|edq }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
</td>
</tr>
</tbody>
@@ -170,7 +170,7 @@
</div>
<div class="tab-pane" id="settings_plugin_pluginmanager_cleanup">
<div class="pull-right">
<button class="btn btn-small" data-bind="click: function() { $root.requestOrphanData({refresh: true}) }" title="{{ _('Refresh')|edq }}"><i class="fas fa-sync"></i></button>
<button class="btn btn-small" data-bind="click: function() { $root.requestOrphanData({refresh: true}) }" title="{{ _('Refresh')|edq }}" aria-label="{{ _('Refresh')|edq }}"><i class="fas fa-sync"></i></button>
</div>
<h3>{{ _('Cleanup') }}</h3>
@@ -190,7 +190,7 @@
<span data-bind="text: identifier"></span>
</td>
<td class="settings_plugin_plugin_manager_orphans_actions">
<a href="javascript:void(0)" class="fas fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" data-bind="click: function() { $root.cleanupPlugin($data.identifier) }"></a>
<a href="javascript:void(0)" class="fas fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" aria-label="{{ _('Cleanup Plugin Data')|edq }}" data-bind="click: function() { $root.cleanupPlugin($data.identifier) }"></a>
</td>
</tr>
</tbody>
@@ -2425,11 +2425,11 @@ class SoftwareUpdatePlugin(
)
if check.get("update_script", None):
# we force an exact version & python unequality check, to be able to downgrade
# we force an exact version & python inequality check, to be able to downgrade
result["force_exact_version"] = True
result["release_compare"] = "python_unequal"
elif check.get("pip", None):
# we force python unequality check for pip installs, to be able to downgrade
# we force python inequality check for pip installs, to be able to downgrade
result["release_compare"] = "python_unequal"
if result.get("pip", None):
@@ -77,13 +77,13 @@
<div class="tab-pane active" id="settings_plugin_softwareupdate_updates">
<div class="pull-right">
<div class="btn-group">
<button class="btn btn-primary" data-bind="click: function() { $root.cancelQueued(); }, enable: enableCancelQueued, css: {disabled: !enableCancelQueued}, visible: enableCancelQueued" title="{{ _('Cancel all queued updates') | edq }}" style="display: none;"><i class="fas fa-spinner fa-spin" data-bind="visible: cancelInProgress"></i> {{ _('Cancel Queued') }}</button>
<button class="btn btn-primary" data-bind="click: function() { $root.cancelQueued(); }, enable: enableCancelQueued, css: {disabled: !enableCancelQueued}, visible: enableCancelQueued" title="{{ _('Cancel all queued updates') | edq }}" aria-label="{{ _('Cancel all queued updates') | edq }}" style="display: none;"><i class="fas fa-spinner fa-spin" data-bind="visible: cancelInProgress"></i> {{ _('Cancel Queued') }}</button>
</div>
<div class="btn-group">
<button class="btn btn-primary" data-bind="click: function() { $root.updateEnabled(); }, enable: enableUpdateEnabled, css: {disabled: !enableUpdateEnabled}" title="{{ _('Update all enabled') | edq }}"><i class="fas fa-spinner fa-spin" data-bind="visible: updateInProgress"></i> {{ _('Update all') }}</button>
<button class="btn btn-primary" data-bind="click: function() { $root.updateEnabled(); }, enable: enableUpdateEnabled, css: {disabled: !enableUpdateEnabled}" title="{{ _('Update all enabled') | edq }}" aria-label="{{ _('Update all enabled') | edq }}"><i class="fas fa-spinner fa-spin" data-bind="visible: updateInProgress"></i> {{ _('Update all') }}</button>
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="javascript:void(0)" data-bind="click: function() { $root.updateAll(); }, enable: enableUpdateAll, css: {disabled: !enableUpdateAll}" title="{{ _('Update all muted & enabled') | edq }}">{{ _('Update all available') }}</a></li>
<li><a href="javascript:void(0)" data-bind="click: function() { $root.updateAll(); }, enable: enableUpdateAll, css: {disabled: !enableUpdateAll}" title="{{ _('Update all muted & enabled') | edq }}" aria-label="{{ _('Update all muted & enabled') | edq }}">{{ _('Update all available') }}</a></li>
</ul>
</div>
<div class="btn-group">
@@ -93,7 +93,7 @@
<li><a href="javascript:void(0)" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}">{{ _('Force check for updates') }}</a></li>
</ul>
</div>
<button class="btn" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
<button class="btn" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}" aria-label="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
</div>
<h3>{{ _('Current versions') }}</h3>
@@ -1778,7 +1778,7 @@ class VirtualPrinter:
filename = filename
if filename.startswith("/"):
filename = filename[1:]
file = os.path.join(self._virtualSd, filename).lower()
file = os.path.join(self._virtualSd, filename.lower())
if os.path.exists(file):
if os.path.isfile(file):
os.remove(file)
+1 -1
View File
@@ -29,7 +29,7 @@ class DevelWebassetsConfig(BaseModel):
class DevelCacheConfig(BaseModel):
enabled: bool = True
"""Whether to enable caching. Defaults to true. Setting it to false will cause the UI to alway be fully rerendered on request to `/` on the server."""
"""Whether to enable caching. Defaults to true. Setting it to false will cause the UI to always be fully rerendered on request to `/` on the server."""
preemptive: bool = True
"""Whether to enable the preemptive cache."""
+4 -4
View File
@@ -1491,19 +1491,19 @@ class Server:
return html_header_regex.sub(repl, s)
markdown_header_regex = re.compile(
r"^(?P<hashs>#+)\s+(?P<content>.*)$", flags=re.MULTILINE
r"^(?P<hashes>#+)\s+(?P<content>.*)$", flags=re.MULTILINE
)
def offset_markdown_headers(s, offset):
def repl(match):
number = len(match.group("hashs"))
number = len(match.group("hashes"))
number += offset
if number > 6:
number = 6
elif number < 1:
number = 1
return "{hashs} {content}".format(
hashs="#" * number, content=match.group("content")
return "{hashes} {content}".format(
hashes="#" * number, content=match.group("content")
)
return markdown_header_regex.sub(repl, s)
+43 -12
View File
@@ -18,6 +18,7 @@ import octoprint.slicing
from octoprint.access.permissions import Permissions
from octoprint.events import Events
from octoprint.filemanager.destinations import FileDestinations
from octoprint.filemanager.storage import StorageError
from octoprint.server import (
NO_CONTENT,
current_user,
@@ -660,11 +661,8 @@ def uploadGcodeFile(target):
allow_overwrite=True,
display=canonFilename,
)
except octoprint.filemanager.storage.StorageError as e:
if e.code == octoprint.filemanager.storage.StorageError.INVALID_FILE:
abort(415, description="Could not upload file, invalid type")
else:
abort(500, description="Could not upload file")
except (OSError, StorageError) as e:
_abortWithException(e)
else:
filename = fileProcessingFinished(
added_file,
@@ -776,11 +774,8 @@ def uploadGcodeFile(target):
added_folder = fileManager.add_folder(
target, futureFullPath, display=canonName
)
except octoprint.filemanager.storage.StorageError as e:
if e.code == octoprint.filemanager.storage.StorageError.INVALID_DIRECTORY:
abort(400, description="Could not create folder, invalid directory")
else:
abort(500, description="Could not create folder")
except (OSError, StorageError) as e:
_abortWithException(e)
location = url_for(
".readGcodeFile",
@@ -1235,7 +1230,10 @@ def deleteGcodeFile(filename, target):
if target == FileDestinations.SDCARD:
printer.delete_sd_file(filename, tags={"source:api", "api:files.sd"})
else:
fileManager.remove_file(target, filename)
try:
fileManager.remove_file(target, filename)
except (OSError, StorageError) as e:
_abortWithException(e)
elif _verifyFolderExists(target, filename):
if _isBusy(target, filename):
@@ -1254,11 +1252,44 @@ def deleteGcodeFile(filename, target):
printer.unselect_file()
# delete it
fileManager.remove_folder(target, filename, recursive=True)
try:
fileManager.remove_folder(target, filename, recursive=True)
except (OSError, StorageError) as e:
_abortWithException(e)
return NO_CONTENT
def _abortWithException(error):
if type(error) is StorageError:
logging.getLogger(__name__).error(
f"{error.message}: {error.code}", exc_info=error.cause
)
if error.code == StorageError.INVALID_DIRECTORY:
abort(400, description="Could not create folder, invalid directory")
elif error.code == StorageError.INVALID_FILE:
abort(415, description="Could not upload file, invalid type")
elif error.code == StorageError.INVALID_SOURCE:
abort(404, description="Source path does not exist, invalid source")
elif error.code == StorageError.INVALID_DESTINATION:
abort(400, description="Destination is invalid")
elif error.code == StorageError.DOES_NOT_EXIST:
abort(404, description="Does not exit")
elif error.code == StorageError.ALREADY_EXISTS:
abort(409, description="File or folder already exists")
elif error.code == StorageError.SOURCE_EQUALS_DESTINATION:
abort(400, description="Source and destination are the same folder")
elif error.code == StorageError.NOT_EMPTY:
abort(409, description="Folder is not empty")
elif error.code == StorageError.UNKNOWN:
abort(500, description=str(error.cause).split(":")[0])
else:
abort(500, description=error.message)
else:
logging.getLogger(__name__).exception(error)
abort(500, description=str(error).split(":")[0])
def _getCurrentFile():
currentJob = printer.get_current_job()
if (
+20
View File
@@ -428,3 +428,23 @@ def require_login(*permissions):
)
return None
def validate_local_redirect(url, allowed_paths):
"""Validates the given local redirect URL against the given allowed paths.
An `url` is valid for a local redirect if it has neither scheme nor netloc defined,
and its path is one of the given allowed paths.
Args:
url (str): URL to validate
allowed_paths (List[str]): List of allowed paths, only paths contained
will be considered valid.
Returns:
bool: Whether the `url` passed validation or not.
"""
from urllib.parse import urlparse
parsed = urlparse(url)
return parsed.scheme == "" and parsed.netloc == "" and parsed.path in allowed_paths
+7 -4
View File
@@ -8,7 +8,6 @@ import logging
import os
import re
from collections import defaultdict
from urllib.parse import urlparse
from flask import (
Response,
@@ -39,7 +38,11 @@ from octoprint.server import ( # noqa: F401
preemptiveCache,
userManager,
)
from octoprint.server.util import has_permissions, require_login_with
from octoprint.server.util import (
has_permissions,
require_login_with,
validate_local_redirect,
)
from octoprint.settings import settings
from octoprint.util import sv, to_bytes, to_unicode
from octoprint.util.version import get_python_version_string
@@ -173,9 +176,9 @@ def login():
default_redirect_url = request.script_root + url_for("index")
redirect_url = request.args.get("redirect", default_redirect_url)
allowed_paths = [url_for("index"), url_for("recovery")]
parsed = urlparse(redirect_url) # check if redirect url is valid
if parsed.scheme != "" or parsed.netloc != "":
if not validate_local_redirect(redirect_url, allowed_paths):
_logger.warning(
f"Got an invalid redirect URL with the login attempt, misconfiguration or attack attempt: {redirect_url}"
)
+54 -47
View File
@@ -25,6 +25,7 @@ import logging
import os
import re
import sys
import threading
import time
from collections import ChainMap
from collections.abc import KeysView
@@ -485,6 +486,8 @@ class Settings:
self._last_effective_hash = None
self._mtime = None
self._lock = threading.RLock()
self._get_preprocessors = {"controls": self._process_custom_controls}
self._set_preprocessors = {}
@@ -711,9 +714,10 @@ class Settings:
self._last_effective_hash = None
def _mark_dirty(self):
self._dirty = True
self._dirty_time = time.time()
self._forget_hashes()
with self._lock:
self._dirty = True
self._dirty_time = time.time()
self._forget_hashes()
@property
def effective(self):
@@ -1460,36 +1464,37 @@ class Settings:
return backup
def save(self, force=False, trigger_event=False):
if not self._dirty and not force:
return False
with self._lock:
if not self._dirty and not force:
return False
try:
with atomic_write(
self._configfile,
mode="wt",
prefix="octoprint-config-",
suffix=".yaml",
permissions=0o600,
max_permissions=0o666,
) as configFile:
yaml.save_to_file(self._map.top_map, file=configFile)
self._dirty = False
except Exception:
self._logger.exception("Error while saving config.yaml!")
raise
else:
from octoprint.events import Events, eventManager
try:
with atomic_write(
self._configfile,
mode="wt",
prefix="octoprint-config-",
suffix=".yaml",
permissions=0o600,
max_permissions=0o666,
) as configFile:
yaml.save_to_file(self._map.top_map, file=configFile)
self._dirty = False
except Exception:
self._logger.exception("Error while saving config.yaml!")
raise
else:
from octoprint.events import Events, eventManager
self.load()
self.load()
if trigger_event:
payload = {
"config_hash": self.config_hash,
"effective_hash": self.effective_hash,
}
eventManager().fire(Events.SETTINGS_UPDATED, payload=payload)
if trigger_event:
payload = {
"config_hash": self.config_hash,
"effective_hash": self.effective_hash,
}
eventManager().fire(Events.SETTINGS_UPDATED, payload=payload)
return True
return True
##~~ Internal getter
@@ -1764,8 +1769,9 @@ class Settings:
chain = self._map.with_config_defaults(config=config, defaults=defaults)
try:
chain.del_by_path(path)
self._mark_dirty()
with self._lock:
chain.del_by_path(path)
self._mark_dirty()
except KeyError:
if error_on_path:
raise NoSuchSettingsPath()
@@ -1819,24 +1825,25 @@ class Settings:
raise NoSuchSettingsPath()
default_value = None
in_local = chain.has_path(path, only_local=True)
in_defaults = chain.has_path(path, only_defaults=True)
with self._lock:
in_local = chain.has_path(path, only_local=True)
in_defaults = chain.has_path(path, only_defaults=True)
if not force and in_defaults and in_local and default_value == value:
try:
chain.del_by_path(path)
if not force and in_defaults and in_local and default_value == value:
try:
chain.del_by_path(path)
self._mark_dirty()
except KeyError:
if error_on_path:
raise NoSuchSettingsPath()
pass
elif (
force
or (not in_local and in_defaults and default_value != value)
or (in_local and current != value)
):
chain.set_by_path(path, value)
self._mark_dirty()
except KeyError:
if error_on_path:
raise NoSuchSettingsPath()
pass
elif (
force
or (not in_local and in_defaults and default_value != value)
or (in_local and current != value)
):
chain.set_by_path(path, value)
self._mark_dirty()
# we've changed the interface to no longer mutate the passed in config, so we
# must manually do that here
+2 -2
View File
@@ -444,7 +444,7 @@ $(function () {
};
}
// make sure we have atleast a function
// make sure we have at least a function
if (!_.isFunction(viewModel.construct)) {
log.error("No function to instantiate with", viewModel);
continue;
@@ -533,7 +533,7 @@ $(function () {
}
}
// anything that's now in the postponed list has to be readded to the unprocessedViewModels
// anything that's now in the postponed list has to be re-added to the unprocessedViewModels
unprocessedViewModels = unprocessedViewModels.concat(postponed);
// if we still have the same amount of items in our list of unprocessed view models it means that we
@@ -888,8 +888,27 @@ $(function () {
deferred.reject();
});
})
.fail(function () {
.fail(function (data) {
deferred.reject();
// Notify user
var error =
"<p>" +
gettext(
"Could not remove entry. Please check octoprint.log for possible reasons."
) +
"</p>";
if (data.responseJSON && data.responseJSON.error) {
error += pnotifyAdditionalInfo(
"<pre>" + _.escape(data.responseJSON.error) + "</pre>"
);
}
new PNotify({
title: gettext("Failed to remove entry"),
text: error,
type: "error",
hide: false
});
});
return deferred.promise().always(function () {
@@ -1584,6 +1603,7 @@ $(function () {
self._handleUploadAdd = function (e, data) {
var file = data.files[0];
var path = self.currentPath();
var fileSizeTooBig = file.size > self.freeSpace();
var formData = {};
if (path !== "") {
@@ -1600,10 +1620,13 @@ $(function () {
name: file.name
})
);
$("p, form", self.uploadExistsDialog).toggle(!fileSizeTooBig);
$("span", self.uploadExistsDialog).toggle(fileSizeTooBig);
$("input", self.uploadExistsDialog)
.val("")
.prop("placeholder", response.suggestion);
$("a.upload-rename", self.uploadExistsDialog)
.toggle(!fileSizeTooBig)
.prop("disabled", false)
.off("click")
.on("click", function () {
@@ -1659,8 +1682,35 @@ $(function () {
}
});
} else {
data.formData = formData;
data.submit();
if (fileSizeTooBig) {
var error =
"<p>" +
gettext(
"Could not upload the file. There is not enough disk space remaining."
) +
"</p>";
error +=
"<pre>" +
_.sprintf(gettext("Free Space: %(freespace)s"), {
freespace: self.freeSpaceString()
}) +
"<br>" +
_.sprintf(gettext("File Size: %(filesize)s"), {
filesize: formatSize(file.size)
}) +
"</pre>";
new PNotify({
title: "Upload failed",
text: error,
type: "error",
hide: false
});
} else {
data.formData = formData;
data.submit();
}
}
};
@@ -1729,9 +1779,9 @@ $(function () {
}
error += "</p>";
if (data.jqXHR.responseText) {
if (data.jqXHR.responseJSON && data.jqXHR.responseJSON.error) {
error += pnotifyAdditionalInfo(
"<pre>" + _.escape(data.jqXHR.responseText) + "</pre>"
"<pre>" + _.escape(data.jqXHR.responseJSON.error) + "</pre>"
);
}
new PNotify({
+5 -5
View File
@@ -32,11 +32,11 @@ $(function () {
OctoPrint.browser
.login(username, password, remember)
.done(function () {
.done(() => {
ignoreDisconnect = true;
window.location.href = REDIRECT_URL;
})
.fail(function () {
.fail(() => {
usernameElement.val(USER_ID);
passwordElement.val("");
@@ -55,18 +55,18 @@ $(function () {
OctoPrint.options.baseurl = BASE_URL;
OctoPrint.socket.onConnected = function () {
OctoPrint.socket.onConnected = () => {
buttonElement.prop("disabled", false);
offlineElement.removeClass("in");
};
OctoPrint.socket.onDisconnected = function () {
OctoPrint.socket.onDisconnected = () => {
if (ignoreDisconnect) return;
buttonElement.prop("disabled", true);
offlineElement.addClass("in");
};
reconnectElement.click(function () {
reconnectElement.click(() => {
OctoPrint.socket.reconnect();
});
+29 -31
View File
@@ -54,7 +54,7 @@ $(function () {
self.backups = ko.observableArray([]);
self.excludeFromBackup = ko.observableArray([]);
self.backupMaxUploadSize = ko.observable();
self.backupIsAboveUploadSize = function (data) {
self.backupIsAboveUploadSize = (data) => {
return data.size > self.backupMaxUploadSize();
};
@@ -64,8 +64,8 @@ $(function () {
self.workLoglines = ko.observableArray([]);
self.workTitle = ko.observable("");
self.request = function () {
OctoPrint.browser.passiveLogin().done(function (resp) {
self.request = () => {
OctoPrint.browser.passiveLogin().done((resp) => {
self.username(resp.name);
self.permitted(_.includes(resp.needs.role, "admin"));
self.known(true);
@@ -73,13 +73,13 @@ $(function () {
OctoPrint.socket.sendAuth(resp.name, resp.session);
});
OctoPrint.system.getCommandsForSource("core").done(function (resp) {
OctoPrint.system.getCommandsForSource("core").done((resp) => {
self.systemCommands(resp);
});
OctoPrint.system.getInfo().done(function (resp) {
OctoPrint.system.getInfo().done((resp) => {
var systeminfo = [];
_.forOwn(resp.systeminfo, function (value, key) {
_.forOwn(resp.systeminfo, (value, key) => {
systeminfo.push({key: key, value: value});
});
self.systemInfo(systeminfo);
@@ -87,25 +87,23 @@ $(function () {
OctoPrint.printer
.getFullState()
.done(function (resp) {
.done((resp) => {
self.printerConnected(true);
self.jobInProgress(resp.state.flags.printing);
})
.fail(function (xhr) {
.fail((xhr) => {
self.printerConnected(false);
self.jobInProgress(false);
});
if (OctoPrint.plugins.backup) {
OctoPrint.plugins.backup.get().done(function (resp) {
OctoPrint.plugins.backup.get().done((resp) => {
self.backupSupported(true);
self.restoreSupported(resp.restore_supported);
self.backupMaxUploadSize(resp.max_upload_size);
var backups = resp.backups;
backups.sort(function (a, b) {
return b.date - a.date;
});
backups.sort((a, b) => b.date - a.date);
self.backups(backups);
});
} else {
@@ -115,15 +113,15 @@ $(function () {
}
};
self.executeSystemCommand = function (command) {
var process = function () {
self.executeSystemCommand = (command) => {
var process = () => {
OctoPrint.system.executeCommand(command.source, command.action);
};
if (command.confirm) {
showConfirmationDialog({
message: command.confirm,
onproceed: function () {
onproceed: () => {
process();
}
});
@@ -132,22 +130,22 @@ $(function () {
}
};
self.copySystemInfo = function () {
self.copySystemInfo = () => {
var text = "";
_.each(self.systemInfo(), function (entry) {
_.each(self.systemInfo(), (entry) => {
text += entry.key + ": " + entry.value + "\r\n";
});
copyToClipboard(text);
};
self.cancelPrint = function () {
OctoPrint.job.cancel().done(function () {
OctoPrint.job.cancel().done(() => {
self.request();
});
};
self.disconnectPrinter = function () {
OctoPrint.connection.disconnect().done(function () {
OctoPrint.connection.disconnect().done(() => {
self.request();
});
};
@@ -160,15 +158,15 @@ $(function () {
if (!self.backupSupported()) return;
var excluded = self.excludeFromBackup();
OctoPrint.plugins.backup.createBackup(excluded).done(function () {
OctoPrint.plugins.backup.createBackup(excluded).done(() => {
self.excludeFromBackup([]);
});
};
self.restoreBackup = function (backup) {
self.restoreBackup = (backup) => {
if (!self.restoreSupported()) return;
var perform = function () {
var perform = () => {
self.workInProgress(true);
self.workTitle(gettext("Restoring backup..."));
self.workLoglines.removeAll();
@@ -192,26 +190,26 @@ $(function () {
);
};
self.logout = function () {
OctoPrint.browser.logout().done(function () {
self.logout = () => {
OctoPrint.browser.logout().done(() => {
window.location.href = LOGIN_URL;
});
};
self.reconnect = function () {
self.reconnect = () => {
OctoPrint.socket.reconnect();
};
self.onSocketConnected = function () {
self.onSocketConnected = () => {
self.connected(true);
self.request();
};
self.onSocketDisconnected = function () {
self.onSocketDisconnected = () => {
self.connected(false);
};
self.onSocketMessage = function (event, data) {
self.onSocketMessage = (event, data) => {
console.log("onSocketMessage", event, data);
if (event === "plugin" && data.plugin === "backup") {
switch (data.data.type) {
@@ -302,15 +300,15 @@ $(function () {
var viewModel = new RecoveryViewModel();
OctoPrint.socket.onConnected = function () {
OctoPrint.socket.onConnected = () => {
viewModel.onSocketConnected();
};
OctoPrint.socket.onDisconnected = function () {
OctoPrint.socket.onDisconnected = () => {
viewModel.onSocketDisconnected();
};
OctoPrint.socket.onMessage("*", function (data) {
OctoPrint.socket.onMessage("*", (data) => {
viewModel.onSocketMessage(data.event, data.data);
});
+1 -1
View File
@@ -316,7 +316,7 @@ textarea[class*="span"],
.row-fluid .controls-row [class*="span"] {
float: left;
}
// Explicity set top padding on all checkboxes/radios, not just first-child
// Explicitly set top padding on all checkboxes/radios, not just first-child
.controls-row .checkbox[class*="span"],
.controls-row .radio[class*="span"] {
padding-top: 5px;
+1 -1
View File
@@ -127,7 +127,7 @@
.input-append,
.input-prepend {
margin-top: 5px;
white-space: nowrap; // preven two items from separating within a .navbar-form that has .pull-left
white-space: nowrap; // prevent two items from separating within a .navbar-form that has .pull-left
input {
margin-top: 0; // remove the margin on top since it's on the parent
}
+2 -2
View File
@@ -2,7 +2,7 @@
// Thumbnails
// --------------------------------------------------
// Note: `.thumbnails` and `.thumbnails > li` are overriden in responsive files
// Note: `.thumbnails` and `.thumbnails > li` are overridden in responsive files
// Make wrapper ul behave like the grid
.thumbnails {
@@ -17,7 +17,7 @@
// Float li to make thumbnails appear in a row
.thumbnails > li {
float: left; // Explicity set the float since we don't require .span* classes
float: left; // Explicitly set the float since we don't require .span* classes
margin-bottom: @baseLineHeight;
margin-left: @gridGutterWidth;
}
@@ -64,6 +64,9 @@
</div>
</div>
</form>
<span hidden>
{{ _('There is not enough free disk space to keep the existing file and upload this one.') }}
</span>
</div>
<div class="modal-footer">
<a href="javascript:void(0)" class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</a>
@@ -300,13 +300,6 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_sdAlwaysAvailable" id="settings-serialSdAlwaysAvailable"> {{ _('Always assume SD card is present') }} <span class="label">{{ _('Repetier') }}</span>
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -372,7 +365,7 @@
</label>
</div>
</div>
</div>
</div>
<div>
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', container: '#settings_serial_protocol_firmware .hide' }"><i class="fas fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
@@ -426,6 +419,13 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_sdAlwaysAvailable" id="settings-serialSdAlwaysAvailable"> {{ _('Always assume SD card is present') }}
</label>
</div>
</div>
<div class="control-group">
<label class="control-label"> {{ _('Simulate <code>ok</code> for resend requests') }}</label>
<div class="controls">
@@ -1,3 +1,3 @@
<a href="https://faq.octoprint.org/connectivity-offline" target="_blank" title="{{ _('There is no connection to the internet') }}" rel="noopener noreferrer" data-bind="visible: offline(), popover: { placement: 'bottom', title: '{{ _('There is no connection to the internet')|esq }}', html: true, content: offlinePopoverContent, trigger: 'hover' }" style="display: none">
<a href="https://faq.octoprint.org/connectivity-offline" target="_blank" title="{{ _('There is no connection to the internet') }}" aria-label="{{ _('There is no connection to the internet') }}" rel="noopener noreferrer" data-bind="visible: offline(), popover: { placement: 'bottom', title: '{{ _('There is no connection to the internet')|esq }}', html: true, content: offlinePopoverContent, trigger: 'hover' }" style="display: none">
<i class="fas fa-unlink"></i>
</a>
@@ -1,3 +1,3 @@
<a id="navbar_show_settings" data-test-id="settings-open" title="{{ _('Settings')|edq }}" class="pull-right" href="#settings_dialog" data-bind="click: function() { $root.show(); }">
<a id="navbar_show_settings" data-test-id="settings-open" title="{{ _('Settings')|edq }}" aria-label="{{ _('Settings')|edq }}" class="pull-right" href="#settings_dialog" data-bind="click: function() { $root.show(); }">
<i class="fas fa-wrench"></i>
</a>
@@ -1,4 +1,4 @@
<a href="javascript:void(0)" title="{{ _('System')|edq }}" class="dropdown-toggle" data-toggle="dropdown" data-bind="visible: system.systemActions().length > 0">
<a href="javascript:void(0)" title="{{ _('System')|edq }}" aria-label="{{ _('System')|edq }}" class="dropdown-toggle" data-toggle="dropdown" data-bind="visible: system.systemActions().length > 0">
<i class="fas fa-power-off"></i>
<b class="caret"></b>
</a>
@@ -1,5 +1,5 @@
<div class="refresh-trigger accordion-heading-button btn-group" data-bind="visible: $root.refreshVisible">
<a href="#" data-bind="click: function() { $root.requestData(); }" title="{{ _('Refresh connection options')|edq }}">
<a href="#" data-bind="click: function() { $root.requestData(); }" title="{{ _('Refresh connection options')|edq }}" aria-label="{{ _('Refresh connection options')|edq }}">
<i class="fas fa-sync"></i>
</a>
</div>
+11 -11
View File
@@ -22,11 +22,11 @@
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
<div class="additionalInfo hide" data-bind="html: $root.getAdditionalData($data)"></div>
<div class="btn-group action-buttons">
<a class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DOWNLOAD), attr: {href: $root.downloadLink($data)}, css: {disabled: !$root.downloadLink($data)}" title="{{ _('Download')|edq }}"><i class="fas fa-download"></i></a>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasAllPermissionsKo($root.access.permissions.FILES_UPLOAD, $root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableMove($data)) { $root.showMoveDialog($data, event); } else { return; } }, css: {disabled: !$root.enableMove($data)}" title="{{ _('Move')|edq }}"><i class="fas fa-cut"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFile($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove')|edq }}"><i class="far fa-trash-alt"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_SELECT), click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}" title="{{ _('Load')|edq }}"><i class="fas fa-folder-open"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.PRINT), click: function() { if ($root.enableSelectAndPrint($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelectAndPrint($data)}" title="{{ _('Load and Print')|edq }}"><i class="fas fa-print"></i></div>
<a class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DOWNLOAD), attr: {href: $root.downloadLink($data)}, css: {disabled: !$root.downloadLink($data)}" title="{{ _('Download')|edq }}" aria-label="{{ _('Download')|edq }}"><i class="fas fa-download"></i></a>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasAllPermissionsKo($root.access.permissions.FILES_UPLOAD, $root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableMove($data)) { $root.showMoveDialog($data, event); } else { return; } }, css: {disabled: !$root.enableMove($data)}" title="{{ _('Move')|edq }}" aria-label="{{ _('Move')|edq }}" role="link"><i class="fas fa-cut"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFile($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove')|edq }}" aria-label="{{ _('Remove')|edq }}" role="link"><i class="far fa-trash-alt"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_SELECT), click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}" title="{{ _('Load')|edq }}" aria-label="{{ _('Load')|edq }}" role="link"><i class="fas fa-folder-open"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.PRINT), click: function() { if ($root.enableSelectAndPrint($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelectAndPrint($data)}" title="{{ _('Load and Print')|edq }}" aria-label="{{ _('Load and Print')|edq }}" role="link"><i class="fas fa-print"></i></div>
</div>
</script>
@@ -36,10 +36,10 @@
<div class="uploaded">{{ _('Uploaded') }}: <span data-bind="text: formatTimeAgo(date), attr: {title: formatDate(date)}"></span></div>
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
<div class="btn-group action-buttons">
<a class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DOWNLOAD), attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}" title="{{ _('Download')|edq }}"><i class="fas fa-download"></i></a>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasAllPermissionsKo($root.access.permissions.FILES_UPLOAD, $root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableMove($data)) { $root.showMoveDialog($data, event); } else { return; } }, css: {disabled: !$root.enableMove($data)}" title="{{ _('Move')|edq }}"><i class="fas fa-cut"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFile($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove')|edq }}"><i class="far fa-trash-alt"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.SLICE), click: function() { if ($root.enableSlicing($data)) { $root.sliceFile($data); } else { return; } }, css: {disabled: !$root.enableSlicing($data)}" title="{{ _('Slice')|edq }}"><i class="fas fa-magic"></i></div>
<a class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DOWNLOAD), attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}" title="{{ _('Download')|edq }}" aria-label="{{ _('Download')|edq }}" role="link"><i class="fas fa-download"></i></a>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasAllPermissionsKo($root.access.permissions.FILES_UPLOAD, $root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableMove($data)) { $root.showMoveDialog($data, event); } else { return; } }, css: {disabled: !$root.enableMove($data)}" title="{{ _('Move')|edq }}" aria-label="{{ _('Move')|edq }}" role="link"><i class="fas fa-cut"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFile($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove')|edq }}" aria-label="{{ _('Remove')|edq }}" role="link"><i class="far fa-trash-alt"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.SLICE), click: function() { if ($root.enableSlicing($data)) { $root.sliceFile($data); } else { return; } }, css: {disabled: !$root.enableSlicing($data)}" title="{{ _('Slice')|edq }}" aria-label="{{ _('Slice')|edq }}" role="link"><i class="fas fa-magic"></i></div>
</div>
</script>
@@ -48,8 +48,8 @@
<div class="internal" data-bind="visible: name != display">{{ _('Internal') }}: <span data-bind="text: name"></span></div>
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
<div class="btn-group action-buttons">
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasAllPermissionsKo($root.access.permissions.FILES_UPLOAD, $root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableMove($data)) { $root.showMoveDialog($data, event); } else { return; } }, css: {disabled: !$root.enableMove($data)}" title="{{ _('Move')|edq }}"><i class="fas fa-cut"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFolder($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove') }}"><i class="far fa-trash-alt"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasAllPermissionsKo($root.access.permissions.FILES_UPLOAD, $root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableMove($data)) { $root.showMoveDialog($data, event); } else { return; } }, css: {disabled: !$root.enableMove($data)}" title="{{ _('Move')|edq }}" aria-label="{{ _('Move')|edq }}" role="link"><i class="fas fa-cut"></i></div>
<div class="btn btn-mini" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.FILES_DELETE), click: function(data, event) { if ($root.enableRemove($data)) { $root.removeFolder($data, event); } else { return; } }, css: {disabled: !$root.enableRemove($data)}" title="{{ _('Remove') }}" aria-label="{{ _('Remove') }}" role="link"><i class="far fa-trash-alt"></i></div>
</div>
</script>
</div>
@@ -1,5 +1,5 @@
<div class="settings-trigger accordion-heading-button btn-group" data-bind="visible: $root.filesListVisible">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="{{ _('File list settings')|edq }}">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="{{ _('File list settings')|edq }}" aria-label="{{ _('File list settings')|edq }}">
<span class="fas fa-wrench"></span>
</a>
<ul class="dropdown-menu">
@@ -34,14 +34,14 @@
</div>
<div class="refresh-trigger accordion-heading-button btn-group" data-bind="visible: $root.filesListVisible">
<a href="#" data-bind="click: function() { $root.requestData({force: true}); }" title="{{ _('Refresh file list')|edq }}">
<a href="#" data-bind="click: function() { $root.requestData({force: true}); }" title="{{ _('Refresh file list')|edq }}" aria-label="{{ _('Refresh file list')|edq }}">
<i class="fas fa-sync"></i>
</a>
</div>
{% if enableSdSupport %}
<div class="sd-trigger accordion-heading-button btn-group" data-bind="visible: $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)() && $root.filesListVisible()">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="{{ _('SD Card operations')|edq }}">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="{{ _('SD Card operations')|edq }}" aria-label="{{ _('SD Card operations')|edq }}">
<i class="fas fa-sd-card"></i>
</a>
<ul class="dropdown-menu">
+8 -8
View File
@@ -68,28 +68,28 @@
<div id="control-jog-xy" class="jog-panel">
<h1>X/Y</h1>
<div>
<button id="control-yinc" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('y',1) }"><i class="fas fa-arrow-up"></i></button>
<button id="control-yinc" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('y',1) }" aria-label="{{ _('Move front')|edq }}"><i class="fas fa-arrow-up"></i></button>
</div>
<div>
<button id="control-xdec" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('x',-1) }"><i class="fas fa-arrow-left"></i></button>
<button id="control-xyhome" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() , click: function() { $root.sendHomeCommand(['x', 'y']) }"><i class="fas fa-home"></i></button>
<button id="control-xinc" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('x',1) }"><i class="fas fa-arrow-right"></i></button>
<button id="control-xdec" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('x',-1) }" aria-label="{{ _('Move left')|edq }}"><i class="fas fa-arrow-left"></i></button>
<button id="control-xyhome" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() , click: function() { $root.sendHomeCommand(['x', 'y']) }" aria-label="{{ _('Home')|edq }}"><i class="fas fa-home"></i></button>
<button id="control-xinc" class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('x',1) }" aria-label="{{ _('Move right')|edq }}"><i class="fas fa-arrow-right"></i></button>
</div>
<div>
<button id="control-ydec" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('y',-1) }"><i class="fas fa-arrow-down"></i></button>
<button id="control-ydec" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('y',-1) }" aria-label="{{ _('Move back')|edq }}"><i class="fas fa-arrow-down"></i></button>
</div>
</div>
<!-- Z jogging control panel -->
<div id="control-jog-z" class="jog-panel">
<h1>Z</h1>
<div>
<button id="control-zinc" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('z',1) }"><i class="fas fa-arrow-up"></i></button>
<button id="control-zinc" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('z',1) }" aria-label="{{ _('Move up')|edq }}"><i class="fas fa-arrow-up"></i></button>
</div>
<div>
<button id="control-zhome" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendHomeCommand(['z']) }"><i class="fas fa-home"></i></button>
<button id="control-zhome" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendHomeCommand(['z']) }" aria-label="{{ _('Home')|edq }}"><i class="fas fa-home"></i></button>
</div>
<div>
<button id="control-zdec" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('z',-1) }"><i class="fas fa-arrow-down"></i></button>
<button id="control-zdec" class="btn box" data-bind="enable: isOperational() && !isPrinting(), click: function() { $root.sendJogCommand('z',-1) }" aria-label="{{ _('Move down')|edq }}"><i class="fas fa-arrow-down"></i></button>
</div>
</div>
@@ -24,7 +24,7 @@
<th class="temperature_target" title="{{ _('Current target temperature as reported by your printer')|edq }}">
{{ _('Target') }}
<div class="btn-group pull-right">
<button class="btn btn-small dropdown-toggle" title="{{ _('Set temperature profile')|edq }}" data-toggle="dropdown" data-bind="enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><span class="caret"></span></button>
<button class="btn btn-small dropdown-toggle" title="{{ _('Set temperature profile')|edq }}" aria-label="{{ _('Set temperature profile')|edq }}" data-toggle="dropdown" data-bind="enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li>
<a href="javascript:void(0)" data-bind="click: $root.setTargetsToZero">{{ _('Off') }}</a>
@@ -53,13 +53,13 @@
<td class="temperature_target">
<form class="form-inline" style="margin:0" data-bind="submit: function(element) { $root.setTarget($data, element) }">
<div class="input-prepend input-append">
<button type="button" class="btn btn-input-dec" data-bind="click: $root.decrementTarget, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()" title="{{ _('Fine adjust: -1°C')|edq }}"><i class="fas fa-minus"></i></button>
<button type="button" class="btn btn-input-dec" data-bind="click: $root.decrementTarget, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()" title="{{ _('Fine adjust: -1°C')|edq }}" aria-label="{{ _('Fine adjust: -1°C')|edq }}"><i class="fas fa-minus"></i></button>
<input type="number" min="0" max="999" class="input-mini input-nospin" style="width: 30px" data-bind="attr: {placeholder: cleanTemperature(target(), 1)}, value: newTarget, valueUpdate: 'input', enable: $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)() && $root.isOperational(), event: { focus: function(d, e) {$root.handleFocus(e, 'target', $data) } }">
<span class="add-on">&deg;C</span>
<button type="button" class="btn btn-input-inc" data-bind="click: $root.incrementTarget, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()" title="{{ _('Fine adjust: +1°C')|edq }}"><i class="fas fa-plus"></i></button>
<button type="button" class="btn btn-input-inc" data-bind="click: $root.incrementTarget, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()" title="{{ _('Fine adjust: +1°C')|edq }}" aria-label="{{ _('Fine adjust: +1°C')|edq }}"><i class="fas fa-plus"></i></button>
</div>
<div class="btn-group">
<button type="submit" data-bind="enable: $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)() && $root.isOperational() && $data.newTargetValid()" class="btn btn-primary" title="{{ _('Set')|edq }}"><i class="fas fa-check"></i></button>
<button type="submit" data-bind="enable: $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)() && $root.isOperational() && $data.newTargetValid()" class="btn btn-primary" title="{{ _('Set')|edq }}" aria-label="{{ _('Set')|edq }}"><i class="fas fa-check"></i></button>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" data-bind="enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()">
<span class="caret"></span>
</button>
@@ -82,8 +82,8 @@
<div class="input-append">
<span class="input-mini uneditable-input text-right" style="width: 30px" data-bind="text: offset"></span>
<span class="add-on">&deg;C</span>
<button class="btn" title="{{ _('Change Offset')|edq }}" data-bind="click: $root.changeOffset, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><i class="fas fa-pencil-alt"></i></button>
<button class="btn" title="{{ _('Delete Offset')|edq }}" data-bind="click: $root.setOffsetToZero, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><i class="far fa-trash-alt"></i></button>
<button class="btn" title="{{ _('Change Offset')|edq }}" aria-label="{{ _('Change Offset')|edq }}" data-bind="click: $root.changeOffset, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><i class="fas fa-pencil-alt"></i></button>
<button class="btn" title="{{ _('Delete Offset')|edq }}" aria-label="{{ _('Delete Offset')|edq }}" data-bind="click: $root.setOffsetToZero, enable: $root.isOperational() && $root.loginState.hasPermissionKo($root.access.permissions.CONTROL)()"><i class="far fa-trash-alt"></i></button>
</div>
</form>
</td>
+24 -25
View File
@@ -2401,25 +2401,25 @@ class MachineCom:
level=logging.INFO,
)
self.refreshSdFiles()
else:
for name, hook in self._printer_action_hooks.items():
try:
hook(
self,
line,
action_command,
name=action_name,
params=action_params,
)
except Exception:
self._logger.exception(
"Error while calling hook from plugin "
"{} with action command {}".format(
name, action_command
),
extra={"plugin": name},
)
continue
for name, hook in self._printer_action_hooks.items():
try:
hook(
self,
line,
action_command,
name=action_name,
params=action_params,
)
except Exception:
self._logger.exception(
"Error while calling hook from plugin "
"{} with action command {}".format(
name, action_command
),
extra={"plugin": name},
)
continue
if self._state not in (
self.STATE_CONNECTING,
@@ -2795,11 +2795,6 @@ class MachineCom:
supportRepetierTargetTemp = True
disable_external_heatup_detection = True
sd_always_available = self._sdAlwaysAvailable
self._sdAlwaysAvailable = True
if not sd_always_available and not self._sdAvailable:
self.initSdCard()
elif "reprapfirmware" in firmware_name.lower():
self._logger.info(
"Detected RepRapFirmware, enabling relevant features for issue free communication"
@@ -2925,11 +2920,15 @@ class MachineCom:
"SD init fail" in line
or "volume.init failed" in line
or "openRoot failed" in line
or "SD Card unmounted" in line
or "SD card released" in line
):
self._sdAvailable = False
self._sdFiles = []
self._callback.on_comm_sd_state_change(self._sdAvailable)
elif "SD card ok" in line and not self._sdAvailable:
elif (
"SD card ok" in line or "Card successfully initialized" in line
) and not self._sdAvailable:
self._sdAvailable = True
self.refreshSdFiles()
self._callback.on_comm_sd_state_change(self._sdAvailable)
+5 -3
View File
@@ -546,13 +546,17 @@ class gcode:
centerArc = Vector3D(oldPos.x + i, oldPos.y + j, oldPos.z)
startAngle = math.atan2(oldPos.y - centerArc.y, oldPos.x - centerArc.x)
endAngle = math.atan2(pos.y - centerArc.y, pos.x - centerArc.x)
arcAngle = endAngle - startAngle
if gcode in ("G2", "G02"):
startAngle, endAngle = endAngle, startAngle
arcAngle = -arcAngle
if startAngle < 0:
startAngle += math.pi * 2
if endAngle < 0:
endAngle += math.pi * 2
if arcAngle < 0:
arcAngle += math.pi * 2
# from now on we only think in counter-clockwise direction
@@ -588,9 +592,7 @@ class gcode:
e = 0
# calculate 3d arc length
arcLengthXYZ = math.sqrt(
(oldPos.z - pos.z) ** 2 + ((endAngle - startAngle) * r) ** 2
)
arcLengthXYZ = math.sqrt((oldPos.z - pos.z) ** 2 + (arcAngle * r) ** 2)
# move time in x, y, z, will be 0 if no movement happened
moveTimeXYZ = abs(arcLengthXYZ / feedrate)
+4 -4
View File
@@ -85,13 +85,13 @@ class SelectedFilesLoader(BaseLoader):
mtime = os.path.getmtime(path)
def uptodate():
def up_to_date():
try:
return os.path.getmtime(path) == mtime
except OSError:
return False
return contents, path, uptodate
return contents, path, up_to_date
def list_templates(self):
return self.files.keys()
@@ -136,11 +136,11 @@ class WarningLoader(BaseLoader):
import logging
try:
contents, filename, uptodate = self.loader.get_source(environment, template)
contents, filename, up_to_date = self.loader.get_source(environment, template)
logging.getLogger(__name__).warning(
self.warning_message.format(template=template, filename=filename)
)
return contents, filename, uptodate
return contents, filename, up_to_date
except TemplateNotFound:
raise
+2 -2
View File
@@ -473,7 +473,7 @@ class PipCaller(CommandlineCaller):
if not output.startswith("pip"):
self._logger.warning(
"pip command returned unparseable output, can't determine version: {}".format(
"pip command returned unparsable output, can't determine version: {}".format(
output
)
)
@@ -481,7 +481,7 @@ class PipCaller(CommandlineCaller):
split_output = list(map(lambda x: x.strip(), output.split()))
if len(split_output) < 2:
self._logger.warning(
"pip command returned unparseable output, can't determine version: {}".format(
"pip command returned unparsable output, can't determine version: {}".format(
output
)
)
+2 -2
View File
@@ -292,7 +292,7 @@ class LocalStorageTest(unittest.TestCase):
getattr(self.storage, operation)("bp_case.stl", "test/crazyradio.stl")
self.fail("Expected an exception")
except StorageError as e:
self.assertEqual(e.code, StorageError.INVALID_DESTINATION)
self.assertEqual(e.code, StorageError.ALREADY_EXISTS)
def test_add_folder(self):
self._add_and_verify_folder("test", "test")
@@ -481,7 +481,7 @@ class LocalStorageTest(unittest.TestCase):
getattr(self.storage, operation)("source", "destination/copied")
self.fail("Expected an exception")
except StorageError as e:
self.assertEqual(e.code, StorageError.INVALID_DESTINATION)
self.assertEqual(e.code, StorageError.ALREADY_EXISTS)
def test_list(self):
bp_case_stl = self._add_and_verify_file(
+36
View File
@@ -0,0 +1,36 @@
__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"
import pytest
@pytest.mark.parametrize(
"url,paths,expected",
[
# various default UI URLs
("/", ["/", "/recovery/"], True),
("/?", ["/", "/recovery/"], True),
("/?l10n=de", ["/", "/recovery/"], True),
("/?l10n=de&", ["/", "/recovery/"], True),
("/octoprint/", ["/octoprint/", "/octoprint/recovery/"], True),
# various recovery URLs
("/recovery/", ["/", "/recovery/"], True),
("/recovery/?", ["/", "/recovery/"], True),
("/recovery/?l10n=de", ["/", "/recovery/"], True),
("/octoprint/recovery/?l10n=de", ["/octoprint/", "/octoprint/recovery/"], True),
# various external URLs
("http://example.com", ["/", "/recovery/"], False),
("https://example.com", ["/", "/recovery/"], False),
("//example.com", ["/", "/recovery/"], False),
("/\\/\\example.com", ["/", "/recovery/"], False),
(" /\\/\\example.com", ["/", "/recovery/"], False),
("\\/\\/example.com", ["/", "/recovery/"], False),
(" \\/\\/example.com", ["/", "/recovery/"], False),
# other stuff
("javascript:alert(document.cookie)", ["/", "/recovery/"], False),
],
)
def test_validate_local_redirect(url, paths, expected):
from octoprint.server.util import validate_local_redirect
assert validate_local_redirect(url, paths) == expected
+6 -6
View File
@@ -992,27 +992,27 @@ QUnit.cases(
},
{
title: "Text",
input: "text",
input: "abcd",
sep: undefined,
stripEmpty: false,
filter: undefined,
expected: ["text"]
expected: ["abcd"]
},
{
title: "TextSeparator",
input: "te#xt",
input: "ab#cd",
sep: "#",
stripEmpty: false,
filter: undefined,
expected: ["te", "xt"]
expected: ["ab", "cd"]
},
{
title: "TrimmedText",
input: "te # xt",
input: "ab # cd",
sep: "#",
stripEmpty: false,
filter: undefined,
expected: ["te", "xt"]
expected: ["ab", "cd"]
}
];
+2 -2
View File
@@ -791,7 +791,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
# TAG-NUM-gHEX
mo = re.search(r'^(.+)-(\\d+)-g([0-9a-f]+)$', git_describe)
if not mo:
# unparseable. Maybe git-describe is misbehaving?
# unparsable. Maybe git-describe is misbehaving?
pieces["error"] = ("unable to parse git-describe output: '%%s'"
%% describe_out)
return pieces
@@ -1380,7 +1380,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
# TAG-NUM-gHEX
mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe)
if not mo:
# unparseable. Maybe git-describe is misbehaving?
# unparsable. Maybe git-describe is misbehaving?
pieces["error"] = "unable to parse git-describe output: '%s'" % describe_out
return pieces