diff --git a/.github/workflows/issue_labeler.yml b/.github/workflows/issue_labeler.yml index a8842872f..5b6e026e7 100644 --- a/.github/workflows/issue_labeler.yml +++ b/.github/workflows/issue_labeler.yml @@ -1,10 +1,10 @@ name: "Issue Labeler" on: issues: - types: [opened, edited] + types: [opened, edited, closed, reopened] jobs: - apply-label: + label-opened-and-edited: runs-on: ubuntu-latest steps: - uses: actions/github-script@v2 @@ -12,19 +12,50 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | let labels = []; + let setLabels = false; + context.payload.issue.labels.forEach(label => { labels.push(label.name) }); - if (context.payload.issue.title.match(/\[request\]|feature request/i)) { - labels.push('type:request'); - } - if (context.payload.issue.title.match(/\[brainstorming\]/i)) { - labels.push('type:brainstorming'); - } - if (context.payload.issue.title.match(/\[rc feedback\]/i)) { - labels.push('type:rc feedback'); + switch (context.payload.action) { + + case 'opened': + case 'edited': { + if (context.payload.issue.title.match(/\[request\]|feature request/i)) { + labels.push('request'); + labels = labels.filter(label => label !== 'triage'); + setLabels = true; + } + if (context.payload.issue.title.match(/\[rc feedback\]/i)) { + labels.push('rc feedback'); + labels = labels.filter(label => label !== 'triage'); + setLabels = true; + } + + if (labels.length === 0) { + labels.push('triage'); + setLabels = true; + } + break; + } + + case 'closed': { + if (labels.includes('bug') || labels.includes('request') || labels.includes('improvement')) { + labels.push('done'); + setLabels = true; + } + break; + } + + case 'reopened': { + if (labels.includes('done')) { + labels = labels.filter(label => label !== 'done'); + setLabels = true; + } + break; + } } - if (labels.length > 0) { - github.issues.addLabels({ + if (setLabels) { + github.issues.setLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a90519e68..c58b5ea58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,8 +5,12 @@ repos: hooks: - id: end-of-file-fixer - id: trailing-whitespace + - id: check-case-conflict + - id: check-json - id: check-yaml - id: check-toml + - id: check-merge-conflict + - id: fix-encoding-pragma - repo: https://github.com/OctoPrint/codemods rev: main hooks: @@ -32,6 +36,8 @@ repos: rev: 3.8.1 hooks: - id: flake8 + additional_dependencies: + - flake8-bugbear - repo: https://github.com/prettier/prettier rev: master hooks: diff --git a/AUTHORS.md b/AUTHORS.md index 57335f17c..2e4c54f02 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -128,6 +128,7 @@ date of first contribution): * [Charlie Powell](https://github.com/cp2004) * [Ollis Git](https://github.com/OllisGit) * [Sophist](https://github.com/Sophist-UK) + * [Manuel McLure](https://github.com/ManuelMcLure) 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/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..ba199875d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +OctoPrint's Code of Conduct can be found at [octoprint.org/conduct/](https://octoprint.org/conduct/). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 068ea1c0a..68c62a498 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -360,8 +360,7 @@ and branching strategy. An [automatic build workflow](https://github.com/OctoPrint/OctoPrint/actions?query=workflow%3ABuild) is in place that will run these checks - if they fail your PR will be marked accordingly. 10. **Test your changes thoroughly**. That also means testing with usage - scenarios you don't normally use, e.g. if you only use access control, test - without and vice versa. If you only test with your printer, test with the + scenarios you don't normally use. If you only test with your printer, test with the virtual printer and vice versa. State in your pull request how you tested your changes. Ideally **add unit tests** - OctoPrint severely lacks in that department, but we are trying to change that, so any new code already covered diff --git a/README.md b/README.md index 1dc986a27..c23ee8ef4 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,20 @@ -# OctoPrint +

OctoPrint's logo

-![GitHub release](https://img.shields.io/github/v/release/OctoPrint/OctoPrint?logo=github&logoColor=white) -![PyPI](https://img.shields.io/pypi/v/OctoPrint?logo=python&logoColor=white) -[![PyPI pyversions](https://img.shields.io/pypi/pyversions/octoprint.svg)](https://pypi.python.org/pypi/octoprint/) -![Build status](https://img.shields.io/github/workflow/status/OctoPrint/OctoPrint/Build) -[![Community Forum](https://img.shields.io/discourse/users?logo=discourse&logoColor=white&server=https%3A%2F%2Fcommunity.octoprint.org)](https://community.octoprint.org) -[![Discord](https://img.shields.io/discord/704958479194128507?label=discord&logo=discord&logoColor=white)](https://discord.octoprint.org) -[![Twitter Follow](https://img.shields.io/twitter/follow/OctoPrint3d.svg?style=social&label=Follow)](https://twitter.com/OctoPrint3d) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/) -[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) +

OctoPrint

+

+ GitHub release + PyPI + Build status + Community Forum + Discord + Twitter Follow + Contributor Covenant + Code style: black + Code style: prettier + Imports: isort + pre-commit +

OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html). @@ -31,7 +34,7 @@ The official plugin repository can be reached at [plugins.octoprint.org](https:/ **OctoPrint's development wouldn't be possible without the [financial support by its community](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme). If you enjoy OctoPrint, please consider becoming a regular supporter!** -![Screenshot](http://i.imgur.com/dF3noFp.png) +![Screenshot](https://octoprint.org/assets/img/screenshot-readme.png) You are currently looking at the source code repository of OctoPrint. If you already installed it (e.g. by using the Raspberry Pi targeted distribution [OctoPi](https://github.com/guysoft/OctoPi)) and only diff --git a/docs/bundledplugins/softwareupdate.rst b/docs/bundledplugins/softwareupdate.rst index ee0cef0d8..f18a3807b 100644 --- a/docs/bundledplugins/softwareupdate.rst +++ b/docs/bundledplugins/softwareupdate.rst @@ -28,7 +28,7 @@ Settings Dialog, navigate to the Software Update section therein and once you ar wrench icon in the upper right corner. .. _fig-bundledplugins-softwareupdate-plugin-configuration: -.. figure:: ../images/bundledplugins-softwareupdate-plugin-configuration.png +.. figure:: ../images/bundledplugins-softwareupdate-configuration.png :align: center :alt: Software Update plugin configuration dialog @@ -38,21 +38,25 @@ There you can adjust the following settings: * **OctoPrint version tracking**: Whether you want to track OctoPrint *releases* or every *commit*. Usually you want to select "Release" here which is also the default, unless you are a developer. - * **OctoPrint Release Channel** (if tracking releases): The release channel of OctoPrint to track for updates. If you only want stable versions, - select "Stable" here which is also the default. "Maintenance RCs" will also allow you to update to maintenance release - candidates, "Devel RCs" will also allow you to update to development release candidates. If in doubt, leave it at - "Stable". `Read more about Release Channels here `_. - * **OctoPrint checkout folder** (if tracking git commits): This must be the path to OctoPrint's git checkout folder + * **Tracked branch** (if tracking is set to "Github Commit"): The branch that will be tracked if you set version tracking to "Github Commit". + * **OctoPrint ``pip`` target** (if tracking is set to "Release" or "Github Commit"): The argument that will be provided to ``pip`` when updating OctoPrint. + Usually you don't want to change this from its default value of ``https://github.com/OctoPrint/OctoPrint/archive/{target_version}.zip``. + * **OctoPrint checkout folder** (if tracking is set to "Local checkout"): This must be the path to OctoPrint's git checkout folder (``/home/pi/OctoPrint`` for OctoPi or `manual installs following the Raspberry Pi setup guide `_). Note that since OctoPrint 1.3.6 you will no longer need to set this to be able to update to releases, only if you want to be able to update against some bleeding edge git branch. + * **Enable ``pip`` update checks**: Whether to have OctoPrint automatically check for updates of + the ``pip`` tool that is used for updating most components. * **Version cache TTL**: The "time to live" of the cache OctoPrint will use to temporarily persist the version information for the various components registered with the plugin, so that they don't have to be queried from the internet every time you load the page. Defaults to 24h, you usually shouldn't need to change that value. + * **Show notifications to users**: Whether to display update notifications (without "Update now" button) to users that cannot + apply updates. + * **Minimum free disk space**: The minimum amount of free disk space needed in order to allow software updates to be run. More settings are available by :ref:`editing the corresponding section in config.yaml `. -That restart commands for OctoPrint and the whole server can be configured under Settings > Server. +Restart commands for OctoPrint and the whole server can be configured under Settings > Server. .. _sec-bundledplugins-softwareupdate-cli: @@ -123,9 +127,6 @@ Configuring the Plugin plugins: softwareupdate: - # the time-to-live of the version cache, in minutes - cache_ttl: 60 - # configured version check and update methods checks: # "octoprint" is reserved for OctoPrint @@ -145,6 +146,41 @@ Configuring the Plugin # used - should normally NOT be necessary and hence set pip_command: /path/to/pip + # the time-to-live of the version cache, in minutes, defaults to 24h + cache_ttl: 1440 + + # whether to show update notifications to users that cannot apply updates + notify_users: true + + # whether to ignore the system throttled state reported by the pisupport plugin and + # allow updating even when the system is not running stable - really not recommended + ignore_throttled: false + + # minimum free storage in MB for updates to be enabled + minimum_free_storage: 150 + + # URL from which to fetch check overlays + check_overlay_url: https://plugins.octoprint.org/update_check_overlay.json + + # time to live of the overlay cache, defaults to 6h + check_overlay_ttl: 360 + + # global credentials to provide to version checks + credentials: + + # GitHub API token to use for the github_release and github_commit version checks. + # Helpful if you regularly run into rate limit issues with the GitHub API using + # the default anonymous access. Use a personal access token: + # https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token + # Unset by default + github: + + # Bitbucket user name and password, used by the bitbucket_commit version check if + # provided, but only if the check doesn't specify credentials on its own. + # Unset by default + bitbucket_user: + bitbucket_password: + .. _sec-bundledplugins-softwareupdate-configuration-versionchecks: Version checks @@ -501,6 +537,28 @@ commit identifier. E.g. ``https://gist.githubusercontent.com///raw ``https://gist.githubusercontent.com///raw//my_plugin.py``. Note that these URLs will be cached by Github for a bit, so an update will not be immediately picked up. +.. _sec-bundledplugins-softwareupdate-configuration-credentials: + +Global credentials +++++++++++++++++++ + +.. versionadded:: 1.5.0 + +Starting with OctoPrint 1.5.0, the Software Update Plugin supports supplyting a GitHub +API token to use for the ``github_release`` and ``github_commit`` version check types, +to work around possible rate limit problems if a lot of checks are to be made from a single +external IP. You may create a `personal access token `_ +and configure that as ``plugins.softwareupdate.credentials.github`` via +:ref:`config.yaml ` in order to get a higher rate limit than with purely anonymous access. + +Additionally, the username and password to use with the ``bitbucket_commit`` version check +type may also be configured via ``plugins.softwareupdate.credentials.bitbucket_user`` and +``plugins.softwareupdate.credentials.bitbucket_password`` respectively. + +None of these configuration options are currently exposed on the UI and can only be used +via :ref:`config.yaml ` or the +:ref:`config command line interface `. + .. _sec-bundledplugins-softwareupdate-events: Events diff --git a/docs/configuration/cli.rst b/docs/configuration/cli.rst new file mode 100644 index 000000000..b24d13865 --- /dev/null +++ b/docs/configuration/cli.rst @@ -0,0 +1,110 @@ +.. _sec-configuration-cli: + +CLI +=== + +.. versionadded:: 1.3.0 + +OctoPrint provides a basic command line interface for manipulation of :ref:`config.yaml `: + +.. code-block:: + + $ octoprint config --help + Usage: octoprint config [OPTIONS] COMMAND [ARGS]... + + Basic config manipulation. + + Options: + --help Show this message and exit. + + Commands: + append_value Appends value to list behind config path. + effective Retrieves the full effective config. + get Retrieves value from config path. + insert_value Inserts value at index of list behind config key. + remove Removes a config path. + remove_value Removes value from list at config path. + set Sets a config path to the provided value. + +.. code-block:: + + $ octoprint config append_value --help + Usage: octoprint config append_value [OPTIONS] PATH VALUE + + Appends value to list behind config path. + + Options: + --json + --help Show this message and exit. + +.. code-block:: + + $ octoprint config effective --help + Usage: octoprint config effective [OPTIONS] + + Retrieves the full effective config. + + Options: + --json Output value formatted as JSON + --yaml Output value formatted as YAML + --raw Output value as raw string representation + --help Show this message and exit. + +.. code-block:: + + $ octoprint config get --help + Usage: octoprint config get [OPTIONS] PATH + + Retrieves value from config path. + + Options: + --json Output value formatted as JSON + --yaml Output value formatted as YAML + --raw Output value as raw string representation + --help Show this message and exit. + +.. code-block:: + + $ octoprint config insert_value --help + Usage: octoprint config insert_value [OPTIONS] PATH INDEX VALUE + + Inserts value at index of list behind config key. + + Options: + --json + --help Show this message and exit. + +.. code-block:: + + $ octoprint config remove --help + Usage: octoprint config remove [OPTIONS] PATH + + Removes a config path. + + Options: + --help Show this message and exit. + +.. code-block:: + + $ octoprint config remove_value --help + Usage: octoprint config remove_value [OPTIONS] PATH VALUE + + Removes value from list at config path. + + Options: + --json + --help Show this message and exit. + +.. code-block:: + + $ octoprint config set --help + Usage: octoprint config set [OPTIONS] PATH VALUE + + Sets a config path to the provided value. + + Options: + --bool Interpret value as bool + --float Interpret value as float + --int Interpret value as int + --json Parse value from json + --help Show this message and exit. diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index f907e96f2..c20c3e275 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -10,6 +10,7 @@ you can just create it - it will only get created by OctoPrint once you save set settings. Note that many of these settings are available from the "Settings" menu in OctoPrint itself. +They can also be configured via :ref:`config command line interface `. .. contents:: diff --git a/docs/configuration/index.rst b/docs/configuration/index.rst index 8348d8e15..5be0a0b22 100644 --- a/docs/configuration/index.rst +++ b/docs/configuration/index.rst @@ -10,3 +10,4 @@ Configuration yaml.rst config_yaml.rst logging_yaml.rst + cli.rst diff --git a/docs/events/index.rst b/docs/events/index.rst index 1054ba2c2..7fa5e733e 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -606,6 +606,32 @@ ToolChange .. versionadded:: 1.3.5 +CommandSuppressed + A command was suppressed by OctoPrint due to according configuration and will not be + sent to the printer. + + Payload: + + * ``command``: the command that was suppressed + * ``message``: a message containing an explanation of the command suppression + * ``severity``: a severity level, either ``warn`` or ``info`` - ``warn`` indicates + that the command was suppressed probably due to a misconfiguration either inside + OctoPrint or the firmware and that it should be investigated by the user + + .. versionadded:: 1.5.0 + +InvalidToolReported + The firmware reported a tool as invalid upon trying to select it. It has thus been marked + as invalid and further attempts to select said tool will result in the tool command + to get suppressed (and ``SuppressedCommand`` to be generated). + + Payload: + + * ``tool``: the tool number that was reported as invalid by the firmware + * ``fallback``: the tool number that OctoPrint will revert to + + .. versionadded:: 1.5.0 + .. _sec-events-available_events-timelapses: Timelapses diff --git a/docs/features/custom_controls.rst b/docs/features/custom_controls.rst index fa69cc435..522d392cb 100644 --- a/docs/features/custom_controls.rst +++ b/docs/features/custom_controls.rst @@ -172,9 +172,10 @@ Controls turn the button red. * - ``enabled`` - (Optional) A JavaScript snippet returning either ``true`` or ``false`` determining whether the control - should be enabled or not. This allow to override the default logic for this (disabled if printer is offline - or currently printing). The JavaScript snippet is ``eval``'d and processed in a context where the control - it is part of is provided as local variable ``data`` and the ``ControlViewModel`` is available as ``self``. + should be enabled or not. This allows to override the default logic for the enable state + of the control (disabled if printer is offline). The JavaScript snippet is ``eval``'d and processed + in a context where the control it is part of is provided as local variable ``data`` and the + ``ControlViewModel`` is available as ``self``. * - ``input`` - (Optional) A list of definitions of input parameters for a ``command`` or ``commands``, to be rendered as additional input fields. ``command``/``commands`` may contain placeholders to be replaced by the values obtained @@ -213,17 +214,28 @@ Controls - (Optional) A :ref:`regular expression ` to match against lines received from the printer to retrieve information from it (e.g. specific output). Together with ``template`` this allows rendition of received data from the printer within the UI. + + **Please also read the note below**. * - ``template`` - (Optional) A template to use for rendering the match of ``regex``. May contain placeholders in :ref:`Python Format String Syntax ` for either named groups within the regex (e.g. ``Temperature: {temperature}`` for a regex ``T:\s*(?P\d+(\.\d*)``) or positional groups within the regex (e.g. ``Position: X={0}, Y={1}, Z={2}, E={3}`` for a regex ``X:([0-9.]+) Y:([0-9.]+) Z:([0-9.]+) E:([0-9.]+)``). + + **Please also read the note below**. * - ``confirm`` - (Optional) A text to display to the user to confirm his button press. Can be used with sensitive custom controls like changing EEPROM values in order to prevent accidental clicks. The text will be displayed in a confirmation dialog like in :numref:`fig-configuration-customcontrols-confirm`. +.. note:: + + ``regex`` and ``template`` are only supported for controls that are defined through + ``config.yaml``. These control properties aren't supported for controls added only in + the frontend by the :ref:`getAdditionalControls ` + view model callback. + .. _fig-configuration-customcontrols-confirm: .. figure:: ../images/features-custom_controls-confirm.png :align: center diff --git a/docs/images/bundledplugins-softwareupdate-configuration.png b/docs/images/bundledplugins-softwareupdate-configuration.png new file mode 100644 index 000000000..e61544dcd Binary files /dev/null and b/docs/images/bundledplugins-softwareupdate-configuration.png differ diff --git a/docs/images/bundledplugins-softwareupdate-plugin-configuration.png b/docs/images/bundledplugins-softwareupdate-plugin-configuration.png deleted file mode 100644 index ba13a9973..000000000 Binary files a/docs/images/bundledplugins-softwareupdate-plugin-configuration.png and /dev/null differ diff --git a/docs/plugins/viewmodels.rst b/docs/plugins/viewmodels.rst index 33d28e9a8..dc8d9cace 100644 --- a/docs/plugins/viewmodels.rst +++ b/docs/plugins/viewmodels.rst @@ -238,6 +238,11 @@ getAdditionalControls() Your view model may return additional custom control definitions for inclusion on the "Control" tab of OctoPrint's interface. See :ref:`the custom control feature`. + .. note:: + + Controls injected from a view model do not support feedback controls (as defined by + ``regex`` and ``template``). + onSettingsShown() Called when the settings dialog is shown. diff --git a/setup.py b/setup.py index dbfbc8158..276d93ea5 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -# coding=utf-8 +# -*- coding: utf-8 -*- import os import sys diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index 6b0a1bb78..9b1c38357 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -228,12 +228,7 @@ def init_settings(basedir, configfile): try: return settings(init=True, basedir=basedir, configfile=configfile) except InvalidSettings as e: - message = "Error parsing the configuration file, it appears to be invalid YAML." - if e.line is not None and e.column is not None: - message += " The parser reported an error on line {}, column {}.".format( - e.line, e.column - ) - raise FatalStartupError(message) + raise FatalStartupError(str(e)) def preinit_logging( @@ -468,7 +463,7 @@ def init_pluginsystem( def validator(phase, plugin_info): if phase in ("before_import", "before_load", "before_enable"): - setattr(plugin_info, "safe_mode_victim", not plugin_info.bundled) + plugin_info.safe_mode_victim = not plugin_info.bundled if not plugin_info.bundled: return False return True @@ -497,7 +492,7 @@ def init_pluginsystem( plugin.needs_restart = True # plugin has a settings overlay, inject it - overlay_definition = getattr(plugin.instance, "__plugin_settings_overlay__") + overlay_definition = plugin.instance.__plugin_settings_overlay__ if isinstance(overlay_definition, (tuple, list)): overlay_definition, order = overlay_definition else: diff --git a/src/octoprint/_version.py b/src/octoprint/_version.py index c9da3f17b..5c78ec1f9 100644 --- a/src/octoprint/_version.py +++ b/src/octoprint/_version.py @@ -687,7 +687,7 @@ def get_versions(): # versionfile_source is the relative path from the top of the source # tree (where the .git directory might live) to this file. Invert # this to find the root from __file__. - for i in cfg.versionfile_source.split("/"): + for _ in cfg.versionfile_source.split("/"): root = os.path.dirname(root) except NameError: return { diff --git a/src/octoprint/access/users.py b/src/octoprint/access/users.py index 951928384..5e3115d15 100644 --- a/src/octoprint/access/users.py +++ b/src/octoprint/access/users.py @@ -35,7 +35,6 @@ class UserManager(GroupChangeListener, object): self._logger = logging.getLogger(__name__) self._session_users_by_session = {} self._sessionids_by_userid = {} - self._enabled = True if settings is None: settings = s() @@ -50,29 +49,14 @@ class UserManager(GroupChangeListener, object): self._login_status_listeners.remove(listener) def anonymous_user_factory(self): - if self.enabled: - return AnonymousUser([self._group_manager.guest_group]) - else: - return AdminUser( - [self._group_manager.admin_group, self._group_manager.user_group] - ) + return AnonymousUser([self._group_manager.guest_group]) def api_user_factory(self): return ApiUser([self._group_manager.admin_group, self._group_manager.user_group]) @property def enabled(self): - return self._enabled - - @enabled.setter - def enabled(self, value): - self._enabled = value - - def enable(self): - self._enabled = True - - def disable(self): - self._enabled = False + return True def login_user(self, user): self._cleanup_sessions() @@ -112,7 +96,7 @@ class UserManager(GroupChangeListener, object): return user def logout_user(self, user, stale=False): - if user is None or user.is_anonymous or isinstance(user, AdminUser): + if user is None or user.is_anonymous: return if isinstance(user, LocalProxy): @@ -1444,11 +1428,3 @@ class SessionUser(wrapt.ObjectProxy): class ApiUser(User): def __init__(self, groups): User.__init__(self, "_api", "", True, [], groups) - - -##~~ User object to use when access control is disabled - - -class AdminUser(User): - def __init__(self, groups): - User.__init__(self, "_admin", "", True, [], groups) diff --git a/src/octoprint/cli/client.py b/src/octoprint/cli/client.py index e84c53c91..9d9b3b00a 100644 --- a/src/octoprint/cli/client.py +++ b/src/octoprint/cli/client.py @@ -106,7 +106,7 @@ def client(ctx, apikey, host, port, httpuser, httppass, https, prefix): ) except FatalStartupError as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) click.echo("There was a fatal error initializing the client.", err=True) ctx.exit(-1) diff --git a/src/octoprint/cli/config.py b/src/octoprint/cli/config.py index 2b20039a8..fb7c960e5 100644 --- a/src/octoprint/cli/config.py +++ b/src/octoprint/cli/config.py @@ -67,7 +67,7 @@ def config(ctx): get_ctx_obj_option(ctx, "configfile", None), ) except FatalStartupError as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) click.echo("There was a fatal error initializing the settings manager.", err=True) ctx.exit(-1) @@ -87,7 +87,7 @@ def set_command(ctx, path, value, as_bool, as_float, as_int, as_json): try: value = json.loads(value) except Exception as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) ctx.exit(-1) data_type = None @@ -124,7 +124,7 @@ def append_value_command(ctx, path, value, as_json=False): try: value = json.loads(value) except Exception as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) ctx.exit(-1) current = ctx.obj.settings.get(path) @@ -153,7 +153,7 @@ def insert_value_command(ctx, path, index, value, as_json=False): try: value = json.loads(value) except Exception as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) ctx.exit(-1) current = ctx.obj.settings.get(path) @@ -181,7 +181,7 @@ def remove_value_command(ctx, path, value, as_json=False): try: value = json.loads(value) except Exception as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) ctx.exit(-1) current = ctx.obj.settings.get(path) diff --git a/src/octoprint/cli/plugins.py b/src/octoprint/cli/plugins.py index 7521ae28b..e5e283110 100644 --- a/src/octoprint/cli/plugins.py +++ b/src/octoprint/cli/plugins.py @@ -89,7 +89,7 @@ class OctoPrintPluginCommands(click.MultiCommand): self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False) ) except FatalStartupError as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) click.echo( "There was a fatal error initializing the settings or the plugin system.", err=True, diff --git a/src/octoprint/cli/server.py b/src/octoprint/cli/server.py index 5680d9177..39f7fab3b 100644 --- a/src/octoprint/cli/server.py +++ b/src/octoprint/cli/server.py @@ -262,7 +262,7 @@ def enable_safemode(ctx, **kwargs): get_ctx_obj_option(ctx, "configfile", None), ) except FatalStartupError as e: - click.echo(e.message, err=True) + click.echo(str(e), err=True) click.echo("There was a fatal error initializing the settings manager.", err=True) ctx.exit(-1) else: diff --git a/src/octoprint/cli/user.py b/src/octoprint/cli/user.py index 466e8d243..9e9a24f67 100644 --- a/src/octoprint/cli/user.py +++ b/src/octoprint/cli/user.py @@ -1,4 +1,4 @@ -# coding=utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" @@ -71,8 +71,6 @@ def user(ctx): err=True, ) user_manager = FilebasedUserManager(group_manager, settings=settings) - finally: - user_manager.enabled = settings.getBoolean(["accessControl", "enabled"]) ctx.obj.user_manager = user_manager diff --git a/src/octoprint/events.py b/src/octoprint/events.py index 2adf17db6..fd4847181 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -104,6 +104,8 @@ class Events(object): FIRMWARE_DATA = "FirmwareData" TOOL_CHANGE = "ToolChange" REGISTERED_MESSAGE_RECEIVED = "RegisteredMessageReceived" + COMMAND_SUPPRESSED = "CommandSuppressed" + INVALID_TOOL_REPORTED = "InvalidToolReported" # Timelapse CAPTURE_START = "CaptureStart" diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index a96c9b6ca..84ceff1c6 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -129,7 +129,7 @@ def get_all_extensions(subtree=None): result = [] if isinstance(subtree, dict): - for key, value in subtree.items(): + for value in subtree.values(): if isinstance(value, dict): result += get_all_extensions(value) elif isinstance(value, (ContentTypeMapping, ContentTypeDetector)): @@ -167,7 +167,7 @@ def get_content_type_mapping_for_extension(extension, subtree=None): if subtree is None: subtree = full_extension_tree() - for key, value in subtree.items(): + for value in subtree.values(): content_extension_matches = ( isinstance(value, (ContentTypeMapping, ContentTypeDetector)) and extension in value.extensions @@ -313,7 +313,7 @@ class FileManager(object): if root is not None: backlog_generator = storage_manager.analysis_backlog_for_path(path=root) - for entry, path, printer_profile in backlog_generator: + for entry, path, _ in backlog_generator: file_type = get_file_type(path)[-1] file_name = storage_manager.split_path(path) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index b46f80cef..b3010b1ec 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -1712,7 +1712,7 @@ class PluginManager(object): ) self.plugin_implementations[name] = plugin.implementation - setattr(plugin.implementation, "__timing_wrapped", True) + plugin.implementation.__timing_wrapped = True def _deactivate_plugin(self, name, plugin): for hook, definition in plugin.hooks.items(): @@ -2354,7 +2354,7 @@ class EntryPointMetadata(pkginfo.Distribution): for metadata_file in metadata_files: try: return self.entry_point.dist.get_metadata(metadata_file) - except (IOError, OSError): + except (IOError, 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 diff --git a/src/octoprint/plugins/action_command_notification/__init__.py b/src/octoprint/plugins/action_command_notification/__init__.py index a91c80155..e58007004 100644 --- a/src/octoprint/plugins/action_command_notification/__init__.py +++ b/src/octoprint/plugins/action_command_notification/__init__.py @@ -100,6 +100,7 @@ class ActionCommandNotificationPlugin( "name": gettext("Printer Notifications"), "icon": "bell-o", "styles_wrapper": ["display: none"], + "template_header": "action_command_notification_sidebar_header.jinja2", "data_bind": "visible: loginState.hasPermissionKo(access.permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW)" " && settings.settings.plugins.action_command_notification.enable()", }, diff --git a/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js b/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js index 6410639fd..c9f092d75 100644 --- a/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js +++ b/src/octoprint/plugins/action_command_notification/static/js/action_command_notification.js @@ -7,6 +7,10 @@ $(function () { self.settings = parameters[2]; self.notifications = ko.observableArray([]); + self.sortDesc = ko.observable(false); + self.sortDesc.subscribe(function () { + self._toLocalStorage(); + }); self.toDateTimeString = function (timestamp) { return formatDate(timestamp); @@ -24,7 +28,11 @@ $(function () { }; self.fromResponse = function (response) { - self.notifications(response.notifications); + var notifications = response.notifications; + if (self.sortDesc()) { + notifications.reverse(); + } + self.notifications(notifications); }; self.clear = function () { @@ -38,6 +46,11 @@ $(function () { OctoPrint.plugins.action_command_notification.clear(); }; + self.toggleSorting = function () { + self.sortDesc(!self.sortDesc()); + self.requestData(); + }; + self.onStartup = self.onUserLoggedIn = self.onUserLoggedOut = function () { self.requestData(); }; @@ -71,6 +84,20 @@ $(function () { }); } }; + + var optionsLocalStorageKey = "core.gcodeviewer.options"; + self._toLocalStorage = function () { + saveToLocalStorage(optionsLocalStorageKey, {sortDesc: self.sortDesc()}); + }; + + self._fromLocalStorage = function () { + var data = loadFromLocalStorage(optionsLocalStorageKey); + if (data["sortDesc"] !== undefined) { + self.sortDesc(!!data["sortDesc"]); + } + }; + + self._fromLocalStorage(); } OCTOPRINT_VIEWMODELS.push({ diff --git a/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 b/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 index 1118af0f3..fb2ed0200 100644 --- a/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 +++ b/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar.jinja2 @@ -5,7 +5,7 @@
- +
{{ _('There are currently no notifications from your printer.') }} diff --git a/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar_header.jinja2 b/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar_header.jinja2 new file mode 100644 index 000000000..237bd9a15 --- /dev/null +++ b/src/octoprint/plugins/action_command_notification/templates/action_command_notification_sidebar_header.jinja2 @@ -0,0 +1,11 @@ + + + diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py index e9bc9b3b5..855ac50b5 100644 --- a/src/octoprint/plugins/appkeys/__init__.py +++ b/src/octoprint/plugins/appkeys/__init__.py @@ -419,11 +419,7 @@ class AppKeysPlugin( with self._keys_lock: for user_id, data in self._keys.items(): if any(filter(lambda x: x.api_key == api_key, data)): - if self._user_manager.enabled: - return self._user_manager.find_user(userid=user_id) - elif user_id == "_admin" or user_id == "dummy": - # dummy = backwards compatible - return self._user_manager.anonymous_user_factory() + return self._user_manager.find_user(userid=user_id) return None def _api_keys_for_user(self, user_id): @@ -433,7 +429,7 @@ class AppKeysPlugin( def _all_api_keys(self): with self._keys_lock: result = [] - for user_id, keys in self._keys.items(): + for keys in self._keys.values(): result += keys return result diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 248316151..ab57aa5dc 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -969,7 +969,7 @@ class BackupPlugin( # add list of installed plugins plugins = [] plugin_folder = settings.global_get_basefolder("plugins") - for key, plugin in plugin_manager.plugins.items(): + for plugin in plugin_manager.plugins.values(): if plugin.bundled or ( isinstance(plugin.origin, FolderOrigin) and plugin.origin.folder == plugin_folder @@ -1101,14 +1101,13 @@ class BackupPlugin( with io.open(configfile, "rt", encoding="utf-8") as f: configdata = yaml.safe_load(f) - if configdata.get("accessControl", {}).get("enabled", True): - userfile = os.path.join(temp, "basedir", "users.yaml") - if not os.path.exists(userfile): - if callable(on_invalid_backup): - on_invalid_backup("Backup lacks users.yaml") - if callable(on_restore_failed): - on_restore_failed(path) - return False + userfile = os.path.join(temp, "basedir", "users.yaml") + if not os.path.exists(userfile): + if callable(on_invalid_backup): + on_invalid_backup("Backup lacks users.yaml") + if callable(on_restore_failed): + on_restore_failed(path) + return False if callable(on_log_progress): on_log_progress("Unpacked") diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index d457c5879..d5fbec327 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -105,7 +105,7 @@ class CoreWizardPlugin( return result def get_wizard_version(self): - return 3 + return 4 # ~~ helpers diff --git a/src/octoprint/plugins/corewizard/static/js/corewizard.js b/src/octoprint/plugins/corewizard/static/js/corewizard.js index c92cb9beb..ba87f2f04 100644 --- a/src/octoprint/plugins/corewizard/static/js/corewizard.js +++ b/src/octoprint/plugins/corewizard/static/js/corewizard.js @@ -9,20 +9,19 @@ $(function () { self.confirmedPassword = ko.observable(undefined); self.setup = ko.observable(false); - self.decision = ko.observable(); self.required = false; self.passwordMismatch = ko.pureComputed(function () { - return self.password() != self.confirmedPassword(); + return self.password() !== self.confirmedPassword(); }); self.validUsername = ko.pureComputed(function () { - return self.username() && self.username().trim() != ""; + return self.username() && self.username().trim() !== ""; }); self.validPassword = ko.pureComputed(function () { - return self.password() && self.password().trim() != ""; + return self.password() && self.password().trim() !== ""; }); self.validData = ko.pureComputed(function () { @@ -31,11 +30,10 @@ $(function () { ); }); - self.keepAccessControl = function () { + self.createAccount = function () { if (!self.validData()) return; var data = { - ac: true, user: self.username(), pass1: self.password(), pass2: self.confirmedPassword() @@ -43,35 +41,27 @@ $(function () { self._sendData(data); }; - self.disableAccessControl = function () { - var message = gettext( - "If you disable Access Control and your OctoPrint installation is accessible from the internet, your printer will be accessible by everyone - that also includes the bad guys!" - ); - showConfirmationDialog({ - message: message, - onproceed: function (e) { - var data = { - ac: false - }; - self._sendData(data); - } - }); - }; - self._sendData = function (data, callback) { OctoPrint.postJson("plugin/corewizard/acl", data).done(function () { self.setup(true); - self.decision(data.ac); - if (data.ac) { - // we now log the user in - var user = data.user; - var pass = data.pass1; - self.loginStateViewModel.login(user, pass, true).done(function () { - if (callback) callback(); - }); - } else { + + // we now log the user in + var user = data.user; + var pass = data.pass1; + self.loginStateViewModel.login(user, pass, true).done(function () { if (callback) callback(); - } + }); + }); + }; + + self._showDecisionNeededDialog = function () { + showMessageDialog({ + title: gettext("Please set up Access Control"), + message: gettext( + "You haven't yet set up access control. You need to setup a " + + 'username and password and click "Create Account" before ' + + "continuing." + ) }); }; @@ -85,12 +75,17 @@ $(function () { ) { return true; } - showMessageDialog({ - title: gettext("Please set up Access Control"), - message: gettext( - 'You haven\'t yet set up access control. You need to either setup a username and password and click "Keep Access Control Enabled" or click "Disable Access Control" before continuing' - ) - }); + + self._showDecisionNeededDialog(); + return false; + }; + + self.onBeforeWizardFinish = function () { + if (!self.required) return true; + + if (self.setup()) return true; + + self._showDecisionNeededDialog(); return false; }; @@ -102,14 +97,6 @@ $(function () { response.corewizard.details.acl && response.corewizard.details.acl.required; }; - - self.onWizardFinish = function () { - if (!self.required) return; - - if (!self.decision()) { - return "reload"; - } - }; } function CoreWizardWebcamViewModel(parameters) { diff --git a/src/octoprint/plugins/corewizard/subwizards.py b/src/octoprint/plugins/corewizard/subwizards.py index 0655de0e5..f88575bc7 100644 --- a/src/octoprint/plugins/corewizard/subwizards.py +++ b/src/octoprint/plugins/corewizard/subwizards.py @@ -63,10 +63,10 @@ class WebcamSubwizard(object): # noinspection PyUnresolvedReferences,PyMethodMayBeStatic class AclSubwizard(object): def _is_acl_wizard_firstrunonly(self): - return True + return False def _is_acl_wizard_required(self): - return self._user_manager.enabled and not self._user_manager.has_been_customized() + return not self._user_manager.has_been_customized() def _get_acl_wizard_details(self): return {"required": self._is_acl_wizard_required()} @@ -81,11 +81,11 @@ class AclSubwizard(object): def acl_wizard_api(self): from flask import abort, request - from octoprint.server.api import NO_CONTENT, valid_boolean_trues + from octoprint.server.api import NO_CONTENT if ( not self._settings.global_get(["server", "firstRun"]) - or self._user_manager.has_been_customized() + and self._user_manager.has_been_customized() ): abort(404) @@ -94,17 +94,12 @@ class AclSubwizard(object): data = request.values if ( - "ac" in data - and data["ac"] in valid_boolean_trues - and "user" in data + "user" in data and "pass1" in data and "pass2" in data and data["pass1"] == data["pass2"] ): # configure access control - self._settings.global_set_boolean(["accessControl", "enabled"], True) - self._user_manager.enable() - self._user_manager.add_user( data["user"], data["pass1"], @@ -113,10 +108,6 @@ class AclSubwizard(object): [USER_GROUP, ADMIN_GROUP], overwrite=True, ) - elif "ac" in data and data["ac"] not in valid_boolean_trues: - # disable access control - self._settings.global_set_boolean(["accessControl", "enabled"], False) - self._user_manager.disable() self._settings.save() return NO_CONTENT diff --git a/src/octoprint/plugins/corewizard/templates/corewizard_acl_wizard.jinja2 b/src/octoprint/plugins/corewizard/templates/corewizard_acl_wizard.jinja2 index 0fae5bcdd..1537989d2 100644 --- a/src/octoprint/plugins/corewizard/templates/corewizard_acl_wizard.jinja2 +++ b/src/octoprint/plugins/corewizard/templates/corewizard_acl_wizard.jinja2 @@ -1,26 +1,10 @@

{{ _('Access Control') }}

-{% trans safe_remote_url='https://octoprint.org/blog/2018/09/03/safe-remote-access/' %}

- Please read the following, it is very important for your printer's health! -

-

- OctoPrint by default ships with Access Control enabled, meaning you won't be able to do anything with the - printer unless you login first as a configured user. This is to prevent strangers - possibly with - malicious intent - to gain access to your printer via an untrustworthy network - and using it in such a way that it is damaged or worse (i.e. causes a fire). -

-

- If you plan on accessing OctoPrint remotely over the internet, you should not only rely on the built-in - Access Control mechanisms however - - take additional precautions. - Your OctoPrint enabled printer is a critical home appliance you really should not give anyone who happens to be - connected to the internet access to - even read-only! An instance available publicly on the internet - will be found, and people will try to break it open. -

-

- It looks like you haven't configured access control yet. Please set up a username and password for the - initial administrator account who will have full access to both the printer and OctoPrint's settings, then click - on "Keep Access Control Enabled": +{% trans %}

+ It looks like you haven't configured access control yet, which is now mandatory. + Please set up a username and password for the + initial administrator account who will have full access to both the printer and + OctoPrint's settings:

{% endtrans %}
@@ -42,26 +26,7 @@ {{ _('Passwords do not match') }}
+ -{% trans %}

- Note: In case that your OctoPrint installation is only accessible from within a trustworthy local network and you don't - need Access Control for other reasons, you may alternatively disable Access Control. You should only - do this if you are absolutely certain that only people you know and trust will be able to connect to it. -

-

- Do NOT underestimate the risk of access from the internet to your printer and OctoPrint instance! -

{% endtrans %} - - - - diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index f73feec88..50b0ee154 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -1,4 +1,4 @@ -# coding=utf-8 +# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" @@ -46,8 +46,8 @@ IGNORED_EXCEPTIONS = [ # IOErrors of any kind due to a full file system ( IOError, - lambda exc, logger, plugin, cb: getattr(exc, "errno") - and exc.errno in (getattr(errno, "ENOSPC"),), + lambda exc, logger, plugin, cb: exc.errorgetattr(exc, "errno") # noqa: B009 + and exc.errno in (getattr(errno, "ENOSPC"),), # noqa: B009 ), # RequestExceptions of any kind requests.exceptions.RequestException, diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index eaf5896d1..6fb9ba4e3 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -860,41 +860,25 @@ $(function () { var optionsLocalStorageKey = "core.gcodeviewer.options"; self._toLocalStorage = function () { - if (!Modernizr.localstorage) return; - - var current = {}; - current["centerViewport"] = self.renderer_centerViewport(); - current["zoomOnModel"] = self.renderer_zoomOnModel(); - current["showMoves"] = self.renderer_showMoves(); - current["showRetracts"] = self.renderer_showRetracts(); - current["showPrinthead"] = self.renderer_showPrinthead(); - current["showPrevious"] = self.renderer_showPrevious(); - current["showCurrent"] = self.renderer_showCurrent(); - current["showNext"] = self.renderer_showNext(); - current["showFullsize"] = self.renderer_showFullSize(); - current["showBoundingBox"] = self.renderer_showBoundingBox(); - current["hideEmptyLayers"] = self.reader_hideEmptyLayers(); - current["sortLayers"] = self.reader_sortLayers(); - - localStorage[optionsLocalStorageKey] = JSON.stringify(current); + saveToLocalStorage(optionsLocalStorageKey, { + centerViewPort: self.renderer_centerViewport(), + zoomOnModel: self.renderer_zoomOnModel(), + showMoves: self.renderer_showMoves(), + showRetracts: self.renderer_showRetracts(), + showPrinthead: self.renderer_showPrinthead(), + showPrevious: self.renderer_showPrevious(), + showCurrent: self.renderer_showCurrent(), + showNext: self.renderer_showNext(), + showFullsize: self.renderer_showFullSize(), + showBoundingBox: self.renderer_showBoundingBox(), + hideEmptyLayers: self.reader_hideEmptyLayers(), + sortLayers: self.reader_sortLayers() + }); }; self._fromLocalStorage = function () { self.resetOptions(); - if (!Modernizr.localstorage) return; - - var currentString = localStorage[optionsLocalStorageKey]; - var current; - if (currentString === undefined) { - current = {}; - } else { - try { - current = JSON.parse(currentString); - } catch (ex) { - current = {}; - } - } - + var current = loadFromLocalStorage(optionsLocalStorageKey); if (current["centerViewport"] !== undefined) self.renderer_centerViewport(current["centerViewport"]); if (current["zoomOnModel"] !== undefined) diff --git a/src/octoprint/plugins/pi_support/__init__.py b/src/octoprint/plugins/pi_support/__init__.py index 721b2cdcd..b46e19820 100644 --- a/src/octoprint/plugins/pi_support/__init__.py +++ b/src/octoprint/plugins/pi_support/__init__.py @@ -252,8 +252,14 @@ class PiSupportPlugin( def on_api_get(self, request): if not Permissions.PLUGIN_PI_SUPPORT_STATUS.can(): return flask.abort(403) - result = {"throttle_state": self._throttle_state.as_dict()} - result.update(self.get_additional_environment()) + + environment = self.get_additional_environment() + + result = { + "throttle_state": self._throttle_state.as_dict(), + "model_unrecommended": "zero" in environment.get("model").lower(), + } + result.update(environment) return flask.jsonify(**result) # ~~ AssetPlugin @@ -309,6 +315,7 @@ class PiSupportPlugin( return { "vcgencmd_throttle_check_enabled": True, "vcgencmd_throttle_check_command": _VCGENCMD_THROTTLE, + "ignore_unrecommended_model": False, } def get_settings_restricted_paths(self): diff --git a/src/octoprint/plugins/pi_support/static/js/pi_support.js b/src/octoprint/plugins/pi_support/static/js/pi_support.js index 75388df75..95112fece 100644 --- a/src/octoprint/plugins/pi_support/static/js/pi_support.js +++ b/src/octoprint/plugins/pi_support/static/js/pi_support.js @@ -4,6 +4,7 @@ $(function () { self.loginState = parameters[0]; self.access = parameters[1]; + self.settings = parameters[2]; self.model = ko.observable(); @@ -27,6 +28,42 @@ $(function () { // Raspberry Pi model self.model(response.model); + // Unrecommended model + if ( + response.model_unrecommended && + !self.settings.settings.plugins.pi_support.ignore_unrecommended_model() + ) { + var warning = gettext( + "OctoPrint does not and never has supported the " + + "RPi Zero or Zero W. Use at least a Raspberry Pi 3, or " + + "risk bad performance and failed prints." + ); + var faq = gettext( + "" + + 'You can read more in the FAQ.' + ); + var remove = gettext( + "You can disable this message via Settings > " + + "Pi Support > Ignore warning on unsupported hardware" + ); + new PNotify({ + title: gettext("Unsupported hardware detected"), + text: + "

" + + warning + + "

" + + _.sprintf(faq, { + url: "https://faq.octoprint.org/recommended-hardware" + }) + + "

" + + "" + + remove + + "

", + type: "error", + hide: false + }); + } + // Throttle state self.fromThrottleState(response.throttle_state); @@ -130,6 +167,6 @@ $(function () { OCTOPRINT_VIEWMODELS.push({ construct: PiSupportViewModel, elements: ["#navbar_plugin_pi_support"], - dependencies: ["loginStateViewModel", "accessViewModel"] + dependencies: ["loginStateViewModel", "accessViewModel", "settingsViewModel"] }); }); diff --git a/src/octoprint/plugins/pi_support/templates/pi_support_settings.jinja2 b/src/octoprint/plugins/pi_support/templates/pi_support_settings.jinja2 index a8abffcc0..b16b8f17f 100644 --- a/src/octoprint/plugins/pi_support/templates/pi_support_settings.jinja2 +++ b/src/octoprint/plugins/pi_support/templates/pi_support_settings.jinja2 @@ -3,6 +3,15 @@

{{ _('Please restart OctoPrint after changing any of this plugin\'s settings.') }}

+
+
+ + {{ _('If you check this, you will no longer get warned if you run OctoPrint on Raspberry Pi models that are not officially supported due to bad performance that can lead to failed prints. Do so at your own risk.') }} +
+
+