diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc40547b1..0b67df9e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,11 +12,13 @@ repos: - id: check-merge-conflict - id: fix-encoding-pragma args: ["--remove"] + exclude: "setup.py|versioneer.py|src/octoprint_setuptools/__init__.py" - repo: https://github.com/asottile/pyupgrade rev: v2.10.0 hooks: - id: pyupgrade args: ["--py37-plus"] + exclude: "setup.py|versioneer.py|src/octoprint_setuptools/__init__.py" - repo: https://github.com/OctoPrint/codemods rev: devel hooks: @@ -24,10 +26,42 @@ repos: args: ["--ignore", "src/octoprint/vendor"] - id: codemod_not_in args: ["--ignore", "src/octoprint/vendor"] + - id: codemod_detect_past_builtins_imports + args: + [ + "--ignore", + "src/octoprint/vendor", + "--ignore", + "setup.py", + "--ignore", + "versioneer.py", + "--ignore", + "src/octoprint_setuptools/__init__.py", + ] - id: codemod_remove_float_conversion - args: ["--ignore", "src/octoprint/vendor"] + args: + [ + "--ignore", + "src/octoprint/vendor", + "--ignore", + "setup.py", + "--ignore", + "versioneer.py", + "--ignore", + "src/octoprint_setuptools/__init__.py", + ] - id: codemod_remove_future_imports - args: ["--ignore", "src/octoprint/vendor"] + args: + [ + "--ignore", + "src/octoprint/vendor", + "--ignore", + "setup.py", + "--ignore", + "versioneer.py", + "--ignore", + "src/octoprint_setuptools/__init__.py", + ] - repo: https://github.com/pre-commit/mirrors-isort rev: v5.5.4 hooks: diff --git a/.versioneer-lookup b/.versioneer-lookup index b3586a09a..f897bb16c 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -24,10 +24,10 @@ maintenance 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev fix/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev improve/.* 1.8.0 3fe45661cd79c5137d9d4f5f4adb4d9519bc2084 pep440-dev -# staging/bugfix is the branch for preparation of the 1.7.3 bugfix release +# staging/bugfix is the branch for preparation of the 1.7.4 bugfix release # so are any bug/... branches -staging/bugfix 1.7.2 d60c5a631aedf2328e4492125d9b86f595e43d00 pep440-dev -bug/.* 1.7.2 d60c5a631aedf2328e4492125d9b86f595e43d00 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 # so is regressionfix/... diff --git a/AUTHORS.md b/AUTHORS.md index 16a42ce8d..f71ad6ce5 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -154,10 +154,14 @@ date of first contribution): * [Bryan Kenote](https://github.com/bryankenote) * [Quinn Damerell](https://github.com/QuinnDamerell) * [Sven Samoray](https://github.com/thelastWallE) + * [Carey Metcalfe](https://github.com/pR0Ps) * [Christian Würthner](https://github.com/crysxd) * [Maciej Urbański](https://github.com/rooterkyberian) * [Adam Wolf](https://github.com/adamwolf) * [Carey Metcalfe](https://github.com/pR0Ps) + * [Didi Kohen](https://github.com/kohend) + * [Taylor Talkington](https://github.com/The-EG) + * [Shell M. Shrader](https://github.com/synman) 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 diff --git a/MANIFEST.in b/MANIFEST.in index 73418c876..7b67855c7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,4 +7,6 @@ include versioneer.py include src/octoprint/_version.py include requirements.txt include *.md +exclude CODE_OF_CONDUCT.md +exclude SECURITY.md exclude CONTRIBUTING.md diff --git a/README.md b/README.md index e4ade6a0c..c68b677fc 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ which is a custom SD card image that includes OctoPrint plus dependencies. The generic steps that should basically be done regardless of operating system and runtime environment are the following (as *regular user*, please keep your hands *off* of the `sudo` command here!) - this assumes -you already have Python 3.6, 3.7 or 3.8, pip and virtualenv and their dependencies set up on your system: +you already have Python 3.7+, pip and virtualenv and their dependencies set up on your system: 1. Create a user-owned virtual environment therein: `virtualenv venv`. If you want to specify a specific python to use instead of whatever version your system defaults to, you can also explicitly require that via the `--python` @@ -87,7 +87,7 @@ access control as necessary. OctoPrint depends on a few python modules to do its job. Those are automatically installed when installing OctoPrint via `pip`. -OctoPrint currently supports Python 3.6, 3.7 and 3.8. +OctoPrint currently supports Python 3.7, 3.8, 3.9 and 3.10. ## Usage diff --git a/SUPPORTERS.md b/SUPPORTERS.md index 36ef22907..cb53fca62 100644 --- a/SUPPORTERS.md +++ b/SUPPORTERS.md @@ -14,9 +14,7 @@ thanks to everyone who contributed! * BigTreeTech * Boris Hussein * Brad Jackson - * BRANDON ROBERTSON * BuildBee - * Chris Lynch * Christian Petropolis * Christian Wolf * Christian Würthner @@ -25,6 +23,7 @@ thanks to everyone who contributed! * David Bounds * DeltaMaker 3D Printers * Dennis Breining + * Douglas Floyd * Dr. Frank Wester * Eric Betts * Ernesto Martinez @@ -33,6 +32,7 @@ thanks to everyone who contributed! * Greg Holloway * Hog Duske * Itay Shem-tov + * James Mackay * Jeff Moe * Jeremy Cole * Joshua Wills @@ -58,7 +58,6 @@ thanks to everyone who contributed! * Nat Friedman * Neil R. Goldberg * Norman Jaffe - * Ory Weaver * Peopoly * Pete Barnwell * Raise3D @@ -71,11 +70,14 @@ thanks to everyone who contributed! * Ronald Griehsler * Sebastien Andrivet * Stefan Krister + * Steve Dougherty * Steve Thompson * Sven Mueller * TH3D * The Spaghetti Detective + * TJ Horner * Ulderico Cirello * Ulrich Kempken + * Yehuda Katz -and 2247 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! +and 2285 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! diff --git a/docs/api/files.rst b/docs/api/files.rst index 3df618d90..1cf439741 100644 --- a/docs/api/files.rst +++ b/docs/api/files.rst @@ -399,7 +399,9 @@ Upload file or create folder } } }, - "done": false + "done": false, + "effectiveSelect": true, + "effectivePrint": true } **Example with UTF-8 encoded filename following RFC 5987** @@ -440,7 +442,9 @@ Upload file or create folder } } }, - "done": true + "done": true, + "effectiveSelect": false, + "effectivePrint": false } **Example for creating a folder** @@ -486,9 +490,12 @@ Upload file or create folder filename or ``foldername`` - basically the parent folder). If unset will be taken from the provided ``file``'s name or ``foldername`` and default to the root folder of the ``location``. :form select: Whether to select the file directly after upload (``true``) or not (``false``). Optional, defaults - to ``false``. Ignored when creating a folder. + to ``false``. If the printer is not operational, this will have no + effect and the ``effectiveSelect`` field in the response will be set to ``false``. Ignored when creating a folder. :form print: Whether to start printing the file directly after upload (``true``) or not (``false``). If set, ``select`` - is implicitly ``true`` as well. Optional, defaults to ``false``. Ignored when creating a folder. + is implicitly ``true`` as well. Optional, defaults to ``false``. If the + printer is not operational, this will have no effect and the ``effectivePrint`` field in the response will be set + to ``false``. Ignored when creating a folder. :form userdata: [Optional] An optional string that if specified will be interpreted as JSON and then saved along with the file as metadata (metadata key ``userdata``). Ignored when creating a folder. :form foldername: The name of the folder to create. Ignored when uploading a file. @@ -869,9 +876,8 @@ Upload response * - ``files`` - 0..1 - Object - - Abridged information regarding the file that was just uploaded. If only uploaded to ``local`` this will only + - (File only) Abridged information regarding the file that was just uploaded. If only uploaded to ``local`` this will only contain the ``local`` property. If uploaded to SD card, this will contain both ``local`` and ``sdcard`` properties. - Only contained if a file was uploaded, not present if only a new folder was created. * - ``files.local`` - 1 - :ref:`sec-api-datamodel-files-fileabridged` @@ -883,12 +889,23 @@ Upload response * - ``folder`` - 0..1 - :ref:`sec-api-datamodel-files-fileabridged` - - Abridged information regarding the folder that was just created. Only contained if a folder - was created, not present if a file was uploaded. + - (Folder only) Abridged information regarding the folder that was just created. * - ``done`` - 1 - Boolean - Whether any file processing after upload has already finished (``true``) or not, e.g. due to first needing to perform a slicing step (``false``). Clients may use this information to direct progress displays related to - the upload. + the upload. Always ``true`` for folders. + * - ``effectiveSelect`` + - 0..1 + - Boolean + - (File only) Whether the file that was just uploaded was selected for printing (``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. + * - ``effectivePrint`` + - 0..1 + - Boolean + - (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. diff --git a/docs/api/timelapse.rst b/docs/api/timelapse.rst index 66e0bb72e..ebe291e83 100644 --- a/docs/api/timelapse.rst +++ b/docs/api/timelapse.rst @@ -27,12 +27,17 @@ Retrieve a list of timelapses and the current config Delete a timelapse ================== -.. http:delete:: /api/timelapse/(string:filename) +.. http:delete:: /api/timelapse/(string:name) - Delete the timelapse ``filename``. + Delete the timelapse ``name``. + + Returns a :ref:`timelapse list ` in the + response body with the updated information. Requires the ``TIMELAPSE_DELETE`` permission. + :param unrendered: If provided and true, also include unrendered timelapses in the response + .. _sec-api-timelapse-render: Issue a command for an unrendered timelapse @@ -56,8 +61,13 @@ Delete an unrendered timelapse Delete the unrendered timelapse ``name``. + Returns a :ref:`timelapse list ` in the + response body. + Requires the ``TIMELAPSE_DELETE`` permission. + :param unrendered: If provided and true, also include unrendered timelapses in the response + .. _sec-api-timelapse-saveconfig: Change current timelapse config @@ -65,12 +75,19 @@ Change current timelapse config .. http:post:: /api/timelapse - Save a new :ref:`timelapse configuration ` to use for the next print. + Save a new :ref:`timelapse configuration ` to use for the next print. Set the optional ``save`` flag in the + configuration to ``true`` in order to make the new configuration persist accross restarts. The configuration is expected as the request body. + Returns a :ref:`timelapse list ` in the + response body. + Requires the ``TIMELAPSE_ADMIN`` permission. + :param unrendered: If provided and true, also include unrendered timelapses in the response + + .. _sec-api-timelapse-datamodel: Data model @@ -135,6 +152,10 @@ Rendered timelapse - 1 - string - URL for downloading the timelapse + * - ``thumbnail`` + - 1 + - string + - URL for downloading a thumbnail of the timelapse (optional) .. _sec-api-timelapse-datamodel-unrendered: @@ -196,6 +217,10 @@ Timelapse configuration - 1 - string - Type of the timelapse, either ``off``, ``zchange`` or ``timed``. + * - ``save`` + - 1 + - bool + - Optional flag to be included when when saving a configuration to make the configuration persist accross restarts Further fields are timelapse type specific, see below for details. diff --git a/docs/bundledplugins/softwareupdate.rst b/docs/bundledplugins/softwareupdate.rst index 42e058df2..78cf9de0c 100644 --- a/docs/bundledplugins/softwareupdate.rst +++ b/docs/bundledplugins/softwareupdate.rst @@ -338,6 +338,15 @@ supported: Additional config parameters: * ``pip``: The URL to use for installing. Presence implies ``method: pip``. + * ``pip_command``: The command to use for installing. Defaults to the ``pip`` instance belong to OctoPrint's environment. + * ``pip_cwd``: The working directory to use for installing. Defaults to the current working directory. + * ``force_reinstall``: Whether to force reinstallation of the package. Defaults to ``false``. Helpful + for development and version checks that don't guarantee a Python package version change (e.g. commit based + version checks like ``git_commit``, ``github_commit``, ``bitbucket_commit``). + + .. versionchanged:: 1.8.0 + + Added ``force_reinstall`` parameter. * ``single_file_plugin``: Update a single file plugin by re-downloading it from a configured URL. Additional config parameters: diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 0cab1bca5..838c5a9b8 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -709,7 +709,7 @@ Use the following settings to configure the serial connection to the printer: - M1 # Commands which should not be sent to the printer and just silently ignored. - # An example of when you may wish to use this could be useful if you wish to manually change a filament on M600, + # An example of when you may wish to use this could be useful if you wish to manually change a filament on M600, # by using that as a Pausing command (below) ignoredCommands: @@ -808,6 +808,12 @@ Use the following settings to configure the serial connection to the printer: # Whether to support resends without follow-up ok or not supportResendsWithoutOk: false + # encoding to use when talking to a machine + # (ascii limits access to characters 0-127) + # (latin_1 enables access to the "extended" ascii characters 0-255) + # other values can be used: https://docs.python.org/3/library/codecs.html#standard-encodings + encoding: ascii + # Whether to "manually" trigger an ok for M29 (a lot of versions of this command are buggy and # the response skips on the ok) triggerOkForM29: true diff --git a/docs/development/environment.rst b/docs/development/environment.rst index 4234cbed5..636678fae 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -14,7 +14,7 @@ below. * Prerequisites: - * `Python 3.8 `_ including ``pip``, ``setuptools`` and ``virtualenv`` + * `Latest stable Python 3 `_ including ``pip``, ``setuptools`` and ``virtualenv`` * `Git `_ * Checkout the OctoPrint sources from their Git repository: @@ -24,14 +24,12 @@ below. * Enter the checked out source folder: ``cd OctoPrint`` * Create a virtual environment in the checked out source folder to use for installing and running OctoPrint and its dependencies. Creating virtual environments avoids potential versioning - issues for the dependencies with system wide installed instances: - - * ``virtualenv --python=python3 venv`` + issues for the dependencies with system wide installed instances: ``virtualenv --python=python3 venv`` .. note:: - This assumes that `python3` is a binary available directly on your ``PATH``. If your Python 3 - binary cannot be found on your ``PATH`` like this you'll need to specify the full path to it here, + This assumes that the ``python3`` binary is available directly on your ``PATH``. If + it cannot be found on your ``PATH`` like this you'll need to specify the full path here, e.g. ``virtualenv --python=/path/to/python3/bin/python venv`` * Activate the virtual environment: ``source venv/bin/activate`` (Linux, macOS) or ``source venv/Scripts/activate`` (Git Bash under Windows, see below) @@ -71,7 +69,7 @@ Linux This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different location, please substitute accordingly. -First make sure you have python 2 and 3 including their header files, pip, setuptools, virtualenv, git and some build requirements +First make sure you have python 3 including its header files, pip, setuptools, virtualenv, git and some build requirements installed: * On apt based distributions (e.g. Debian, Ubuntu, ...): @@ -100,7 +98,6 @@ Then: pre-commit install git config blame.ignoreRevsFile .git-blame-ignore-revs -You can then start OctoPrint via ``octoprint`` after activating one of the two virtual environments. .. _sec-development-environment-windows: @@ -134,9 +131,9 @@ Open the Git Bash you just installed and in that: cd /c/Devel git clone https://github.com/OctoPrint/OctoPrint.git cd OctoPrint - virtualenv --python=C:/Python3/python.exe venv3 + virtualenv --python=C:/Python3/python.exe venv source ./venv/Scripts/activate - python -m pip install --upgrade pip + pip install --upgrade pip python -m pip install -e '.[develop,plugins,docs]' pre-commit install git config blame.ignoreRevsFile .git-blame-ignore-revs @@ -176,12 +173,6 @@ Mac OS X This guide is based on the `Setup Guide for Mac OS X on OctoPrint's Community Forum `_. Please report back if it works for you, due to lack of access to a Mac I cannot test it myself. Thanks. -.. todo:: - - This guide is not yet adapted to the concurrent use of Python 2 and 3 environments during development. Please send a - `Pull Request `_ to get the necessary - steps into this guide! - This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different location, please substitute accordingly. @@ -194,7 +185,7 @@ You'll need a user account with administrator privileges. * ``sudo xcodebuild`` (ensure the license was accepted) * If you have more than one Xcode installed: ``sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`` - * Install Homebrew and use that to install Python: + * Install Homebrew and use that to install Python 3: * ``ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` * ``brew install python`` @@ -245,7 +236,7 @@ PyCharm - **(macOS)** "PyCharm" > "Preferences ..." > "Project: OctoPrint" > "Project Interpreter" > "Add ..." > "Virtualenv Environment > "Existing Environment", select OctoPrint ``venv`` folder (e.g. ``~/devel/OctoPrint/venv``). - If desired, repeat for any other additional Python venvs (e.g. different versions). + If desired, repeat for any other additional Python venvs (e.g. for separate Python 3 versions). - Right click "src" in project tree, mark as source folder - Add Run/Debug Configuration, select "Python": @@ -303,7 +294,7 @@ PyCharm * Name: pre-commit * File type: Python * Scope: Module 'OctoPrint' - * Program: ``$PyInterpreterDirectory$/bin/pre-commit`` (Linux) or ``$PyInterpreterDirectory$/Scripts/pre-commit`` (Windows) + * Program: ``/bin/pre-commit`` (Linux) or ``/Scripts/pre-commit`` (Windows) * Arguments: ``run --hook-stage manual --files $FilePath$`` * Output paths to refresh: ``$FilePath$`` * Working directory: ``$ProjectFileDir$`` @@ -334,7 +325,7 @@ Visual Studio Code (vscode) .. code-block:: json { - "python.defaultInterpreterPath": "venv3/bin/python", + "python.defaultInterpreterPath": "venv/bin/python", "python.formatting.provider": "black", "python.formatting.blackArgs": [ "--config", diff --git a/docs/events/index.rst b/docs/events/index.rst index a9b030095..6b75699f2 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -220,8 +220,10 @@ Upload * ``name``: the file's name * ``path``: the file's path within its storage location * ``target``: the target storage location to which the file was uploaded, either ``local`` or ``sdcard`` - * ``select``: whether the file will immediately be selected, as requested on the API by the corresponding parameter - * ``print``: whether the file will immediately start printing, as requested on the API by the corresponding parameter + * ``select``: whether an immediate selection of the file was requested on the API by the corresponding parameter + * ``print``: whether an immediate print start of the file was requested on the API by the corresponding parameter + * ``effective_select``: whether the file will actually be selected (``select`` request got granted) + * ``effective_print``: whether the file will actually start printing (``print`` request got granted) * ``userdata``: optional ``userdata`` if provided on the API, will only be present if supplied in the upload request .. deprecated:: 1.3.0 diff --git a/docs/plugins/controlproperties.rst b/docs/plugins/controlproperties.rst index c8ac018a0..b5905fa07 100644 --- a/docs/plugins/controlproperties.rst +++ b/docs/plugins/controlproperties.rst @@ -57,10 +57,13 @@ The following properties are recognized: ``__plugin_pythoncompat__`` Python compatibility string of your plugin, optional, defaults to ``>=2.7,<3`` if not set and thus Python 2 but no - Python 3 compatibility. + Python 3 compatibility. This is used as a precaution against issues with some of the Python 2 only plugins + that are still out there, as OctoPrint will not even attempt to load plugins whose Python compatibility + information doesn't match its current environment. - If your plugin is compatible to Python 3, you should set this to ``>=2.7,<4``, otherwise your plugin will not load - on OctoPrint instances installed under Python 3. + If your plugin is compatible to Python 3 only, you should set this to ``>=3.7,<4``. + + If your plugin is compatible to Python 2 and Python 3, you should set this to ``>=2.7,<4``. .. code-block:: python diff --git a/docs/plugins/gettingstarted.rst b/docs/plugins/gettingstarted.rst index 3ac2939d5..41765ab83 100644 --- a/docs/plugins/gettingstarted.rst +++ b/docs/plugins/gettingstarted.rst @@ -57,13 +57,10 @@ We'll start at the most basic form a plugin can take - just a few simple lines o .. code-block:: python :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - __plugin_name__ = "Hello World" __plugin_version__ = "1.0.0" __plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" Saving this as ``helloworld.py`` in ``~/.octoprint/plugins`` yields you something resembling these log entries upon server startup:: @@ -81,8 +78,9 @@ OctoPrint found that plugin in the folder and took a look into it. The name and entry it got from the ``__plugin_name__`` and ``__plugin_version__`` lines. It also read the description from ``__plugin_description__`` and stored it in an internal data structure, but we'll just ignore this for now. Additionally there is ``__plugin_pythoncompat__`` which tells OctoPrint here that your plugin can be run under any Python versions -between 2.7 and 4. That is necessary so that your plugin will be loadable in OctoPrint instances running under either -Python 2 or Python 3, and compatibility to both should be your goal. +between 3.7 and 4. That is necessary so that your plugin will be loadable in OctoPrint instances running under Python 3 +but not Python 2 (so you can use modern language features), and going forward you really should no longer have to care about +the end-of-life Python 2. .. _sec-plugins-gettingstarted-sayinghello: @@ -96,9 +94,6 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t :emphasize-lines: 4-8,14 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin): @@ -108,7 +103,7 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t __plugin_name__ = "Hello World" __plugin_version__ = "1.0.0" __plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() and restart OctoPrint. You now get this output in the log:: @@ -297,16 +292,13 @@ and ``__plugin_description__`` from ``__init__.py``, but leave ``__plugin_implem .. code-block:: python :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin): def on_after_startup(self): self._logger.info("Hello World!") - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() and restart OctoPrint:: @@ -320,12 +312,9 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the "OctoPrint-HelloWorld". That's a bit redundant and squashed, so we'll override that bit via ``__plugin_name__`` again: .. code-block:: python - :emphasize-lines: 10 + :emphasize-lines: 7 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin): @@ -333,7 +322,7 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the self._logger.info("Hello World!") __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() @@ -369,12 +358,9 @@ navigation bar right at the top that links to the Wikipedia node about "Hello Wo add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class: .. code-block:: python - :emphasize-lines: 7 + :emphasize-lines: 4 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -383,7 +369,7 @@ add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class: self._logger.info("Hello World!") __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Next, we'll create a sub folder ``templates`` underneath our ``octoprint_helloworld`` folder, and within that a file @@ -436,12 +422,9 @@ mixin. Let's take a look at how all that would look in our plugin's ``__init__.py``: .. code-block:: python - :emphasize-lines: 8, 10, 12-13 + :emphasize-lines: 5, 7, 9-10 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -454,7 +437,7 @@ Let's take a look at how all that would look in our plugin's ``__init__.py``: return dict(url="https://en.wikipedia.org/wiki/Hello_world") __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Restart OctoPrint. You should see something like this:: @@ -471,12 +454,9 @@ to add our URL as a template variable. Adjust your plugin's ``__init__.py`` like this: .. code-block:: python - :emphasize-lines: 15-16 + :emphasize-lines: 12-13 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -492,7 +472,7 @@ Adjust your plugin's ``__init__.py`` like this: return dict(url=self._settings.get(["url"])) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this: @@ -579,12 +559,9 @@ for both our ``navbar`` and our ``settings`` plugin. We'll also remove the overr again since we don't use that anymore: .. code-block:: python - :emphasize-lines: 15-19 + :emphasize-lines: 12-16 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -603,7 +580,7 @@ again since we don't use that anymore: ] __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Restart OctoPrint and shift-reload your browser. Your link in the navigation bar should still point to the URL we @@ -677,12 +654,9 @@ just need to subclass :class:`~octoprint.plugin.AssetPlugin` and override its me like so: .. code-block:: python - :emphasize-lines: 9,22-25 + :emphasize-lines: 6,19-22 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -707,7 +681,7 @@ like so: ) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Note how we did not add another entry to the return value of :func:`~octoprint.plugin.TemplatePlugin.get_template_configs`. @@ -858,12 +832,9 @@ Then adjust our plugin's ``__init__.py`` so that the :func:`~octoprint.plugin.As a reference to our CSS file: .. code-block:: python - :emphasize-lines: 26 + :emphasize-lines: 23 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -890,7 +861,7 @@ a reference to our CSS file: ) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() OctoPrint by default bundles all CSS, JavaScript and LESS files to reduce the amount of requests necessary to fully @@ -944,12 +915,9 @@ in the process. The folder structure of our plugin should now look like this:: Then adjust our returned assets to include our LESS file as well: .. code-block:: python - :emphasize-lines: 27 + :emphasize-lines: 24 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -977,7 +945,7 @@ Then adjust our returned assets to include our LESS file as well: ) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index 1f65e91af..8a78c7785 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -28,7 +28,6 @@ or as ``postfix`` (after the existing lines). .. code-block:: python :linenos: - from past import basestring self._gcode_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts") # ... @@ -45,7 +44,7 @@ or as ``postfix`` (after the existing lines). continue def to_list(data): - if isinstance(data, basestring): + if isinstance(data, str): data = map(x.strip() for x in data.split("\n")) if isinstance(data, (list, tuple)): diff --git a/run b/run deleted file mode 100755 index fdc3699b8..000000000 --- a/run +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -basedir = os.path.dirname(os.path.realpath(__file__)) - -old = os.path.join(basedir, "octoprint") -if os.path.exists(old): - # rename left-overs from old file structure - print( - """ -Found left-overs from old file structure, renaming to -"octoprint.backup". Please remove this manually (I don't -dare to do so myself since you might have changes in there -I don't know anything about). -""" - ) - os.rename(old, os.path.join(basedir, "octoprint.backup")) - -sys.path.insert(0, os.path.join(basedir, "src")) - -import octoprint # noqa: E402 - -if len(sys.argv) == 1: - sys.argv.append("serve") -octoprint.main() diff --git a/scripts/README.md b/scripts/README.md index 14792931b..872759b4f 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -28,7 +28,12 @@ Download the systemd files to the locations shown: octoprint.service => /etc/systemd/system/octoprint.service ``` -Next, enable and start the `octoprint` service: +Next, make necessary modifications (if any) then notify systemd: +```sh +sudo systemctl daemon-reload +``` + +Finally, enable and start the `octoprint` service: ```sh # Enable octoprint service diff --git a/setup.py b/setup.py index df23d48be..dcce524e7 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,13 @@ +# -*- coding: utf-8 -*- + +### NOTE ################################################################################# +# This file has to stay format compatible to Python 2, or pip under Python 2 will +# not be able to detect that OctoPrint requires Python 3 but instead fail with a +# syntax error. +# +# So, no f-strings, no walrus operators, no pyupgrade or codemods. +########################################################################################## + import os import sys from distutils.command.build_py import build_py as _build_py @@ -12,75 +22,71 @@ import octoprint_setuptools # noqa: F401,E402 # ---------------------------------------------------------------------------------------- # Supported python versions -PYTHON_REQUIRES = ">=3.7,<4" +PYTHON_REQUIRES = ">=3.7, <4" # Requirements for setup.py -SETUP_REQUIRES = [ - "markdown>=3.2.2,<4", -] +SETUP_REQUIRES = [] # Requirements for our application -INSTALL_REQUIRES = [ - # additional OctoPrint plugins that are maintained on a different release cycle +bundled_plugins = [ "OctoPrint-FileCheck>=2021.2.23", "OctoPrint-FirmwareCheck>=2021.10.11", "OctoPrint-PiSupport>=2021.10.28", - # the following dependencies are non trivial to update since later versions - # introduce backwards incompatible changes that might affect plugins, or due to - # other observed problems - "regex!=2018.11.6", # avoid broken 2018.11.6. See #2874 - "wrapt>=1.12.1,<1.13", # newer versions fail to build on OctoPi 0.15 - # anything below this should be checked on releases for new versions - "tornado>=6.0.4,<7", - "markdown>=3.2.2,<4", - "flask>=2,<3", - "Flask-Login>=0.5,<0.6", # flask-login doesn't use semver & breaks stuff on minor version increases - "Flask-Babel>=2.0,<3", - "Flask-Assets>=2.0,<3", +] +core_deps = [ "cachelib>=0.2,<0.3", - "PyYAML>=5.4.1,<6", - "pyserial>=3.4,<4", - "netaddr>=0.7.19,<1", - "watchdog==1.0.0", - "sarge==0.1.5post0", - "netifaces>=0.10.9,<1", - "pylru>=1.2,<2", - "rsa>=4.0,<5", - "pkginfo>=1.5.0.1,<2", - "requests>=2.23.0,<3", - "semantic_version>=2.8.5,<3", - "psutil>=5.8,<6", "Click>=8.0.3,<9", - "feedparser>=6.0.8,<7", - "future>=0.18.2,<1", # not really needed anymore, but leaving in for py2/3 compat plugins - "websocket-client>=1.2.1,<2", - "wrapt>=1.12.1,<2", - "emoji>=1.4.2,<2", - "sentry-sdk>=1.5.0,<2", - "filetype>=1.0.7,<2", - "frozendict>=2.0,<3", - "zeroconf>=0.33,<0.34", # breaking changes can happen on minor version increases - "zipstream-ng>=1.3.1,<2.0.0", - "pathvalidate>=2.4.1,<3", "colorlog>=5.0.1,<6", - # vendor bundled dependencies + "emoji>=1.4.2,<2", + "feedparser>=6.0.8,<7", + "filetype>=1.0.7,<2", + "Flask-Assets>=2.0,<3", + "Flask-Babel>=2.0,<3", + "Flask-Login>=0.5,<0.6", # flask-login doesn't use semver & breaks stuff on minor version increases + "flask>=2,<3", + "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", + "netaddr>=0.8,<0.9", # changelog hints at breaking changes on minor version increases + "netifaces>=0.11,<1", + "pathvalidate>=2.4.1,<3", + "pkginfo>=1.7.1,<2", + "psutil>=5.8,<6", + "pylru>=1.2,<2", + "pyserial>=3.4,<4", + "PyYAML>=5.4.1,<6", + "requests>=2.26.0,<3", + "sarge==0.1.6", + "semantic_version>=2.8.5,<3", + "sentry-sdk>=1.3.1,<2", + "tornado>=6.0.4,<7", + "watchdog==1.0.0", + "websocket-client>=1.2.1,<2", + "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", +] +vendored_deps = [ "blinker>=1.4,<2", # dependency of flask_principal - "unidecode", # dependency of awesome-slugify, leave w/o range to not cause dependency hell w/ Octolapse deps + "regex", # dependency of awesome-slugify + "unidecode", # dependency of awesome-slugify ] -# OSX specific requirements -INSTALL_REQUIRES_OSX = [ - "appdirs>=1.4.4,<2", -] +INSTALL_REQUIRES = bundled_plugins + core_deps + vendored_deps -# Additional requirements for optional install options +# Additional requirements for optional install options and/or OS-specific dependencies EXTRA_REQUIRES = { + # Dependencies for OSX + ":sys_platform == 'darwin'": [ + "appdirs>=1.4.4,<2", + ], + # Dependencies for core development "develop": [ # Testing dependencies - "mock>=4,<5", - "pytest>=6.2.5,<7", - "pytest-doctest-custom>=1.0.0,<2", "ddt", + "mock>=4,<5", + "pytest-doctest-custom>=1.0.0,<2", + "pytest>=6.2.5,<7", # pre-commit "pre-commit", # profiler @@ -90,39 +96,36 @@ EXTRA_REQUIRES = { "plugins": ["cookiecutter>=1.7.2,<1.8"], # Dependencies for building the documentation "docs": [ + "readthedocs-sphinx-ext", + "sphinx_rtd_theme", "sphinx>=3,<4", "sphinxcontrib-httpdomain", "sphinxcontrib-mermaid", - "sphinx_rtd_theme", - "readthedocs-sphinx-ext", ], } -# Dependency links for any of the aforementioned dependencies -DEPENDENCY_LINKS = [] - -EXTRA_REQUIRES[":sys_platform == 'darwin'"] = INSTALL_REQUIRES_OSX - -# ----------------------------------------------------------------------------------------------------------------------- +# ---------------------------------------------------------------------------------------- # Anything below here is just command setup and general setup configuration here = os.path.abspath(os.path.dirname(__file__)) def read_file_contents(path): - import codecs + import io - with codecs.open(path, encoding="utf-8") as f: + with io.open(path, encoding="utf-8") as f: return f.read() -def md_to_html_build_py_factory(files, baseclass): - class md_to_html_build_py(baseclass): +def copy_files_build_py_factory(files, baseclass): + class copy_files_build_py(baseclass): files = {} def run(self): - print("RUNNING md_to_html_build_py") + print("RUNNING copy_files_build_py") if not self.dry_run: + import shutil + for directory, files in self.files.items(): target_dir = os.path.join(self.build_lib, directory) self.mkpath(target_dir) @@ -134,17 +137,15 @@ def md_to_html_build_py_factory(files, baseclass): source, dest = entry[0], os.path.join(target_dir, entry[1]) else: source = entry - dest = os.path.join(target_dir, source + ".html") + dest = os.path.join(target_dir, source) - print(f"Rendering markdown from {source} to {dest}") + print("Copying {} to {}".format(source, dest)) + shutil.copy2(source, dest) - from markdown import markdownFromFile - - markdownFromFile(input=source, output=dest, encoding="utf-8") baseclass.run(self) - return type(md_to_html_build_py)( - md_to_html_build_py.__name__, (md_to_html_build_py,), {"files": files} + return type(copy_files_build_py)( + copy_files_build_py.__name__, (copy_files_build_py,), {"files": files} ) @@ -177,7 +178,7 @@ def get_cmdclass(): ) ) - cmdclass["build_py"] = md_to_html_build_py_factory( + cmdclass["build_py"] = copy_files_build_py_factory( { "octoprint/templates/_data": [ "AUTHORS.md", @@ -193,7 +194,7 @@ def get_cmdclass(): def params(): # make sure these are always available, even when run by dependabot - global versioneer, get_cmdclass, read_file_contents, here, PYTHON_REQUIRES, SETUP_REQUIRES, INSTALL_REQUIRES, EXTRA_REQUIRES, DEPENDENCY_LINKS + global versioneer, get_cmdclass, read_file_contents, here, PYTHON_REQUIRES, SETUP_REQUIRES, INSTALL_REQUIRES, EXTRA_REQUIRES name = "OctoPrint" version = versioneer.get_version() @@ -207,7 +208,6 @@ def params(): setup_requires = SETUP_REQUIRES install_requires = INSTALL_REQUIRES extras_require = EXTRA_REQUIRES - dependency_links = DEPENDENCY_LINKS classifiers = [ "Development Status :: 5 - Production/Stable", @@ -225,7 +225,6 @@ def params(): "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -264,8 +263,7 @@ def params(): if os.environ.get("READTHEDOCS", None) == "True": # we can't tell read the docs to please perform a pip install -e .[docs], so we help - # it a bit here by explicitly adding the development dependencies, which include our - # documentation dependencies + # it a bit here by explicitly adding the docs dependencies install_requires = install_requires + extras_require["docs"] entry_points = {"console_scripts": ["octoprint = octoprint:main"]} diff --git a/src/octoprint/cli/__init__.py b/src/octoprint/cli/__init__.py index bd386f202..827396249 100644 --- a/src/octoprint/cli/__init__.py +++ b/src/octoprint/cli/__init__.py @@ -7,6 +7,7 @@ import sys import click import octoprint +from octoprint.cli.common import LazyGroup click.disable_unicode_literals_warning = True @@ -274,16 +275,56 @@ legacy_options = bulk_options( Kept available for reasons of backwards compatibility, but hidden from the generated help pages.""" +# ~~ command groups from sub modules + + +@click.group() +def subcommands(): + pass + + +@subcommands.group( + name="analysis", cls=LazyGroup, import_name="octoprint.cli.analysis:cli" +) +def analysis(): + """Analysis tools.""" + pass + + +@subcommands.group(name="client", cls=LazyGroup, import_name="octoprint.cli.client:cli") +def client(): + """Basic API client.""" + pass + + +@subcommands.group(name="config", cls=LazyGroup, import_name="octoprint.cli.config:cli") +def config(): + """Basic config manipulation.""" + pass + + +@subcommands.group(name="dev", cls=LazyGroup, import_name="octoprint.cli.dev:cli") +def dev(): + """Additional commands for development tasks.""" + pass + + +@subcommands.group(name="plugins", cls=LazyGroup, import_name="octoprint.cli.plugins:cli") +def plugins(): + """Additional commands provided by plugins.""" + pass + + +@subcommands.group(name="user", cls=LazyGroup, import_name="octoprint.cli.user:cli") +def user(): + """User management.""" + pass + + # ~~ "octoprint" command, merges server_commands and plugin_commands groups -from .analysis import analysis_commands # noqa: E402 -from .client import client_commands # noqa: E402 -from .config import config_commands # noqa: E402 -from .dev import dev_commands # noqa: E402 -from .plugins import plugin_commands # noqa: E402 -from .server import server_commands # noqa: E402 -from .systeminfo import systeminfo_commands # noqa: E402 -from .user import user_commands # noqa: E402 +from .server import cli as server_commands # noqa: E402 +from .systeminfo import cli as systeminfo_commands # noqa: E402 @click.group( @@ -291,13 +332,8 @@ from .user import user_commands # noqa: E402 invoke_without_command=True, cls=click.CommandCollection, sources=[ + subcommands, server_commands, - plugin_commands, - dev_commands, - client_commands, - config_commands, - analysis_commands, - user_commands, systeminfo_commands, ], ) diff --git a/src/octoprint/cli/analysis.py b/src/octoprint/cli/analysis.py index f2d93b4a9..f3b4bf33c 100644 --- a/src/octoprint/cli/analysis.py +++ b/src/octoprint/cli/analysis.py @@ -55,17 +55,12 @@ def validate_result(result): @click.group() -def analysis_commands(): - pass - - -@analysis_commands.group(name="analysis") -def util(): +def cli(): """Analysis tools.""" pass -@util.command(name="gcode") +@cli.command(name="gcode") @click.option("--throttle", "throttle", type=float, default=None) @click.option("--throttle-lines", "throttle_lines", type=int, default=None) @click.option("--speed-x", "speedx", type=float, default=6000) diff --git a/src/octoprint/cli/client.py b/src/octoprint/cli/client.py index d3739fc6a..c5e9a48ff 100644 --- a/src/octoprint/cli/client.py +++ b/src/octoprint/cli/client.py @@ -78,15 +78,10 @@ client_options = bulk_options( """Common options to configure an API client.""" -@click.group() -def client_commands(): - pass - - -@client_commands.group("client", context_settings={"ignore_unknown_options": True}) +@click.group(context_settings={"ignore_unknown_options": True}) @client_options @click.pass_context -def client(ctx, apikey, host, port, httpuser, httppass, https, prefix): +def cli(ctx, apikey, host, port, httpuser, httppass, https, prefix): """Basic API client.""" try: settings = None @@ -124,7 +119,7 @@ def log_response(response, status_code=True, body=True, headers=False): click.echo(response.text) -@client.command("get") +@cli.command("get") @click.argument("path") @click.option("--timeout", type=float, default=None) @click.pass_context @@ -134,7 +129,7 @@ def get(ctx, path, timeout): log_response(r) -@client.command("post_json") +@cli.command("post_json") @click.argument("path") @click.argument("data", type=JsonStringParamType()) @click.option("--timeout", type=float, default=None) @@ -145,7 +140,7 @@ def post_json(ctx, path, data, timeout): log_response(r) -@client.command("patch_json") +@cli.command("patch_json") @click.argument("path") @click.argument("data", type=JsonStringParamType()) @click.option("--timeout", type=float, default=None, help="Request timeout in seconds") @@ -156,7 +151,7 @@ def patch_json(ctx, path, data, timeout): log_response(r) -@client.command("post_from_file") +@cli.command("post_from_file") @click.argument("path") @click.argument( "file_path", type=click.Path(exists=True, dir_okay=False, resolve_path=True) @@ -184,7 +179,7 @@ def post_from_file(ctx, path, file_path, json_flag, yaml_flag, timeout): log_response(r) -@client.command("command") +@cli.command("command") @click.argument("path") @click.argument("command") @click.option( @@ -228,7 +223,7 @@ def command( log_response(r, body=False) -@client.command("upload") +@cli.command("upload") @click.argument("path") @click.argument( "file_path", type=click.Path(exists=True, dir_okay=False, resolve_path=True) @@ -262,7 +257,7 @@ def upload(ctx, path, file_path, params, file_name, content_type, timeout): log_response(r) -@client.command("delete") +@cli.command("delete") @click.argument("path") @click.option("--timeout", type=float, default=None, help="Request timeout in seconds") @click.pass_context @@ -272,7 +267,7 @@ def delete(ctx, path, timeout): log_response(r) -@client.command("listen") +@cli.command("listen") @click.pass_context def listen(ctx): def on_connect(ws): diff --git a/src/octoprint/cli/common.py b/src/octoprint/cli/common.py new file mode 100644 index 000000000..0b4a6d681 --- /dev/null +++ b/src/octoprint/cli/common.py @@ -0,0 +1,43 @@ +__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" +__copyright__ = "Copyright (C) 2022 The OctoPrint Project - Released under terms of the AGPLv3 License" + + +from importlib import import_module + +import click +from werkzeug.utils import cached_property + + +class LazyGroup(click.Group): + """ + A click Group that imports the actual implementation only when + needed. This allows for more resilient CLIs where the top-level + command does not fail when a subcommand is broken enough to fail + at import time. + """ + + # shared by https://github.com/indico/indico in pallets/click#945 + + def __init__(self, import_name, **kwargs): + self._import_name = import_name + click.Group.__init__(self, **kwargs) + + @cached_property + def _impl(self): + module, name = self._import_name.split(":", 1) + return getattr(import_module(module), name) + + def get_command(self, ctx, cmd_name): + return self._impl.get_command(ctx, cmd_name) + + def list_commands(self, ctx): + return self._impl.list_commands(ctx) + + def invoke(self, ctx): + return self._impl.invoke(ctx) + + def get_usage(self, ctx): + return self._impl.get_usage(ctx) + + def get_params(self, ctx): + return self._impl.get_params(ctx) diff --git a/src/octoprint/cli/config.py b/src/octoprint/cli/config.py index b7fd050bc..7ace969c5 100644 --- a/src/octoprint/cli/config.py +++ b/src/octoprint/cli/config.py @@ -45,13 +45,8 @@ def _set_helper(settings, path, value, data_type=None): @click.group() -def config_commands(): - pass - - -@config_commands.group(name="config") @click.pass_context -def config(ctx): +def cli(ctx): """Basic config manipulation.""" logging.basicConfig( level=logging.DEBUG @@ -70,7 +65,7 @@ def config(ctx): ctx.exit(-1) -@config.command(name="set") +@cli.command(name="set") @standard_options(hidden=True) @click.argument("path", type=click.STRING) @click.argument("value", type=click.STRING) @@ -99,7 +94,7 @@ def set_command(ctx, path, value, as_bool, as_float, as_int, as_json): _set_helper(ctx.obj.settings, path, value, data_type=data_type) -@config.command(name="remove") +@cli.command(name="remove") @standard_options(hidden=True) @click.argument("path", type=click.STRING) @click.pass_context @@ -108,7 +103,7 @@ def remove_command(ctx, path): _set_helper(ctx.obj.settings, path, None) -@config.command(name="append_value") +@cli.command(name="append_value") @standard_options(hidden=True) @click.argument("path", type=click.STRING) @click.argument("value", type=click.STRING) @@ -136,7 +131,7 @@ def append_value_command(ctx, path, value, as_json=False): _set_helper(ctx.obj.settings, path, current) -@config.command(name="insert_value") +@cli.command(name="insert_value") @standard_options(hidden=True) @click.argument("path", type=click.STRING) @click.argument("index", type=click.INT) @@ -165,7 +160,7 @@ def insert_value_command(ctx, path, index, value, as_json=False): _set_helper(ctx.obj.settings, path, current) -@config.command(name="remove_value") +@cli.command(name="remove_value") @standard_options(hidden=True) @click.argument("path", type=click.STRING) @click.argument("value", type=click.STRING) @@ -197,7 +192,7 @@ def remove_value_command(ctx, path, value, as_json=False): _set_helper(ctx.obj.settings, path, current) -@config.command(name="get") +@cli.command(name="get") @click.argument("path", type=click.STRING) @click.option("--json", "as_json", is_flag=True, help="Output value formatted as JSON") @click.option("--yaml", "as_yaml", is_flag=True, help="Output value formatted as YAML") @@ -223,7 +218,7 @@ def get_command(ctx, path, as_json=False, as_yaml=False, as_raw=False): click.echo(output) -@config.command(name="effective") +@cli.command(name="effective") @click.option("--json", "as_json", is_flag=True, help="Output value formatted as JSON") @click.option("--yaml", "as_yaml", is_flag=True, help="Output value formatted as YAML") @click.option( diff --git a/src/octoprint/cli/dev.py b/src/octoprint/cli/dev.py index 394450670..a23033780 100644 --- a/src/octoprint/cli/dev.py +++ b/src/octoprint/cli/dev.py @@ -250,12 +250,7 @@ class OctoPrintDevelCommands(click.MultiCommand): return command -@click.group() -def dev_commands(): - pass - - -@dev_commands.group(name="dev", cls=OctoPrintDevelCommands) -def dev(): +@click.group(cls=OctoPrintDevelCommands) +def cli(): """Additional commands for development tasks.""" pass diff --git a/src/octoprint/cli/plugins.py b/src/octoprint/cli/plugins.py index 642d7f431..a19e174c5 100644 --- a/src/octoprint/cli/plugins.py +++ b/src/octoprint/cli/plugins.py @@ -138,13 +138,8 @@ class OctoPrintPluginCommands(click.MultiCommand): return result -@click.group() +@click.group(cls=OctoPrintPluginCommands) @pass_octoprint_ctx -def plugin_commands(obj): - pass - - -@plugin_commands.group(name="plugins", cls=OctoPrintPluginCommands) -def plugins(): +def cli(obj): """Additional commands provided by plugins.""" pass diff --git a/src/octoprint/cli/server.py b/src/octoprint/cli/server.py index 6f48bb3af..dcefd9d07 100644 --- a/src/octoprint/cli/server.py +++ b/src/octoprint/cli/server.py @@ -248,11 +248,11 @@ daemon_options = bulk_options( @click.group() -def server_commands(): +def cli(): pass -@server_commands.command(name="safemode") +@cli.command(name="safemode") @standard_options() @click.pass_context def enable_safemode(ctx, **kwargs): @@ -283,7 +283,7 @@ def enable_safemode(ctx, **kwargs): ) -@server_commands.command(name="serve") +@cli.command(name="serve") @standard_options() @server_options @click.pass_context @@ -330,7 +330,7 @@ def serve_command(ctx, **kwargs): if sys.platform != "win32" and sys.platform != "darwin": # we do not support daemon mode under windows or macosx - @server_commands.command(name="daemon") + @cli.command(name="daemon") @standard_options() @server_options @daemon_options diff --git a/src/octoprint/cli/systeminfo.py b/src/octoprint/cli/systeminfo.py index cb5e2d107..236a84468 100644 --- a/src/octoprint/cli/systeminfo.py +++ b/src/octoprint/cli/systeminfo.py @@ -79,7 +79,7 @@ def get_systeminfo_bundle(systeminfo, logbase, printer=None, plugin_manager=None # Add printer log, if available if hasattr(printer, "_log"): - z.add(to_bytes("\n".join(printer._log)), "terminal.txt") + z.add(to_bytes("\n".join(printer._log)), arcname="terminal.txt") # add systeminfo systeminfotxt = [] @@ -137,11 +137,11 @@ def get_systeminfo_bundle_name(): @click.group() -def systeminfo_commands(): +def cli(): pass -@systeminfo_commands.command(name="systeminfo") +@cli.command(name="systeminfo") @standard_options() @click.argument( "path", diff --git a/src/octoprint/cli/user.py b/src/octoprint/cli/user.py index b172548c8..78f50cefe 100644 --- a/src/octoprint/cli/user.py +++ b/src/octoprint/cli/user.py @@ -23,13 +23,8 @@ click.disable_unicode_literals_warning = True @click.group() -def user_commands(): - pass - - -@user_commands.group(name="user") @click.pass_context -def user(ctx): +def cli(ctx): """ User management. @@ -84,7 +79,7 @@ def user(ctx): ctx.exit(-1) -@user.command(name="list") +@cli.command(name="list") @click.pass_context def list_users_command(ctx): """Lists user information""" @@ -92,7 +87,7 @@ def list_users_command(ctx): _print_list(users) -@user.command(name="add") +@cli.command(name="add") @click.argument("username", type=click.STRING, required=True) @click.password_option("--password", "password", help="Password for the user") @click.option("-g", "--group", "groups", multiple=True, help="Groups to set on the user") @@ -133,7 +128,7 @@ def add_user_command(ctx, username, password, groups, permissions, is_admin): click.echo(f"A user with the name {username} does already exist!", err=True) -@user.command(name="remove") +@cli.command(name="remove") @click.argument("username", type=click.STRING) @click.pass_context def remove_user_command(ctx, username): @@ -150,7 +145,7 @@ def remove_user_command(ctx, username): click.echo(f"User {username} not removed.") -@user.command(name="password") +@cli.command(name="password") @click.argument("username", type=click.STRING) @click.password_option("--password", "password", help="New password for user") @click.pass_context @@ -163,7 +158,7 @@ def change_password_command(ctx, username, password): click.echo(f"User {username} does not exist!", err=True) -@user.command(name="activate") +@cli.command(name="activate") @click.argument("username", type=click.STRING) @click.pass_context def activate_command(ctx, username): @@ -180,7 +175,7 @@ def activate_command(ctx, username): click.echo(f"User {username} does not exist!", err=True) -@user.command(name="deactivate") +@cli.command(name="deactivate") @click.argument("username", type=click.STRING) @click.pass_context def deactivate_command(ctx, username): diff --git a/src/octoprint/filemanager/util.py b/src/octoprint/filemanager/util.py index 1948a2f6b..18509fd60 100644 --- a/src/octoprint/filemanager/util.py +++ b/src/octoprint/filemanager/util.py @@ -125,7 +125,7 @@ class MultiStream(io.RawIOBase): """ def __init__(self, *streams): - io.RawIOBase.__init__(self) + super().__init__() self.streams = streams self.current_stream = 0 @@ -184,7 +184,7 @@ class LineProcessorStream(io.RawIOBase): """ def __init__(self, input_stream): - io.RawIOBase.__init__(self) + super().__init__() self.input_stream = io.BufferedReader(input_stream) self.leftover = bytearray() diff --git a/src/octoprint/logging/__init__.py b/src/octoprint/logging/__init__.py index 14a2762b4..4aefdbd10 100644 --- a/src/octoprint/logging/__init__.py +++ b/src/octoprint/logging/__init__.py @@ -84,17 +84,17 @@ def get_divider_line(c, message=None, length=78, indent=3): Examples: - >>> get_divider_line("-") # doctest: +ALLOW_UNICODE + >>> get_divider_line("-") '------------------------------------------------------------------------------' - >>> get_divider_line("=", length=10) # doctest: +ALLOW_UNICODE + >>> get_divider_line("=", length=10) '==========' - >>> get_divider_line("-", message="Hi", length=10) # doctest: +ALLOW_UNICODE + >>> get_divider_line("-", message="Hi", length=10) '--- Hi ---' - >>> get_divider_line("-", message="A slightly longer text") # doctest: +ALLOW_UNICODE + >>> get_divider_line("-", message="A slightly longer text") '--- A slightly longer text ---------------------------------------------------' - >>> get_divider_line("-", message="A slightly longer text", indent=5) # doctest: +ALLOW_UNICODE + >>> get_divider_line("-", message="A slightly longer text", indent=5) '----- A slightly longer text -------------------------------------------------' - >>> get_divider_line("-", message="Hello World!", length=10) # doctest: +ALLOW_UNICODE + >>> get_divider_line("-", message="Hello World!", length=10) '--- Hello World!' >>> get_divider_line(None) Traceback (most recent call last): diff --git a/src/octoprint/logging/filters.py b/src/octoprint/logging/filters.py index ea16ffc44..0885a491a 100644 --- a/src/octoprint/logging/filters.py +++ b/src/octoprint/logging/filters.py @@ -1,5 +1,5 @@ import logging -from urllib import parse as urlparse +import urllib.parse class TornadoAccessFilter(logging.Filter): @@ -9,8 +9,8 @@ class TornadoAccessFilter(logging.Filter): if status == 409: - method, url, client = request_line.split() - u = urlparse.urlparse(url) + _, url, _ = request_line.split() + u = urllib.parse.urlparse(url) if u.path in ("/api/printer",): record.levelno = logging.INFO record.levelname = logging.getLevelName(record.levelno) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 979769cc6..7c075eafb 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -69,7 +69,7 @@ def parse_plugin_metadata(path): # we only support parsing plain text source files return result - logger.debug(f"Parsing plugin metadata from AST of {path}".format(path)) + logger.debug(f"Parsing plugin metadata from AST of {path}") try: import ast @@ -781,9 +781,7 @@ class PluginInfo: try: return parse_plugin_metadata(self.location) except SyntaxError: - self._logger.exception( - f"Invalid syntax in plugin file of plugin {self.key}".format(self.key) - ) + self._logger.exception(f"Invalid syntax in plugin file of plugin {self.key}") self.invalid_syntax = True return {} @@ -891,13 +889,9 @@ class PluginManager: def _detect_python_environment(self): import sys - from distutils.command.install import install as cmd_install - from distutils.dist import Distribution + import sysconfig - cmd = cmd_install(Distribution()) - cmd.finalize_options() - - self._python_install_dir = cmd.install_lib + self._python_install_dir = sysconfig.get_path("purelib") self._python_prefix = os.path.realpath(sys.prefix) self._python_virtual_env = hasattr(sys, "real_prefix") or ( hasattr(sys, "base_prefix") @@ -2333,8 +2327,6 @@ class EntryPointMetadata(pkginfo.Distribution): return self.entry_point.dist.get_metadata(metadata_file) except OSError: # noqa: B014 # file not found, metadata file might be missing, ignore - # IOError: file not found in Py2 - # OSError (specifically FileNotFoundError): file not found in Py3 pass warnings.warn( diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index 49c29e50a..b43982670 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -2073,12 +2073,11 @@ class SlicerPlugin(OctoPrintPlugin): .. versionadded:: 1.3.0 """ import os - from os import scandir lms = [os.stat(profile_path).st_mtime] lms += [ os.stat(entry.path).st_mtime - for entry in scandir(profile_path) + for entry in os.scandir(profile_path) if entry.name.endswith(".profile") ] return max(lms) diff --git a/src/octoprint/plugins/action_command_notification/__init__.py b/src/octoprint/plugins/action_command_notification/__init__.py index a3e147990..3b3ae1c10 100644 --- a/src/octoprint/plugins/action_command_notification/__init__.py +++ b/src/octoprint/plugins/action_command_notification/__init__.py @@ -141,7 +141,7 @@ __plugin_disabling_discouraged__ = gettext( " notifications in OctoPrint" ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = ActionCommandNotificationPlugin() __plugin_hooks__ = { "octoprint.comm.protocol.action": __plugin_implementation__.action_command_handler, diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index 5e3b077e1..8a43d33dc 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -290,7 +290,7 @@ __plugin_disabling_discouraged__ = gettext( " confirmation or selection prompts in OctoPrint" ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = ActionCommandPromptPlugin() __plugin_hooks__ = { "octoprint.comm.protocol.action": __plugin_implementation__.action_command_handler, diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py index 7eaf806c3..42bbe0aa2 100644 --- a/src/octoprint/plugins/announcements/__init__.py +++ b/src/octoprint/plugins/announcements/__init__.py @@ -6,7 +6,6 @@ __copyright__ = "Copyright (C) 2016 The OctoPrint Project - Released under terms import calendar import os import re -import sys import threading import time from collections import OrderedDict @@ -27,8 +26,6 @@ from octoprint.server.util.flask import ( from octoprint.util import count, utmify from octoprint.util.text import sanitize -PY2 = sys.version_info[0] < 3 - class AnnouncementPlugin( octoprint.plugin.AssetPlugin, @@ -523,11 +520,11 @@ _image_tag_re = re.compile(r"") def _strip_images(text): """ - >>> _strip_images("I'm a link and this is an image: foo") # doctest: +ALLOW_UNICODE + >>> _strip_images("I'm a link and this is an image: foo") "I'm a link and this is an image: " - >>> _strip_images("One and two and three and four \\"four\\"") # doctest: +ALLOW_UNICODE + >>> _strip_images("One and two and three and four \\"four\\"") 'One and two and three and four ' - >>> _strip_images("No images here") # doctest: +ALLOW_UNICODE + >>> _strip_images("No images here") 'No images here' """ return _image_tag_re.sub("", text) @@ -536,9 +533,9 @@ def _strip_images(text): def _replace_images(text, callback): """ >>> callback = lambda img: "foobar" - >>> _replace_images("I'm a link and this is an image: foo", callback) # doctest: +ALLOW_UNICODE + >>> _replace_images("I'm a link and this is an image: foo", callback) "I'm a link and this is an image: foobar" - >>> _replace_images("One and two and three and four \\"four\\"", callback) # doctest: +ALLOW_UNICODE + >>> _replace_images("One and two and three and four \\"four\\"", callback) 'One foobar and two foobar and three foobar and four foobar' """ result = text @@ -554,13 +551,13 @@ _image_src_re = re.compile(r'src=(?P[\'"]*)(?P.*?)(?P=quote)(?=\s+|> def _lazy_images(text, placeholder=None): """ - >>> _lazy_images("I'm a link and this is an image: foo") # doctest: +ALLOW_UNICODE + >>> _lazy_images("I'm a link and this is an image: foo") 'I\\'m a link and this is an image: \\'foo\\'' - >>> _lazy_images("I'm a link and this is an image: foo", placeholder="ph.png") # doctest: +ALLOW_UNICODE + >>> _lazy_images("I'm a link and this is an image: foo", placeholder="ph.png") 'I\\'m a link and this is an image: \\'foo\\'' - >>> _lazy_images("One and two and three and four \\"four\\"", placeholder="ph.png") # doctest: +ALLOW_UNICODE + >>> _lazy_images("One and two and three and four \\"four\\"", placeholder="ph.png") 'One and two and three and four four' - >>> _lazy_images("No images here") # doctest: +ALLOW_UNICODE + >>> _lazy_images("No images here") 'No images here' """ if placeholder is None: @@ -583,9 +580,9 @@ def _lazy_images(text, placeholder=None): def _strip_tags(text): """ - >>> _strip_tags("Hello world<img src='foo.jpg'>") # doctest: +ALLOW_UNICODE + >>> _strip_tags("Hello world<img src='foo.jpg'>") "Hello world<img src='foo.jpg'>" - >>> _strip_tags("> > Foo") # doctest: +ALLOW_UNICODE + >>> _strip_tags("> > Foo") '> > Foo' """ from html.parser import HTMLParser @@ -607,7 +604,7 @@ def _strip_tags(text): def get_data(self): return "".join(self._fed) - tag_stripper = TagStripper() if PY2 else TagStripper(convert_charrefs=False) + tag_stripper = TagStripper(convert_charrefs=False) tag_stripper.feed(text) return tag_stripper.get_data() @@ -620,7 +617,7 @@ __plugin_disabling_discouraged__ = gettext( "regarding security or other critical issues concerning OctoPrint." ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = AnnouncementPlugin() __plugin_hooks__ = { diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py index 270926d94..e3190ad36 100644 --- a/src/octoprint/plugins/appkeys/__init__.py +++ b/src/octoprint/plugins/appkeys/__init__.py @@ -541,7 +541,7 @@ __plugin_disabling_discouraged__ = gettext( "obtain an API key without you manually copy-pasting it." ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = AppKeysPlugin() __plugin_hooks__ = { "octoprint.accesscontrol.keyvalidator": __plugin_implementation__.validate_api_key, diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 1072ac691..f7adc08e8 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -1,8 +1,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License" -from os import scandir - import octoprint.plugin from octoprint.access import ADMIN_GROUP from octoprint.access.permissions import Permissions @@ -729,7 +727,7 @@ class BackupPlugin( def _get_backups(self): backups = [] - for entry in scandir(self.get_plugin_data_folder()): + for entry in os.scandir(self.get_plugin_data_folder()): if is_hidden_path(entry.path): continue if not entry.is_file(): @@ -828,7 +826,7 @@ class BackupPlugin( return 0 total = 0 - for entry in scandir(path): + for entry in os.scandir(path): if entry.is_dir(): total += cls._get_disk_size(entry.path, ignored=ignored) elif entry.is_file(): @@ -1015,7 +1013,7 @@ class BackupPlugin( return if os.path.isdir(source): - for entry in scandir(source): + for entry in os.scandir(source): add_to_zip( entry.path, os.path.join(target, entry.name), @@ -1402,7 +1400,7 @@ __plugin_disabling_discouraged__ = gettext( "& restore your OctoPrint settings and data." ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = BackupPlugin() __plugin_hooks__ = { "octoprint.server.http.routes": __plugin_implementation__.route_hook, diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index 0096f5822..7752d50b4 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -133,5 +133,5 @@ __plugin_disabling_discouraged__ = gettext( "setup steps that might be required after an update." ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = CoreWizardPlugin() diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py index f8b6c4432..9d0fbeebd 100644 --- a/src/octoprint/plugins/discovery/__init__.py +++ b/src/octoprint/plugins/discovery/__init__.py @@ -57,7 +57,7 @@ class DiscoveryPlugin( self.port = None # zeroconf - self._zeroconf = zeroconf.Zeroconf() + self._zeroconf = None self._zeroconf_registrations = collections.defaultdict(list) # upnp/ssdp @@ -66,6 +66,9 @@ class DiscoveryPlugin( self._ssdp_notify_timeout = 30 self._ssdp_last_notify = 0 + def initialize(self): + self._zeroconf = zeroconf.Zeroconf(interfaces=self.get_interface_addresses()) + ##~~ SettingsPlugin API def get_settings_defaults(self): @@ -87,7 +90,9 @@ class DiscoveryPlugin( "vendorUrl": None, }, "addresses": None, + "ignoredAddresses": None, "interfaces": None, + "ignoredInterfaces": None, } ##~~ BlueprintPlugin API -- used for providing the SSDP device descriptor XML @@ -187,7 +192,7 @@ class DiscoveryPlugin( def _format_zeroconf_name(self, name, service_type): service_type = self._format_zeroconf_service_type(service_type) - return name + "." + service_type + return f"{name}.{service_type}" def _format_zeroconf_txt(self, record): result = {} @@ -779,8 +784,11 @@ class DiscoveryPlugin( if addresses: return addresses else: - return octoprint.util.interface_addresses( - interfaces=self._settings.get(["interfaces"]) + return list( + octoprint.util.interface_addresses( + interfaces=self._settings.get(["interfaces"]), + ignored=self._settings.get(["ignoredInterfaces"]), + ) ) @@ -795,4 +803,4 @@ __plugin_disabling_discouraged__ = gettext( "discoverable on the network via Bonjour and uPnP." ) __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index e6319f4b6..58a5abcbb 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -18,10 +18,10 @@ from octoprint.util.version import ( ) SENTRY_URL_SERVER = ( - "https://690e174698034bcc95928e6bfa8573f7@o118517.ingest.sentry.io/1373987" + "https://871751d3af18492bbfe9db952cb1929c@o118517.ingest.sentry.io/1373987" ) SENTRY_URL_COREUI = ( - "https://186f1dc5da7d46ab9d6b6de564d839bb@o118517.ingest.sentry.io/1374096" + "https://1c7e28064b0646c3aa109793a49eea81@o118517.ingest.sentry.io/1374096" ) SETTINGS_DEFAULTS = { @@ -250,5 +250,5 @@ def __plugin_enable__(): __plugin_name__ = "Error Tracking" __plugin_author__ = "Gina Häußge" __plugin_license__ = "AGPLv3" -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = ErrorTrackingPlugin() diff --git a/src/octoprint/plugins/eventmanager/__init__.py b/src/octoprint/plugins/eventmanager/__init__.py index bda534ce2..667c783b3 100644 --- a/src/octoprint/plugins/eventmanager/__init__.py +++ b/src/octoprint/plugins/eventmanager/__init__.py @@ -53,7 +53,7 @@ class EventManagerPlugin( __plugin_name__ = gettext("Event Manager") -__plugin_pythoncompat__ = ">=2.7,<4" +__plugin_pythoncompat__ = ">=3.7,<4" __plugin_author__ = "jneilliii" __plugin_license__ = "AGPLv3" __plugin_description__ = gettext( diff --git a/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 b/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 index 414c51078..27408c35d 100644 --- a/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 +++ b/src/octoprint/plugins/eventmanager/templates/eventmanager_settings.jinja2 @@ -56,6 +56,9 @@ +

+ {{ _('Please note that any event handlers you define here will be processed asynchronously to OctoPrint\'s own processing of the event. You cannot stall, block or otherwise influence internal execution with event handlers.') }} +