diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 7a3f3bd3e..c1c9fc706 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -2,6 +2,7 @@ # pre-commit version updates b4f265d9f67508677e1697e74e248b895da7f43c +2231e81efd32d649798f7a58cdb1755e34902d8a # Switch to black formatting 1f93b2355a2816918e11a55e61b42010d15a6720 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ca5d8d6f..6ffd3a093 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,9 @@ -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) +default_language_version: + python: python3.10 +exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|scripts/|translations/|.*\.css|.*\.svg) repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.4.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -14,7 +16,7 @@ repos: args: ["--remove"] exclude: "setup.py|versioneer.py|src/octoprint_setuptools/__init__.py" - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v3.3.1 hooks: - id: pyupgrade args: ["--py37-plus"] @@ -43,26 +45,23 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.1.0 hooks: - id: black - additional_dependencies: - - click==8.0.4 - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 6.0.0 hooks: - id: flake8 args: [--config=setup.cfg] additional_dependencies: - - flake8-bugbear==22.3.20 - - importlib-metadata<5.0 + - flake8-bugbear==23.2.13 exclude: ^(docs/) - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.5.1 + rev: v2.7.1 hooks: - id: prettier - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.8.0 + rev: v8.34.0 hooks: - id: eslint additional_dependencies: @@ -70,7 +69,7 @@ repos: 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 + rev: v2.2.2 hooks: - id: codespell exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|tests/playwright|scripts/) diff --git a/docs/bundledplugins/pluginmanager.rst b/docs/bundledplugins/pluginmanager.rst index 82eb6f393..02f4a7218 100644 --- a/docs/bundledplugins/pluginmanager.rst +++ b/docs/bundledplugins/pluginmanager.rst @@ -10,7 +10,26 @@ The OctoPrint Plugin Manager comes bundled with OctoPrint. It allows management of installed plugins (listing, enabling, disabling and uninstalling) and installing new plugins from the official `OctoPrint Plugin Repository `_, web addresses -or uploaded file archives. +or uploaded files. + +Installing from URL or file uploads currently supports the following file +formats: + + * ``.zip``, ``.tar.gz``, ``.tgz``, ``.tar``, ``.gz``, ``.whl``: Will be considered to be + plugin archive and installed via ``pip``. + * ``.py``: Will be considered to be a single file plugin and installed by copying it + into ``~/.octoprint/plugins``. + * ``.json``: Will be considered to be either a plugin manager export file (created by the Export button) or a manually created + list of URLs to install from, e.g. + + .. code-block:: json + + [ + "https://github.com/jneilliii/OctoPrint-BedLevelVisualizer/archive/master.zip", + "https://github.com/eyal0/OctoPrint-PrintTimeGenius/archive/master.zip" + ] + + The plugin manager will feed all contained URLs to the same logic as above. .. _fig-bundledplugins-pluginmanager-mainscreen: .. figure:: ../images/bundledplugins-pluginmanager-mainscreen.png diff --git a/docs/events/index.rst b/docs/events/index.rst index 4289ca425..8a882596f 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -610,9 +610,13 @@ ChartMarked Payload: - * ``type``: the marking's ID. Built-in types are ``print``, ``done``, ``cancel``, ``pause``, and ``resume``. Plugins may set arbitrary types - * ``label``: the human-readable short label of the marking - * ``time``: the epoch time of marking + * ``type``: The marking's ID. Built-in types are ``print``, ``done``, ``cancel``, ``pause``, and ``resume``. + Plugins may set arbitrary types, which should be prefixed, e.g. ``pluginname_eventtype``. In the UI, the type + ID is used to stylize the marking label. + * ``label``: The human-readable short label of the marking, ideally one short word. Optional but recommended; if + not specified, the UI will display the ``type``. The label may be localized in the UI. + * ``time``: The epoch time of marking. Defaults to the event fire time if not specified. Plugins may set a time + in the past if it makes sense for the event. .. versionadded:: 1.9.0 diff --git a/docs/images/bundledplugins-pluginmanager-installing.png b/docs/images/bundledplugins-pluginmanager-installing.png index d97eaf39c..a27398a00 100644 Binary files a/docs/images/bundledplugins-pluginmanager-installing.png and b/docs/images/bundledplugins-pluginmanager-installing.png differ diff --git a/docs/images/bundledplugins-pluginmanager-mainscreen.png b/docs/images/bundledplugins-pluginmanager-mainscreen.png index fa432c7bc..f2b7c35f0 100644 Binary files a/docs/images/bundledplugins-pluginmanager-mainscreen.png and b/docs/images/bundledplugins-pluginmanager-mainscreen.png differ diff --git a/docs/images/bundledplugins-pluginmanager-repofilters.png b/docs/images/bundledplugins-pluginmanager-repofilters.png index ab62e4a3c..1138afbe7 100644 Binary files a/docs/images/bundledplugins-pluginmanager-repofilters.png and b/docs/images/bundledplugins-pluginmanager-repofilters.png differ diff --git a/docs/images/template-plugin-types-main.png b/docs/images/template-plugin-types-main.png index 3b4267faf..2c98a3bce 100644 Binary files a/docs/images/template-plugin-types-main.png and b/docs/images/template-plugin-types-main.png differ diff --git a/docs/images/template-plugin-types-settings.png b/docs/images/template-plugin-types-settings.png index 2ad2b5dd2..7b377c1cf 100644 Binary files a/docs/images/template-plugin-types-settings.png and b/docs/images/template-plugin-types-settings.png differ diff --git a/docs/jsclientlib/socket.rst b/docs/jsclientlib/socket.rst index aaf5a5e6a..631d0b97c 100644 --- a/docs/jsclientlib/socket.rst +++ b/docs/jsclientlib/socket.rst @@ -60,7 +60,7 @@ :param string message: The type of message for which to register :param function handler: The handler function -.. js:function:: OctoPrintClient.socker.removeMessage(message, handler) +.. js:function:: OctoPrintClient.socket.removeMessage(message, handler) Removes the ``handler`` for messages of type ``message``. diff --git a/docs/modules/users.rst b/docs/modules/access.rst similarity index 100% rename from docs/modules/users.rst rename to docs/modules/access.rst diff --git a/docs/modules/index.rst b/docs/modules/index.rst index 0f67513b7..024eaad03 100644 --- a/docs/modules/index.rst +++ b/docs/modules/index.rst @@ -7,12 +7,13 @@ Internal Modules .. toctree:: :maxdepth: 3 + access.rst cli.rst filemanager.rst plugin.rst printer.rst + schema.rst server.rst settings.rst slicing.rst - users.rst util.rst diff --git a/docs/modules/schema.rst b/docs/modules/schema.rst new file mode 100644 index 000000000..9ee0260f7 --- /dev/null +++ b/docs/modules/schema.rst @@ -0,0 +1,111 @@ +.. _sec-modules-schema: + +octoprint.schema +---------------- + +.. automodule:: octoprint.schema + :members: + :undoc-members: + +.. _sec-modules-schema-config: + +octoprint.schema.config +----------------------- + +.. automodule:: octoprint.schema.config + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.access_control + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.api + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.appearance + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.controls + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.devel + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.estimation + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.events + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.feature + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.folder + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.gcode_analysis + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.plugins + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.printer_parameters + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.printer_profiles + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.scripts + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.serial + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.server + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.slicing + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.system + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.temperature + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.terminalfilters + :members: + :undoc-members: + +.. automodule:: octoprint.schema.config.webcam + :members: + :undoc-members: + + +.. _sec-modules-schema-webcam: + +octoprint.schema.webcam +----------------------- + +.. automodule:: octoprint.schema.webcam + :members: + :undoc-members: diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index bf4207bea..a04e32a29 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -1177,6 +1177,42 @@ octoprint.plugin.backup.additional_excludes See :ref:`here `. +.. _sec-plugins-hook-plugin-backup-before-backup: + +octoprint.plugin.backup.before_backup +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.9.0 + +See :ref:`here `. + +.. _sec-plugins-hook-plugin-backup-after-backup: + +octoprint.plugin.backup.after_backup +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.9.0 + +See :ref:`here `. + +.. _sec-plugins-hook-plugin-backup-before-restore: + +octoprint.plugin.backup.before_restore +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.9.0 + +See :ref:`here `. + +.. _sec-plugins-hook-plugin-backup-after-restore: + +octoprint.plugin.backup.after_restore +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.9.0 + +See :ref:`here `. + .. _sec-plugins-hook-plugin-pluginmanager-reconnect: octoprint.plugin.pluginmanager.reconnect_hooks @@ -1360,7 +1396,7 @@ octoprint.printer.sdcardupload to be created on the ``sdcard`` storage. ``elapsed`` is the elapsed time in seconds. If the hook is going to handle the upload, it must return the (future) remote filename of the file on the ``sdcard`` - storage. If it returns ``None`` (or an otherwise falsy value), OctoPrint will interpret this as the hook not going to + storage. If it returns ``None`` (or an otherwise false-y value), OctoPrint will interpret this as the hook not going to handle the file upload, in which case the next hook or - if no other hook is registered - the default implementation will be called. diff --git a/docs/plugins/mixins.rst b/docs/plugins/mixins.rst index edf9e2a23..e7dd6d780 100644 --- a/docs/plugins/mixins.rst +++ b/docs/plugins/mixins.rst @@ -198,33 +198,6 @@ The following plugin mixins are currently available: Please note that all plugin mixins inherit from :class:`~octoprint.plugin.core.Plugin` and :class:`~octoprint.plugin.types.OctoPrintPlugin`, which also provide attributes of interest to plugin developers. -.. _sec-plugins-mixins-startupplugin: - -StartupPlugin -~~~~~~~~~~~~~ - -.. autoclass:: octoprint.plugin.StartupPlugin - :members: - :show-inheritance: - -.. _sec-plugins-mixins-shutdownplugin: - -ShutdownPlugin -~~~~~~~~~~~~~~ - -.. autoclass:: octoprint.plugin.ShutdownPlugin - :members: - :show-inheritance: - -.. _sec-plugins-mixins-settingsplugin: - -SettingsPlugin -~~~~~~~~~~~~~~ - -.. autoclass:: octoprint.plugin.SettingsPlugin - :members: - :show-inheritance: - .. _sec-plugins-mixins-assetplugin: AssetPlugin @@ -234,42 +207,6 @@ AssetPlugin :members: :show-inheritance: -.. _sec-plugins-mixins-templateplugin: - -TemplatePlugin -~~~~~~~~~~~~~~ - -.. autoclass:: octoprint.plugin.TemplatePlugin - :members: - :show-inheritance: - -.. _sec-plugins-mixins-wizardplugin: - -WizardPlugin -~~~~~~~~~~~~ - -.. autoclass:: octoprint.plugin.WizardPlugin - :members: - :show-inheritance: - -.. _sec-plugins-mixins-uiplugin: - -UiPlugin -~~~~~~~~ - -.. autoclass:: octoprint.plugin.UiPlugin - :members: - :show-inheritance: - -.. _sec-plugins-mixins-simpleapiplugin: - -SimpleApiPlugin -~~~~~~~~~~~~~~~ - -.. autoclass:: octoprint.plugin.SimpleApiPlugin - :members: - :show-inheritance: - .. _sec-plugins-mixins-blueprintplugin: BlueprintPlugin @@ -297,12 +234,12 @@ ProgressPlugin :members: :show-inheritance: -.. _sec-plugins-mixins-slicerplugin: +.. _sec-plugins-mixins-reloadneeding: -SlicerPlugin -~~~~~~~~~~~~ +ReloadNeedingPlugin +~~~~~~~~~~~~~~~~~~~ -.. autoclass:: octoprint.plugin.SlicerPlugin +.. autoclass:: octoprint.plugin.ReloadNeedingPlugin :members: :show-inheritance: @@ -315,11 +252,83 @@ RestartNeedingPlugin :members: :show-inheritance: -.. _sec-plugins-mixins-reloadneeding: +.. _sec-plugins-mixins-settingsplugin: -ReloadNeedingPlugin -~~~~~~~~~~~~~~~~~~~ +SettingsPlugin +~~~~~~~~~~~~~~ -.. autoclass:: octoprint.plugin.ReloadNeedingPlugin +.. autoclass:: octoprint.plugin.SettingsPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-shutdownplugin: + +ShutdownPlugin +~~~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.ShutdownPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-simpleapiplugin: + +SimpleApiPlugin +~~~~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.SimpleApiPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-slicerplugin: + +SlicerPlugin +~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.SlicerPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-startupplugin: + +StartupPlugin +~~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.StartupPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-templateplugin: + +TemplatePlugin +~~~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.TemplatePlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-uiplugin: + +UiPlugin +~~~~~~~~ + +.. autoclass:: octoprint.plugin.UiPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-webcamproviderplugin: + +WebcamProviderPlugin +~~~~~~~~~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.WebcamProviderPlugin + :members: + :show-inheritance: + +.. _sec-plugins-mixins-wizardplugin: + +WizardPlugin +~~~~~~~~~~~~ + +.. autoclass:: octoprint.plugin.WizardPlugin :members: :show-inheritance: diff --git a/docs/sphinxext/onlineinclude.py b/docs/sphinxext/onlineinclude.py index 508591d14..ad83f035c 100644 --- a/docs/sphinxext/onlineinclude.py +++ b/docs/sphinxext/onlineinclude.py @@ -26,7 +26,6 @@ cache = {} class OnlineIncludeReader(LiteralIncludeReader): def read_file(self, filename: str, location: Any = None) -> list[str]: - global cache try: if filename in cache: diff --git a/setup.cfg b/setup.cfg index f02d12124..6d4730827 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,7 @@ lookupfile = .versioneer-lookup [flake8] max-line-length = 90 -extend-ignore = E203, E231, E265, E266, E402, E501, E731 +extend-ignore = E203, E231, E265, E266, E402, E501, E731, B023, B903, B904, B907, B950, W503 select = B,C,E,F,W,T4,B9 exclude = src/octoprint/vendor diff --git a/src/octoprint/access/permissions.py b/src/octoprint/access/permissions.py index cb4519491..311f3172c 100644 --- a/src/octoprint/access/permissions.py +++ b/src/octoprint/access/permissions.py @@ -268,7 +268,6 @@ class PermissionsMetaClass(type): class Permissions(metaclass=PermissionsMetaClass): - # Special permission ADMIN = OctoPrintPermission( "Admin", diff --git a/src/octoprint/cli/__init__.py b/src/octoprint/cli/__init__.py index 91a57b79a..b08415610 100644 --- a/src/octoprint/cli/__init__.py +++ b/src/octoprint/cli/__init__.py @@ -362,7 +362,6 @@ from .systeminfo import cli as systeminfo_commands # noqa: E402 @click.version_option(version=octoprint.__version__, allow_from_autoenv=False) @click.pass_context def octo(ctx, **kwargs): - if ctx.invoked_subcommand is None: # We have to support calling the octoprint command without any # sub commands to remain backwards compatible. diff --git a/src/octoprint/daemon.py b/src/octoprint/daemon.py index 2ec04e98f..48f66dd04 100644 --- a/src/octoprint/daemon.py +++ b/src/octoprint/daemon.py @@ -63,8 +63,8 @@ class Daemon: sys.stdout.flush() sys.stderr.flush() si = open(os.devnull, encoding="utf-8") - so = open(os.devnull, "at+", encoding="utf-8") - se = open(os.devnull, "at+", encoding="utf-8") + so = open(os.devnull, "a+", encoding="utf-8") + se = open(os.devnull, "a+", encoding="utf-8") os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdout.fileno()) @@ -160,7 +160,7 @@ class Daemon: def set_pid(self, pid): """Write the pid to the pidfile.""" - with open(self.pidfile, "wt+", encoding="utf-8") as f: + with open(self.pidfile, "w+", encoding="utf-8") as f: f.write(str(pid) + "\n") def remove_pidfile(self): diff --git a/src/octoprint/environment.py b/src/octoprint/environment.py index be6a21e8b..6ae4768c1 100644 --- a/src/octoprint/environment.py +++ b/src/octoprint/environment.py @@ -167,7 +167,7 @@ class EnvironmentDetector: dumped_environment = yaml.dump(environment, pretty=True).strip() environment_lines = "\n".join( - map(lambda l: f"| {l}", dumped_environment.split("\n")) + map(lambda x: f"| {x}", dumped_environment.split("\n")) ) return "Detected environment is Python {} under {} ({}). Details:\n{}".format( environment["python"]["version"], diff --git a/src/octoprint/filemanager/destinations.py b/src/octoprint/filemanager/destinations.py index ea9496d32..42f17c4ed 100644 --- a/src/octoprint/filemanager/destinations.py +++ b/src/octoprint/filemanager/destinations.py @@ -2,6 +2,5 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp class FileDestinations: - SDCARD = "sdcard" LOCAL = "local" diff --git a/src/octoprint/logging/filters.py b/src/octoprint/logging/filters.py index 0885a491a..0b6c941fc 100644 --- a/src/octoprint/logging/filters.py +++ b/src/octoprint/logging/filters.py @@ -8,7 +8,6 @@ class TornadoAccessFilter(logging.Filter): status, request_line, rtt = record.args if status == 409: - _, url, _ = request_line.split() u = urllib.parse.urlparse(url) if u.path in ("/api/printer",): diff --git a/src/octoprint/logging/handlers.py b/src/octoprint/logging/handlers.py index 479cba474..fe7fcac36 100644 --- a/src/octoprint/logging/handlers.py +++ b/src/octoprint/logging/handlers.py @@ -66,7 +66,6 @@ class OctoPrintStreamHandler(AsyncLogHandlerMixin, logging.StreamHandler): class TriggeredRolloverLogHandler( AsyncLogHandlerMixin, logging.handlers.RotatingFileHandler ): - do_rollover = False suffix_template = "%Y-%m-%d_%H-%M-%S" file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$") diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 0d8fe2246..ad66d87a2 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -2350,7 +2350,8 @@ class EntryPointMetadata(pkginfo.Distribution): warnings.warn( "No package metadata found for package {}".format( self.entry_point.module_name - ) + ), + stacklevel=2, ) diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index f98be4141..f6f7b835e 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -331,6 +331,18 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin): wrapper div and the link in the navigation will have the additional classes and styles applied as defined via the configuration through :func:`get_template_configs`. + Webcam + Plugins can provide a custom webcam view for watching a camera stream, which will be embedded into the "Control" + panel of OctoPrint's default UI. + + The included template must be called ``_webcam.jinja2`` (e.g. ``myplugin_webcam.jinja2``) unless + overridden by the configuration supplied through :func:`get_template_configs`. + + The template will be already wrapped into the necessary structure, plugins just need to supply the pure content. The + wrapper div will have the additional classes and styles applied as defined via the configuration through :func:`get_template_configs`. + + .. versionadded:: 1.9.0 + Wizards Plugins may define wizard dialogs to display to the user if necessary (e.g. in case of missing information that needs to be queried from the user to make the plugin work). Note that with the current implementation, all @@ -518,12 +530,22 @@ class TemplatePlugin(OctoPrintPlugin, ReloadNeedingPlugin): .. list-table:: :widths: 5 95 - * - classes_link - - Like ``classes`` but only applied to the link in the navigation. * - classes_content - Like ``classes`` but only applied to the content pane itself. + * - styles_content + - Like ``styles`` but only applied to the content pane itself. + * - classes_link + - Like ``classes`` but only applied to the link in the navigation. * - styles_link - Like ``styles`` but only applied to the link in the navigation. + + ``webcam`` type + + .. list-table:: + :widths: 5 95 + + * - classes_content + - Like ``classes`` but only applied to the content pane itself. * - styles_content - Like ``styles`` but only applied to the content pane itself. diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index 8a43d33dc..bb0dcb1eb 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -38,7 +38,6 @@ class ActionCommandPromptPlugin( octoprint.plugin.SimpleApiPlugin, octoprint.plugin.TemplatePlugin, ): - COMMAND = "M876" CAP_PROMPT_SUPPORT = "PROMPT_SUPPORT" diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py index f0e713b9c..15f52ca3e 100644 --- a/src/octoprint/plugins/announcements/__init__.py +++ b/src/octoprint/plugins/announcements/__init__.py @@ -36,7 +36,6 @@ class AnnouncementPlugin( octoprint.plugin.TemplatePlugin, octoprint.plugin.EventHandlerPlugin, ): - # noinspection PyMissingConstructor def __init__(self): self._cached_channel_configs = None diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 129e51859..a721aa7d0 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -60,7 +60,6 @@ class BackupPlugin( octoprint.plugin.StartupPlugin, octoprint.plugin.WizardPlugin, ): - _pip_caller = None _backup_in_progress = threading.Lock() @@ -168,7 +167,6 @@ class BackupPlugin( @no_firstrun_access @Permissions.PLUGIN_BACKUP_ACCESS.require(403) def create_backup(self): - data = flask.request.json exclude = data.get("exclude", []) filename = self._build_backup_filename(settings=self._settings) @@ -922,7 +920,6 @@ class BackupPlugin( ) with cls._backup_in_progress: - if name is None: name = cls._build_backup_filename(settings) @@ -971,7 +968,9 @@ class BackupPlugin( final_path = os.path.join(datafolder, name) own_folder = datafolder - defaults = [os.path.join(basedir, "config.yaml"),] + [ + defaults = [ + os.path.join(basedir, "config.yaml"), + ] + [ os.path.join(basedir, folder) for folder in default_settings["folder"].keys() ] @@ -1179,7 +1178,6 @@ class BackupPlugin( on_restore_start(path) try: - with zipfile.ZipFile(path, "r") as zip: # read metadata try: diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index 9a9f27c2c..6b94247c1 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -16,7 +16,6 @@ class CoreWizardPlugin( octoprint.plugin.BlueprintPlugin, Subwizards, ): - # ~~ TemplatePlugin API def get_template_configs(self): diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py index 6e617bd78..62f07de93 100644 --- a/src/octoprint/plugins/discovery/__init__.py +++ b/src/octoprint/plugins/discovery/__init__.py @@ -42,7 +42,6 @@ class DiscoveryPlugin( octoprint.plugin.BlueprintPlugin, octoprint.plugin.SettingsPlugin, ): - ssdp_multicast_addr = "239.255.255.250" # IPv6: ff0X::c ssdp_multicast_port = 1900 @@ -688,7 +687,6 @@ class DiscoveryPlugin( ) class Request(BaseHTTPRequestHandler): - # noinspection PyMissingConstructor def __init__(self, request_text): self.rfile = BytesIO(request_text) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index 00d89cffc..5b49120f8 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -496,8 +496,8 @@ $(function () { }; self._configureContainerElement = function (containerElement) { - // Prevent the default browser action for the mouse wheel down event. The desired behavor is to have the - // gocde canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser + // Prevent the default browser action for the mouse wheel down event. The desired behavior is to have the + // gcode canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser // will also scroll the entire page. containerElement.mousedown(function (event) { // Middle mouse button diff --git a/src/octoprint/plugins/logging/__init__.py b/src/octoprint/plugins/logging/__init__.py index 5e3f2ec58..41f40e93d 100644 --- a/src/octoprint/plugins/logging/__init__.py +++ b/src/octoprint/plugins/logging/__init__.py @@ -23,7 +23,6 @@ class LoggingPlugin( octoprint.plugin.TemplatePlugin, octoprint.plugin.BlueprintPlugin, ): - # Additional permissions hook def get_additional_permissions(self): diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 52773ca10..f715ed19d 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -114,7 +114,6 @@ class PluginManagerPlugin( octoprint.plugin.BlueprintPlugin, octoprint.plugin.EventHandlerPlugin, ): - ARCHIVE_EXTENSIONS = (".zip", ".tar.gz", ".tgz", ".tar", ".gz", ".whl") PYTHON_EXTENSIONS = (".py",) JSON_EXTENSIONS = (".json",) @@ -1823,7 +1822,6 @@ class PluginManagerPlugin( additional_args = self._settings.get(["pip_args"]) if additional_args is not None: - inapplicable_arguments = self.__class__.PIP_INAPPLICABLE_ARGUMENTS.get( args[0], list() ) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 03dc48326..7c7b599c2 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -230,7 +230,6 @@ class SoftwareUpdatePlugin( or self._configured_checks is None or self._check_overlays_stale ): - self._refresh_configured_checks = False overlays = self._get_check_overlays() @@ -933,7 +932,6 @@ class SoftwareUpdatePlugin( return 9 def on_settings_migrate(self, target, current=None): - if current is None or current < 6: # up until & including config version 5 we didn't set the method parameter for the octoprint check # configuration @@ -1656,7 +1654,6 @@ class SoftwareUpdatePlugin( continue for future in futures.as_completed(futures_to_result): - target, populated_check = futures_to_result[future] if future.exception() is not None: self._logger.error( @@ -2033,7 +2030,6 @@ class SoftwareUpdatePlugin( return to_be_updated, check_data def _update_worker(self, checks, check_targets, force): - restart_type = None credentials = self._settings.get(["credentials"], merged=True) diff --git a/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py b/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py index 6612e9296..6daf17ead 100644 --- a/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py +++ b/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py @@ -231,7 +231,7 @@ def _rescue_changes(git_executable, folder): ) ) - with open(patch, "wt", encoding="utf-8", errors="replace") as f: + with open(patch, "w", encoding="utf-8", errors="replace") as f: for line in stdout: f.write(line) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index d8e05e52f..abe0a1e7a 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -1817,7 +1817,7 @@ class VirtualPrinter: handle = None try: - handle = open(file, "wt", encoding="utf-8") + handle = open(file, "w", encoding="utf-8") except Exception: self._send("error writing to file") self._writingToSdHandle = handle @@ -2150,7 +2150,7 @@ class VirtualEEPROM: else: # no eeprom file, make new one with defaults data = self.get_default_settings() - with open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file: + with open(self._eeprom_file_path, "w", encoding="utf-8") as eeprom_file: eeprom_file.write(to_unicode(json.dumps(data))) return data @@ -2261,7 +2261,7 @@ class VirtualEEPROM: def save_settings(self): # M500 behind-the-scenes - with open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file: + with open(self._eeprom_file_path, "w", encoding="utf-8") as eeprom_file: eeprom_file.write(to_unicode(json.dumps(self._eeprom))) def read_settings(self): diff --git a/src/octoprint/printer/estimation.py b/src/octoprint/printer/estimation.py index 90b18ea08..76ac45bd3 100644 --- a/src/octoprint/printer/estimation.py +++ b/src/octoprint/printer/estimation.py @@ -197,7 +197,6 @@ class PrintTimeEstimator: class TimeEstimationHelper: - STABLE_THRESHOLD = 0.1 STABLE_COUNTDOWN = 250 STABLE_ROLLING_WINDOW = 250 diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 72e9a2e6f..ebdfea124 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -360,7 +360,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): for name, hook in self._handle_connect_hooks.items(): try: if hook( - self, port=port, baudrate=baudrate, profile=profile, *args, **kwargs + self, *args, port=port, baudrate=baudrate, profile=profile, **kwargs ): self._logger.info(f"Connect signalled as handled by plugin {name}") return @@ -403,7 +403,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._firmware_info = None def get_transport(self, *args, **kwargs): - if self._comm is None: return None diff --git a/src/octoprint/schema/webcam/__init__.py b/src/octoprint/schema/webcam/__init__.py index d1c04895f..18a223dc0 100644 --- a/src/octoprint/schema/webcam/__init__.py +++ b/src/octoprint/schema/webcam/__init__.py @@ -15,7 +15,6 @@ class RatioEnum(str, Enum): @with_attrs_docs class WebcamCompatibility(BaseModel): - streamTimeout: int = 5 """The timeout of the stream in seconds""" @@ -43,7 +42,6 @@ class WebcamCompatibility(BaseModel): @with_attrs_docs class Webcam(BaseModel): - name: str """Identifier of this webcam""" diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index fcd020b7c..124cb3365 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -2741,10 +2741,10 @@ class Server: permission = PluginOctoPrintPermission( permission_name(plugin_info.name, definition), description, + *roles_and_permissions, plugin=plugin_info.key, dangerous=dangerous, default_groups=default_groups, - *roles_and_permissions, ) setattr( octoprint.access.permissions.Permissions, @@ -2752,10 +2752,10 @@ class Server: PluginOctoPrintPermission( permission_name(plugin_info.name, definition), description, + *roles_and_permissions, plugin=plugin_info.key, dangerous=dangerous, default_groups=default_groups, - *roles_and_permissions, ), ) diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index 7d647e4fc..36f8c75f0 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -1289,9 +1289,7 @@ def deleteGcodeFile(filename, target): def _abortWithException(error): if type(error) is StorageError: - logging.getLogger(__name__).error( - f"{error.message}: {error.code}", exc_info=error.cause - ) + logging.getLogger(__name__).error(f"{error}: {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: @@ -1311,7 +1309,7 @@ def _abortWithException(error): elif error.code == StorageError.UNKNOWN: abort(500, description=str(error.cause).split(":")[0]) else: - abort(500, description=error.message) + abort(500, description=error) else: logging.getLogger(__name__).exception(error) abort(500, description=str(error).split(":")[0]) diff --git a/src/octoprint/server/api/languages.py b/src/octoprint/server/api/languages.py index 714f1229f..fef19f9bb 100644 --- a/src/octoprint/server/api/languages.py +++ b/src/octoprint/server/api/languages.py @@ -153,7 +153,6 @@ def uploadLanguagePack(): @no_firstrun_access @Permissions.SETTINGS.require(403) def deleteInstalledLanguagePack(locale, pack): - if pack == "_core": target_path = os.path.join(settings().getBaseFolder("translations"), locale) else: diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index f718f3ddf..ae5f907a8 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -274,7 +274,6 @@ class ReverseProxiedEnvironment: server=None, port=None, ): - # sensible defaults if header_prefix is None: header_prefix = ["x-script-name", "x-forwarded-prefix"] @@ -1723,7 +1722,6 @@ class PluginAssetResolver(flask_assets.FlaskResolver): class SettingsCheckUpdater(webassets.updater.BaseUpdater): - updater = "always" def __init__(self): diff --git a/src/octoprint/server/util/sockjs.py b/src/octoprint/server/util/sockjs.py index f6aa9a971..3140887d7 100644 --- a/src/octoprint/server/util/sockjs.py +++ b/src/octoprint/server/util/sockjs.py @@ -77,7 +77,6 @@ class PrinterStateConnection( LoginStatusListener, GroupChangeListener, ): - _event_permissions = { Events.USER_LOGGED_IN: [Permissions.ADMIN], Events.USER_LOGGED_OUT: [Permissions.ADMIN], diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index 0957fb577..b4be6a6d9 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -92,7 +92,6 @@ def fix_websocket_check_origin(): class RequestlessExceptionLoggingMixin(tornado.web.RequestHandler): - LOG_REQUEST = False def log_exception(self, typ, value, tb, *args, **kwargs): @@ -1616,7 +1615,6 @@ class SystemInfoBundleHandler(CorsSupportMixin, tornado.web.RequestHandler): class GlobalHeaderTransform(tornado.web.OutputTransform): - HEADERS = {} FORCED_HEADERS = {} REMOVED_HEADERS = [] diff --git a/src/octoprint/settings/__init__.py b/src/octoprint/settings/__init__.py index 9da25abcb..0e0ceab02 100644 --- a/src/octoprint/settings/__init__.py +++ b/src/octoprint/settings/__init__.py @@ -961,7 +961,6 @@ class Settings: self.remove_overlay(key) if deprecated is not None: - self._logger.debug( f"Marking all (recursive) paths in this overlay as deprecated: {overlay}" ) @@ -2099,7 +2098,7 @@ def _validate_folder(folder, create=True, check_writable=True, deep_check_writab # to determine whether things are *actually* writable testfile = os.path.join(folder, ".testballoon.txt") try: - with open(testfile, "wt", encoding="utf-8") as f: + with open(testfile, "w", encoding="utf-8") as f: f.write("test") os.remove(testfile) except Exception: diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 35784ddde..0f97b1da2 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -1008,6 +1008,11 @@ $(function () { return; } + if (self.webcamCompat.hasOwnProperty(observable)) { + // webcam compat layer, skip + return; + } + if (mapping && mapping[key] && _.isFunction(mapping[key])) { result[key] = mapping[key](); flag = true; diff --git a/src/octoprint/systemcommands/__init__.py b/src/octoprint/systemcommands/__init__.py index cf91b9db3..b281c329d 100644 --- a/src/octoprint/systemcommands/__init__.py +++ b/src/octoprint/systemcommands/__init__.py @@ -23,7 +23,6 @@ def system_command_manager(): class SystemCommandManager: - SERVER_RESTART_COMMAND = "serverRestartCommand" SYSTEM_RESTART_COMMAND = "systemRestartCommand" SYSTEM_SHUTDOWN_COMMAND = "systemShutdownCommand" diff --git a/src/octoprint/timelapse.py b/src/octoprint/timelapse.py index 4d7360ca1..8483a9f41 100644 --- a/src/octoprint/timelapse.py +++ b/src/octoprint/timelapse.py @@ -536,7 +536,7 @@ class Timelapse: eventManager().subscribe(Events.PRINT_FAILED, self.on_print_done) eventManager().subscribe(Events.PRINT_DONE, self.on_print_done) eventManager().subscribe(Events.PRINT_RESUMED, self.on_print_resumed) - for (event, callback) in self.event_subscriptions(): + for event, callback in self.event_subscriptions(): eventManager().subscribe(event, callback) @property @@ -560,7 +560,7 @@ class Timelapse: eventManager().unsubscribe(Events.PRINT_FAILED, self.on_print_done) eventManager().unsubscribe(Events.PRINT_DONE, self.on_print_done) eventManager().unsubscribe(Events.PRINT_RESUMED, self.on_print_resumed) - for (event, callback) in self.event_subscriptions(): + for event, callback in self.event_subscriptions(): eventManager().unsubscribe(event, callback) def on_print_started(self, event, payload): @@ -951,7 +951,6 @@ class TimedTimelapse(Timelapse): class TimelapseRenderJob: - render_job_lock = threading.RLock() def __init__( diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 00ca0bd23..907db9cc3 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -887,7 +887,6 @@ def dict_filter(dictionary, filter_function): # Source: http://stackoverflow.com/a/6190500/562769 class DefaultOrderedDict(collections.OrderedDict): def __init__(self, default_factory=None, *a, **kw): - if default_factory is not None and not callable(default_factory): raise TypeError("first argument must be callable") collections.OrderedDict.__init__(self, *a, **kw) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 3ab1afed7..2be15d04e 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2714,7 +2714,6 @@ class MachineCom: or line.startswith("T0:") or ((" B:" in line or line.startswith("B:")) and "A:" not in line) ): - if ( not disable_external_heatup_detection and not self._temperature_autoreporting @@ -3049,7 +3048,6 @@ class MachineCom: else: self._consecutive_not_sd_printing = 0 if self.isSdFileSelected(): - # If we are not yet sd printing, the current does not equal the total, is larger # than zero and has increased since the last time we saw a position report, then # yes, this looks like we just started printing due to an external trigger. @@ -4485,7 +4483,7 @@ class MachineCom: enqueued_something = False # process all but the last ... - for (cmd, cmd_type, gcode, subcode, tags) in results: + for cmd, cmd_type, gcode, subcode, tags in results: enqueued_something = ( process(cmd, cmd_type, gcode, subcode, tags=tags) or enqueued_something diff --git a/src/octoprint/util/commandline.py b/src/octoprint/util/commandline.py index b6f8c4791..0601b5d19 100644 --- a/src/octoprint/util/commandline.py +++ b/src/octoprint/util/commandline.py @@ -53,6 +53,7 @@ def clean_ansi(line: Union[str, bytes]) -> Union[str, bytes]: warnings.warn( "Calling clean_ansi with bytes is deprecated, call with str instead", DeprecationWarning, + stacklevel=2, ) return to_bytes(_ANSI_REGEX.sub("", to_unicode(line))) return _ANSI_REGEX.sub("", line) diff --git a/src/octoprint/util/version.py b/src/octoprint/util/version.py index ad016e5d7..34ffa00bc 100644 --- a/src/octoprint/util/version.py +++ b/src/octoprint/util/version.py @@ -219,7 +219,6 @@ def is_prerelease(version): def normalize_version(version): - # Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072) if version.endswith("+"): version = version[:-1] diff --git a/src/octoprint/util/yaml.py b/src/octoprint/util/yaml.py index d36f652c4..3b9a5561b 100644 --- a/src/octoprint/util/yaml.py +++ b/src/octoprint/util/yaml.py @@ -31,7 +31,7 @@ def load_from_file( def _save_to_file_base(data, file=None, path=None, pretty=False, **kwargs): if path is not None: assert file is None - with open(path, "wt", encoding="utf-8") as f: + with open(path, "w", encoding="utf-8") as f: return _save_to_file_base(data, file=f, pretty=pretty, **kwargs) if file is not None: diff --git a/tests/filemanager/test_localstorage.py b/tests/filemanager/test_localstorage.py index f825c8e67..97d226628 100644 --- a/tests/filemanager/test_localstorage.py +++ b/tests/filemanager/test_localstorage.py @@ -833,7 +833,7 @@ class LocalStorageTest(unittest.TestCase): # prepare import yaml - with open(yaml_path, "wt") as f: + with open(yaml_path, "w") as f: yaml.safe_dump(metadata, f) # migrate diff --git a/tests/playwright/fixtures.js b/tests/playwright/fixtures.js index 8a1d13b5a..641be78d6 100644 --- a/tests/playwright/fixtures.js +++ b/tests/playwright/fixtures.js @@ -8,10 +8,10 @@ const credentials = { const expect = base.expect; exports.test = base.test.extend({ - loginApi: async ({context}, use) => { + loginApi: async ({context, baseURL}, use) => { const loginApi = { login: async (username, password) => { - return await context.request.post("/api/login", { + return await context.request.post(baseURL + "/api/login", { data: { user: username, pass: password @@ -20,7 +20,7 @@ exports.test = base.test.extend({ }, logout: async () => { - return await context.request.post("/api/logout"); + return await context.request.post(baseURL + "/api/logout"); }, loginDefault: async () => { @@ -36,12 +36,12 @@ exports.test = base.test.extend({ await use(loginApi); }, - connectionApi: async ({context}, use) => { + connectionApi: async ({context, baseURL}, use) => { const connectionApi = { connect: async (port, baudrate) => { port = port || "AUTO"; baudrate = baudrate || 0; - return await context.request.post("/api/connection", { + return await context.request.post(baseURL + "/api/connection", { data: { command: "connect", port: port, @@ -51,7 +51,7 @@ exports.test = base.test.extend({ }, disconnect: async () => { - return await context.request.post("/api/connection", { + return await context.request.post(baseURL + "/api/connection", { data: { command: "disconnect" } @@ -61,10 +61,12 @@ exports.test = base.test.extend({ await use(connectionApi); }, - filesApi: async ({context}, use) => { + filesApi: async ({context, baseURL}, use) => { const filesApi = { ensureFileUnknown: async (location, name) => { - return await context.request.delete(`/api/files/${location}/${name}`); + return await context.request.delete( + baseURL + `/api/files/${location}/${name}` + ); } }; await use(filesApi); @@ -74,16 +76,16 @@ exports.test = base.test.extend({ await use(credentials); }, - ui: async ({page, util, loginApi}, use) => { + ui: async ({page, util, loginApi, baseURL}, use) => { const ui = { gotoLogin: async () => { - await page.goto("/?l10n=en"); + await page.goto(baseURL + "/?l10n=en"); await ui.loginHasLoaded(); }, gotoLoggedInCore: async () => { await loginApi.loginDefault(); - await page.goto("/?l10n=en"); + await page.goto(baseURL + "/?l10n=en"); await ui.coreHasLoaded(); }, diff --git a/tests/settings/test_settings.py b/tests/settings/test_settings.py index 8112f48a9..ce282d3bd 100644 --- a/tests/settings/test_settings.py +++ b/tests/settings/test_settings.py @@ -34,7 +34,7 @@ def _load_yaml(fname): def _dump_yaml(fname, config): - with open(fname, "wt", encoding="utf-8") as f: + with open(fname, "w", encoding="utf-8") as f: yaml.safe_dump(config, f) diff --git a/tests/test_daemon.py b/tests/test_daemon.py index d5a35d0c8..65948853f 100644 --- a/tests/test_daemon.py +++ b/tests/test_daemon.py @@ -10,7 +10,6 @@ class ExpectedExit(BaseException): class DaemonTest(unittest.TestCase): def setUp(self): - run_method = mock.MagicMock() echo_method = mock.MagicMock() error_method = mock.MagicMock() @@ -19,10 +18,10 @@ class DaemonTest(unittest.TestCase): def run(self): run_method() - def echo(cls, line): + def echo(self, line): echo_method(line) - def error(cls, line): + def error(self, line): error_method(line) self.pidfile = "/my/pid/file" @@ -132,8 +131,8 @@ class DaemonTest(unittest.TestCase): mock_open.mock_calls, [ mock.call(mock_devnull, encoding="utf-8"), - mock.call(mock_devnull, "at+", encoding="utf-8"), - mock.call(mock_devnull, "at+", encoding="utf-8"), + mock.call(mock_devnull, "a+", encoding="utf-8"), + mock.call(mock_devnull, "a+", encoding="utf-8"), ], ) self.assertListEqual( @@ -448,7 +447,7 @@ class DaemonTest(unittest.TestCase): self.daemon.set_pid(pid) # assert - m.assert_called_once_with(self.pidfile, "wt+", encoding="utf-8") + m.assert_called_once_with(self.pidfile, "w+", encoding="utf-8") handle = m() handle.write.assert_called_once_with(f"{pid}\n") @@ -461,7 +460,7 @@ class DaemonTest(unittest.TestCase): self.daemon.set_pid(pid) # assert - m.assert_called_once_with(self.pidfile, "wt+", encoding="utf-8") + m.assert_called_once_with(self.pidfile, "w+", encoding="utf-8") handle = m() handle.write.assert_called_once_with(f"{pid}\n") diff --git a/tests/timelapse/test_timelapse_helpers.py b/tests/timelapse/test_timelapse_helpers.py index 1129dbb38..c9c96c14c 100644 --- a/tests/timelapse/test_timelapse_helpers.py +++ b/tests/timelapse/test_timelapse_helpers.py @@ -129,7 +129,6 @@ class TimelapseTest(unittest.TestCase): @mock.patch("os.scandir") def test_get_finished_timelapses(self, mock_listdir): - ## prepare mocked_path = "/path/to/timelapse" @@ -215,7 +214,6 @@ class TimelapseTest(unittest.TestCase): return result def test_ffmpeg_parse(self): - # Test strings noChange1Str = " built on Jan 7 2014 22:07:02 with gcc 4.8.2 (GCC)" durationStr = ( diff --git a/tests/util/test_file_helpers.py b/tests/util/test_file_helpers.py index dba10debc..cb15f7dfb 100644 --- a/tests/util/test_file_helpers.py +++ b/tests/util/test_file_helpers.py @@ -554,7 +554,7 @@ class IsHiddenPathTest(unittest.TestCase): "path_always_hidden", ): path = getattr(self, attr) - with open(path, "wt+", encoding="utf-8") as f: + with open(path, "w+", encoding="utf-8") as f: f.write(attr) if sys.platform == "win32":