diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e34fb27e1..f61b5143d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,8 @@ jobs: name: dist path: dist - lint-black: - name: ๐Ÿงน black + pre-commit: + name: ๐Ÿงน Pre-commit runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -42,79 +42,15 @@ jobs: - name: ๐Ÿ— Set up dev dependencies run: | pip install -e .[develop] - - name: ๐Ÿš€ Run black + - name: ๐Ÿš€ Run pre-commit run: | - pre-commit run --hook-stage manual black --all-files --show-diff-on-failure - - lint-isort: - name: ๐Ÿงน isort - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: ๐Ÿ— Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: ๐Ÿ— Set up dev dependencies - run: | - pip install -e .[develop] - - name: ๐Ÿš€ Run isort - run: | - pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure - - lint-flake8: - name: ๐Ÿงน Flake8 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: ๐Ÿ— Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: ๐Ÿ— Set up dev dependencies - run: | - pip install -e .[develop] - - name: ๐Ÿš€ Run flake8 - run: | - pre-commit run --hook-stage manual flake8 --all-files - - lint-prettier: - name: ๐Ÿงน prettier - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: ๐Ÿ— Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: ๐Ÿ— Set up dev dependencies - run: | - pip install -e .[develop] - - name: ๐Ÿš€ Run prettier - run: | - pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure - - lint-eslint: - name: ๐Ÿงน eslint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: ๐Ÿ— Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: ๐Ÿ— Set up dev dependencies - run: | - pip install -e .[develop] - - name: ๐Ÿš€ Run eslint - run: | - pre-commit run --hook-stage manual eslint --all-files + pre-commit run --all-files --show-diff-on-failure test-unit: name: ๐Ÿงช Unit tests strategy: matrix: - python: ["3.7", "3.8"] + python: ["3.7", "3.8", "3.9"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -134,7 +70,7 @@ jobs: needs: build strategy: matrix: - python: ["3.7", "3.8"] + python: ["3.7", "3.8", "3.9"] installable: ["wheel", "sdist"] runs-on: ubuntu-latest steps: @@ -207,11 +143,7 @@ jobs: name: ๐Ÿ“ฆ Publish on TestPyPI if: github.event_name == 'release' needs: - - lint-black - - lint-isort - - lint-flake8 - - lint-prettier - - lint-eslint + - pre-commit - test-unit - test-install - test-e2e diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index b1a0bc8ec..aae343c08 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python: ["3.7", "3.8"] + python: ["3.7", "3.8", "3.9"] branch: ["master"] runs-on: ${{ matrix.os }} steps: @@ -49,7 +49,7 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] - python: ["3.7", "3.8"] + python: ["3.7", "3.8", "3.9"] runs-on: ${{ matrix.os }} steps: - name: ๐Ÿ‘€ Determine latest release diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 549db9c6f..a20d098c7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,35 +12,22 @@ repos: - id: check-merge-conflict - id: fix-encoding-pragma args: ["--remove"] + - repo: https://github.com/asottile/pyupgrade + rev: v2.10.0 + hooks: + - id: pyupgrade + args: ["--py37-plus"] - repo: https://github.com/OctoPrint/codemods rev: 0.4.0 hooks: - id: codemod_detect_past_builtins_imports args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_dict_comprehension_to_literal - args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_dict_to_literal - args: ["--ignore", "src/octoprint/vendor"] - id: codemod_not_in args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_oserror_merge - args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_py3_class_inheritance - args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_py3_super - args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_remove_builtins_imports - args: ["--ignore", "src/octoprint/vendor"] - id: codemod_remove_float_conversion args: ["--ignore", "src/octoprint/vendor"] - id: codemod_remove_future_imports args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_set_to_literal - args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_string_encoding - args: ["--ignore", "src/octoprint/vendor"] - - id: codemod_yield_from_generator - args: ["--ignore", "src/octoprint/vendor"] - repo: https://github.com/pre-commit/mirrors-isort rev: v5.5.4 hooks: diff --git a/AUTHORS.md b/AUTHORS.md index c996bc1a4..7aecc1391 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -138,6 +138,9 @@ date of first contribution): * [Nils Hofmann](https://github.com/Master92) * [Miroslav ล edivรฝ](https://github.com/eumiro) * [Costas Basdekis](https://github.com/costas-basdekis) + * [Joe Martella](https://github.com/martellaj) + * [Scott Lahteine](https://github.com/thinkyhead) + * [Karthikeyan Singaravelan](https://github.com/tirkarthi) 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/CONTRIBUTING.md b/CONTRIBUTING.md index ba81eaba8..2097ccd8d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ into one ticket: One ticket per bug, request, brainstorming thread please. ## How to file a bug report If you encounter an issue with OctoPrint, you are welcome to -[submit a bug report](https://github.com/foosel/OctoPrint/issues/new). +[submit a bug report](https://github.com/OctoPrint/OctoPrint/issues/new?template=bug_report.yml). Before you do that for the first time though please take a moment to read the following section *completely* and also follow the instructions in the @@ -287,6 +287,7 @@ See [the corresponding chapter in the documentation](https://docs.octoprint.org/ * 2020-09-23: Move branch & versioning into development docs * 2020-10-07: Introduce `pre-commit` * 2021-02-04: Issue forms! \o/ + * 2020-03-04: Correct issue forms link ## Footnotes * [1] - If you are wondering why, the problem is that anything that you add diff --git a/docs/api/files.rst b/docs/api/files.rst index d295ee2b9..0757bde41 100644 --- a/docs/api/files.rst +++ b/docs/api/files.rst @@ -14,7 +14,8 @@ Retrieve all files .. http:get:: /api/files Retrieve information regarding all files currently available and regarding the disk space still available - locally in the system. + locally in the system. The results are cached for performance reasons. If you + want to override the cache, supply the query parameter ``force`` and set it to ``true``. By default only returns the files and folders in the root directory. If the query parameter ``recursive`` is provided and set to ``true``, returns all files and folders. @@ -234,6 +235,7 @@ Retrieve all files "free": "3.2GB" } + :param force: If set to ``true``, forces a refresh, overriding the cache. :param recursive: If set to ``true``, return all files and folders recursively. Otherwise only return items on same level. :statuscode 200: No error @@ -245,7 +247,8 @@ Retrieve files from specific location .. http:get:: /api/files/(string:location) Retrieve information regarding the files currently available on the selected `location` and -- if targeting - the ``local`` location -- regarding the disk space still available locally in the system. + the ``local`` location -- regarding the disk space still available locally in the system. The results are cached for performance reasons. If you + want to override the cache, supply the query parameter ``force`` and set it to ``true``. By default only returns the files and folders in the root directory. If the query parameter ``recursive`` is provided and set to ``true``, returns all files and folders. @@ -305,6 +308,7 @@ Retrieve files from specific location :param location: The origin location from which to retrieve the files. Currently only ``local`` and ``sdcard`` are supported, with ``local`` referring to files stored in OctoPrint's ``uploads`` folder and ``sdcard`` referring to files stored on the printer's SD card (if available). + :param force: If set to ``true``, forces a refresh, overriding the cache. :param recursive: If set to ``true``, return all files and folders recursively. Otherwise only return items on same level. :statuscode 200: No error :statuscode 404: If `location` is neither ``local`` nor ``sdcard`` diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 56a0a5fce..a945a6c2a 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -1132,9 +1132,9 @@ Use `Javascript regular expressions Tools > File Watchers (you might have to enable this, it's a bundled plugin), add new: diff --git a/docs/features/action_commands.rst b/docs/features/action_commands.rst index 6e5f8830a..b3d298e2e 100644 --- a/docs/features/action_commands.rst +++ b/docs/features/action_commands.rst @@ -54,6 +54,27 @@ resumed disconnect When this command is received from the printer, OctoPrint will immediately disconnect from it. +sd_inserted + When this command is received from the printer, OctoPrint will assume an SD card is present in the printer, + set the corresponding internal state flags and send a file list request. This command is only recognized + if SD support is enabled in OctoPrint. + + .. versionadded:: 1.6.0 + +sd_ejected + When this command is received from the printer, OctoPrint will assume the SD card has been removed from + the printer and clear the corresponding internal state flags. This command is only recognized + if SD support is enabled in OctoPrint. + + .. versionadded:: 1.6.0 + +sd_updated + When this command is received from the printer, OctoPrint will assume something on the SD card in the + printer has changed and trigger a file list request. This command is only recognized + if SD support is enabled in OctoPrint. + + .. versionadded:: 1.6.0 + If the bundled :ref:`Action Command Prompt Support Plugin ` is enabled (which should be the case by default), OctoPrint will also interactive dialog creation through its :ref:`supported commands `. diff --git a/setup.py b/setup.py index c0abd505c..8fcd2a705 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ INSTALL_REQUIRES = [ "websocket-client>=0.57,<1", "wrapt>=1.12.1,<2", "emoji>=0.5.4,<1", - "frozendict>=1.2,<2", + "immutabledict>=1.2.0,<2", "sentry-sdk>=0.15.1,<1", "filetype>=1.0.7,<2", "zeroconf>=0.24,<0.25", @@ -134,7 +134,7 @@ def md_to_html_build_py_factory(files, baseclass): source = entry dest = os.path.join(target_dir, source + ".html") - print("Rendering markdown from {} to {}".format(source, dest)) + print(f"Rendering markdown from {source} to {dest}") from markdown import markdownFromFile diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index 4e6f41be7..3c75d9490 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import io import logging as log import os import sys @@ -373,7 +372,7 @@ def init_logging( if os.path.exists(logging_file) and os.path.isfile(logging_file): import yaml - with io.open(logging_file, "rt", encoding="utf-8") as f: + with open(logging_file, encoding="utf-8") as f: config_from_file = yaml.safe_load(f) # we merge that with the default config @@ -403,7 +402,7 @@ def octoprint_plugin_inject_factory(settings, components): def wrapper(*args, **kwargs): tags = kwargs.get("tags", set()) | { "source:plugin", - "plugin:{}".format(name), + f"plugin:{name}", } kwargs["tags"] = tags return f(*args, **kwargs) @@ -528,7 +527,7 @@ def init_custom_events(plugin_manager): if isinstance(result, (list, tuple)): for event in result: constant, value = octoprint.events.Events.register_event( - event, prefix="plugin_{}_".format(name) + event, prefix=f"plugin_{name}_" ) logger.debug( 'Registered event {} of plugin {} as Events.{} = "{}"'.format( @@ -537,7 +536,7 @@ def init_custom_events(plugin_manager): ) except Exception: logger.exception( - "Error while retrieving custom event list from plugin {}".format(name), + f"Error while retrieving custom event list from plugin {name}", extra={"plugin": name}, ) @@ -664,7 +663,7 @@ def init_pluginsystem( disabled_from_overlays[name] = (disabled_plugins, order) settings_overlays[name] = overlay - logger.debug("Found settings overlay on plugin {}".format(name)) + logger.debug(f"Found settings overlay on plugin {name}") def handle_plugins_loaded( startup=False, initialize_implementations=True, force_reload=None @@ -706,7 +705,7 @@ def init_pluginsystem( def handle_plugin_enabled(name, plugin): if name in settings_overlays: settings.add_overlay(settings_overlays[name]) - logger.info("Added settings overlay from plugin {}".format(name)) + logger.info(f"Added settings overlay from plugin {name}") pm.on_plugin_loaded = handle_plugin_loaded pm.on_plugins_loaded = handle_plugins_loaded @@ -735,7 +734,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None): format_entry = ( lambda x: "{} ({})".format(x[0], x[1]) if isinstance(x, (list, tuple)) and len(x) == 2 - else "{} (any)".format(x) + else f"{x} (any)" ) return ", ".join(map(format_entry, entries)) diff --git a/src/octoprint/_version.py b/src/octoprint/_version.py index 7920e56d2..bff3b84f6 100644 --- a/src/octoprint/_version.py +++ b/src/octoprint/_version.py @@ -10,7 +10,6 @@ """Git implementation of _version.py.""" import errno -import io import logging import os import re @@ -97,7 +96,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): return None else: if verbose: - print("unable to find command, tried %s" % (commands,)) + print(f"unable to find command, tried {commands}") return None stdout = p.communicate()[0].strip() if sys.version_info[0] >= 3: @@ -140,7 +139,7 @@ def git_get_keywords(versionfile_abs): # _version.py. keywords = {} try: - f = io.open(versionfile_abs, "rt", encoding="utf-8") + f = open(versionfile_abs, encoding="utf-8") for line in f.readlines(): if line.strip().startswith("git_refnames ="): mo = re.search(r'=\s*"(.*)"', line) @@ -299,7 +298,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): if verbose: fmt = "tag '%s' doesn't start with prefix '%s'" print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( + pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format( full_tag, tag_prefix, ) @@ -334,7 +333,7 @@ def git_parse_lookup_file(path): import re lookup = [] - with io.open(path, "rt", encoding="utf-8") as f: + with open(path, encoding="utf-8") as f: for line in f: if "#" in line: line = line[: line.index("#")] diff --git a/src/octoprint/access/groups.py b/src/octoprint/access/groups.py index d63363ff6..00c6f0d41 100644 --- a/src/octoprint/access/groups.py +++ b/src/octoprint/access/groups.py @@ -2,7 +2,6 @@ __author__ = "Marc Hannappel " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import logging import os from functools import partial @@ -183,13 +182,13 @@ class GroupManager: return None def _notify_listeners(self, action, group, *args, **kwargs): - method = "on_group_{}".format(action) + method = f"on_group_{action}" for listener in self._group_change_listeners: try: getattr(listener, method)(group, *args, **kwargs) except Exception: self._logger.exception( - "Error notifying listener {!r} via {}".format(listener, method) + f"Error notifying listener {listener!r} via {method}" ) @@ -227,7 +226,7 @@ class FilebasedGroupManager(GroupManager): def _load(self): if os.path.exists(self._groupfile) and os.path.isfile(self._groupfile): try: - with io.open(self._groupfile, "rt", encoding="utf-8") as f: + with open(self._groupfile, encoding="utf-8") as f: data = yaml.safe_load(f) if "groups" not in data: @@ -316,7 +315,7 @@ class FilebasedGroupManager(GroupManager): except Exception: self._logger.exception( - "Error while loading groups from file {}".format(self._groupfile) + f"Error while loading groups from file {self._groupfile}" ) def _save(self, force=False): diff --git a/src/octoprint/access/users.py b/src/octoprint/access/users.py index feacd6722..a327bf22f 100644 --- a/src/octoprint/access/users.py +++ b/src/octoprint/access/users.py @@ -2,7 +2,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" import hashlib -import io import logging import os import time @@ -83,11 +82,11 @@ class UserManager(GroupChangeListener): listener.on_user_logged_in(user) except Exception: self._logger.exception( - "Error in on_user_logged_in on {!r}".format(listener), + f"Error in on_user_logged_in on {listener!r}", extra={"callback": fqcn(listener)}, ) - self._logger.info("Logged in user: {}".format(user.get_id())) + self._logger.info(f"Logged in user: {user.get_id()}") return user @@ -121,11 +120,11 @@ class UserManager(GroupChangeListener): listener.on_user_logged_out(user, stale=stale) except Exception: self._logger.exception( - "Error in on_user_logged_out on {!r}".format(listener), + f"Error in on_user_logged_out on {listener!r}", extra={"callback": fqcn(listener)}, ) - self._logger.info("Logged out user: {}".format(user.get_id())) + self._logger.info(f"Logged out user: {user.get_id()}") def _cleanup_sessions(self): for session, user in list(self._session_users_by_session.items()): @@ -269,9 +268,7 @@ class UserManager(GroupChangeListener): return False def on_group_removed(self, group): - self._logger.debug( - "Group {} got removed, removing from all users".format(group.key) - ) + self._logger.debug(f"Group {group.key} got removed, removing from all users") self.remove_groups_from_users([group]) def on_group_permissions_changed(self, group, added=None, removed=None): @@ -282,7 +279,7 @@ class UserManager(GroupChangeListener): listener.on_user_modified(user) except Exception: self._logger.exception( - "Error in on_user_modified on {!r}".format(listener), + f"Error in on_user_modified on {listener!r}", extra={"callback": fqcn(listener)}, ) @@ -295,7 +292,7 @@ class UserManager(GroupChangeListener): listener.on_user_modified(user) except Exception: self._logger.exception( - "Error in on_user_modified on {!r}".format(listener), + f"Error in on_user_modified on {listener!r}", extra={"callback": fqcn(listener)}, ) @@ -327,7 +324,7 @@ class UserManager(GroupChangeListener): listener.on_user_modified(user) except Exception: self._logger.exception( - "Error in on_user_modified on {!r}".format(listener), + f"Error in on_user_modified on {listener!r}", extra={"callback": fqcn(listener)}, ) @@ -337,7 +334,7 @@ class UserManager(GroupChangeListener): listener.on_user_removed(username) except Exception: self._logger.exception( - "Error in on_user_removed on {!r}".format(listener), + f"Error in on_user_removed on {listener!r}", extra={"callback": fqcn(listener)}, ) @@ -516,7 +513,7 @@ class FilebasedUserManager(UserManager): def _load(self): if os.path.exists(self._userfile) and os.path.isfile(self._userfile): # noinspection PyBroadException - with io.open(self._userfile, "rt", encoding="utf-8") as f: + with open(self._userfile, encoding="utf-8") as f: data = yaml.safe_load(f) if not data or not isinstance(data, dict): diff --git a/src/octoprint/cli/analysis.py b/src/octoprint/cli/analysis.py index 1b335aa76..151de614d 100644 --- a/src/octoprint/cli/analysis.py +++ b/src/octoprint/cli/analysis.py @@ -66,6 +66,7 @@ def util(): @click.option("--offset", "offset", type=(float, float), multiple=True) @click.option("--max-t", "maxt", type=int, default=10) @click.option("--g90-extruder", "g90_extruder", is_flag=True) +@click.option("--bed-z", "bedz", type=float, default=0) @click.option("--progress", "progress", is_flag=True) @click.argument("path", type=click.Path()) def gcode_command( @@ -78,6 +79,7 @@ def gcode_command( throttle, throttle_lines, g90_extruder, + bedz, progress, ): """Runs a GCODE file analysis.""" @@ -111,7 +113,7 @@ def gcode_command( if progress: def progress_callback(percentage): - click.echo("PROGRESS:{}".format(percentage)) + click.echo(f"PROGRESS:{percentage}") interpreter = gcode(progress_callback=progress_callback) @@ -123,6 +125,7 @@ def gcode_command( throttle=throttle_callback, max_extruders=maxt, g90_extruder=g90_extruder, + bed_z=bedz, ) click.echo("DONE:{}s".format(time.monotonic() - start_time)) diff --git a/src/octoprint/cli/client.py b/src/octoprint/cli/client.py index e0d6f809f..212485e66 100644 --- a/src/octoprint/cli/client.py +++ b/src/octoprint/cli/client.py @@ -1,7 +1,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import json import os @@ -45,11 +44,11 @@ def create_client( if not apikey: cli_key_file = os.path.join(settings.getBaseFolder("generated"), "cli.key") try: - with io.open(cli_key_file, "r", encoding="utf8") as f: + with open(cli_key_file, encoding="utf8") as f: apikey = f.readline() except Exception: raise FatalStartupError( - "Can not authenticate with server at {}:{}, no key".format(host, port) + f"Can not authenticate with server at {host}:{port}, no key" ) baseurl = octoprint_client.build_base_url( @@ -115,10 +114,10 @@ def client(ctx, apikey, host, port, httpuser, httppass, https, prefix): def log_response(response, status_code=True, body=True, headers=False): if status_code: - click.echo("Status Code: {}".format(response.status_code)) + click.echo(f"Status Code: {response.status_code}") if headers: for header, value in response.headers.items(): - click.echo("{}: {}".format(header, value)) + click.echo(f"{header}: {value}") click.echo() if body: click.echo(response.text) @@ -169,17 +168,17 @@ def post_from_file(ctx, path, file_path, json_flag, yaml_flag, timeout): """POSTs JSON data to the specified server path, taking the data from the specified file.""" if json_flag or yaml_flag: if json_flag: - with io.open(file_path, "rt") as fp: + with open(file_path) as fp: data = json.load(fp) else: import yaml - with io.open(file_path, "rt") as fp: + with open(file_path) as fp: data = yaml.safe_load(fp) r = ctx.obj.client.post_json(path, data, timeout=timeout) else: - with io.open(file_path, "rb") as fp: + with open(file_path, "rb") as fp: data = fp.read() r = ctx.obj.client.post(path, data, timeout=timeout) @@ -285,7 +284,7 @@ def listen(ctx): click.echo("--- Connection closed!") def on_error(ws, error): - click.echo("!!! Error: {}".format(error)) + click.echo(f"!!! Error: {error}") def on_sent(ws, data): click.echo(">>> {}".format(json.dumps(data))) diff --git a/src/octoprint/cli/dev.py b/src/octoprint/cli/dev.py index 7da5de9c6..394450670 100644 --- a/src/octoprint/cli/dev.py +++ b/src/octoprint/cli/dev.py @@ -33,9 +33,7 @@ class OctoPrintDevelCommands(click.MultiCommand): return log self.command_caller = CommandlineCaller() - self.command_caller.on_log_call = log_util( - lambda x: click.echo(">> {}".format(x)) - ) + self.command_caller.on_log_call = log_util(lambda x: click.echo(f">> {x}")) self.command_caller.on_log_stdout = log_util(click.echo) self.command_caller.on_log_stderr = log_util(partial(click.echo, err=True)) @@ -53,7 +51,7 @@ class OctoPrintDevelCommands(click.MultiCommand): def _get_commands(self): result = {} for group in self.groups: - for command in self._get_commands_from_prefix_methods("{}_".format(group)): + for command in self._get_commands_from_prefix_methods(f"{group}_"): result[group + self.sep + command.name] = command return result diff --git a/src/octoprint/cli/plugins.py b/src/octoprint/cli/plugins.py index 72d750bf1..642d7f431 100644 --- a/src/octoprint/cli/plugins.py +++ b/src/octoprint/cli/plugins.py @@ -131,7 +131,7 @@ class OctoPrintPluginCommands(click.MultiCommand): result[name + self.sep + command.name] = command except Exception: self._logger.exception( - "Error while retrieving cli commands for plugin {}".format(name), + f"Error while retrieving cli commands for plugin {name}", extra={"plugin": name}, ) diff --git a/src/octoprint/cli/server.py b/src/octoprint/cli/server.py index b961418df..003c01173 100644 --- a/src/octoprint/cli/server.py +++ b/src/octoprint/cli/server.py @@ -44,7 +44,7 @@ def run_server( PluginTimingsLogHandler.arm_rollover(logger) logger.info(get_divider_line("*")) - logger.info("Starting OctoPrint {}".format(__display_version__)) + logger.info(f"Starting OctoPrint {__display_version__}") if safe_mode: logger.info("Starting in SAFE MODE. Third party plugins will be disabled!") if safe_mode == "flag": @@ -55,7 +55,7 @@ def run_server( reason = "problem during last startup" else: reason = "unknown" - logger.info("Reason for safe mode: {}".format(reason)) + logger.info(f"Reason for safe mode: {reason}") if recorder and len(recorder): logger.info(get_divider_line("-", "Logged during platform initialization:")) @@ -98,7 +98,7 @@ def run_server( log_to_handler(logger, handler, level, message) _log(get_divider_line("-", "Log roll over detected")) - _log("OctoPrint {}".format(__display_version__)) + _log(f"OctoPrint {__display_version__}") if safe_mode: _log("SAFE MODE is active. Third party plugins are disabled!") plugin_manager.log_all_plugins(only_to_handler=handler) diff --git a/src/octoprint/cli/systeminfo.py b/src/octoprint/cli/systeminfo.py index 75fe2e773..ccbb66edd 100644 --- a/src/octoprint/cli/systeminfo.py +++ b/src/octoprint/cli/systeminfo.py @@ -135,7 +135,7 @@ def systeminfo_command(ctx, path, **kwargs): if path: # create zip at path zipfilename = os.path.join(path, get_systeminfo_bundle_name()) - click.echo("Writing systeminfo bundle to {}...".format(zipfilename)) + click.echo(f"Writing systeminfo bundle to {zipfilename}...") z = get_systeminfo_bundle(systeminfo, settings.getBaseFolder("logs")) try: @@ -144,9 +144,7 @@ def systeminfo_command(ctx, path, **kwargs): f.write(data) except Exception as e: click.echo(str(e), err=True) - click.echo( - "There was an error writing to {}.".format(zipfilename), err=True - ) + click.echo(f"There was an error writing to {zipfilename}.", err=True) ctx.exit(-1) click.echo("Done!") diff --git a/src/octoprint/cli/user.py b/src/octoprint/cli/user.py index 373ab1d95..b172548c8 100644 --- a/src/octoprint/cli/user.py +++ b/src/octoprint/cli/user.py @@ -130,9 +130,7 @@ def add_user_command(ctx, username, password, groups, permissions, is_admin): click.echo("User created:") click.echo("\t{}".format(_user_to_line(user.as_dict()))) except UserAlreadyExists: - click.echo( - "A user with the name {} does already exist!".format(username), err=True - ) + click.echo(f"A user with the name {username} does already exist!", err=True) @user.command(name="remove") @@ -147,9 +145,9 @@ def remove_user_command(ctx, username): if confirm.lower() == "yes": ctx.obj.user_manager.remove_user(username) - click.echo("User {} removed.".format(username)) + click.echo(f"User {username} removed.") else: - click.echo("User {} not removed.".format(username)) + click.echo(f"User {username} not removed.") @user.command(name="password") @@ -160,9 +158,9 @@ def change_password_command(ctx, username, password): """Change an existing user's password.""" try: ctx.obj.user_manager.change_user_password(username, password) - click.echo("Password changed for user {}.".format(username)) + click.echo(f"Password changed for user {username}.") except UnknownUser: - click.echo("User {} does not exist!".format(username), err=True) + click.echo(f"User {username} does not exist!", err=True) @user.command(name="activate") @@ -172,14 +170,14 @@ def activate_command(ctx, username): """Activate a user account.""" try: ctx.obj.user_manager.change_user_activation(username, True) - click.echo("User {} activated.".format(username)) + click.echo(f"User {username} activated.") user = ctx.obj.user_manager.find_user(username) if user: click.echo("User created:") click.echo("\t{}".format(_user_to_line(user.asDict()))) except UnknownUser: - click.echo("User {} does not exist!".format(username), err=True) + click.echo(f"User {username} does not exist!", err=True) @user.command(name="deactivate") @@ -189,14 +187,14 @@ def deactivate_command(ctx, username): """Activate a user account.""" try: ctx.obj.user_manager.change_user_activation(username, False) - click.echo("User {} activated.".format(username)) + click.echo(f"User {username} activated.") user = ctx.obj.user_manager.find_user(username) if user: click.echo("User created:") click.echo("\t{}".format(_user_to_line(user.asDict()))) except UnknownUser: - click.echo("User {} does not exist!".format(username), err=True) + click.echo(f"User {username} does not exist!", err=True) def _print_list(users): diff --git a/src/octoprint/daemon.py b/src/octoprint/daemon.py index 7548e23c2..07ac5d091 100644 --- a/src/octoprint/daemon.py +++ b/src/octoprint/daemon.py @@ -4,7 +4,6 @@ Generic linux daemon base class Originally from http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/#c35 """ -import io import os import signal import sys @@ -63,9 +62,9 @@ class Daemon: # redirect standard file descriptors sys.stdout.flush() sys.stderr.flush() - si = io.open(os.devnull, "rt", encoding="utf-8") - so = io.open(os.devnull, "at+", encoding="utf-8") - se = io.open(os.devnull, "at+", encoding="utf-8") + si = open(os.devnull, encoding="utf-8") + so = open(os.devnull, "at+", encoding="utf-8") + se = open(os.devnull, "at+", encoding="utf-8") os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdout.fileno()) @@ -153,7 +152,7 @@ class Daemon: def get_pid(self): """Get the pid from the pidfile.""" try: - with io.open(self.pidfile, "rt", encoding="utf-8") as pf: + with open(self.pidfile, encoding="utf-8") as pf: pid = int(pf.read().strip()) except (OSError, ValueError): pid = None @@ -161,7 +160,7 @@ class Daemon: def set_pid(self, pid): """Write the pid to the pidfile.""" - with io.open(self.pidfile, "wt+", encoding="utf-8") as f: + with open(self.pidfile, "wt+", 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 59e7cd65f..6711dc02b 100644 --- a/src/octoprint/environment.py +++ b/src/octoprint/environment.py @@ -169,7 +169,7 @@ class EnvironmentDetector: environment, default_flow_style=False, indent=2, allow_unicode=True ).strip() environment_lines = "\n".join( - map(lambda l: "| {}".format(l), dumped_environment.split("\n")) + map(lambda l: f"| {l}", dumped_environment.split("\n")) ) return "Detected environment is Python {} under {} ({}). Details:\n{}".format( environment["python"]["version"], diff --git a/src/octoprint/events.py b/src/octoprint/events.py index 2a349717b..f93553ee9 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -160,7 +160,7 @@ class EventManager: def __init__(self): self._registeredListeners = collections.defaultdict(list) self._logger = logging.getLogger(__name__) - self._logger_fire = logging.getLogger("{}.fire".format(__name__)) + self._logger_fire = logging.getLogger(f"{__name__}.fire") self._startup_signaled = False self._shutdown_signaled = False @@ -184,12 +184,10 @@ class EventManager: self._shutdown_signaled = True eventListeners = self._registeredListeners[event] - self._logger_fire.debug( - "Firing event: {} (Payload: {!r})".format(event, payload) - ) + self._logger_fire.debug(f"Firing event: {event} (Payload: {payload!r})") for listener in eventListeners: - self._logger.debug("Sending action to {!r}".format(listener)) + self._logger.debug(f"Sending action to {listener!r}") try: listener(event, payload) except Exception: @@ -256,9 +254,7 @@ class EventManager: return self._registeredListeners[event].append(callback) - self._logger.debug( - "Subscribed listener {!r} for event {}".format(callback, event) - ) + self._logger.debug(f"Subscribed listener {callback!r} for event {event}") def unsubscribe(self, event, callback): """ @@ -317,7 +313,7 @@ class DebugEventListener(GenericEventListener): def eventCallback(self, event, payload): GenericEventListener.eventCallback(self, event, payload) - self._logger.debug("Received event: %s (Payload: %r)" % (event, payload)) + self._logger.debug(f"Received event: {event} (Payload: {payload!r})") class CommandTrigger(GenericEventListener): @@ -364,7 +360,7 @@ class CommandTrigger(GenericEventListener): continue if "enabled" in subscription and not subscription["enabled"]: - self._logger.info("Disabled command trigger: {!r}".format(subscription)) + self._logger.info(f"Disabled command trigger: {subscription!r}") continue events = subscription["event"] @@ -423,7 +419,7 @@ class CommandTrigger(GenericEventListener): def _executeSystemCommand(self, command, debug=False): def commandExecutioner(cmd): if debug: - self._logger.info("Executing system command: {}".format(cmd)) + self._logger.info(f"Executing system command: {cmd}") else: self._logger.info("Executing a system command") # we run this with shell=True since we have to trust whatever diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index 70f554a33..2fe84dbea 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -445,8 +445,6 @@ class FileManager: source_meta = self.get_metadata(source_location, source_path) hash = source_meta.get("hash", "n/a") - import io - links = [("model", {"name": source_path})] _, stl_name = self.split_path(source_location, source_path) file_obj = StreamWrapper( @@ -960,7 +958,7 @@ class FileManager: ) except Exception: self._logger.exception( - "Could not write recovery data to file {}".format(self._recovery_file) + f"Could not write recovery data to file {self._recovery_file}" ) def delete_recovery_data(self): @@ -971,7 +969,7 @@ class FileManager: os.remove(self._recovery_file) except Exception: self._logger.exception( - "Error deleting recovery data file {}".format(self._recovery_file) + f"Error deleting recovery data file {self._recovery_file}" ) def get_recovery_data(self): @@ -981,7 +979,7 @@ class FileManager: import yaml try: - with io.open(self._recovery_file, "rt", encoding="utf-8") as f: + with open(self._recovery_file, encoding="utf-8") as f: data = yaml.safe_load(f) if not isinstance(data, dict) or not all( map(lambda x: x in data, ("origin", "path", "pos", "date")) @@ -990,7 +988,7 @@ class FileManager: return data except Exception: self._logger.exception( - "Could not read recovery data from file {}".format(self._recovery_file) + f"Could not read recovery data from file {self._recovery_file}" ) self.delete_recovery_data() diff --git a/src/octoprint/filemanager/analysis.py b/src/octoprint/filemanager/analysis.py index 3e611d539..0391fd513 100644 --- a/src/octoprint/filemanager/analysis.py +++ b/src/octoprint/filemanager/analysis.py @@ -39,7 +39,7 @@ class QueueEntry( """ def __str__(self): - return "{location}:{path}".format(location=self.location, path=self.path) + return f"{self.location}:{self.path}" class AnalysisAborted(Exception): @@ -114,7 +114,7 @@ class AnalysisQueue: callback(entry, result) except Exception: self._logger.exception( - "Error while pushing analysis data to callback {}".format(callback), + f"Error while pushing analysis data to callback {callback}", extra={"callback": fqcn(callback)}, ) eventManager().fire( @@ -185,9 +185,7 @@ class AbstractAnalysisQueue: """ if settings().get(["gcodeAnalysis", "runAt"]) == "never": - self._logger.debug( - "Ignoring entry {entry} for analysis queue".format(entry=entry) - ) + self._logger.debug(f"Ignoring entry {entry} for analysis queue") return elif high_priority: self._logger.debug( @@ -254,7 +252,7 @@ class AbstractAnalysisQueue: while True: (priority, entry, high_priority) = self._queue.get() self._logger.debug( - "Processing entry {} from queue (priority {})".format(entry, priority) + f"Processing entry {entry} from queue (priority {priority})" ) self._active.wait() @@ -273,7 +271,7 @@ class AbstractAnalysisQueue: high_priority, ) ) - self._logger.debug("Running analysis of entry {} aborted".format(entry)) + self._logger.debug(f"Running analysis of entry {entry} aborted") self._queue.task_done() self._done.set() else: @@ -290,7 +288,7 @@ class AbstractAnalysisQueue: try: start_time = time.monotonic() - self._logger.info("Starting analysis of {}".format(entry)) + self._logger.info(f"Starting analysis of {entry}") eventManager().fire( Events.METADATA_ANALYSIS_STARTED, { @@ -311,9 +309,7 @@ class AbstractAnalysisQueue: ) self._finished_callback(self._current, result) except RuntimeError as exc: - self._logger.error( - "Analysis for {} ran into error: {}".format(self._current, exc) - ) + self._logger.error(f"Analysis for {self._current} ran into error: {exc}") finally: self._current = None self._current_progress = None @@ -410,6 +406,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): throttle_lines = settings().getInt(["gcodeAnalysis", "throttle_lines"]) max_extruders = settings().getInt(["gcodeAnalysis", "maxExtruders"]) g90_extruder = settings().getBoolean(["feature", "g90InfluencesExtruder"]) + bed_z = settings().getFloat(["gcodeAnalysis", "bedZ"]) speedx = self._current.printer_profile["axes"]["x"]["speed"] speedy = self._current.printer_profile["axes"]["y"]["speed"] offsets = self._current.printer_profile["extruder"]["offsets"] @@ -420,11 +417,12 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): "octoprint", "analysis", "gcode", - "--speed-x={}".format(speedx), - "--speed-y={}".format(speedy), - "--max-t={}".format(max_extruders), - "--throttle={}".format(throttle), - "--throttle-lines={}".format(throttle_lines), + f"--speed-x={speedx}", + f"--speed-y={speedy}", + f"--max-t={max_extruders}", + f"--throttle={throttle}", + f"--throttle-lines={throttle_lines}", + f"--bed-z={bed_z}", ] for offset in offsets[1:]: command += ["--offset", str(offset[0]), str(offset[1])] @@ -470,7 +468,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): p.close() output = p.stdout.text - self._logger.debug("Got output: {!r}".format(output)) + self._logger.debug(f"Got output: {output!r}") if "ERROR:" in output: _, error = output.split("ERROR:") diff --git a/src/octoprint/filemanager/storage/local.py b/src/octoprint/filemanager/storage/local.py index 6aaf81a04..f00f7e431 100644 --- a/src/octoprint/filemanager/storage/local.py +++ b/src/octoprint/filemanager/storage/local.py @@ -3,7 +3,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" import copy -import io import logging import os import shutil @@ -63,9 +62,7 @@ class LocalFileStorage(Storage): self._initialize_metadata() def _initialize_metadata(self): - self._logger.info( - "Initializing the file metadata for {}...".format(self.basefolder) - ) + self._logger.info(f"Initializing the file metadata for {self.basefolder}...") old_metadata_path = os.path.join(self.basefolder, "metadata.yaml") backup_path = os.path.join(self.basefolder, "metadata.yaml.backup") @@ -73,7 +70,7 @@ class LocalFileStorage(Storage): if os.path.exists(old_metadata_path): # load the old metadata file try: - with io.open(old_metadata_path, "rt", encoding="utf-8") as f: + with open(old_metadata_path, encoding="utf-8") as f: import yaml self._old_metadata = yaml.safe_load(f) @@ -97,7 +94,7 @@ class LocalFileStorage(Storage): self._list_folder(self.basefolder) self._logger.info( - "... file metadata for {} initialized successfully.".format(self.basefolder) + f"... file metadata for {self.basefolder} initialized successfully." ) @property @@ -290,7 +287,7 @@ class LocalFileStorage(Storage): if not os.path.exists(source_fullpath): raise StorageError( - "{} in {} does not exist".format(source_name, source_path), + f"{source_name} in {source_path} does not exist", code=StorageError.INVALID_SOURCE, ) @@ -306,7 +303,7 @@ class LocalFileStorage(Storage): and source_fullpath != destination_fullpath ): raise StorageError( - "{} does already exist in {}".format(destination_name, destination_path), + f"{destination_name} does already exist in {destination_path}", code=StorageError.INVALID_DESTINATION, ) @@ -795,16 +792,14 @@ class LocalFileStorage(Storage): while os.path.exists(sanitized_path): counter += 1 sanitized = self.sanitize_name( - "{}_({}){}".format(sanitized_name, counter, sanitized_ext) + f"{sanitized_name}_({counter}){sanitized_ext}" ) sanitized_path = os.path.join(path, sanitized) try: shutil.move(entry_path, sanitized_path) - self._logger.info( - 'Sanitized "{}" to "{}"'.format(entry_path, sanitized_path) - ) + self._logger.info(f'Sanitized "{entry_path}" to "{sanitized_path}"') return sanitized, sanitized_path except Exception: self._logger.exception( @@ -1084,6 +1079,7 @@ class LocalFileStorage(Storage): logtarget=__name__ + ".timings", message="{func}({func_args},{func_kwargs}) took {timing:.2f}ms", incl_func_args=True, + log_enter=True, ) def _list_folder(self, path, base="", force_refresh=False, **kwargs): def get_size(nodes): @@ -1111,11 +1107,8 @@ class LocalFileStorage(Storage): try: with self._filelist_cache_mutex: cache = self._filelist_cache.get(path) - if ( - not force_refresh - and cache - and cache[0] >= self.last_modified(path, recursive=True) - ): + lm = self.last_modified(path, recursive=True) + if not force_refresh and cache and cache[0] >= lm: return enrich_folders(cache[1]) metadata = self._get_metadata(path) @@ -1251,12 +1244,12 @@ class LocalFileStorage(Storage): except Exception: # So something went wrong somewhere while processing this file entry - log that and continue self._logger.exception( - "Error while processing entry {}".format(entry_path) + f"Error while processing entry {entry_path}" ) continue self._filelist_cache[path] = ( - self.last_modified(path, recursive=True), + lm, result, ) return enrich_folders(result) @@ -1321,7 +1314,7 @@ class LocalFileStorage(Storage): blocksize = 65536 hash = hashlib.sha1() - with io.open(path, "rb") as f: + with open(path, "rb") as f: buffer = f.read(blocksize) while len(buffer) > 0: hash.update(buffer) @@ -1402,7 +1395,7 @@ class LocalFileStorage(Storage): metadata = None with self._get_persisted_metadata_lock(path): if os.path.exists(metadata_path): - with io.open(metadata_path, "rt", encoding="utf-8") as f: + with open(metadata_path, encoding="utf-8") as f: try: metadata = json.load(f) except Exception: @@ -1509,7 +1502,7 @@ class LocalFileStorage(Storage): ) return - with io.open(metadata_path_yaml, "rt", encoding="utf-8") as f: + with open(metadata_path_yaml, encoding="utf-8") as f: try: metadata = yaml.safe_load(f) except Exception: diff --git a/src/octoprint/filemanager/util.py b/src/octoprint/filemanager/util.py index a23f81aa9..a86e9a7f2 100644 --- a/src/octoprint/filemanager/util.py +++ b/src/octoprint/filemanager/util.py @@ -72,7 +72,7 @@ class DiskFileWrapper(AbstractFileWrapper): os.chmod(path, permissions) def stream(self): - return io.open(self.path, "rb") + return open(self.path, "rb") class StreamWrapper(AbstractFileWrapper): diff --git a/src/octoprint/logging/filters.py b/src/octoprint/logging/filters.py index fcd545ae0..9df05352e 100644 --- a/src/octoprint/logging/filters.py +++ b/src/octoprint/logging/filters.py @@ -20,7 +20,7 @@ class TornadoAccessFilter(logging.Filter): record.levelname = logging.getLevelName(record.levelno) except Exception: logging.getLogger(__name__).exception( - "Error while filtering log record {!r}".format(record) + f"Error while filtering log record {record!r}" ) return logging.Filter.filter(self, record) diff --git a/src/octoprint/plugin/__init__.py b/src/octoprint/plugin/__init__.py index f9d807a22..1ceddee57 100644 --- a/src/octoprint/plugin/__init__.py +++ b/src/octoprint/plugin/__init__.py @@ -186,7 +186,7 @@ def plugin_settings_for_settings_plugin(plugin_key, instance, settings=None): get_preprocessors, set_preprocessors = instance.get_settings_preprocessors() except Exception: logging.getLogger(__name__).exception( - "Error while retrieving preprocessors for plugin {}".format(plugin_key) + f"Error while retrieving preprocessors for plugin {plugin_key}" ) return None @@ -263,7 +263,7 @@ def call_plugin( continue if hasattr(plugin, method): - logger.debug("Calling {} on {}".format(method, plugin._identifier)) + logger.debug(f"Calling {method} on {plugin._identifier}") try: result = getattr(plugin, method)(*args, **kwargs) if callback: diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 9e7db9af8..71bf3218f 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -24,7 +24,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import fnmatch import inspect -import io import logging import os from collections import OrderedDict, defaultdict, namedtuple @@ -306,7 +305,7 @@ class PluginInfo: def __str__(self): if self.version: - return "{name} ({version})".format(name=self.name, version=self.version) + return f"{self.name} ({self.version})" else: return to_unicode(self.name) @@ -684,14 +683,12 @@ class PluginInfo: # we only support parsing plain text source files return result - self._logger.debug( - "Parsing plugin metadata for {} from AST of {}".format(self.key, path) - ) + self._logger.debug(f"Parsing plugin metadata for {self.key} from AST of {path}") try: import ast - with io.open(path, "rb") as f: + with open(path, "rb") as f: root = ast.parse(f.read(), filename=path) assignments = list( @@ -765,13 +762,11 @@ class PluginInfo: break except SyntaxError: - self._logger.exception( - "Invalid syntax in {} for plugin {}".format(path, self.key) - ) + self._logger.exception(f"Invalid syntax in {path} for plugin {self.key}") self.invalid_syntax = True except Exception: self._logger.exception( - "Error while parsing AST from {} for plugin {}".format(path, self.key) + f"Error while parsing AST from {path} for plugin {self.key}" ) return result @@ -1001,7 +996,7 @@ class PluginManager: module_name = None if package: - module_name = "{}.{}".format(package, key) + module_name = f"{package}.{key}" plugin = self._import_plugin_from_module( key, module_name=module_name, folder=folder, bundled=bundled @@ -1025,7 +1020,7 @@ class PluginManager: ) ) except Exception: - self.logger.exception("Error processing folder {}".format(folder)) + self.logger.exception(f"Error processing folder {folder}") return added, found @@ -1163,7 +1158,7 @@ class PluginManager: else: return None except Exception: - self.logger.exception("Could not locate plugin {key}".format(key=key)) + self.logger.exception(f"Could not locate plugin {key}") return None # Create a simple dummy entry first ... @@ -1181,14 +1176,14 @@ class PluginManager: plugin.bundled = bundled if self._is_plugin_disabled(key): - self.logger.info("Plugin {} is disabled.".format(plugin)) + self.logger.info(f"Plugin {plugin} is disabled.") plugin.forced_disabled = True if self._is_plugin_blacklisted(key) or ( plugin.version is not None and self._is_plugin_version_blacklisted(key, plugin.version) ): - self.logger.warning("Plugin {} is blacklisted.".format(plugin)) + self.logger.warning(f"Plugin {plugin} is blacklisted.") plugin.blacklisted = True python_version = get_python_version_string() @@ -1264,7 +1259,7 @@ class PluginManager: plugin.bundled = bundled except Exception: - self.logger.exception("Error loading plugin {key}".format(key=key)) + self.logger.exception(f"Error loading plugin {key}") return None if plugin.check(): @@ -1386,7 +1381,7 @@ class PluginManager: ): if plugin.blacklisted: self.logger.warning( - "Plugin {} is blacklisted. Not enabling it.".format(plugin) + f"Plugin {plugin} is blacklisted. Not enabling it." ) continue self.enable_plugin( @@ -2272,11 +2267,11 @@ def is_sub_path_of(path, parent): def is_editable_install(install_dir, package, module, location): - package_link = os.path.join(install_dir, "{}.egg-link".format(package)) + package_link = os.path.join(install_dir, f"{package}.egg-link") if os.path.isfile(package_link): expected_target = os.path.normcase(os.path.realpath(location)) try: - with io.open(package_link, "rt", encoding="utf-8") as f: + with open(package_link, encoding="utf-8") as f: contents = f.readlines() for line in contents: target = os.path.normcase( diff --git a/src/octoprint/plugin/types.py b/src/octoprint/plugin/types.py index a8fb9b869..4cf1d661d 100644 --- a/src/octoprint/plugin/types.py +++ b/src/octoprint/plugin/types.py @@ -1276,7 +1276,7 @@ class SimpleApiPlugin(OctoPrintPlugin): If your plugin returns nothing here, OctoPrint will return an empty response with return code ``204 No content`` for you. You may also return regular responses as you would return from any Flask view here though, e.g. - ``return flask.jsonify(result="some json result")`` or ``return flask.make_response("Not found", 404)``. + ``return flask.jsonify(result="some json result")`` or ``flask.abort(404)``. :param string command: the command with which the resource was called :param dict data: the full request body of the POST request parsed from JSON into a Python dictionary @@ -1294,7 +1294,7 @@ class SimpleApiPlugin(OctoPrintPlugin): If your plugin returns nothing here, OctoPrint will return an empty response with return code ``204 No content`` for you. You may also return regular responses as you would return from any Flask view here though, e.g. - ``return flask.jsonify(result="some json result")`` or ``return flask.make_response("Not found", 404)``. + ``return flask.jsonify(result="some json result")`` or ``flask.abort(404)``. :param request: the Flask request object :return: ``None`` in which case OctoPrint will generate a ``204 No content`` response with empty body, or optionally @@ -1324,7 +1324,7 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin): @octoprint.plugin.BlueprintPlugin.route("/echo", methods=["GET"]) def myEcho(self): if not "text" in flask.request.values: - return flask.make_response("Expected a text to echo back.", 400) + abort(400, description="Expected a text to echo back.") return flask.request.values["text"] __plugin_implementation__ = MyBlueprintPlugin() @@ -1474,9 +1474,22 @@ class BlueprintPlugin(OctoPrintPlugin, RestartNeedingPlugin): If you want your blueprint's endpoints to have specific permissions, return ``False`` for this and do your permissions checks explicitly. """ - return True + # noinspection PyMethodMayBeStatic + def get_blueprint_api_prefixes(self): + """ + Return all prefixes of your endpoint that are an API that should be containing JSON only. + + Anything that matches this will generate JSON error messages in case of flask.abort + calls, instead of the default HTML ones. + + Defaults to all endpoints under the blueprint. Limit this further as needed. E.g., + if you only want your endpoints /foo, /foo/1 and /bar to be declared as API, + return ``["/foo", "/bar"]``. A match will be determined via startswith. + """ + return [""] + class SettingsPlugin(OctoPrintPlugin): """ diff --git a/src/octoprint/plugins/action_command_notification/__init__.py b/src/octoprint/plugins/action_command_notification/__init__.py index 060539d66..a3e147990 100644 --- a/src/octoprint/plugins/action_command_notification/__init__.py +++ b/src/octoprint/plugins/action_command_notification/__init__.py @@ -66,7 +66,7 @@ class ActionCommandNotificationPlugin( def on_api_get(self, request): if not Permissions.PLUGIN_ACTION_COMMAND_NOTIFICATION_SHOW.can(): - return flask.abort(403, "Insufficient permissions") + return flask.abort(403) return flask.jsonify( notifications=[ {"timestamp": notification[0], "message": notification[1]} @@ -123,7 +123,7 @@ class ActionCommandNotificationPlugin( self._notifications.append((time.time(), message)) self._plugin_manager.send_plugin_message(self._identifier, {"message": message}) - self._logger.info("Got a notification: {}".format(message)) + self._logger.info(f"Got a notification: {message}") def _clear_notifications(self): self._notifications = [] 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 c9f092d75..6574cad0e 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 @@ -85,7 +85,7 @@ $(function () { } }; - var optionsLocalStorageKey = "core.gcodeviewer.options"; + var optionsLocalStorageKey = "plugin.action_command_notification.options"; self._toLocalStorage = function () { saveToLocalStorage(optionsLocalStorageKey, {sortDesc: self.sortDesc()}); }; diff --git a/src/octoprint/plugins/action_command_prompt/__init__.py b/src/octoprint/plugins/action_command_prompt/__init__.py index 8d6305126..5e3b077e1 100644 --- a/src/octoprint/plugins/action_command_prompt/__init__.py +++ b/src/octoprint/plugins/action_command_prompt/__init__.py @@ -90,7 +90,7 @@ class ActionCommandPromptPlugin( and self._enable == "always" and self._enable_signal_support ): - self._printer.commands(["{command} P1".format(command=self._command)]) + self._printer.commands([f"{self._command} P1"]) elif event == Events.DISCONNECTED: self._close_prompt() @@ -123,22 +123,20 @@ class ActionCommandPromptPlugin( def on_api_command(self, command, data): if command == "select": if not Permissions.PLUGIN_ACTION_COMMAND_PROMPT_INTERACT.can(): - return flask.abort(403, "Insufficient permissions") + return flask.abort(403) if self._prompt is None: - return flask.abort(409, "No active prompt") + return flask.abort(409, description="No active prompt") choice = data["choice"] if not isinstance(choice, int) or not self._prompt.validate_choice(choice): - return flask.abort( - 400, "{!r} is not a valid value for choice".format(choice) - ) + return flask.abort(400, f"{choice!r} is not a valid value for choice") self._answer_prompt(choice) def on_api_get(self, request): if not Permissions.PLUGIN_ACTION_COMMAND_PROMPT_INTERACT.can(): - return flask.abort(403, "Insufficient permissions") + return flask.abort(403) if self._prompt is None: return flask.jsonify() else: @@ -208,7 +206,7 @@ class ActionCommandPromptPlugin( subcode=None, tags=None, *args, - **kwargs + **kwargs, ): if gcode != self._command: return @@ -226,7 +224,7 @@ class ActionCommandPromptPlugin( # noinspection PyProtectedMember return comm_instance._emergency_force_send( - cmd, "Force-sending {} to the printer".format(self._command), gcode=gcode + cmd, f"Force-sending {self._command} to the printer", gcode=gcode ) # ~ capability reporting @@ -237,7 +235,7 @@ class ActionCommandPromptPlugin( if capability == self.CAP_PROMPT_SUPPORT and enabled: self._cap_prompt_support = True if self._enable == "detected" and self._enable_signal_support: - self._printer.commands(["{command} P1".format(command=self._command)]) + self._printer.commands([f"{self._command} P1"]) # ~ prompt handling @@ -277,7 +275,7 @@ class ActionCommandPromptPlugin( self._printer.commands([self._command.format(choice=choice)], force=True) else: self._printer.commands( - ["{command} S{choice}".format(command=self._command, choice=choice)], + [f"{self._command} S{choice}"], force=True, ) diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py index 40af06709..7eaf806c3 100644 --- a/src/octoprint/plugins/announcements/__init__.py +++ b/src/octoprint/plugins/announcements/__init__.py @@ -4,7 +4,6 @@ __copyright__ = "Copyright (C) 2016 The OctoPrint Project - Released under terms import calendar -import io import os import re import sys @@ -286,7 +285,7 @@ class AnnouncementPlugin( elif command == "toggle": if not Permissions.PLUGIN_ANNOUNCEMENTS_MANAGE.can(): - return flask.make_response("Insufficient rights", 403) + flask.abort(403) self._toggle(channel) return NO_CONTENT @@ -434,9 +433,7 @@ class AnnouncementPlugin( now = time.time() if os.stat(channel_path).st_mtime + ttl > now: d = feedparser.parse(channel_path) - self._logger.debug( - "Loaded channel {} from cache at {}".format(key, channel_path) - ) + self._logger.debug(f"Loaded channel {key} from cache at {channel_path}") return d return None @@ -464,7 +461,7 @@ class AnnouncementPlugin( response = r.text channel_path = self._get_channel_cache_path(key) - with io.open(channel_path, mode="wt", encoding="utf-8") as f: + with open(channel_path, mode="wt", encoding="utf-8") as f: f.write(response) return feedparser.parse(response) @@ -518,7 +515,7 @@ class AnnouncementPlugin( """Retrieve cache path for channel key.""" safe_key = sanitize(key) - return os.path.join(self.get_plugin_data_folder(), "{}.cache".format(safe_key)) + return os.path.join(self.get_plugin_data_folder(), f"{safe_key}.cache") _image_tag_re = re.compile(r"") @@ -577,7 +574,7 @@ def _lazy_images(text, placeholder=None): quote = match.group("quote") quoted_src = quote + src + quote img_tag = img_tag.replace( - match.group(0), 'src="{}" data-src={}'.format(placeholder, quoted_src) + match.group(0), f'src="{placeholder}" data-src={quoted_src}' ) return img_tag @@ -602,10 +599,10 @@ def _strip_tags(text): self._fed.append(data) def handle_entityref(self, ref): - self._fed.append("&{};".format(ref)) + self._fed.append(f"&{ref};") def handle_charref(self, ref): - self._fed.append("&#{};".format(ref)) + self._fed.append(f"&#{ref};") def get_data(self): return "".join(self._fed) diff --git a/src/octoprint/plugins/appkeys/__init__.py b/src/octoprint/plugins/appkeys/__init__.py index c3c7110d3..ca8ff3024 100644 --- a/src/octoprint/plugins/appkeys/__init__.py +++ b/src/octoprint/plugins/appkeys/__init__.py @@ -1,4 +1,3 @@ -import io import os import threading import time @@ -155,10 +154,10 @@ class AppKeysPlugin( def handle_request(self): data = flask.request.json if data is None: - return flask.make_response("Missing key request", 400) + flask.abort(400, description="Missing key request") if "app" not in data: - return flask.make_response("No app name provided", 400) + flask.abort(400, description="No app name provided") app_name = data["app"] user_id = None @@ -206,7 +205,7 @@ class AppKeysPlugin( def handle_decision(self, user_token): data = flask.request.json if "decision" not in data: - return flask.make_response("No decision provided", 400) + flask.abort(400, description="No decision provided") decision = data["decision"] in valid_boolean_trues user_id = current_user.get_name() @@ -439,13 +438,11 @@ class AppKeysPlugin( return try: - with io.open( - self._key_path, "rt", encoding="utf-8", errors="strict" - ) as f: + with open(self._key_path, encoding="utf-8", errors="strict") as f: persisted = yaml.safe_load(f) except Exception: self._logger.exception( - "Could not load application keys from {}".format(self._key_path) + f"Could not load application keys from {self._key_path}" ) return @@ -470,7 +467,7 @@ class AppKeysPlugin( yaml.safe_dump(to_persist, f, allow_unicode=True) except Exception: self._logger.exception( - "Could not write application keys to {}".format(self._key_path) + f"Could not write application keys to {self._key_path}" ) diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 0ad10d229..13174e9d8 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -26,7 +26,6 @@ except ImportError: zlib = None -import io import json import logging import os @@ -197,12 +196,13 @@ class BackupPlugin( if not Permissions.PLUGIN_BACKUP_ACCESS.can() and not self._settings.global_get( ["server", "firstRun"] ): - return flask.abort(403) + flask.abort(403) if not self._restore_supported(self._settings): - return flask.make_response( - "Invalid request, the restores are not supported on the underlying operating system", + flask.abort( 400, + description="Invalid request, the restores are not " + "supported on the underlying operating system", ) input_name = "file" @@ -230,9 +230,10 @@ class BackupPlugin( return flask.abort(404) else: - return flask.make_response( - "Invalid request, neither a file nor a path of a file to restore provided", + flask.abort( 400, + description="Invalid request, neither a file nor a path of a file to " + "restore provided", ) def on_install_plugins(plugins): @@ -504,7 +505,7 @@ class BackupPlugin( if not os.path.isdir(datafolder): os.makedirs(datafolder) - click.echo("Creating backup at {}, please wait...".format(filename)) + click.echo(f"Creating backup at {filename}, please wait...") self._create_backup( filename, exclude=exclude, @@ -548,7 +549,7 @@ class BackupPlugin( path = os.path.join(datafolder, path) if not os.path.exists(path): - click.echo("Backup {} does not exist".format(path), err=True) + click.echo(f"Backup {path} does not exist", err=True) sys.exit(-1) archive = tempfile.NamedTemporaryFile(delete=False) @@ -566,7 +567,7 @@ class BackupPlugin( pip_args = settings.global_get(["plugins", "pluginmanager", "pip_args"]) def log(line): - click.echo("\t{}".format(line)) + click.echo(f"\t{line}") for plugin in plugins: octoprint_compatible = is_octoprint_compatible( @@ -642,9 +643,9 @@ class BackupPlugin( on_log_error=on_log_error, on_invalid_backup=on_log_error, ): - click.echo("Restored from {}".format(path)) + click.echo(f"Restored from {path}") else: - click.echo("Restoring from {} failed".format(path), err=True) + click.echo(f"Restoring from {path} failed", err=True) return [backup_command, restore_command] @@ -723,7 +724,7 @@ class BackupPlugin( try: os.remove(full_path) except Exception: - self._logger.exception("Could not delete {}".format(filename)) + self._logger.exception(f"Could not delete {filename}") raise def _get_backups(self): @@ -752,7 +753,7 @@ class BackupPlugin( data_file = os.path.join(self.get_plugin_data_folder(), UNKNOWN_PLUGINS_FILE) if os.path.exists(data_file): try: - with io.open(data_file, mode="rt", encoding="utf-8") as f: + with open(data_file, mode="rt", encoding="utf-8") as f: unknown_plugins = json.load(f) assert isinstance(unknown_plugins, list) @@ -850,7 +851,7 @@ class BackupPlugin( r.raise_for_status() except Exception: logger.exception( - "Error while fetching the plugin repository data from {}".format(url) + f"Error while fetching the plugin repository data from {url}" ) return {} @@ -871,7 +872,7 @@ class BackupPlugin( # prepare pip caller def log(prefix, *lines): for line in lines: - on_log("{} {}".format(prefix, line.rstrip())) + on_log(f"{prefix} {line.rstrip()}") def log_call(*lines): log(">", *lines) @@ -965,7 +966,7 @@ class BackupPlugin( configfile = settings._configfile basedir = settings._basedir - temporary_path = os.path.join(datafolder, ".{}".format(name)) + temporary_path = os.path.join(datafolder, f".{name}") final_path = os.path.join(datafolder, name) own_folder = datafolder @@ -1160,7 +1161,7 @@ class BackupPlugin( temp = tempfile.mkdtemp() try: if callable(on_log_progress): - on_log_progress("Unpacking backup to {}...".format(temp)) + on_log_progress(f"Unpacking backup to {temp}...") abstemp = os.path.abspath(temp) dirs = {} @@ -1191,7 +1192,7 @@ class BackupPlugin( import yaml - with io.open(configfile, "rt", encoding="utf-8") as f: + with open(configfile, encoding="utf-8") as f: configdata = yaml.safe_load(f) userfile = os.path.join(temp, "basedir", "users.yaml") @@ -1209,7 +1210,7 @@ class BackupPlugin( plugins = [] plugin_list_file = os.path.join(temp, "plugin_list.json") if os.path.exists(plugin_list_file): - with io.open(os.path.join(temp, "plugin_list.json"), "rb") as f: + with open(os.path.join(temp, "plugin_list.json"), "rb") as f: plugins = json.load(f) known_plugins = [] @@ -1259,16 +1260,12 @@ class BackupPlugin( basedir_extracted = os.path.join(temp, "basedir") if callable(on_log_progress): - on_log_progress( - "Renaming {} to {}...".format(basedir, basedir_backup) - ) + on_log_progress(f"Renaming {basedir} to {basedir_backup}...") shutil.move(basedir, basedir_backup) try: if callable(on_log_progress): - on_log_progress( - "Moving {} to {}...".format(basedir_extracted, basedir) - ) + on_log_progress(f"Moving {basedir_extracted} to {basedir}...") shutil.move(basedir_extracted, basedir) except Exception: if callable(on_log_error): @@ -1295,7 +1292,7 @@ class BackupPlugin( datafolder, UNKNOWN_PLUGINS_FILE ) try: - with io.open(unknown_plugins_path, mode="wb") as f: + with open(unknown_plugins_path, mode="wb") as f: f.write(to_bytes(json.dumps(unknown_plugins))) except Exception: if callable(on_log_error): @@ -1349,7 +1346,7 @@ class BackupPlugin( except Exception: if callable(on_log_error): on_log_error( - "Error while restarting via command {}".format(restart_command), + f"Error while restarting via command {restart_command}", exc_info=sys.exc_info(), ) on_log_error("Please restart OctoPrint manually") diff --git a/src/octoprint/plugins/corewizard/__init__.py b/src/octoprint/plugins/corewizard/__init__.py index 043cac4af..0096f5822 100644 --- a/src/octoprint/plugins/corewizard/__init__.py +++ b/src/octoprint/plugins/corewizard/__init__.py @@ -54,9 +54,9 @@ class CoreWizardPlugin( config = { "type": "wizard", "name": name, - "template": "corewizard_{}_wizard.jinja2".format(key), - "div": "wizard_plugin_corewizard_{}".format(key), - "suffix": "_{}".format(key), + "template": f"corewizard_{key}_wizard.jinja2", + "div": f"wizard_plugin_corewizard_{key}", + "suffix": f"_{key}", } if key in additional: additional_result = additional[key]() diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py index 054288b80..28d0e5fab 100644 --- a/src/octoprint/plugins/discovery/__init__.py +++ b/src/octoprint/plugins/discovery/__init__.py @@ -228,15 +228,15 @@ class DiscoveryPlugin( name, addresses=addresses, port=port, - server="{}.local.".format(socket.gethostname()), + server=f"{socket.gethostname()}.local.", properties=txt_record, ) self._zeroconf.register_service(info, allow_name_change=True) self._zeroconf_registrations[key].append(info) - self._logger.info("Registered '{}' for {}".format(name, reg_type)) + self._logger.info(f"Registered '{name}' for {reg_type}") except Exception: self._logger.exception( - "Could not register {} for {} on port {}".format(name, reg_type, port) + f"Could not register {name} for {reg_type} on port {port}" ) def zeroconf_unregister(self, reg_type, port=None): @@ -260,10 +260,10 @@ class DiscoveryPlugin( try: for info in infos: self._zeroconf.unregister_service(info) - self._logger.debug("Unregistered {} on port {}".format(reg_type, port)) + self._logger.debug(f"Unregistered {reg_type} on port {port}") except Exception: self._logger.exception( - "Could not (fully) unregister {} on port {}".format(reg_type, port) + f"Could not (fully) unregister {reg_type} on port {port}" ) def zeroconf_browse( @@ -349,9 +349,7 @@ class DiscoveryPlugin( for address in map(lambda x: socket.inet_ntoa(x), info.addresses): result.append(to_result(info, address)) - self._logger.debug( - "Browsing Zeroconf for {service_type}".format(service_type=service_type) - ) + self._logger.debug(f"Browsing Zeroconf for {service_type}") def browse(): listener = ZeroconfListener(self._logger) @@ -706,7 +704,7 @@ class DiscoveryPlugin( + socket.inet_aton("0.0.0.0"), ) - self._logger.info("Registered {} for SSDP".format(self.get_instance_name())) + self._logger.info(f"Registered {self.get_instance_name()} for SSDP") self._ssdp_notify(alive=True) @@ -728,7 +726,7 @@ class DiscoveryPlugin( interface_address = octoprint.util.address_for_client( *address, addresses=self._settings.get(["addresses"]), - interfaces=self._settings.get(["interfaces"]) + interfaces=self._settings.get(["interfaces"]), ) if not interface_address: continue @@ -772,9 +770,9 @@ class DiscoveryPlugin( def get_instance_name(self): name = self._settings.global_get(["appearance", "name"]) if name: - return 'OctoPrint instance "{}"'.format(name) + return f'OctoPrint instance "{name}"' else: - return "OctoPrint instance on {}".format(socket.gethostname()) + return f"OctoPrint instance on {socket.gethostname()}" def get_interface_addresses(self): addresses = self._settings.get(["addresses"]) diff --git a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js index 5f194574a..9986b0b8a 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/gcodeviewer.js @@ -365,7 +365,8 @@ $(function () { onLayerSelected: self._onLayerSelected, bed: self._retrieveBedDimensions(), toolOffsets: self._retrieveToolOffsets(), - invertAxes: self._retrieveAxesConfiguration() + invertAxes: self._retrieveAxesConfiguration(), + bedZ: self.settings.settings.gcodeAnalysis.bedZ() }); if (!initResult) { diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js index 48dd4e49c..507976f8a 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/reader.js @@ -39,7 +39,8 @@ GCODE.gCodeReader = (function () { centeredOrigin: undefined }, ignoreOutsideBed: false, - g90InfluencesExtruder: false + g90InfluencesExtruder: false, + bedZ: 0 }; var percentageTree = undefined; @@ -166,7 +167,8 @@ GCODE.gCodeReader = (function () { toolOffsets: gCodeOptions["toolOffsets"], bed: gCodeOptions["bed"], ignoreOutsideBed: gCodeOptions["ignoreOutsideBed"], - g90InfluencesExtruder: gCodeOptions["g90InfluencesExtruder"] + g90InfluencesExtruder: gCodeOptions["g90InfluencesExtruder"], + bedZ: gCodeOptions["bedZ"] } } }); @@ -174,11 +176,11 @@ GCODE.gCodeReader = (function () { setOption: function (options) { var dirty = false; - for (var opt in options) { - if (options[opt] === undefined) continue; - dirty = dirty || gCodeOptions[opt] != options[opt]; - gCodeOptions[opt] = options[opt]; - } + _.forOwn(options, function (value, key) { + if (value === undefined) return; + dirty = dirty || gCodeOptions[key] !== value; + gCodeOptions[key] = value; + }); if (dirty) { if (model && model.length > 0) this.passDataToRenderer(); } diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js index e8c3863ee..50e1410b5 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/ui.js @@ -156,7 +156,8 @@ GCODE.ui = (function () { }); GCODE.gCodeReader.setOption({ toolOffsets: options.toolOffsets, - bed: options.bed + bed: options.bed, + bedZ: options.bedZ }); GCODE.renderer.render(0, 0); diff --git a/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js b/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js index 350102285..b75b7f15e 100644 --- a/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js +++ b/src/octoprint/plugins/gcodeviewer/static/js/viewer/worker.js @@ -715,6 +715,7 @@ var parseGCode = function (message) { bed = message.options.bed; ignoreOutsideBed = message.options.ignoreOutsideBed; g90InfluencesExtruder = message.options.g90InfluencesExtruder; + boundingBox.minZ = min.z = message.options.bedZ; doParse(); gcode = []; diff --git a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 index 1520023a1..1ba49d79b 100644 --- a/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 +++ b/src/octoprint/plugins/gcodeviewer/templates/gcodeviewer_settings.jinja2 @@ -1,9 +1,9 @@
- +
- +
{{ _('on desktop')}}
@@ -19,12 +19,10 @@
-
- -
- -
+
+
+ {% trans %}If provided, the GCode Viewer will search for a line beginning with this string. If found, all GCode up to that point will be skipped. This can be used to skip "purge/nozzle wipe" GCode in the viewer. Note the search is case sensitive. Example: ; layer 1{% endtrans %} diff --git a/src/octoprint/plugins/logging/__init__.py b/src/octoprint/plugins/logging/__init__.py index 62f202ce9..a27da578c 100644 --- a/src/octoprint/plugins/logging/__init__.py +++ b/src/octoprint/plugins/logging/__init__.py @@ -1,12 +1,11 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import os from os import scandir import yaml -from flask import jsonify, make_response, request, url_for +from flask import abort, jsonify, request, url_for from flask_babel import gettext from werkzeug.exceptions import BadRequest from werkzeug.utils import secure_filename @@ -17,6 +16,7 @@ from octoprint.access.permissions import Permissions from octoprint.server import NO_CONTENT from octoprint.server.util.flask import no_firstrun_access, redirect_to_tornado from octoprint.settings import settings +from octoprint.util import is_hidden_path class LoggingPlugin( @@ -81,8 +81,12 @@ class LoggingPlugin( @Permissions.PLUGIN_LOGGING_MANAGE.require(403) def delete_log(self, filename): secure = os.path.join(settings().getBaseFolder("logs"), secure_filename(filename)) - if not os.path.exists(secure): - return make_response("File not found: %s" % filename, 404) + if ( + not os.path.exists(secure) + or is_hidden_path(secure) + or not filename.endswith(".log") + ): + abort(404) os.remove(secure) @@ -107,15 +111,15 @@ class LoggingPlugin( @Permissions.PLUGIN_LOGGING_MANAGE.require(403) def set_logging_levels_api(self): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") try: json_data = request.json except BadRequest: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") if not isinstance(json_data, dict): - return make_response("Invalid log level configuration", 400) + abort(400, description="Invalid log level configuration") # TODO validate further @@ -135,6 +139,12 @@ class LoggingPlugin( files = [] basedir = settings().getBaseFolder("logs", check_writable=False) for entry in scandir(basedir): + if is_hidden_path(entry.path) or not entry.name.endswith(".log"): + continue + + if not entry.is_file(): + continue + files.append( { "name": entry.name, @@ -172,7 +182,7 @@ class LoggingPlugin( if os.path.exists(logging_file) and os.path.isfile(logging_file): import yaml - with io.open(logging_file, "rt", encoding="utf-8") as f: + with open(logging_file, encoding="utf-8") as f: config_from_file = yaml.safe_load(f) return config_from_file @@ -231,7 +241,7 @@ class LoggingPlugin( for logger, level in new_levels.items(): level = logging.getLevelName(level) - self._logger.info("Setting logger {} level to {}".format(logger, level)) + self._logger.info(f"Setting logger {logger} level to {level}") self._logger.manager.loggerDict[logger].setLevel(level) def _is_managed_logger(self, logger): diff --git a/src/octoprint/plugins/logging/static/clientjs/logging.js b/src/octoprint/plugins/logging/static/clientjs/logging.js index bccbfc216..78b739f27 100644 --- a/src/octoprint/plugins/logging/static/clientjs/logging.js +++ b/src/octoprint/plugins/logging/static/clientjs/logging.js @@ -13,6 +13,8 @@ this.setupUrl = this.baseUrl + "setup"; }; + var bulkDownloadUrl = "downloads/logs"; + OctoPrintLoggingClient.prototype.get = function (opts) { return this.base.get(this.baseUrl, opts); }; @@ -31,6 +33,10 @@ return this.base.download(fileUrl, opts); }; + OctoPrintLoggingClient.prototype.bulkDownloadUrl = function (filenames) { + return this.base.bulkDownloadUrl(bulkDownloadUrl, filenames); + }; + OctoPrintLoggingClient.prototype.updateLevels = function (config, opts) { return this.base.putJson(this.setupUrl + "/levels", config, opts); }; diff --git a/src/octoprint/plugins/logging/static/js/logging.js b/src/octoprint/plugins/logging/static/js/logging.js index 53052f376..d403ef0e0 100644 --- a/src/octoprint/plugins/logging/static/js/logging.js +++ b/src/octoprint/plugins/logging/static/js/logging.js @@ -273,6 +273,27 @@ $(function () { ); }; + self.enableBulkDownload = ko.pureComputed(function () { + return self.markedForDeletion().length && !self.bulkDownloadUrlTooLong(); + }); + + self.bulkDownloadUrlTooLong = ko.pureComputed(function () { + return BASEURL.length + self.bulkDownloadUrl().length >= 2000; + }); + + self.bulkDownloadButtonUrl = ko.pureComputed(function () { + var files = self.markedForDeletion(); + if (!files.length || self.bulkDownloadUrlTooLong()) { + return "javascript:void(0)"; + } + return self.bulkDownloadUrl(); + }); + + self.bulkDownloadUrl = function () { + var files = self.markedForDeletion(); + return OctoPrint.plugins.logging.bulkDownloadUrl(files); + }; + self.onServerReconnect = self.onUserLoggedIn = self.onEventSettingsUpdated = self.onSettingsShown = function () { if ( !self.loginState.hasPermission( diff --git a/src/octoprint/plugins/logging/templates/logging_settings.jinja2 b/src/octoprint/plugins/logging/templates/logging_settings.jinja2 index b00b55db5..e19755068 100644 --- a/src/octoprint/plugins/logging/templates/logging_settings.jinja2 +++ b/src/octoprint/plugins/logging/templates/logging_settings.jinja2 @@ -21,6 +21,7 @@
+ {{_('Download selected')}}
diff --git a/src/octoprint/plugins/pi_support/__init__.py b/src/octoprint/plugins/pi_support/__init__.py index 63ad242ac..850d28ef2 100644 --- a/src/octoprint/plugins/pi_support/__init__.py +++ b/src/octoprint/plugins/pi_support/__init__.py @@ -1,7 +1,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import os import flask @@ -95,7 +94,7 @@ class ThrottleState: self._past_throttled = False for key, value in kwargs.items(): - local_key = "_{}".format(key) + local_key = f"_{key}" if hasattr(self, local_key) and isinstance(value, bool): setattr(self, local_key, value) @@ -141,7 +140,7 @@ class ThrottleState: @property def raw_value_hex(self): - return "0x{:X}".format(self._raw_value) + return f"0x{self._raw_value:X}" def __eq__(self, other): if not isinstance(other, ThrottleState): @@ -176,7 +175,7 @@ def get_proc_dt_model(): global _proc_dt_model if _proc_dt_model is None: - with io.open(_PROC_DT_MODEL_PATH, "rt", encoding="utf-8") as f: + with open(_PROC_DT_MODEL_PATH, encoding="utf-8") as f: _proc_dt_model = f.readline().strip(" \t\r\n\0") return _proc_dt_model @@ -189,7 +188,7 @@ def get_vcgencmd_throttled_state(command): output = sarge.get_stdout(command, close_fds=CLOSE_FDS) if "throttled=0x" not in output: - raise ValueError('cannot parse "{}" output: {}'.format(command, output)) + raise ValueError(f'cannot parse "{command}" output: {output}') value = output[len("throttled=") :].strip(" \t\r\n\0") value = int(value, 0) @@ -207,7 +206,7 @@ def get_octopi_version(): global _octopi_version if _octopi_version is None: - with io.open(_OCTOPI_VERSION_PATH, "rt", encoding="utf-8") as f: + with open(_OCTOPI_VERSION_PATH, encoding="utf-8") as f: _octopi_version = f.readline().strip(" \t\r\n\0") return _octopi_version @@ -362,7 +361,7 @@ class PiSupportPlugin( def _check_throttled_state(self): command = self._settings.get(["vcgencmd_throttle_check_command"]) - self._logger.debug('Retrieving throttle state via "{}"'.format(command)) + self._logger.debug(f'Retrieving throttle state via "{command}"') try: state = get_vcgencmd_throttled_state(command) except ValueError: diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 6c3607f46..375412f8d 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -3,7 +3,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" import copy -import io import logging import os import re @@ -19,7 +18,7 @@ import filetype import pkg_resources import requests import sarge -from flask import jsonify, make_response +from flask import Response, abort, jsonify, request from flask_babel import gettext import octoprint.plugin @@ -27,13 +26,14 @@ import octoprint.plugin.core from octoprint.access import ADMIN_GROUP from octoprint.access.permissions import Permissions from octoprint.events import Events +from octoprint.server import safe_mode from octoprint.server.util.flask import ( check_etag, no_firstrun_access, with_revalidation_checking, ) from octoprint.settings import valid_boolean_trues -from octoprint.util import TemporaryDirectory, to_bytes +from octoprint.util import TemporaryDirectory, deprecated, to_bytes from octoprint.util.net import download_file from octoprint.util.pip import create_pip_caller from octoprint.util.platform import get_os, is_os_compatible @@ -358,7 +358,7 @@ class PluginManagerPlugin( input_upload_path not in flask.request.values or input_upload_name not in flask.request.values ): - return flask.make_response("No file included", 400) + abort(400, description="No file included") upload_path = flask.request.values[input_upload_path] upload_name = flask.request.values[input_upload_name] @@ -369,9 +369,9 @@ class PluginManagerPlugin( ) ) if not len(exts): - return flask.make_response( - "File doesn't have a valid extension for a plugin archive or a single file plugin", + abort( 400, + description="File doesn't have a valid extension for a plugin archive or a single file plugin", ) ext = exts[0] @@ -398,7 +398,7 @@ class PluginManagerPlugin( with self._install_lock: if self._install_task is not None: - return make_response("There's already a plugin being installed", 409) + abort(409, description="There's already a plugin being installed") self._install_task = threading.Thread( target=perform_install, @@ -419,16 +419,159 @@ class PluginManagerPlugin( def export_plugin_list(self): import json - import flask - plugins = self.generate_plugins_json(self._settings, self._plugin_manager) - return flask.Response( + return Response( json.dumps(plugins), mimetype="text/plain", headers={"Content-Disposition": 'attachment; filename="plugin_list.json"'}, ) + def _plugin_response(self): + return { + "plugins": self._get_plugins(), + "os": get_os(), + "octoprint": get_octoprint_version_string(), + "pip": { + "available": self._pip_caller.available, + "version": self._pip_caller.version_string, + "install_dir": self._pip_caller.install_dir, + "use_user": self._pip_caller.use_user, + "virtual_env": self._pip_caller.virtual_env, + "additional_args": self._settings.get(["pip_args"]), + "python": sys.executable, + }, + "safe_mode": safe_mode, + "online": self._connectivity_checker.online, + } + + @octoprint.plugin.BlueprintPlugin.route("/plugins") + @Permissions.PLUGIN_PLUGINMANAGER_MANAGE.require(403) + def retrieve_plugins(self): + refresh = request.values.get("refresh", "false") in valid_boolean_trues + if refresh or not self._is_notices_cache_valid(): + self._notices_available = self._refresh_notices() + + def view(): + return jsonify(**self._plugin_response()) + + def etag(): + import hashlib + + hash = hashlib.sha1() + + def hash_update(value): + value = value.encode("utf-8") + hash.update(value) + + hash_update(repr(self._get_plugins())) + hash_update(str(self._notices_available)) + hash_update(repr(self._notices)) + hash_update(repr(safe_mode)) + hash_update(repr(self._connectivity_checker.online)) + hash_update(repr(_DATA_FORMAT_VERSION)) + return hash.hexdigest() + + def condition(): + return check_etag(etag()) + + return with_revalidation_checking( + etag_factory=lambda *args, **kwargs: etag(), + condition=lambda *args, **kwargs: condition(), + unless=lambda: refresh, + )(view)() + + @octoprint.plugin.BlueprintPlugin.route("/plugins/") + @Permissions.PLUGIN_PLUGINMANAGER_MANAGE.require(403) + def retrieve_specific_plugin(self, key): + plugin = self._plugin_manager.get_plugin_info(key, require_enabled=False) + if plugin is None: + return abort(404) + + return jsonify(plugin=self._to_external_plugin(plugin)) + + def _orphan_response(self): + return {"orphan_data": self._get_orphans()} + + @octoprint.plugin.BlueprintPlugin.route("/orphans") + @Permissions.PLUGIN_PLUGINMANAGER_MANAGE.require(403) + def retrieve_plugin_orphans(self): + if not Permissions.PLUGIN_PLUGINMANAGER_MANAGE.can(): + abort(403) + + refresh = request.values.get("refresh", "false") in valid_boolean_trues + if refresh: + self._get_orphans(refresh=True) + + def view(): + return jsonify(**self._orphan_response()) + + def etag(): + import hashlib + + hash = hashlib.sha1() + + def hash_update(value): + value = value.encode("utf-8") + hash.update(value) + + hash_update(repr(self._get_orphans())) + hash_update(repr(_DATA_FORMAT_VERSION)) + return hash.hexdigest() + + def condition(): + return check_etag(etag()) + + return with_revalidation_checking( + etag_factory=lambda *args, **kwargs: etag(), + condition=lambda *args, **kwargs: condition(), + unless=lambda: refresh, + )(view)() + + def _repository_response(self): + return { + "repository": { + "available": self._repository_available, + "plugins": self._repository_plugins, + } + } + + @octoprint.plugin.BlueprintPlugin.route("/repository") + @Permissions.PLUGIN_PLUGINMANAGER_MANAGE.require(403) + def retrieve_plugin_repository(self): + if not Permissions.PLUGIN_PLUGINMANAGER_MANAGE.can(): + abort(403) + + refresh = request.values.get("refresh", "false") in valid_boolean_trues + if refresh or not self._is_repository_cache_valid(): + self._repository_available = self._refresh_repository() + + def view(): + return jsonify(**self._repository_response()) + + def etag(): + import hashlib + + hash = hashlib.sha1() + + def hash_update(value): + value = value.encode("utf-8") + hash.update(value) + + hash_update(str(self._repository_available)) + hash_update(repr(self._repository_plugins)) + hash_update(repr(_DATA_FORMAT_VERSION)) + return hash.hexdigest() + + def condition(): + return check_etag(etag()) + + return with_revalidation_checking( + etag_factory=lambda *args, **kwargs: etag(), + condition=lambda *args, **kwargs: condition(), + unless=lambda: refresh, + )(view)() + def is_blueprint_protected(self): return False @@ -458,97 +601,23 @@ class PluginManagerPlugin( "refresh_repository": [], } - def on_api_get(self, request): - if not Permissions.PLUGIN_PLUGINMANAGER_MANAGE.can(): - return make_response("Insufficient rights", 403) - - from octoprint.server import safe_mode - - refresh_repository = ( - request.values.get("refresh_repository", "false") in valid_boolean_trues - ) - if refresh_repository or not self._is_repository_cache_valid(): - self._repository_available = self._refresh_repository() - - refresh_notices = ( - request.values.get("refresh_notices", "false") in valid_boolean_trues - ) - if refresh_notices or not self._is_notices_cache_valid(): - self._notices_available = self._refresh_notices() - - refresh_orphan = ( - request.values.get("refresh_orphans", "false") in valid_boolean_trues - ) - - def view(): - return jsonify( - plugins=self._get_plugins(), - repository={ - "available": self._repository_available, - "plugins": self._repository_plugins, - }, - orphan_data=self._get_orphans(refresh=refresh_orphan), - os=get_os(), - octoprint=get_octoprint_version_string(), - pip={ - "available": self._pip_caller.available, - "version": self._pip_caller.version_string, - "install_dir": self._pip_caller.install_dir, - "use_user": self._pip_caller.use_user, - "virtual_env": self._pip_caller.virtual_env, - "additional_args": self._settings.get(["pip_args"]), - "python": sys.executable, - }, - safe_mode=safe_mode, - online=self._connectivity_checker.online, - ) - - def etag(): - import hashlib - - hash = hashlib.sha1() - - def hash_update(value): - value = value.encode("utf-8") - hash.update(value) - - hash_update(repr(self._get_plugins())) - hash_update(str(self._repository_available)) - hash_update(repr(self._repository_plugins)) - hash_update(str(self._notices_available)) - hash_update(repr(self._notices)) - hash_update(repr(self._get_orphans())) - hash_update(repr(safe_mode)) - hash_update(repr(self._connectivity_checker.online)) - hash_update(repr(_DATA_FORMAT_VERSION)) - return hash.hexdigest() - - def condition(): - return check_etag(etag()) - - return with_revalidation_checking( - etag_factory=lambda *args, **kwargs: etag(), - condition=lambda *args, **kwargs: condition(), - unless=lambda: refresh_repository or refresh_notices or refresh_orphan, - )(view)() - def on_api_command(self, command, data): if not Permissions.PLUGIN_PLUGINMANAGER_MANAGE.can(): - return make_response("Insufficient rights", 403) + abort(403) if self._printer.is_printing() or self._printer.is_paused(): # do not update while a print job is running - return make_response("Printer is currently printing or paused", 409) + abort(409, description="Printer is currently printing or paused") if command == "install": if not Permissions.PLUGIN_PLUGINMANAGER_INSTALL.can(): - return make_response("Insufficient rights", 403) + abort(403) url = data["url"] plugin_name = data["plugin"] if "plugin" in data else None with self._install_lock: if self._install_task is not None: - return make_response("There's already a plugin being installed", 409) + abort(409, description="There's already a plugin being installed") self._install_task = threading.Thread( target=self.command_install, @@ -568,7 +637,7 @@ class PluginManagerPlugin( elif command == "uninstall": plugin_name = data["plugin"] if plugin_name not in self._plugin_manager.plugins: - return make_response("Unknown plugin: %s" % plugin_name, 404) + abort(404, description="Unknown plugin") plugin = self._plugin_manager.plugins[plugin_name] return self.command_uninstall(plugin, cleanup=data.get("cleanup", False)) @@ -589,11 +658,44 @@ class PluginManagerPlugin( elif command == "enable" or command == "disable": plugin_name = data["plugin"] if plugin_name not in self._plugin_manager.plugins: - return make_response("Unknown plugin: %s" % plugin_name, 404) + abort(404, description="Unknown plugin") plugin = self._plugin_manager.plugins[plugin_name] return self.command_toggle(plugin, command) + @deprecated( + "Deprecated API endpoint api/plugin/pluginmanager used. " + "Please switch clients to plugin/pluginmanager/*", + since="1.6.0", + ) + def on_api_get(self, r): + if not Permissions.PLUGIN_PLUGINMANAGER_MANAGE.can(): + abort(403) + + refresh_repository = ( + request.values.get("refresh_repository", "false") in valid_boolean_trues + ) + if refresh_repository or not self._is_repository_cache_valid(): + self._repository_available = self._refresh_repository() + + refresh_notices = ( + request.values.get("refresh_notices", "false") in valid_boolean_trues + ) + if refresh_notices or not self._is_notices_cache_valid(): + self._notices_available = self._refresh_notices() + + refresh_orphan = ( + request.values.get("refresh_orphans", "false") in valid_boolean_trues + ) + if refresh_orphan: + self._get_orphans(refresh=True) + + result = {} + result.update(**self._plugin_response()) + result.update(**self._orphan_response()) + result.update(**self._repository_response()) + return jsonify(**result) + # noinspection PyMethodMayBeStatic def _is_archive(self, path): _, ext = os.path.splitext(path) @@ -602,7 +704,7 @@ class PluginManagerPlugin( kind = filetype.guess(path) if kind: - return ".{}".format(kind.extension) in PluginManagerPlugin.ARCHIVE_EXTENSIONS + return f".{kind.extension}" in PluginManagerPlugin.ARCHIVE_EXTENSIONS return False def _is_pythonfile(self, path): @@ -611,13 +713,11 @@ class PluginManagerPlugin( import ast try: - with io.open(path, "rb") as f: + with open(path, "rb") as f: ast.parse(f.read(), filename=path) return True except Exception as exc: - self._logger.exception( - "Could not parse {} as python file: {}".format(path, exc) - ) + self._logger.exception(f"Could not parse {path} as python file: {exc}") return False @@ -664,12 +764,12 @@ class PluginManagerPlugin( raise exceptions.InvalidPackageFormat() except requests.exceptions.HTTPError as e: - self._logger.error("Could not fetch plugin from server, got {}".format(e)) + self._logger.error(f"Could not fetch plugin from server, got {e}") result = { "result": False, "source": source, "source_type": source_type, - "reason": "Could not fetch plugin from server, got {}".format(e), + "reason": f"Could not fetch plugin from server, got {e}", } self._send_result_notification("install", result) @@ -760,7 +860,7 @@ class PluginManagerPlugin( lambda line: path_url in line.lower() ) # lower case in case of windows - self._logger.info("Installing plugin from {}".format(source)) + self._logger.info(f"Installing plugin from {source}") pip_args = [ "--disable-pip-version-check", "install", @@ -806,7 +906,7 @@ class PluginManagerPlugin( ) force = True except Exception as e: - self._logger.exception("Could not install plugin from {}".format(source)) + self._logger.exception(f"Could not install plugin from {source}") self._logger.exception("Reason: {}".format(repr(e))) result = { "result": False, @@ -827,9 +927,7 @@ class PluginManagerPlugin( try: returncode, stdout, stderr = self._call_pip(pip_args) except Exception as e: - self._logger.exception( - "Could not install plugin from {}".format(source) - ) + self._logger.exception(f"Could not install plugin from {source}") self._logger.exception("Reason: {}".format(repr(e))) result = { "result": False, @@ -989,7 +1087,7 @@ class PluginManagerPlugin( if name is None: name = os.path.basename(path) - self._logger.info("Installing single file plugin {} from {}".format(name, source)) + self._logger.info(f"Installing single file plugin {name} from {source}") all_plugins_before = self._plugin_manager.find_plugins(existing={}) @@ -997,10 +1095,10 @@ class PluginManagerPlugin( plugin_id, _ = os.path.splitext(name) try: - self._log_call("cp {} {}".format(path, destination)) + self._log_call(f"cp {path} {destination}") shutil.copy(path, destination) except Exception: - self._logger.exception("Installing plugin from {} failed".format(source)) + self._logger.exception(f"Installing plugin from {source} failed") result = { "result": False, "source": source, @@ -1076,15 +1174,15 @@ class PluginManagerPlugin( def command_uninstall(self, plugin, cleanup=False): if plugin.key == "pluginmanager": - return make_response("Can't uninstall Plugin Manager", 403) + abort(403, description="Can't uninstall Plugin Manager") if not plugin.managable: - return make_response( - "Plugin is not managable and hence cannot be uninstalled", 403 + abort( + 403, description="Plugin is not managable and hence cannot be uninstalled" ) if plugin.bundled: - return make_response("Bundled plugins cannot be uninstalled", 403) + abort(403, description="Bundled plugins cannot be uninstalled") if plugin.origin is None: self._logger.warning( @@ -1092,7 +1190,7 @@ class PluginManagerPlugin( **locals() ) ) - return make_response("Could not uninstall plugin, its origin is unknown") + abort(500, description="Could not uninstall plugin, its origin is unknown") if plugin.origin.type == "entry_point": # plugin is installed through entry point, need to use pip to uninstall it @@ -1105,9 +1203,9 @@ class PluginManagerPlugin( self._call_pip(pip_args) except Exception: self._logger.exception("Could not uninstall plugin via pip") - return make_response( - "Could not uninstall plugin via pip, see the log for more details", + abort( 500, + description="Could not uninstall plugin via pip, see the log for more details", ) elif plugin.origin.type == "folder": @@ -1118,22 +1216,16 @@ class PluginManagerPlugin( if os.path.isdir(full_path): # plugin is installed via a plugin folder, need to use rmtree to get rid of it - self._log_stdout( - "Deleting plugin from {folder}".format(folder=plugin.location) - ) + self._log_stdout(f"Deleting plugin from {plugin.location}") shutil.rmtree(full_path) elif os.path.isfile(full_path): - self._log_stdout( - "Deleting plugin from {file}".format(file=plugin.location) - ) + self._log_stdout(f"Deleting plugin from {plugin.location}") os.remove(full_path) if full_path.endswith(".py"): pyc_file = "{full_path}c".format(**locals()) if os.path.isfile(pyc_file): - self._log_stdout( - "Deleting plugin from {file}".format(file=pyc_file) - ) + self._log_stdout(f"Deleting plugin from {pyc_file}") os.remove(pyc_file) else: @@ -1142,7 +1234,7 @@ class PluginManagerPlugin( **locals() ) ) - return make_response("Could not uninstall plugin, its origin is unknown") + abort(500, description="Could not uninstall plugin, its origin is unknown") needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin) or cleanup needs_refresh = plugin.implementation and isinstance( @@ -1167,9 +1259,7 @@ class PluginManagerPlugin( if plugin.enabled: self._plugin_manager.disable_plugin(plugin.key, plugin=plugin) except octoprint.plugin.core.PluginLifecycleException as e: - self._logger.exception( - "Problem disabling plugin {name}".format(name=plugin.key) - ) + self._logger.exception(f"Problem disabling plugin {plugin.key}") result = { "result": False, "uninstalled": True, @@ -1184,9 +1274,7 @@ class PluginManagerPlugin( if plugin.loaded: self._plugin_manager.unload_plugin(plugin.key) except octoprint.plugin.core.PluginLifecycleException as e: - self._logger.exception( - "Problem unloading plugin {name}".format(name=plugin.key) - ) + self._logger.exception(f"Problem unloading plugin {plugin.key}") result = { "result": False, "uninstalled": True, @@ -1213,7 +1301,7 @@ class PluginManagerPlugin( "plugin": self._to_external_plugin(plugin), } self._send_result_notification("uninstall", result) - self._logger.info("Plugin {} uninstalled".format(plugin.key)) + self._logger.info(f"Plugin {plugin.key} uninstalled") self._cleanup_disabled(plugin.key) if cleanup: @@ -1234,7 +1322,7 @@ class PluginManagerPlugin( key = plugin.key result_value = self._to_external_plugin(plugin) - message = "Cleaning up plugin {}...".format(key) + message = f"Cleaning up plugin {key}..." self._logger.info(message) self._log_stdout(message) @@ -1248,7 +1336,7 @@ class PluginManagerPlugin( # delete plugin data folder result_data = True if not self._cleanup_data(key): - message = "Could not delete data folder of plugin {}".format(key) + message = f"Could not delete data folder of plugin {key}" self._logger.exception(message) self._log_stderr(message) result_data = False @@ -1322,7 +1410,7 @@ class PluginManagerPlugin( return True except Exception: self._logger.exception( - "Could not delete plugin data folder at {}".format(data_folder) + f"Could not delete plugin data folder at {data_folder}" ) return False else: @@ -1330,7 +1418,7 @@ class PluginManagerPlugin( def command_toggle(self, plugin, command): if plugin.key == "pluginmanager" or (plugin.hidden and plugin.bundled): - return make_response("Can't enable/disable Plugin Manager", 400) + abort(400, description="Can't enable/disable Plugin Manager") pending = (command == "disable" and plugin.key in self._pending_enable) or ( command == "enable" and plugin.key in self._pending_disable @@ -1576,9 +1664,7 @@ class PluginManagerPlugin( try: import json - with io.open( - self._repository_cache_path, "rt", encoding="utf-8" - ) as f: + with open(self._repository_cache_path, encoding="utf-8") as f: repo_data = json.load(f) self._repository_mtime = mtime self._logger.info( @@ -1604,9 +1690,7 @@ class PluginManagerPlugin( try: r = requests.get(repository_url, timeout=30) r.raise_for_status() - self._logger.info( - "Loaded plugin repository data from {}".format(repository_url) - ) + self._logger.info(f"Loaded plugin repository data from {repository_url}") except Exception as e: self._logger.exception( "Could not fetch plugins from repository at {repository_url}: {message}".format( @@ -1618,13 +1702,13 @@ class PluginManagerPlugin( try: repo_data = r.json() except Exception as e: - self._logger.exception("Error while reading repository data: {}".format(e)) + self._logger.exception(f"Error while reading repository data: {e}") return None # validation if not isinstance(repo_data, (list, tuple)): self._logger.warning( - "Invalid repository data: expected a list, got {!r}".format(repo_data) + f"Invalid repository data: expected a list, got {repo_data!r}" ) return None @@ -1671,7 +1755,7 @@ class PluginManagerPlugin( try: import json - with io.open(self._notices_cache_path, "rt", encoding="utf-8") as f: + with open(self._notices_cache_path, encoding="utf-8") as f: notice_data = json.load(f) self._notices_mtime = mtime self._logger.info("Loaded notice data from disk, was still valid") @@ -1695,7 +1779,7 @@ class PluginManagerPlugin( try: r = requests.get(notices_url, timeout=30) r.raise_for_status() - self._logger.info("Loaded plugin notices data from {}".format(notices_url)) + self._logger.info(f"Loaded plugin notices data from {notices_url}") except Exception as e: self._logger.exception( "Could not fetch notices from {notices_url}: {message}".format( diff --git a/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js index 2197e0d45..e240c3fcc 100644 --- a/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js +++ b/src/octoprint/plugins/pluginmanager/static/clientjs/pluginmanager.js @@ -10,6 +10,10 @@ }; OctoPrintPluginManagerClient.prototype.get = function (refresh, opts) { + console.log( + "Deprecated endpoint OctoPrint.plugin.pluginmanager.get, " + + "please use OctoPrint.plugin.pluginmanager.get*" + ); var refresh_repo, refresh_notices, refresh_orphans; if (_.isPlainObject(refresh)) { refresh_repo = refresh.repo || false; @@ -34,13 +38,41 @@ }; OctoPrintPluginManagerClient.prototype.getWithRefresh = function (opts) { + console.log( + "Deprecated endpoint OctoPrint.plugin.pluginmanager.getWithRefresh, " + + "please use OctoPrint.plugin.pluginmanager.get*" + ); return this.get(true, opts); }; OctoPrintPluginManagerClient.prototype.getWithoutRefresh = function (opts) { + console.log( + "Deprecated endpoint OctoPrint.plugin.pluginmanager.getWithoutRefresh, " + + "please use OctoPrint.plugin.pluginmanager.get*" + ); return this.get(false, opts); }; + OctoPrintPluginManagerClient.prototype.getPlugins = function (refresh, opts) { + var url = this.base.getBlueprintUrl("pluginmanager") + "plugins"; + return this.base.get(url + (refresh ? "?refresh=true" : ""), opts); + }; + + OctoPrintPluginManagerClient.prototype.getPlugin = function (plugin, opts) { + var url = this.base.getBlueprintUrl("pluginmanager") + "plugins/" + plugin; + return this.base.get(url, opts); + }; + + OctoPrintPluginManagerClient.prototype.getOrphans = function (refresh, opts) { + var url = this.base.getBlueprintUrl("pluginmanager") + "orphans"; + return this.base.get(url + (refresh ? "?refresh=true" : ""), opts); + }; + + OctoPrintPluginManagerClient.prototype.getRepository = function (refresh, opts) { + var url = this.base.getBlueprintUrl("pluginmanager") + "repository"; + return this.base.get(url + (refresh ? "?refresh=true" : ""), opts); + }; + OctoPrintPluginManagerClient.prototype.install = function ( pluginUrl, dependencyLinks, diff --git a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js index b0a72ccfe..7d7eba04b 100644 --- a/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js +++ b/src/octoprint/plugins/pluginmanager/static/js/pluginmanager.js @@ -50,7 +50,7 @@ $(function () { return !item.enabled; } }, - "name", + "popularity", [], [ ["bundled", "3rdparty"], @@ -174,7 +174,7 @@ $(function () { "#settings_plugin_pluginmanager_repositorydialog_upload_start" ); - self.repositoryAvailable = ko.observable(false); + self.repositoryAvailable = ko.observable(undefined); self.repositorySearchQuery = ko.observable(); self.repositorySearchQuery.subscribe(function () { @@ -499,17 +499,7 @@ $(function () { return false; }; - self.fromResponse = function (data, options) { - self._fromPluginsResponse(data.plugins, options); - self._fromOrphanResponse(data.orphan_data, options); - self._fromRepositoryResponse(data.repository, options); - self._fromPipResponse(data.pip, options); - - self.safeMode(data.safe_mode || false); - self.online(data.online !== undefined ? data.online : true); - }; - - self._fromPluginsResponse = function (data, options) { + self.fromPluginsResponse = function (data, options) { var evalNotices = options.eval_notices || false; var ignoreNoticeHidden = options.ignore_notice_hidden || false; var ignoreNoticeIgnored = options.ignore_notice_ignored || false; @@ -549,7 +539,7 @@ $(function () { self.plugins.updateItems(data); }; - self._fromOrphanResponse = function (data) { + self.fromOrphanResponse = function (data) { var orphans = []; _.each(data, function (value, key) { orphans.push({ @@ -561,7 +551,7 @@ $(function () { self.orphans.updateItems(orphans); }; - self._fromRepositoryResponse = function (data) { + self.fromRepositoryResponse = function (data) { self.repositoryAvailable(data.available); if (data.available) { self.repositoryplugins.updateItems(data.plugins); @@ -570,7 +560,7 @@ $(function () { } }; - self._fromPipResponse = function (data) { + self.fromPipResponse = function (data) { self.pipAvailable(data.available); if (data.available) { self.pipVersion(data.version); @@ -588,41 +578,23 @@ $(function () { } }; - self.dataDeferred = undefined; - self.requestData = function (options) { + self.dataPluginsDeferred = undefined; + self.requestPluginData = function (options) { if (!_.isPlainObject(options)) { - options = { - refresh_repo: options, - refresh_orphans: false, - refresh_notices: false, - eval_notices: false - }; + options = {}; } - options.refresh_repo = options.refresh_repo || false; - options.refresh_orphans = options.refresh_orphans || false; - options.refresh_notices = options.refresh_notices || false; - options.eval_notices = options.eval_notices || false; - if ( - self.dataDeferred && - self.dataDeferred.state() === "pending" && - !options.refresh_repo && - !options.refresh_orphans && - !options.refresh_notices && - !options.eval_notices + self.dataPluginsDeferred && + self.dataPluginsDeferred.state() === "pending" && + !!!options.refresh ) { - return self.dataDeferred.promise(); + return self.dataPluginsDeferred.promise(); } var deferred = new $.Deferred(); - if ( - !options.refresh_repo && - !options.refresh_orphans && - !options.refresh_notices && - !options.eval_notices - ) { - self.dataDeferred = deferred; + if (!!!options.refresh) { + self.dataPluginsDeferred = deferred; } if ( @@ -635,18 +607,99 @@ $(function () { } OctoPrint.plugins.pluginmanager - .get({ - repo: options.refresh_repo, - notices: options.refresh_notices, - orphans: options.refresh_orphans - }) + .getPlugins(!!options.refresh) .fail(function () { self.requestError(true); deferred.reject(); }) .done(function (data) { self.requestError(false); - self.fromResponse(data, options); + self.fromPluginsResponse(data.plugins, options); + self.fromPipResponse(data.pip); + self.safeMode(data.safe_mode || false); + deferred.resolveWith(data); + }); + + return deferred.promise(); + }; + + self.dataOrphansDeferred = undefined; + self.requestOrphanData = function (options) { + if (!_.isPlainObject(options)) { + options = {}; + } + + if ( + self.dataOrphansDeferred && + self.dataOrphansDeferred.state() === "pending" && + !!!options.refresh + ) { + return self.dataOrphansDeferred.promise(); + } + + var deferred = new $.Deferred(); + if (!!!options.refresh) { + self.dataOrphansDeferred = deferred; + } + + if ( + !self.loginState.hasPermission( + self.access.permissions.PLUGIN_PLUGINMANAGER_MANAGE + ) + ) { + deferred.fail(); + return deferred.promise(); + } + + OctoPrint.plugins.pluginmanager + .getOrphans(!!options.refresh) + .fail(function () { + deferred.reject(); + }) + .done(function (data) { + self.fromOrphanResponse(data.orphans); + deferred.resolveWith(data); + }); + + return deferred.promise(); + }; + + self.dataRepositoryDeferred = undefined; + self.requestRepositoryData = function (options) { + if (!_.isPlainObject(options)) { + options = {}; + } + + if ( + self.dataRepositoryDeferred && + self.dataRepositoryDeferred.state() === "pending" && + !!!options.refresh + ) { + return self.dataRepositoryDeferred.promise(); + } + + var deferred = new $.Deferred(); + if (!!!options.refresh) { + self.dataRepositoryDeferred = deferred; + } + + if ( + !self.loginState.hasPermission( + self.access.permissions.PLUGIN_PLUGINMANAGER_MANAGE + ) + ) { + deferred.fail(); + return deferred.promise(); + } + + OctoPrint.plugins.pluginmanager + .getRepository(!!options.refresh) + .fail(function () { + deferred.reject(); + }) + .done(function (data) { + self.fromRepositoryResponse(data.repository); + self.online(data.online !== undefined ? data.online : true); deferred.resolveWith(data); }); @@ -669,7 +722,7 @@ $(function () { if (data.key === "pluginmanager") return; var onSuccess = function () { - self.requestData().always(function () { + self.requestPluginData().always(function () { self.toggling(false); }); }, @@ -891,7 +944,7 @@ $(function () { OctoPrint.plugins.pluginmanager .uninstall(data.key, cleanup) .done(function () { - self.requestData(); + self.requestPluginData(); }) .fail(function () { new PNotify({ @@ -947,7 +1000,7 @@ $(function () { OctoPrint.plugins.pluginmanager .cleanup(key) .done(function () { - self.requestData(); + self.requestOrphanData(); }) .fail(function () { new PNotify({ @@ -1019,7 +1072,7 @@ $(function () { ) { return; } - self.requestData({refresh_repo: true}); + self.requestRepositoryData({refresh: true}); }; self.refreshNotices = function () { @@ -1027,8 +1080,8 @@ $(function () { return; } - self.requestData({ - refresh_notices: true, + self.requestPluginData({ + refresh: true, eval_notices: true, ignore_notice_hidden: true, ignore_notice_ignored: true @@ -1040,7 +1093,7 @@ $(function () { return; } - self.requestData({ + self.requestPluginData({ eval_notices: true, ignore_notice_hidden: true, ignore_notice_ignored: true @@ -1098,11 +1151,15 @@ $(function () { self.settingsViewModel.saveData(data, function () { self.configurationDialog.modal("hide"); self._copyConfig(); - self.requestData({ - refresh_repo: true, - refresh_notices: true, + self.requestPluginData({ + refresh: true, eval_notices: true }); + if (self.repositoryAvailable() !== undefined) { + self.requestRepositoryData({ + refresh: true + }); + } }); }; @@ -1601,7 +1658,7 @@ $(function () { if (!self.hiddenNoticeNotifications[key]) return false; return _.any( _.map(self.hiddenNoticeNotifications[key], function (d) { - return date == d; + return date === d; }) ); }; @@ -1656,14 +1713,25 @@ $(function () { self.access.permissions.PLUGIN_PLUGINMANAGER_MANAGE ) ) { - self.requestData({eval_notices: true}); + self.requestPluginData({eval_notices: true}); } else { self._resetNotifications(); } }; + self.onSettingsShown = function () { + if ( + self.loginState.hasPermission( + self.access.permissions.PLUGIN_PLUGINMANAGER_MANAGE + ) + ) { + self.requestRepositoryData(); + self.requestOrphanData(); + } + }; + self.onEventConnectivityChanged = function (payload) { - self.requestData({eval_notices: true}); + self.requestPluginData({eval_notices: true}); }; self._resetNotifications = function () { @@ -1727,7 +1795,7 @@ $(function () { } self._processPluginManagementResult(data, action, name); - self.requestData(); + self.requestPluginData(); } }; diff --git a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 index 7faddf746..8776ca55f 100644 --- a/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 +++ b/src/octoprint/plugins/pluginmanager/templates/pluginmanager_settings.jinja2 @@ -153,7 +153,7 @@
- +

{{ _('Cleanup') }}

diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index b3949b0ff..c0c954cd7 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -5,7 +5,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import copy import hashlib -import io import logging import logging.handlers import os @@ -334,9 +333,7 @@ class SoftwareUpdatePlugin( data = psutil.disk_usage(path) info["free"] = data.free except Exception: - self._logger.exception( - "Error while determining disk usage of {}".format(path) - ) + self._logger.exception(f"Error while determining disk usage of {path}") continue storage_info[key] = info @@ -372,15 +369,13 @@ class SoftwareUpdatePlugin( ) def _get_check_overlay(self, url): - self._logger.info("Fetching check overlays from {}".format(url)) + self._logger.info(f"Fetching check overlays from {url}") try: r = requests.get(url, timeout=3.1) r.raise_for_status() data = r.json() except Exception as exc: - self._logger.error( - "Could not fetch check overlay from {}: {}".format(url, exc) - ) + self._logger.error(f"Could not fetch check overlay from {url}: {exc}") return {} else: return data @@ -426,7 +421,7 @@ class SoftwareUpdatePlugin( import yaml try: - with io.open(self._version_cache_path, "rt", encoding="utf-8") as f: + with open(self._version_cache_path, encoding="utf-8") as f: data = yaml.safe_load(f) timestamp = os.stat(self._version_cache_path).st_mtime except Exception: @@ -1012,8 +1007,11 @@ class SoftwareUpdatePlugin( } ) except exceptions.ConfigurationInvalid as e: - return flask.make_response( - "Update not properly configured, can't proceed: {}".format(e), 500 + flask.abort( + 500, + description="Update not properly configured, can't proceed: {}".format( + e + ), ) def etag(): @@ -1078,30 +1076,35 @@ class SoftwareUpdatePlugin( and not self._settings.get_boolean(["ignore_throttled"]) ): # currently throttled, we refuse to run - return flask.make_response( + message = ( "System is currently throttled, refusing to update " - "anything due to possible stability issues", + "anything due to possible stability issues" + ) + self._logger.error(message) + flask.abort( 409, + description=message, ) if self._printer.is_printing() or self._printer.is_paused(): # do not update while a print job is running - return flask.make_response("Printer is currently printing or paused", 409) + flask.abort(409, description="Printer is currently printing or paused") if not self._environment_supported: - return flask.make_response( - "Direct updates are not supported in this Python environment", 409 + flask.abort( + 409, + description="Direct updates are not supported in this Python environment", ) if not self._storage_sufficient: - return flask.make_response("Not enough free disk space for updating", 409) + flask.abort(409, description="Not enough free disk space for updating") if "application/json" not in flask.request.headers["Content-Type"]: - return flask.make_response("Expected content-type JSON", 400) + flask.abort(400, description="Expected content-type JSON") json_data = flask.request.get_json(silent=True) if json_data is None: - return flask.make_response("Invalid JSON", 400) + flask.abort(400, description="Invalid JSON") if "targets" in json_data or "checks" in json_data: targets = list( @@ -1124,7 +1127,7 @@ class SoftwareUpdatePlugin( def configure_update(self): json_data = flask.request.get_json(silent=True) if json_data is None: - return flask.make_response("Invalid JSON", 400) + flask.abort(400) checks = self._get_configured_checks() @@ -1136,9 +1139,7 @@ class SoftwareUpdatePlugin( try: populated_check = self._populated_check(target, checks[target]) except exceptions.UnknownCheckType: - self._logger.debug( - "Ignoring unknown check type for target {}".format(target) - ) + self._logger.debug(f"Ignoring unknown check type for target {target}") continue except Exception: self._logger.exception( @@ -1306,7 +1307,7 @@ class SoftwareUpdatePlugin( continue except Exception: self._logger.exception( - "Could not check {} for updates".format(target) + f"Could not check {target} for updates" ) continue @@ -1457,7 +1458,7 @@ class SoftwareUpdatePlugin( if isinstance(value, dict): lines.append("{!r}: {}".format(key, dict_to_sorted_repr(value))) else: - lines.append("{!r}: {!r}".format(key, value)) + lines.append(f"{key!r}: {value!r}") return "{" + ", ".join(lines) + "}" @@ -1534,7 +1535,7 @@ class SoftwareUpdatePlugin( error = "unknown_check" except exceptions.NetworkError: self._logger.warning( - "Could not check {} for updates due to a network error".format(target) + f"Could not check {target} for updates due to a network error" ) update_possible = False error = "network" @@ -1548,12 +1549,12 @@ class SoftwareUpdatePlugin( error = "ratelimit" except exceptions.CheckError: self._logger.warning( - "Could not check {} for updates due to a check error".format(target) + f"Could not check {target} for updates due to a check error" ) update_possible = False error = "check" except Exception: - self._logger.exception("Could not check {} for updates".format(target)) + self._logger.exception(f"Could not check {target} for updates") update_possible = False error = "unknown" else: @@ -1563,9 +1564,7 @@ class SoftwareUpdatePlugin( target, check, online=online ) except Exception: - self._logger.exception( - "Error while checking if {} can be updated".format(target) - ) + self._logger.exception(f"Error while checking if {target} can be updated") update_possible = False self._version_cache[target] = { @@ -1605,9 +1604,7 @@ class SoftwareUpdatePlugin( try: populated_checks[target] = self._populated_check(target, check) except exceptions.UnknownCheckType: - self._logger.debug( - "Ignoring unknown check type for target {}".format(target) - ) + self._logger.debug(f"Ignoring unknown check type for target {target}") except Exception: self._logger.exception( "Error while populating check prior to update for target {}".format( @@ -1796,7 +1793,7 @@ class SoftwareUpdatePlugin( populated_check = self._populated_check(target, check) try: - self._logger.info("Starting update of %s to %s..." % (target, target_version)) + self._logger.info(f"Starting update of {target} to {target_version}...") self._send_client_message( "updating", { @@ -1813,7 +1810,7 @@ class SoftwareUpdatePlugin( target, populated_check, target_version, log_cb=self._log, online=online ) target_result = ("success", update_result) - self._logger.info("Update of %s to %s successful!" % (target, target_version)) + self._logger.info(f"Update of {target} to {target_version} successful!") trigger_event(True) except exceptions.UnknownUpdateType: @@ -1918,10 +1915,10 @@ class SoftwareUpdatePlugin( util.execute(restart_command, evaluate_returncode=False, do_async=True) except exceptions.ScriptError as e: self._logger.exception( - "Error while restarting via command {}".format(restart_command) + f"Error while restarting via command {restart_command}" ) - self._logger.warning("Restart stdout:\n{}".format(e.stdout)) - self._logger.warning("Restart stderr:\n{}".format(e.stderr)) + self._logger.warning(f"Restart stdout:\n{e.stdout}") + self._logger.warning(f"Restart stderr:\n{e.stderr}") raise exceptions.RestartFailed() def _populated_check(self, target, check): @@ -2059,7 +2056,7 @@ class SoftwareUpdatePlugin( data={"loglines": [{"line": line, "stream": stream} for line in lines]}, ) for line in lines: - self._console_logger.debug("{} {}".format(prefix, line)) + self._console_logger.debug(f"{prefix} {line}") def _send_client_message(self, message_type, data=None): self._plugin_manager.send_plugin_message( diff --git a/src/octoprint/plugins/softwareupdate/cli.py b/src/octoprint/plugins/softwareupdate/cli.py index 0c9b2c0f4..4590f0b96 100644 --- a/src/octoprint/plugins/softwareupdate/cli.py +++ b/src/octoprint/plugins/softwareupdate/cli.py @@ -62,7 +62,7 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs): try: r.raise_for_status() except requests.exceptions.HTTPError as e: - click.echo("Could not get update information from server, got {}".format(e)) + click.echo(f"Could not get update information from server, got {e}") sys.exit(1) data = r.json() @@ -230,7 +230,7 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs): try: r.raise_for_status() except requests.exceptions.HTTPError as e: - click.echo("Could not get update information from server, got {}".format(e)) + click.echo(f"Could not get update information from server, got {e}") sys.exit(1) data = r.json() diff --git a/src/octoprint/plugins/softwareupdate/exceptions.py b/src/octoprint/plugins/softwareupdate/exceptions.py index 6d6d0d892..93fb909b7 100644 --- a/src/octoprint/plugins/softwareupdate/exceptions.py +++ b/src/octoprint/plugins/softwareupdate/exceptions.py @@ -29,7 +29,7 @@ class NetworkError(Exception): if self.message is not None: return self.message elif self.cause is not None: - return "NetworkError caused by {}".format(self.cause) + return f"NetworkError caused by {self.cause}" else: return "NetworkError" diff --git a/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py b/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py index 9f03044cd..0a9873553 100644 --- a/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py +++ b/src/octoprint/plugins/softwareupdate/scripts/update-octoprint.py @@ -91,14 +91,12 @@ def _execute(command, **kwargs): if not p.commands[0].process: # the process might have been set to None in case of any exception print( - "Error while trying to run command {}".format(joined_command), + f"Error while trying to run command {joined_command}", file=sys.stderr, ) return None, [], [] except Exception: - print( - "Error while trying to run command {}".format(joined_command), file=sys.stderr - ) + print(f"Error while trying to run command {joined_command}", file=sys.stderr) traceback.print_exc(file=sys.stderr) return None, [], [] @@ -214,7 +212,7 @@ def _rescue_changes(git_executable, folder): ) if returncode is None or returncode != 0: raise RuntimeError( - 'Could not update, "git diff" failed with returncode {}'.format(returncode) + f'Could not update, "git diff" failed with returncode {returncode}' ) if stdout and "".join(stdout).strip(): # we got changes in the working tree, maybe from the user, so we'll now rescue those into a patch @@ -222,9 +220,9 @@ def _rescue_changes(git_executable, folder): import time timestamp = time.strftime("%Y%m%d%H%M") - patch = os.path.join(folder, "{}-preupdate.patch".format(timestamp)) + patch = os.path.join(folder, f"{timestamp}-preupdate.patch") - print(">>> Running: git diff and saving output to {}".format(patch)) + print(f">>> Running: git diff and saving output to {patch}") returncode, stdout, stderr = _git(["diff"], folder, git_executable=git_executable) if returncode is None or returncode != 0: raise RuntimeError( @@ -233,9 +231,7 @@ def _rescue_changes(git_executable, folder): ) ) - import io - - with io.open(patch, "wt", encoding="utf-8", errors="replace") as f: + with open(patch, "wt", encoding="utf-8", errors="replace") as f: for line in stdout: f.write(line) @@ -274,11 +270,11 @@ def update_source(git_executable, folder, target, force=False, branch=None): returncode, stdout, stderr = _git(["fetch"], folder, git_executable=git_executable) if returncode is None or returncode != 0: raise RuntimeError( - 'Could not update, "git fetch" failed with returncode {}'.format(returncode) + f'Could not update, "git fetch" failed with returncode {returncode}' ) if branch is not None and branch.strip() != "": - print(">>> Running: git checkout {}".format(branch)) + print(f">>> Running: git checkout {branch}") returncode, stdout, stderr = _git( ["checkout", branch], folder, git_executable=git_executable ) @@ -293,7 +289,7 @@ def update_source(git_executable, folder, target, force=False, branch=None): returncode, stdout, stderr = _git(["pull"], folder, git_executable=git_executable) if returncode is None or returncode != 0: raise RuntimeError( - 'Could not update, "git pull" failed with returncode {}'.format(returncode) + f'Could not update, "git pull" failed with returncode {returncode}' ) if force: @@ -316,7 +312,7 @@ def install_source(python_executable, folder, user=False, sudo=False): print(">>> Running: python setup.py clean") returncode, stdout, stderr = _python(["setup.py", "clean"], folder, python_executable) if returncode is None or returncode != 0: - print('"python setup.py clean" failed with returncode {}'.format(returncode)) + print(f'"python setup.py clean" failed with returncode {returncode}') print("Continuing anyways") print(">>> Running: python setup.py install") @@ -407,7 +403,7 @@ def main(): if python_executable.endswith('"'): python_executable = python_executable[:-1] - print("Python executable: {!r}".format(python_executable)) + print(f"Python executable: {python_executable!r}") folder = args.folder diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index b090c2651..56e8b6f75 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -680,13 +680,20 @@ $(function () { gettext("Updating, please wait.") ); }) - .fail(function () { + .fail(function (response) { self.updateInProgress = false; + var message = + "

" + + gettext( + "The update could not be started. Is it already active? Please consult octoprint.log for details." + ) + + "

" +
+                        _.escape(response.responseJSON.error) +
+                        "
"; + self._showPopup({ title: gettext("Update not started!"), - text: gettext( - "The update could not be started. Is it already active? Please consult octoprint.log for details." - ), + text: message, type: "error", hide: false, buttons: { diff --git a/src/octoprint/plugins/softwareupdate/updaters/pip.py b/src/octoprint/plugins/softwareupdate/updaters/pip.py index 1c9716e34..b1dfbcdcb 100644 --- a/src/octoprint/plugins/softwareupdate/updaters/pip.py +++ b/src/octoprint/plugins/softwareupdate/updaters/pip.py @@ -98,7 +98,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc target_version=target_version, target=target_version ) - logger.debug("Target: %s, executing pip install %s" % (target, install_arg)) + logger.debug(f"Target: {target}, executing pip install {install_arg}") pip_args = ["--disable-pip-version-check", "install", install_arg, "--no-cache-dir"] pip_kwargs = { "env": {"PYTHONWARNINGS": b"ignore:DEPRECATION::pip._internal.cli.base_command"} diff --git a/src/octoprint/plugins/softwareupdate/updaters/single_file_plugin.py b/src/octoprint/plugins/softwareupdate/updaters/single_file_plugin.py index 9e39ea6c5..6af58a171 100644 --- a/src/octoprint/plugins/softwareupdate/updaters/single_file_plugin.py +++ b/src/octoprint/plugins/softwareupdate/updaters/single_file_plugin.py @@ -2,7 +2,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License" import ast -import io import logging import os import shutil @@ -46,7 +45,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc folder = None try: try: - _log_message("Download file from {}".format(url)) + _log_message(f"Download file from {url}") folder = TemporaryDirectory() path = download_file(url, folder.name) except Exception as exc: @@ -55,29 +54,25 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc filename = os.path.basename(path) _, ext = os.path.splitext(filename) if ext not in (".py",): - raise exceptions.UpdateError( - "File is not a python file: {}".format(filename), None - ) + raise exceptions.UpdateError(f"File is not a python file: {filename}", None) try: - with io.open(path, "rb") as f: + with open(path, "rb") as f: ast.parse(f.read(), filename=path) except Exception: - logger.exception("Could not parse {} as python file".format(path), None) + logger.exception(f"Could not parse {path} as python file", None) raise exceptions.UpdateError( - "Could not parse {} as python file.".format(filename), None + f"Could not parse {filename} as python file.", None ) destination = os.path.join(settings().getBaseFolder("plugins"), filename) try: - _log_message("Copy {} to {}".format(path, destination)) + _log_message(f"Copy {path} to {destination}") shutil.copy(path, destination) except Exception: - logger.exception("Could not copy {} to {}".format(path, destination)) - raise exceptions.UpdateError( - "Could not copy {} to {}".format(path, destination), None - ) + logger.exception(f"Could not copy {path} to {destination}") + raise exceptions.UpdateError(f"Could not copy {path} to {destination}", None) return "ok" finally: diff --git a/src/octoprint/plugins/softwareupdate/updaters/update_script.py b/src/octoprint/plugins/softwareupdate/updaters/update_script.py index c27eb4b77..d0b1ee44c 100644 --- a/src/octoprint/plugins/softwareupdate/updaters/update_script.py +++ b/src/octoprint/plugins/softwareupdate/updaters/update_script.py @@ -78,9 +78,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True): ### pre update if pre_update_script is not None: - logger.debug( - "Target: %s, running pre-update script: %s" % (target, pre_update_script) - ) + logger.debug(f"Target: {target}, running pre-update script: {pre_update_script}") try: caller.checked_call(pre_update_script, cwd=folder) except CommandlineError as e: @@ -100,7 +98,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True): force="true" if force_exact_version else "false", ) - logger.debug("Target %s, running update script: %s" % (target, update_command)) + logger.debug(f"Target {target}, running update script: {update_command}") caller.checked_call(update_command, cwd=folder) except CommandlineError as e: @@ -116,7 +114,9 @@ def perform_update(target, check, target_version, log_cb=None, online=True): if post_update_script is not None: logger.debug( - "Target: %s, running post-update script %s..." % (target, post_update_script) + "Target: {}, running post-update script {}...".format( + target, post_update_script + ) ) try: caller.checked_call(post_update_script, cwd=folder) diff --git a/src/octoprint/plugins/softwareupdate/util.py b/src/octoprint/plugins/softwareupdate/util.py index 69f83dcc2..f9b2a2922 100644 --- a/src/octoprint/plugins/softwareupdate/util.py +++ b/src/octoprint/plugins/softwareupdate/util.py @@ -27,9 +27,7 @@ def execute(command, cwd=None, evaluate_returncode=True, **kwargs): async_=do_async, ) except Exception: - logging.getLogger(__name__).exception( - "Error while executing command: {}".format(command) - ) + logging.getLogger(__name__).exception(f"Error while executing command: {command}") returncode = p.returncode if p is not None else None stdout = p.stdout.text if p is not None and p.stdout is not None else "" stderr = p.stderr.text if p is not None and p.stderr is not None else "" diff --git a/src/octoprint/plugins/softwareupdate/version_checks/__init__.py b/src/octoprint/plugins/softwareupdate/version_checks/__init__.py index b831968d5..737fbe3ce 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/__init__.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/__init__.py @@ -21,7 +21,7 @@ from . import ( # noqa: F401 class GithubRateLimitCheckError(RateLimitCheckError): def __init__(self, remaining, ratelimit, reset): if reset: - message = "Github rate limit exceeded, reset at {}".format(reset) + message = f"Github rate limit exceeded, reset at {reset}" else: message = "Github rate limit exceeded" super().__init__(message, remaining=remaining, limit=ratelimit, reset=reset) diff --git a/src/octoprint/plugins/softwareupdate/version_checks/bitbucket_commit.py b/src/octoprint/plugins/softwareupdate/version_checks/bitbucket_commit.py index 9dbb37d1f..45a51d824 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/bitbucket_commit.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/bitbucket_commit.py @@ -24,7 +24,7 @@ def _get_latest_commit(user, repo, branch, api_user=None, api_password=None): auth_value = base64.b64encode( b"{user}:{pw}".format(user=api_user, pw=api_password) ) - headers["authorization"] = "Basic {}".format(auth_value) + headers["authorization"] = f"Basic {auth_value}" try: r = requests.get(url, headers=headers, timeout=(3.05, 30)) @@ -79,17 +79,13 @@ def get_latest(target, check, online=True, credentials=None, *args, **kwargs): remote_commit = _get_latest_commit( check["user"], check["repo"], branch, api_user, api_password ) - remote_name = ( - "Commit {commit}".format(commit=remote_commit) - if remote_commit is not None - else "-" - ) + remote_name = f"Commit {remote_commit}" if remote_commit is not None else "-" information["remote"] = {"name": remote_name, "value": remote_commit} is_current = ( current is not None and current == remote_commit ) or remote_commit is None - logger.debug("Target: %s, local: %s, remote: %s" % (target, current, remote_commit)) + logger.debug(f"Target: {target}, local: {current}, remote: {remote_commit}") return information, is_current diff --git a/src/octoprint/plugins/softwareupdate/version_checks/commandline.py b/src/octoprint/plugins/softwareupdate/version_checks/commandline.py index 2840f6784..42ec5d963 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/commandline.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/commandline.py @@ -56,6 +56,6 @@ def get_latest(target, check, online=True, *args, **kwargs): logger = logging.getLogger( "octoprint.plugins.softwareupdate.version_checks.github_commit" ) - logger.debug("Target: %s, local: %s, remote: %s" % (target, local_name, remote_name)) + logger.debug(f"Target: {target}, local: {local_name}, remote: {remote_name}") return information, is_current diff --git a/src/octoprint/plugins/softwareupdate/version_checks/git_commit.py b/src/octoprint/plugins/softwareupdate/version_checks/git_commit.py index 72f431b7f..1fa0e3591 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/git_commit.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/git_commit.py @@ -97,8 +97,6 @@ def get_latest(target, check, online=True, *args, **kwargs): logger = logging.getLogger( "octoprint.plugins.softwareupdate.version_checks.git_commit" ) - logger.debug( - "Target: %s, local: %s, remote: %s" % (target, local_commit, remote_commit) - ) + logger.debug(f"Target: {target}, local: {local_commit}, remote: {remote_commit}") return information, is_current diff --git a/src/octoprint/plugins/softwareupdate/version_checks/github_commit.py b/src/octoprint/plugins/softwareupdate/version_checks/github_commit.py index 42e548c56..551dd7d69 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/github_commit.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/github_commit.py @@ -83,17 +83,13 @@ def get_latest(target, check, online=True, credentials=None, *args, **kwargs): remote_commit = _get_latest_commit( check["user"], check["repo"], branch, apikey=apikey ) - remote_name = ( - "Commit {commit}".format(commit=remote_commit) - if remote_commit is not None - else "-" - ) + remote_name = f"Commit {remote_commit}" if remote_commit is not None else "-" information["remote"] = {"name": remote_name, "value": remote_commit} is_current = ( current is not None and current == remote_commit ) or remote_commit is None - logger.debug("Target: %s, local: %s, remote: %s" % (target, current, remote_commit)) + logger.debug(f"Target: {target}, local: {current}, remote: {remote_commit}") return information, is_current diff --git a/src/octoprint/plugins/softwareupdate/version_checks/github_release.py b/src/octoprint/plugins/softwareupdate/version_checks/github_release.py index 0f6ef6228..c755bf639 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/github_release.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/github_release.py @@ -198,7 +198,7 @@ def _get_comparable_version_semantic(version_string, force_base=True): version = semantic_version.Version.coerce(version_string, partial=False) if force_base: - version_string = "{}.{}.{}".format(version.major, version.minor, version.patch) + version_string = f"{version.major}.{version.minor}.{version.patch}" version = semantic_version.Version.coerce(version_string, partial=False) return version @@ -355,7 +355,7 @@ def get_latest( "release_notes": release_notes, } - logger.debug("Target: %s, local: %s, remote: %s" % (target, current, remote_tag)) + logger.debug(f"Target: {target}, local: {current}, remote: {remote_tag}") return information, _is_current( information, compare_type, custom=custom_compare, force_base=force_base diff --git a/src/octoprint/plugins/softwareupdate/version_checks/httpheader.py b/src/octoprint/plugins/softwareupdate/version_checks/httpheader.py index ce8232e63..0d1d48107 100644 --- a/src/octoprint/plugins/softwareupdate/version_checks/httpheader.py +++ b/src/octoprint/plugins/softwareupdate/version_checks/httpheader.py @@ -26,7 +26,7 @@ def get_latest(target, check, online=True, *args, **kwargs): method = check.get("header_method", "head") prefix = check.get("header_prefix", header) if prefix: - prefix = "{} ".format(prefix) + prefix = f"{prefix} " try: with requests.request(method, url) as r: diff --git a/src/octoprint/plugins/tracking/__init__.py b/src/octoprint/plugins/tracking/__init__.py index 1119ef04f..20cf99e52 100644 --- a/src/octoprint/plugins/tracking/__init__.py +++ b/src/octoprint/plugins/tracking/__init__.py @@ -479,7 +479,7 @@ class TrackingPlugin( # Don't print the URL or UUID! That would expose the UUID in forums/tickets # if pasted. It's okay for the user to know their uuid, but it shouldn't be shared. - headers = {"User-Agent": "OctoPrint/{}".format(get_octoprint_version_string())} + headers = {"User-Agent": f"OctoPrint/{get_octoprint_version_string()}"} try: params = urlencode(kwargs, doseq=True).replace("+", "%20") @@ -488,9 +488,7 @@ class TrackingPlugin( else: requests.get(url, params=params, timeout=3.1, headers=headers) - self._logger.info( - "Sent tracking event {}, payload: {!r}".format(event, kwargs) - ) + self._logger.info(f"Sent tracking event {event}, payload: {kwargs!r}") except Exception: if self._logger.isEnabledFor(logging.DEBUG): self._logger.exception( diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index 88d8af7b6..c7cd5c6c7 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -3,7 +3,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp import collections -import io import json import math import os @@ -303,7 +302,7 @@ class VirtualPrinter: @timeout.setter def timeout(self, value): - self._logger.debug("Setting read timeout to {}s".format(value)) + self._logger.debug(f"Setting read timeout to {value}s") self._read_timeout = value @property @@ -312,7 +311,7 @@ class VirtualPrinter: @write_timeout.setter def write_timeout(self, value): - self._logger.debug("Setting write timeout to {}s".format(value)) + self._logger.debug(f"Setting write timeout to {value}s") self._write_timeout = value @property @@ -496,7 +495,7 @@ class VirtualPrinter: try: # if we have a method _gcode_G, _gcode_M or _gcode_T, execute that first - letter_handler = "_gcode_{}".format(letter) + letter_handler = f"_gcode_{letter}" if hasattr(self, letter_handler): code = command_match.group(2) handled = getattr(self, letter_handler)(code, data) @@ -504,7 +503,7 @@ class VirtualPrinter: continue # then look for a method _gcode_ and execute that if it exists - command_handler = "_gcode_{}".format(command) + command_handler = f"_gcode_{command}" if hasattr(self, command_handler): handled = getattr(self, command_handler)(data) if handled: @@ -544,7 +543,7 @@ class VirtualPrinter: self.currentExtruder = t self._send("Active Extruder: %d" % self.currentExtruder) else: - self._send("echo:T{} Invalid extruder ".format(t)) + self._send(f"echo:T{t} Invalid extruder ") # noinspection PyUnusedLocal def _gcode_F(self, code, data): @@ -691,7 +690,7 @@ class VirtualPrinter: if not self._okBeforeCommandOutput: ok = self._ok() if ok: - output = "{} {}".format(self._ok(), output) + output = f"{self._ok()} {output}" self._send(output) return True @@ -707,7 +706,10 @@ class VirtualPrinter: def _gcode_M117(self, data: str) -> None: # we'll just use this to echo a message, to allow playing around with pause triggers if self._echoOnM117: - self._send("echo:%s" % re.search(r"M117\s+(.*)", data).group(1)) + try: + self._send("echo:%s" % re.search(r"M117\s+(.*)", data).group(1)) + except AttributeError: + self._send("echo:") def _gcode_M155(self, data: str) -> None: matchS = re.search(r"S([0-9]+)", data) @@ -1236,7 +1238,7 @@ class VirtualPrinter: | Unsets the busy loop. """ for line in usage.split("\n"): - self._send("echo: {}".format(line.strip())) + self._send(f"echo: {line.strip()}") elif data == "action_pause": self._send("// action:pause") elif data == "action_resume": @@ -1306,9 +1308,7 @@ class VirtualPrinter: if sleep_match is not None: interval = int(sleep_match.group(1)) - self._send( - "// sleeping for {interval} seconds".format(interval=interval) - ) + self._send(f"// sleeping for {interval} seconds") self._debug_sleep = interval elif sleep_after_match is not None: command = sleep_after_match.group(1) @@ -1463,7 +1463,7 @@ class VirtualPrinter: ["smoothieTemperatureReporting"] ): continue - temps["T{}".format(i)] = (self.temp[i], self.targetTemp[i]) + temps[f"T{i}"] = (self.temp[i], self.targetTemp[i]) if self._settings.get_boolean(["hasBed"]): temps["B"] = (self.bedTemp, self.bedTargetTemp) @@ -1500,7 +1500,7 @@ class VirtualPrinter: if includeOk: ok = self._ok() if ok: - output = "{} {}".format(ok, output) + output = f"{ok} {output}" self._send(output) def _parseHotendCommand( @@ -1742,7 +1742,7 @@ class VirtualPrinter: handle = None try: - handle = io.open(file, "wt", encoding="utf-8") + handle = open(file, "wt", encoding="utf-8") except Exception: self._send("error writing to file") if handle is not None: @@ -1769,7 +1769,7 @@ class VirtualPrinter: def _sdPrintingWorker(self): self._selectedSdFilePos = 0 try: - with io.open(self._selectedSdFile, "rt", encoding="utf-8") as f: + with open(self._selectedSdFile, encoding="utf-8") as f: for line in iter(f.readline, ""): if self._killed or not self._sdPrinting: break @@ -1930,7 +1930,7 @@ class VirtualPrinter: def loop(): while self._busy: - self._send("echo:busy {}".format(self._busy)) + self._send(f"echo:busy {self._busy}") time.sleep(self._busyInterval) self._sendOk() @@ -1944,9 +1944,9 @@ class VirtualPrinter: def _showPrompt(self, text, choices): self._hidePrompt() - self._send("//action:prompt_begin {}".format(text)) + self._send(f"//action:prompt_begin {text}") for choice in choices: - self._send("//action:prompt_button {}".format(choice)) + self._send(f"//action:prompt_button {choice}") self._send("//action:prompt_show") def _hidePrompt(self): @@ -1970,7 +1970,7 @@ class VirtualPrinter: return 0 if b"M112" in data and self._supportM112: - self._seriallog.info("<<< {}".format(u_data)) + self._seriallog.info(f"<<< {u_data}") self._kill() return len(data) @@ -1978,7 +1978,7 @@ class VirtualPrinter: written = self.incoming.put( data, timeout=self._write_timeout, partial=True ) - self._seriallog.info("<<< {}".format(u_data)) + self._seriallog.info(f"<<< {u_data}") return written except queue.Full: self._logger.info( @@ -2113,13 +2113,13 @@ class VirtualEEPROM: def _initialise_eeprom(self): if os.path.exists(self._eeprom_file_path): # file exists, read it - with io.open(self._eeprom_file_path, "rt", encoding="utf-8") as eeprom_file: + with open(self._eeprom_file_path, encoding="utf-8") as eeprom_file: data = json.load(eeprom_file) return data else: # no eeprom file, make new one with defaults data = self.get_default_settings() - with io.open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file: + with open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file: eeprom_file.write(to_unicode(json.dumps(data))) return data @@ -2230,7 +2230,7 @@ class VirtualEEPROM: def save_settings(self): # M500 behind-the-scenes - with io.open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file: + with open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file: eeprom_file.write(to_unicode(json.dumps(self._eeprom))) def read_settings(self): @@ -2238,7 +2238,7 @@ class VirtualEEPROM: if not os.path.exists(self._eeprom_file_path): self.load_defaults() self.save_settings() - with io.open(self._eeprom_file_path, "rt") as eeprom_file: + with open(self._eeprom_file_path) as eeprom_file: self._eeprom = json.load(eeprom_file) def load_defaults(self): diff --git a/src/octoprint/printer/profile.py b/src/octoprint/printer/profile.py index b1c28a5aa..2d16336f9 100644 --- a/src/octoprint/printer/profile.py +++ b/src/octoprint/printer/profile.py @@ -145,7 +145,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import copy -import io import logging import os from os import scandir @@ -475,7 +474,7 @@ class PrinterProfileManager: try: profile = self._load_from_path(path) except InvalidProfileError: - self._logger.warning("Profile {} is invalid, skipping".format(identifier)) + self._logger.warning(f"Profile {identifier} is invalid, skipping") continue if profile is None: @@ -503,7 +502,7 @@ class PrinterProfileManager: import yaml - with io.open(path, "rt", encoding="utf-8") as f: + with open(path, encoding="utf-8") as f: profile = yaml.safe_load(f) if profile is None or not isinstance(profile, dict): @@ -549,7 +548,7 @@ class PrinterProfileManager: self._logger.exception( "Error while trying to save profile %s" % profile["id"] ) - raise SaveError("Cannot save profile %s: %s" % (profile["id"], str(e))) + raise SaveError("Cannot save profile {}: {}".format(profile["id"], str(e))) def _remove_from_path(self, path): try: diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 28dbf8166..311b3d27b 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -14,7 +14,7 @@ import threading import time from collections import namedtuple -from frozendict import frozendict +from immutabledict import immutabledict import octoprint.util.json from octoprint import util as util @@ -73,7 +73,7 @@ def _serial_factory(port=None, baudrate=None): ) except Exception: logging.getLogger(__name__).exception( - "Error while creating serial via factory {}".format(name) + f"Error while creating serial via factory {name}" ) return None @@ -101,10 +101,10 @@ class Printer( from collections import deque self._logger = logging.getLogger(__name__) - self._logger_job = logging.getLogger("{}.job".format(__name__)) + self._logger_job = logging.getLogger(f"{__name__}.job") self._dict = ( - frozendict + immutabledict if settings().getBoolean(["devel", "useFrozenDictForPrinterState"]) else dict ) @@ -157,13 +157,11 @@ class Printer( try: estimator = hook() if estimator is not None: - self._logger.info( - "Using print time estimator provided by {}".format(name) - ) + self._logger.info(f"Using print time estimator provided by {name}") self._estimator_factory = estimator except Exception: self._logger.exception( - "Error while processing analysis queues from {}".format(name), + f"Error while processing analysis queues from {name}", extra={"plugin": name}, ) @@ -245,7 +243,7 @@ class Printer( @property def firmware_info(self): - return frozendict(self._firmware_info) if self._firmware_info else None + return immutabledict(self._firmware_info) if self._firmware_info else None # ~~ handling of PrinterCallbacks @@ -332,7 +330,7 @@ class Printer( plugin_data[name] = additional except ValueError: self._logger.exception( - "Invalid additional data from plugin {}".format(name), + f"Invalid additional data from plugin {name}", extra={"plugin": name}, ) except Exception: @@ -404,8 +402,8 @@ class Printer( from octoprint.logging.handlers import CommunicationLogHandler - CommunicationLogHandler.arm_rollover(u"CONNECTION") - CommunicationLogHandler.arm_rollover(u"COMMDEBUG") + CommunicationLogHandler.arm_rollover("CONNECTION") + CommunicationLogHandler.arm_rollover("COMMDEBUG") if not logging.getLogger("CONNECTION").isEnabledFor(logging.DEBUG): # is protocol.log is not enabled, log a line to explain to reduce "connection.log is empty" in tickets... @@ -525,7 +523,7 @@ class Printer( transport_class = lookup_transport(selected_transport) if not transport_class: - raise ValueError("Invalid transport: {}".format(selected_transport)) + raise ValueError(f"Invalid transport: {selected_transport}") transport = transport_class(**transport_kwargs) self._transport = transport @@ -536,7 +534,7 @@ class Printer( protocol_class = lookup_protocol(selected_protocol) if not protocol_class: - raise ValueError("Invalid protocol: {}".format(selected_protocol)) + raise ValueError(f"Invalid protocol: {selected_protocol}") protocol = protocol_class(**protocol_kwargs) self._protocol = protocol @@ -623,7 +621,7 @@ class Printer( # this code preserves existing CamelCase event_name = name[0].upper() + name[1:] - event_start = "GcodeScript{}Running".format(event_name) + event_start = f"GcodeScript{event_name}Running" payload = context.get("event", None) if isinstance(context, dict) else None eventManager().fire(event_start, payload) @@ -642,7 +640,7 @@ class Printer( if must_be_set: raise - event_end = "GcodeScript{}Finished".format(event_name) + event_end = f"GcodeScript{event_name}Finished" eventManager().fire(event_end, payload) def jog(self, axes, relative=True, speed=None, *args, **kwargs): @@ -654,9 +652,7 @@ class Printer( raise ValueError("amount not set") amount = args[0] if not isinstance(amount, (int, float)): - raise ValueError( - "amount must be a valid number: {amount}".format(amount=amount) - ) + raise ValueError(f"amount must be a valid number: {amount}") axes = {} axes[axis] = amount @@ -689,9 +685,7 @@ class Printer( if isinstance(axes, str): axes = [axes] else: - raise ValueError( - "axes is neither a list nor a string: {axes}".format(axes=axes) - ) + raise ValueError(f"axes is neither a list nor a string: {axes}") validated_axes = list( filter( @@ -699,16 +693,14 @@ class Printer( ) ) if len(axes) != len(validated_axes): - raise ValueError("axes contains invalid axes: {axes}".format(axes=axes)) + raise ValueError(f"axes contains invalid axes: {axes}") kwargs = {axes: True for axes in validated_axes} self._protocol.home(**kwargs) def extrude(self, amount, speed=None, *args, **kwargs): if not isinstance(amount, (int, float)): - raise ValueError( - "amount must be a valid number: {amount}".format(amount=amount) - ) + raise ValueError(f"amount must be a valid number: {amount}") printer_profile = self._printer_profile_manager.get_current_or_default() @@ -731,7 +723,7 @@ class Printer( def change_tool(self, tool, *args, **kwargs): if not PrinterInterface.valid_tool_regex.match(tool): - raise ValueError('tool must match "tool[0-9]+": {tool}'.format(tool=tool)) + raise ValueError(f'tool must match "tool[0-9]+": {tool}') tool_num = int(tool[len("tool") :]) self._protocol.change_tool( @@ -748,9 +740,7 @@ class Printer( ) if not isinstance(value, (int, float)) or value < 0: - raise ValueError( - "value must be a valid number >= 0: {value}".format(value=value) - ) + raise ValueError(f"value must be a valid number >= 0: {value}") tags = kwargs.get("tags", set()) | {"trigger:printer.set_temperature"} self._protocol.set_temperature(heater, value, wait=False, tags=tags) @@ -770,13 +760,9 @@ class Printer( ) if len(validated_keys) != len(offsets): - raise ValueError( - "offsets contains invalid keys: {offsets}".format(offsets=offsets) - ) + raise ValueError(f"offsets contains invalid keys: {offsets}") if len(validated_values) != len(offsets): - raise ValueError( - "offsets contains invalid values: {offsets}".format(offsets=offsets) - ) + raise ValueError(f"offsets contains invalid values: {offsets}") if self._protocol is None: return @@ -793,9 +779,9 @@ class Printer( factor = int(factor * 100) if min_val and factor < min_val: - raise ValueError("factor must be a value >={}".format(min_val)) + raise ValueError(f"factor must be a value >={min_val}") elif max_val and factor > max_val: - raise ValueError("factor must be a value <={}".format(max_val)) + raise ValueError(f"factor must be a value <={max_val}") return factor @@ -963,9 +949,9 @@ class Printer( elif state == ProtocolState.PAUSED: return "Paused" elif state == ProtocolState.DISCONNECTED_WITH_ERROR: - return "Error: {}".format(self._protocol.error) + return f"Error: {self._protocol.error}" - return "Unknown state ({})".format(self._protocol.state) + return f"Unknown state ({self._protocol.state})" def get_state_id(self, state=None, *args, **kwargs): if state is None: @@ -999,11 +985,11 @@ class Printer( return self._protocol.error def get_current_data(self, *args, **kwargs): - return util.thaw_frozendict(self._state_monitor.get_current_data()) + return util.thaw_immutabledict(self._state_monitor.get_current_data()) def get_current_job(self): data = self._state_monitor.get_current_data() - return util.thaw_frozendict(data["job"]) + return util.thaw_immutabledict(data["job"]) def get_current_temperatures(self, *args, **kwargs): if self._protocol is not None: @@ -1194,7 +1180,7 @@ class Printer( sd_upload_succeeded, sd_upload_failed, *args, - **kwargs + **kwargs, ) if result is not None: return result @@ -1577,7 +1563,7 @@ class Printer( callback.on_printer_send_initial_data(data) except Exception: self._logger.exception( - u"Error while pushing initial state update to callback {}".format( + "Error while pushing initial state update to callback {}".format( callback ), extra={"callback": fqcn(callback)}, @@ -1636,9 +1622,7 @@ class Printer( if protocol != self._protocol: return - self._logger.info( - "Protocol state changed from {} to {}".format(old_state, new_state) - ) + self._logger.info(f"Protocol state changed from {old_state} to {new_state}") # forward relevant state changes to file manager if old_state == ProtocolState.PROCESSING: diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 2ca138a74..f99e4066d 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -4,7 +4,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import atexit import base64 -import io import logging import logging.config import mimetypes @@ -37,6 +36,7 @@ from flask_login import ( # noqa: F401 ) from watchdog.observers import Observer from watchdog.observers.polling import PollingObserver +from werkzeug.exceptions import HTTPException import octoprint.util import octoprint.util.net @@ -60,8 +60,8 @@ except ImportError: fcntl = None SUCCESS = {} -NO_CONTENT = ("", 204) -NOT_MODIFIED = ("Not Modified", 304) +NO_CONTENT = ("", 204, {"Content-Type": "text/plain"}) +NOT_MODIFIED = ("Not Modified", 304, {"Content-Type": "text/plain"}) app = Flask("octoprint") @@ -396,7 +396,7 @@ class Server: analysis_queue_factories.update(**additional_factories) except Exception: self._logger.exception( - "Error while processing analysis queues from {}".format(name), + f"Error while processing analysis queues from {name}", extra={"plugin": name}, ) analysisQueue = octoprint.filemanager.analysis.AnalysisQueue( @@ -495,7 +495,7 @@ class Server: groupManager = factory(components, self._settings) if groupManager is not None: self._logger.debug( - "Created group manager instance from factory {}".format(name) + f"Created group manager instance from factory {name}" ) break except Exception: @@ -529,7 +529,7 @@ class Server: userManager = factory(components, self._settings) if userManager is not None: self._logger.debug( - "Created user manager instance from factory {}".format(name) + f"Created user manager instance from factory {name}" ) break except Exception: @@ -560,13 +560,11 @@ class Server: try: printer = factory(components) if printer is not None: - self._logger.debug( - "Created printer instance from factory {}".format(name) - ) + self._logger.debug(f"Created printer instance from factory {name}") break except Exception: self._logger.exception( - "Error while creating printer instance from factory {}".format(name), + f"Error while creating printer instance from factory {name}", extra={"plugin": name}, ) else: @@ -759,23 +757,38 @@ class Server: lambda path: not octoprint.util.is_hidden_path(path), status_code=404 ) } + + valid_timelapse = lambda path: not octoprint.util.is_hidden_path( + path + ) and octoprint.timelapse.valid_timelapse(path) timelapse_path_validator = { "path_validation": util.tornado.path_validation_factory( - lambda path: not octoprint.util.is_hidden_path(path) - and octoprint.timelapse.valid_timelapse(path), + valid_timelapse, status_code=404, ) } timelapses_path_validator = { "path_validation": util.tornado.path_validation_factory( - lambda path: not octoprint.util.is_hidden_path(path) - and octoprint.timelapse.valid_timelapse(path), + lambda path: valid_timelapse(path) + and os.path.realpath(os.path.abspath(path)).startswith( + settings().getBaseFolder("timelapse") + ), status_code=400, ) } + + valid_log = lambda path: not octoprint.util.is_hidden_path( + path + ) and path.endswith(".log") + log_path_validator = { + "path_validation": util.tornado.path_validation_factory( + valid_log, + status_code=404, + ) + } logs_path_validator = { "path_validation": util.tornado.path_validation_factory( - lambda path: not octoprint.util.is_hidden_path(path) + lambda path: valid_log(path) and os.path.realpath(os.path.abspath(path)).startswith( settings().getBaseFolder("logs") ), @@ -853,6 +866,7 @@ class Server: }, download_handler_kwargs, log_permission_validator, + log_path_validator, ), ), # zipped log file bundles @@ -1150,9 +1164,7 @@ class Server: if self._host == "::": if self._v6_only: # only v6 - self._logger.info( - "Listening on http://[::]:{port}".format(port=self._port) - ) + self._logger.info(f"Listening on http://[::]:{self._port}") else: # all v4 and v6 self._logger.info( @@ -1337,7 +1349,7 @@ class Server: logger.info("Server heartbeat <3") interval = settings().getFloat(["server", "heartbeat"]) - logger.info("Starting server heartbeat, {}s interval".format(interval)) + logger.info(f"Starting server heartbeat, {interval}s interval") timer = octoprint.util.RepeatedTimer(interval, log_heartbeat) timer.start() @@ -1437,7 +1449,7 @@ class Server: result.add(locale.language) if locale.territory: # if a territory is specified, add that too - result.add("%s_%s" % (locale.language, locale.territory)) + result.add(f"{locale.language}_{locale.territory}") return result @@ -1505,7 +1517,7 @@ class Server: tag += ' target="_blank" rel="noreferrer noopener"' content = match.group("content") - return "<{tag}>{content}".format(tag=tag, content=content) + return f"<{tag}>{content}" return html_link_regex.sub(repl, text) @@ -1740,12 +1752,19 @@ class Server: # do not remove or the index view won't be found import octoprint.server.views # noqa: F401 from octoprint.server.api import api + from octoprint.server.util.flask import make_api_error blueprints = OrderedDict() blueprints["/api"] = api + json_errors = ["/api"] # also register any blueprints defined in BlueprintPlugins - blueprints.update(self._prepare_blueprint_plugins()) + ( + blueprint_from_plugins, + api_prefixes_from_plugins, + ) = self._prepare_blueprint_plugins() + blueprints.update(blueprint_from_plugins) + json_errors += api_prefixes_from_plugins # and register a blueprint for serving the static files of asset plugins which are not blueprint plugins themselves blueprints.update(self._prepare_asset_plugins()) @@ -1757,8 +1776,16 @@ class Server: for url_prefix, blueprint in blueprints.items(): app.register_blueprint(blueprint, url_prefix=url_prefix) + @app.errorhandler(HTTPException) + def _handle_api_error(ex): + if any(map(lambda x: request.path.startswith(x), json_errors)): + return make_api_error(ex.description, ex.code) + else: + return ex + def _prepare_blueprint_plugins(self): blueprints = OrderedDict() + api_prefixes = [] blueprint_plugins = octoprint.plugin.plugin_manager().get_implementations( octoprint.plugin.BlueprintPlugin @@ -1766,6 +1793,9 @@ class Server: for plugin in blueprint_plugins: try: blueprint, prefix = self._prepare_blueprint_plugin(plugin) + api_prefixes += map( + lambda x: prefix + x, plugin.get_blueprint_api_prefixes() + ) blueprints[prefix] = blueprint except Exception: self._logger.exception( @@ -1775,7 +1805,7 @@ class Server: ) continue - return blueprints + return blueprints, api_prefixes def _prepare_asset_plugins(self): blueprints = OrderedDict() @@ -1812,7 +1842,7 @@ class Server: if plugin.is_blueprint_protected(): blueprint.before_request(requireLoginRequestHandler) - url_prefix = "/plugin/{name}".format(name=name) + url_prefix = f"/plugin/{name}" app.register_blueprint(blueprint, url_prefix=url_prefix) if self._logger: @@ -1827,7 +1857,7 @@ class Server: def _prepare_asset_plugin(self, plugin): name = plugin._identifier - url_prefix = "/plugin/{name}".format(name=name) + url_prefix = f"/plugin/{name}" blueprint = Blueprint( "plugin." + name, name, static_folder=plugin.get_asset_folder() ) @@ -1887,7 +1917,7 @@ class Server: cli_key_file = os.path.join(self._settings.getBaseFolder("generated"), "cli.key") cli_key = generate_api_key() - with io.open(cli_key_file, "w", encoding="utf8") as f: + with open(cli_key_file, "w", encoding="utf8") as f: f.write(cli_key) return cli_key @@ -2172,7 +2202,7 @@ class Server: js_plugins_bundle = Bundle( *js_plugins.values(), output="webassets/packed_plugins.js", - filters=",".join(js_plugin_filters) + filters=",".join(js_plugin_filters), ) js_app_bundle = Bundle( @@ -2185,7 +2215,7 @@ class Server: js_client_core_bundle = Bundle( *clientjs_core, output="webassets/packed_client_core.js", - filters=",".join(js_filters) + filters=",".join(js_filters), ) if len(clientjs_plugins) == 0: @@ -2194,7 +2224,7 @@ class Server: js_client_plugins_bundle = Bundle( *clientjs_plugins.values(), output="webassets/packed_client_plugins.js", - filters=",".join(js_plugin_filters) + filters=",".join(js_plugin_filters), ) js_client_bundle = Bundle( @@ -2225,7 +2255,7 @@ class Server: css_core_bundle = Bundle( *css_core, output="webassets/packed_core.css", - filters=",".join(css_filters) + filters=",".join(css_filters), ) if len(css_plugins) == 0: @@ -2234,7 +2264,7 @@ class Server: css_plugins_bundle = Bundle( *css_plugins, output="webassets/packed_plugins.css", - filters=",".join(css_filters) + filters=",".join(css_filters), ) css_app_bundle = Bundle( @@ -2259,7 +2289,7 @@ class Server: less_core_bundle = Bundle( *less_core, output="webassets/packed_core.less", - filters=",".join(less_filters) + filters=",".join(less_filters), ) if len(less_plugins) == 0: @@ -2268,7 +2298,7 @@ class Server: less_plugins_bundle = Bundle( *less_plugins, output="webassets/packed_plugins.less", - filters=",".join(less_filters) + filters=",".join(less_filters), ) less_app_bundle = Bundle( @@ -2284,13 +2314,13 @@ class Server: assets.register("js_client_core", js_client_core_bundle) for plugin, bundle in clientjs_plugins.items(): # register our collected clientjs plugin bundles so that they are bound to the environment - assets.register("js_client_plugin_{}".format(plugin), bundle) + assets.register(f"js_client_plugin_{plugin}", bundle) assets.register("js_client_plugins", js_client_plugins_bundle) assets.register("js_client", js_client_bundle) assets.register("js_core", js_core_bundle) for plugin, bundle in js_plugins.items(): # register our collected plugin bundles so that they are bound to the environment - assets.register("js_plugin_{}".format(plugin), bundle) + assets.register(f"js_plugin_{plugin}", bundle) assets.register("js_plugins", js_plugins_bundle) assets.register("js_app", js_app_bundle) assets.register("css_libs", css_libs_bundle) @@ -2381,7 +2411,7 @@ class Server: if not os.path.isfile(path): return "" - with io.open(path, "rb") as f: + with open(path, "rb") as f: data = f.read() return data @@ -2436,9 +2466,7 @@ class Server: if host == "::": if self._v6_only: - self._logger.debug( - "Starting intermediary server on http://[::]:{port}".format(port=port) - ) + self._logger.debug(f"Starting intermediary server on http://[::]:{port}") else: self._logger.debug( "Starting intermediary server on http://0.0.0.0:{port} and http://[::]:{port}".format( @@ -2526,7 +2554,7 @@ class Server: return "{}: {}".format(plugin, definition["name"]) def permission_role(plugin, role): - return "plugin_{}_{}".format(plugin, role) + return f"plugin_{plugin}_{role}" def process_regular_permission(plugin_info, definition): permissions = [] @@ -2556,7 +2584,7 @@ class Server: plugin=plugin_info.key, dangerous=dangerous, default_groups=default_groups, - *roles_and_permissions + *roles_and_permissions, ) setattr( octoprint.access.permissions.Permissions, @@ -2567,7 +2595,7 @@ class Server: plugin=plugin_info.key, dangerous=dangerous, default_groups=default_groups, - *roles_and_permissions + *roles_and_permissions, ), ) @@ -2615,7 +2643,7 @@ class Server: postponed.append((plugin_info, p)) except Exception: self._logger.exception( - "Error while creating permission instance/s from {}".format(name) + f"Error while creating permission instance/s from {name}" ) # final resolution passes diff --git a/src/octoprint/server/api/__init__.py b/src/octoprint/server/api/__init__.py index 3ad83499a..60f973f7f 100644 --- a/src/octoprint/server/api/__init__.py +++ b/src/octoprint/server/api/__init__.py @@ -2,11 +2,11 @@ __author__ = "Gina HรคuรŸge " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import logging from flask import ( Blueprint, + Response, abort, current_app, g, @@ -78,31 +78,47 @@ def pluginData(name): lambda p: p._identifier == name, octoprint.plugin.SimpleApiPlugin ) if not api_plugins: - return make_response("Not found", 404) + abort(404) if len(api_plugins) > 1: - return make_response( - "More than one api provider registered for {name}, can't proceed".format( - name=name - ), - 500, - ) + abort(500, description="More than one api provider registered, can't proceed") try: api_plugin = api_plugins[0] if api_plugin.is_api_adminonly() and not current_user.is_admin: - return make_response("Forbidden", 403) + abort(403) response = api_plugin.on_api_get(request) if response is not None: + message = ( + "Rewriting response from {} to use abort(msg, code) - please " + "consider upgrading the implementation accordingly".format(name) + ) + if ( + isinstance(response, Response) + and response.mimetype == "text/html" + and response.status_code >= 300 + ): + # this actually looks like an error response + logging.getLogger(__name__).info(message) + abort(response.status_code, description=response.data) + elif ( + isinstance(response, tuple) + and len(response) == 2 + and isinstance(response[0], (str, bytes)) + and response[1] >= 300 + ): + # this actually looks like an error response + logging.getLogger(__name__).info(message) + abort(response[1], response[0]) return response return NO_CONTENT except HTTPException: raise except Exception: logging.getLogger(__name__).exception( - "Error calling SimpleApiPlugin {}".format(name), extra={"plugin": name} + f"Error calling SimpleApiPlugin {name}", extra={"plugin": name} ) return abort(500) @@ -118,24 +134,19 @@ def pluginCommand(name): ) if not api_plugins: - return make_response("Not found", 404) + abort(400) if len(api_plugins) > 1: - return make_response( - "More than one api provider registered for {name}, can't proceed".format( - name=name - ), - 500, - ) + abort(500, description="More than one api provider registered, can't proceed") api_plugin = api_plugins[0] try: valid_commands = api_plugin.get_api_commands() if valid_commands is None: - return make_response("Method not allowed", 405) + abort(405) if api_plugin.is_api_adminonly() and not Permissions.ADMIN.can(): - return make_response("Forbidden", 403) + abort(403) command, data, response = get_json_command_from_request(request, valid_commands) if response is not None: @@ -149,7 +160,7 @@ def pluginCommand(name): raise except Exception: logging.getLogger(__name__).exception( - "Error while executing SimpleApiPlugin {}".format(name), + f"Error while executing SimpleApiPlugin {name}", extra={"plugin": name}, ) return abort(500) @@ -251,21 +262,13 @@ def wizardFinish(): # ~~ system state -@api.route("/state", methods=["GET"]) -@no_firstrun_access -def apiPrinterState(): - return make_response( - ("/api/state has been deprecated, use /api/printer instead", 405, []) - ) - - @api.route("/version", methods=["GET"]) @Permissions.STATUS.require(403) def apiVersion(): return jsonify( server=octoprint.server.VERSION, api=VERSION, - text="OctoPrint {}".format(octoprint.server.DISPLAY_VERSION), + text=f"OctoPrint {octoprint.server.DISPLAY_VERSION}", ) @@ -300,7 +303,7 @@ def login(): if user is not None: if octoprint.server.userManager.check_password(username, password): if not user.is_active: - return make_response(("Your account is deactivated", 403, [])) + abort(403) user = octoprint.server.userManager.login_user(user) session["usersession.id"] = user.session @@ -337,12 +340,12 @@ def login(): return r - return make_response(("User unknown or password incorrect", 403, [])) + abort(403) elif "passive" in data: return passive_login() - return make_response("Neither user and pass attributes nor passive flag present", 400) + abort(400, description="Neither user and pass attributes nor passive flag present") @api.route("/logout", methods=["POST"]) @@ -478,7 +481,7 @@ def _test_path(data): os.makedirs(path) except Exception: logging.getLogger(__name__).exception( - "Error while trying to create {}".format(path) + f"Error while trying to create {path}" ) return jsonify( path=path, @@ -511,12 +514,12 @@ def _test_path(data): if check_writable_dir and check_type == "dir": try: test_path = os.path.join(path, ".testballoon.txt") - with io.open(test_path, "wb") as f: + with open(test_path, "wb") as f: f.write(b"Test") os.remove(test_path) except Exception: logging.getLogger(__name__).exception( - "Error while testing if {} is really writable".format(path) + f"Error while testing if {path} is really writable" ) return jsonify( path=path, @@ -586,12 +589,7 @@ def _test_url(data): try: timeout = float(data["timeout"]) except Exception: - return make_response( - "{!r} is not a valid value for timeout (must be int or float)".format( - data["timeout"] - ), - 400, - ) + abort(400, description="timeout is invalid") if "validSsl" in data: valid_ssl = data["validSsl"] in valid_boolean_trues @@ -615,13 +613,13 @@ def _test_url(data): if "content_type_whitelist" in data: if not isinstance(data["content_type_whitelist"], (list, tuple)): - return make_response("content_type_whitelist must be a list of mime types") + abort(400, description="content_type_whitelist must be a list of mime types") content_type_whitelist = list( map(util.parse_mime_type, data["content_type_whitelist"]) ) if "content_type_blacklist" in data: if not isinstance(data["content_type_whitelist"], (list, tuple)): - return make_response("content_type_blacklist must be a list of mime types") + abort(400, description="content_type_blacklist must be a list of mime types") content_type_blacklist = list( map(util.parse_mime_type, data["content_type_blacklist"]) ) @@ -686,7 +684,7 @@ def _test_url(data): response_result["content"] = content except Exception: logging.getLogger(__name__).exception( - "Error while running a test {} request on {}".format(method, url) + f"Error while running a test {method} request on {url}" ) outcome = False @@ -702,28 +700,18 @@ def _test_server(data): try: port = int(data["port"]) except Exception: - return make_response( - "{!r} is not a valid value for port (must be int)".format(data["port"]), 400 - ) + abort(400, description="Invalid value for port") timeout = 3.05 if "timeout" in data: try: timeout = float(data["timeout"]) except Exception: - return make_response( - "{!r} is not a valid value for timeout (must be int or float)".format( - data["timeout"] - ), - 400, - ) + abort(400, description="Invalid value for timeout") protocol = data.get("protocol", "tcp") if protocol not in ("tcp", "udp"): - return make_response( - "{!r} is not a valid value for protocol, must be tcp or udp".format(protocol), - 400, - ) + abort(400, description="Invalid value for protocol") from octoprint.util import server_reachable diff --git a/src/octoprint/server/api/access.py b/src/octoprint/server/api/access.py index 21d7659e9..a41badce9 100644 --- a/src/octoprint/server/api/access.py +++ b/src/octoprint/server/api/access.py @@ -2,9 +2,8 @@ __author__ = "Marc Hannappel " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License" -from flask import abort, jsonify, make_response, request +from flask import abort, jsonify, request from flask_login import current_user -from werkzeug.exceptions import BadRequest import octoprint.access.groups as groups import octoprint.access.users as users @@ -36,19 +35,16 @@ def get_groups(): @Permissions.SETTINGS.require(403) def add_group(): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + data = request.get_json() if "key" not in data: - return make_response("Missing mandatory key field", 400) + abort(400, description="key is missing") if "name" not in data: - return make_response("Missing mandatory name field", 400) + abort(400, description="name is missing") if "permissions" not in data: - return make_response("Missing mandatory permissions field", 400) + abort(400, description="permissions are missing") key = data["key"] name = data["name"] @@ -87,12 +83,9 @@ def get_group(key): @Permissions.SETTINGS.require(403) def update_group(key): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + data = request.get_json() try: kwargs = {} @@ -146,22 +139,18 @@ def get_users(): @Permissions.SETTINGS.require(403) def add_user(): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) - - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Expected content-type JSON") + data = request.get_json() if data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") if "name" not in data: - return make_response("Missing mandatory name field", 400) + abort(400, description="name is missing") if "password" not in data: - return make_response("Missing mandatory password field", 400) + abort(400, description="password is missing") if "active" not in data: - return make_response("Missing mandatory active field", 400) + abort(400, description="active is missing") name = data["name"] password = data["password"] @@ -204,12 +193,12 @@ def update_user(username): user = userManager.find_user(username) if user is not None: if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + data = request.get_json() + + if data is None: + abort(400, description="Malformed JSON body in request") # change groups if "groups" in data: @@ -221,9 +210,6 @@ def update_user(username): permissions = data["permissions"] userManager.change_user_permissions(username, permissions) - if data is None: - return make_response("Malformed JSON body in request", 400) - # change activation if "active" in data: userManager.change_user_activation( @@ -258,27 +244,24 @@ def change_password_for_user(username): and (current_user.get_name() == username or current_user.is_admin) ): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + data = request.get_json() if data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") if "password" not in data or not data["password"]: - return make_response("password is missing from request", 400) + abort(400, description="password is missing") try: userManager.change_user_password(username, data["password"]) except users.UnknownUser: - return make_response(("Unknown user: %s" % username, 404, [])) + abort(404) return jsonify(SUCCESS) else: - return make_response(("Forbidden", 403, [])) + abort(403) @api.route("/access/users//settings", methods=["GET"]) @@ -292,12 +275,12 @@ def get_settings_for_user(username): and not current_user.has_permission(Permissions.ADMIN) ) ): - return make_response("Forbidden", 403) + abort(403) try: return jsonify(userManager.get_all_user_settings(username)) except users.UnknownUser: - return make_response("Unknown user: %s" % username, 404) + abort(404) @api.route("/access/users//settings", methods=["PATCH"]) @@ -311,21 +294,18 @@ def change_settings_for_user(username): and not current_user.has_permission(Permissions.ADMIN) ) ): - return make_response("Forbidden", 403) + abort(403) - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + data = request.get_json() if data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") try: userManager.change_user_settings(username, data) return jsonify(SUCCESS) except users.UnknownUser: - return make_response("Unknown user: %s" % username, 404) + abort(404) @api.route("/access/users//apikey", methods=["DELETE"]) @@ -342,10 +322,10 @@ def delete_apikey_for_user(username): try: userManager.delete_api_key(username) except users.UnknownUser: - return make_response(("Unknown user: %s" % username, 404, [])) + abort(404) return jsonify(SUCCESS) else: - return make_response(("Forbidden", 403, [])) + abort(403) @api.route("/access/users//apikey", methods=["POST"]) @@ -365,10 +345,10 @@ def generate_apikey_for_user(username): try: apikey = userManager.generate_api_key(username) except users.UnknownUser: - return make_response(("Unknown user: %s" % username, 404, [])) + abort(404) return jsonify({"apikey": apikey}) else: - return make_response(("Forbidden", 403, [])) + abort(403) def _to_external_permissions(*permissions): diff --git a/src/octoprint/server/api/connection.py b/src/octoprint/server/api/connection.py index 63e45581b..c86ddf6ff 100644 --- a/src/octoprint/server/api/connection.py +++ b/src/octoprint/server/api/connection.py @@ -2,7 +2,7 @@ __author__ = "Gina HรคuรŸge " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" -from flask import jsonify, make_response, request +from flask import abort, jsonify, request from octoprint.access.permissions import Permissions from octoprint.comm.protocol import all_protocols @@ -74,7 +74,7 @@ def connectionCommand(): if "printerProfile" in data: printerProfile = data["printerProfile"] if not printerProfileManager.exists(printerProfile): - return make_response("Invalid printer profile: %s" % printerProfile, 400) + abort(400, description="printerProfile is invalid") kwargs["profile"] = printerProfile if "save" in data and data["save"]: # TODO diff --git a/src/octoprint/server/api/files.py b/src/octoprint/server/api/files.py index 506549b4f..a33cdd616 100644 --- a/src/octoprint/server/api/files.py +++ b/src/octoprint/server/api/files.py @@ -8,7 +8,7 @@ import os import threading import psutil -from flask import jsonify, make_response, request, url_for +from flask import abort, jsonify, make_response, request, url_for import octoprint.filemanager import octoprint.filemanager.storage @@ -156,7 +156,7 @@ def readGcodeFiles(): recursive=recursive, allow_from_cache=not force, ) - files.extend(_getFileList(FileDestinations.SDCARD)) + files.extend(_getFileList(FileDestinations.SDCARD, allow_from_cache=not force)) usage = psutil.disk_usage(settings().getBaseFolder("uploads", check_writable=False)) return jsonify(files=files, free=usage.free, total=usage.total) @@ -179,7 +179,7 @@ def readGcodeFiles(): ) def readGcodeFilesForOrigin(origin): if origin not in [FileDestinations.LOCAL, FileDestinations.SDCARD]: - return make_response("Unknown origin: %s" % origin, 404) + abort(404) filter = request.values.get("filter", False) recursive = request.values.get("recursive", "false") in valid_boolean_trues @@ -215,7 +215,10 @@ def readGcodeFilesForOrigin(origin): ) def readGcodeFile(target, filename): if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]: - return make_response("Unknown target: %s" % target, 404) + abort(404) + + if not _validate(target, filename): + abort(404) recursive = False if "recursive" in request.values: @@ -223,7 +226,7 @@ def readGcodeFile(target, filename): file = _getFileDetails(target, filename, recursive=recursive) if not file: - return make_response("File not found on '%s': %s" % (target, filename), 404) + abort(404) return jsonify(file) @@ -243,12 +246,14 @@ def _getFileDetails(origin, path, recursive=True): logtarget=__name__ + ".timings", message="{func}({func_args},{func_kwargs}) took {timing:.2f}ms", incl_func_args=True, + log_enter=True, + message_enter="Entering {func}({func_args},{func_kwargs})...", ) def _getFileList( origin, path=None, filter=None, recursive=False, level=0, allow_from_cache=True ): if origin == FileDestinations.SDCARD: - sdFileList = printer.get_sd_files() + sdFileList = printer.get_sd_files(refresh=not allow_from_cache) files = [] if sdFileList is not None: @@ -287,7 +292,7 @@ def _getFileList( ) with _file_cache_mutex: - cache_key = "{}:{}:{}:{}".format(origin, path, recursive, filter) + cache_key = f"{origin}:{path}:{recursive}:{filter}" files, lastmodified = _file_cache.get(cache_key, ([], None)) # recursive needs to be True for lastmodified queries so we get lastmodified of whole subtree - #3422 if ( @@ -449,7 +454,7 @@ def uploadGcodeFile(target): ) if input_upload_name in request.values and input_upload_path in request.values: if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]: - return make_response("Unknown target: %s" % target, 404) + abort(404) upload = octoprint.filemanager.util.DiskFileWrapper( request.values[input_upload_name], request.values[input_upload_path] @@ -463,12 +468,12 @@ def uploadGcodeFile(target): try: userdata = json.loads(request.values["userdata"]) except Exception: - return make_response("userdata contains invalid JSON", 400) + abort(400, description="userdata contains invalid JSON") if target == FileDestinations.SDCARD and not settings().getBoolean( ["feature", "sdSupport"] ): - return make_response("SD card support is disabled", 404) + abort(404) sd = target == FileDestinations.SDCARD selectAfterUpload = ( @@ -488,14 +493,12 @@ def uploadGcodeFile(target): printer.is_operational() and not (printer.is_printing() or printer.is_paused()) ): - return make_response( - "Can not upload to SD card, printer is either not operational or already busy", + abort( 409, + description="Can not upload to SD card, printer is either not operational or already busy", ) if not printer.is_sd_ready(): - return make_response( - "Can not upload to SD card, not yet initialized", 409 - ) + abort(409, description="Can not upload to SD card, not yet initialized") # determine future filename of file to be uploaded, abort if it can't be uploaded try: @@ -513,9 +516,7 @@ def uploadGcodeFile(target): futureFilename = None if futureFilename is None: - return make_response( - "Can not upload file %s, wrong format?" % upload.filename, 415 - ) + abort(415, description="Can not upload file, wrong format?") if "path" in request.values and request.values["path"]: # we currently only support uploads to sdcard via local, so first target is local instead of "target" @@ -532,10 +533,9 @@ def uploadGcodeFile(target): ) if not printer.can_modify_file(futureFullPathInStorage, sd): - return make_response( - "Trying to overwrite file that is currently being printed: %s" - % futureFullPath, + abort( 409, + description="Trying to overwrite file that is currently being printed", ) reselect = printer.is_current_file(futureFullPathInStorage, sd) @@ -594,16 +594,9 @@ def uploadGcodeFile(target): ) except octoprint.filemanager.storage.StorageError as e: if e.code == octoprint.filemanager.storage.StorageError.INVALID_FILE: - return make_response( - 'Could not upload the file "{}", invalid type'.format( - upload.filename - ), - 400, - ) + abort(400, description="Could not upload file, invalid type") else: - return make_response( - 'Could not upload the file "{}"'.format(upload.filename), 500 - ) + abort(500, description="Could not upload file") if octoprint.filemanager.valid_file_type(added_file, "stl"): filename = added_file @@ -688,13 +681,13 @@ def uploadGcodeFile(target): foldername = request.values["foldername"] if target not in [FileDestinations.LOCAL]: - return make_response("Unknown target: %s" % target, 400) + abort(400, description="target is invalid") canonPath, canonName = fileManager.canonicalize(target, foldername) futurePath = fileManager.sanitize_path(target, canonPath) futureName = fileManager.sanitize_name(target, canonName) if not futureName or not futurePath: - return make_response("Can't create a folder with an empty name", 400) + abort(400, description="folder name is empty") if "path" in request.values and request.values["path"]: futurePath = fileManager.sanitize_path( @@ -703,10 +696,7 @@ def uploadGcodeFile(target): futureFullPath = fileManager.join_path(target, futurePath, futureName) if octoprint.filemanager.valid_file_type(futureName): - return make_response( - "Can't create a folder named %s, please try another name" % futureName, - 409, - ) + abort(409, description="Can't create folder, please try another name") try: added_folder = fileManager.add_folder( @@ -714,11 +704,9 @@ def uploadGcodeFile(target): ) except octoprint.filemanager.storage.StorageError as e: if e.code == octoprint.filemanager.storage.StorageError.INVALID_DIRECTORY: - return make_response( - "Could not create folder {}, invalid directory".format(futureName) - ) + abort(400, description="Could not create folder, invalid directory") else: - return make_response("Could not create folder {}".format(futureName)) + abort(500, description="Could not create folder") location = url_for( ".readGcodeFile", @@ -738,14 +726,17 @@ def uploadGcodeFile(target): return r else: - return make_response("No file to upload and no folder to create", 400) + abort(400, description="No file to upload and no folder to create") @api.route("/files//", methods=["POST"]) @no_firstrun_access def gcodeFileCommand(filename, target): if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]: - return make_response("Unknown target: %s" % target, 404) + abort(404) + + if not _validate(target, filename): + abort(404) # valid file commands, dict mapping command name to mandatory parameters valid_commands = { @@ -765,31 +756,28 @@ def gcodeFileCommand(filename, target): if command == "select": with Permissions.FILES_SELECT.require(403): if not _verifyFileExists(target, filename): - return make_response( - "File not found on '%s': %s" % (target, filename), 404 - ) + abort(404) # selects/loads a file if not octoprint.filemanager.valid_file_type(filename, type="machinecode"): - return make_response( - "Cannot select {filename} for printing, not a machinecode file".format( - **locals() - ), + abort( 415, + description="Cannot select file for printing, not a machinecode file", ) if not printer.is_ready(): - return make_response( - "Printer is already printing, cannot select a new file", 409 + abort( + 409, + description="Printer is already printing, cannot select a new file", ) print_after_loading = False if "print" in data and data["print"] in valid_boolean_trues: with Permissions.PRINT.require(403): if not printer.is_operational(): - return make_response( - "Printer is not operational, cannot directly start printing", + abort( 409, + description="Printer is not operational, cannot directly start printing", ) print_after_loading = True @@ -799,9 +787,7 @@ def gcodeFileCommand(filename, target): elif command == "slice": with Permissions.SLICE.require(403): if not _verifyFileExists(target, filename): - return make_response( - "File not found on '%s': %s" % (target, filename), 404 - ) + abort(404) try: if "slicer" in data: @@ -814,14 +800,9 @@ def gcodeFileCommand(filename, target): slicer_instance = slicingManager.get_slicer("cura") else: - return make_response( - "Cannot slice {filename}, no slicer available".format(**locals()), - 415, - ) - except octoprint.slicing.UnknownSlicer as e: - return make_response( - "Slicer {slicer} is not available".format(slicer=e.slicer), 400 - ) + abort(415, description="Cannot slice file, no slicer available") + except octoprint.slicing.UnknownSlicer: + abort(404) if not any( [ @@ -831,9 +812,7 @@ def gcodeFileCommand(filename, target): ) ] ): - return make_response( - "Cannot slice {filename}, not a model file".format(**locals()), 415 - ) + abort(415, description="Cannot slice file, not a model file") cores = psutil.cpu_count() if ( @@ -842,11 +821,9 @@ def gcodeFileCommand(filename, target): and (cores is None or cores < 2) ): # slicer runs on same device as OctoPrint, slicing while printing is hence disabled - return make_response( - "Cannot slice on {slicer} while printing on single core systems or systems of unknown core count due to performance reasons".format( - **locals() - ), + abort( 409, + description="Cannot slice on this slicer while printing on single core systems or systems of unknown core count due to performance reasons", ) if "destination" in data and data["destination"]: @@ -890,10 +867,9 @@ def gcodeFileCommand(filename, target): and currentOrigin == target and (printer.is_printing() or printer.is_paused()) ): - make_response( - "Trying to slice into file that is currently being printed: %s" - % full_path, + abort( 409, + description="Trying to slice into file that is currently being printed", ) if "profile" in data and data["profile"]: @@ -923,17 +899,18 @@ def gcodeFileCommand(filename, target): select_after_slicing = False if "select" in data and data["select"] in valid_boolean_trues: if not printer.is_operational(): - return make_response( - "Printer is not operational, cannot directly select for printing", + abort( 409, + description="Printer is not operational, cannot directly select for printing", ) select_after_slicing = True print_after_slicing = False if "print" in data and data["print"] in valid_boolean_trues: if not printer.is_operational(): - return make_response( - "Printer is not operational, cannot directly start printing", 409 + abort( + 409, + description="Printer is not operational, cannot directly start printing", ) select_after_slicing = print_after_slicing = True @@ -975,11 +952,8 @@ def gcodeFileCommand(filename, target): ), ) except octoprint.slicing.UnknownProfile: - return make_response( - "Profile {profile} doesn't exist".format(**locals()), 400 - ) + abort(404, description="Unknown profile") - files = {} location = url_for( ".readGcodeFile", target=target, filename=full_path, _external=True ) @@ -1005,9 +979,7 @@ def gcodeFileCommand(filename, target): elif command == "analyse": with Permissions.FILES_UPLOAD.require(403): if not _verifyFileExists(target, filename): - return make_response( - "File not found on '%s': %s" % (target, filename), 404 - ) + abort(404) printer_profile = None if "printerProfile" in data and data["printerProfile"]: @@ -1016,24 +988,18 @@ def gcodeFileCommand(filename, target): if not fileManager.analyse( target, filename, printer_profile_id=printer_profile ): - return make_response( - "No analysis possible for {} on {}".format(filename, target), 400 - ) + abort(400, description="No analysis possible") elif command == "copy" or command == "move": with Permissions.FILES_UPLOAD.require(403): # Copy and move are only possible on local storage if target not in [FileDestinations.LOCAL]: - return make_response( - "Unsupported target for {}: {}".format(command, target), 400 - ) + abort(400, description=f"Unsupported target for {command}") if not _verifyFileExists(target, filename) and not _verifyFolderExists( target, filename ): - return make_response( - "File or folder not found on {}: {}".format(target, filename), 404 - ) + abort(404) path, name = fileManager.split_path(target, filename) @@ -1054,35 +1020,20 @@ def gcodeFileCommand(filename, target): if _verifyFileExists(target, destination) or _verifyFolderExists( target, destination ): - return make_response( - "File or folder does already exist on {}: {}".format( - target, destination - ), - 409, - ) + abort(409, description="File or folder does already exist") is_file = fileManager.file_exists(target, filename) is_folder = fileManager.folder_exists(target, filename) if not (is_file or is_folder): - return make_response( - "{} on {} is neither file or folder, can't {}".format( - filename, target, command - ), - 400, - ) + abort(400, description=f"Neither file nor folder, can't {command}") if command == "copy": # destination already there? error... if _verifyFileExists(target, destination) or _verifyFolderExists( target, destination ): - return make_response( - "File or folder does already exist on {}: {}".format( - target, destination - ), - 409, - ) + abort(409, description="File or folder does already exist") if is_file: fileManager.copy_file(target, filename, destination) @@ -1092,11 +1043,9 @@ def gcodeFileCommand(filename, target): elif command == "move": with Permissions.FILES_DELETE.require(403): if _isBusy(target, filename): - return make_response( - "Trying to move a file or folder that is currently in use: {}".format( - filename - ), + abort( 409, + description="Trying to move a file or folder that is currently in use", ) # destination already there AND not ourselves (= display rename)? error... @@ -1104,12 +1053,7 @@ def gcodeFileCommand(filename, target): _verifyFileExists(target, destination) or _verifyFolderExists(target, destination) ) and sanitized_destination != filename: - return make_response( - "File or folder does already exist on {}: {}".format( - target, destination - ), - 409, - ) + abort(409, description="File or folder does already exist") # deselect the file if it's currently selected currentOrigin, currentFilename = _getCurrentFile() @@ -1150,21 +1094,20 @@ def gcodeFileCommand(filename, target): @no_firstrun_access @Permissions.FILES_DELETE.require(403) def deleteGcodeFile(filename, target): + if not _validate(target, filename): + abort(404) + if not _verifyFileExists(target, filename) and not _verifyFolderExists( target, filename ): - return make_response( - "File/Folder not found on '%s': %s" % (target, filename), 404 - ) + abort(404) + + if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]: + abort(404) if _verifyFileExists(target, filename): - if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]: - return make_response("Unknown target: %s" % target, 400) - if _isBusy(target, filename): - return make_response( - "Trying to delete a file that is currently in use: %s" % filename, 409 - ) + abort(409, description="Trying to delete a file that is currently in use") # deselect the file if it's currently selected currentOrigin, currentPath = _getCurrentFile() @@ -1182,14 +1125,10 @@ def deleteGcodeFile(filename, target): fileManager.remove_file(target, filename) elif _verifyFolderExists(target, filename): - if target not in [FileDestinations.LOCAL]: - return make_response("Unknown target: %s" % target, 400) - if _isBusy(target, filename): - return make_response( - "Trying to delete a folder that contains a file that is currently in use: %s" - % filename, + abort( 409, + description="Trying to delete a folder that contains a file that is currently in use", ) # deselect the file if it's currently selected @@ -1220,6 +1159,12 @@ def _getCurrentFile(): return None, None +def _validate(target, filename): + return filename == "/".join( + map(lambda x: fileManager.sanitize_name(target, x), filename.split("/")) + ) + + class WerkzeugFileWrapper(octoprint.filemanager.util.AbstractFileWrapper): """ A wrapper around a Werkzeug ``FileStorage`` object. diff --git a/src/octoprint/server/api/job.py b/src/octoprint/server/api/job.py index be202e0d3..4de446326 100644 --- a/src/octoprint/server/api/job.py +++ b/src/octoprint/server/api/job.py @@ -2,7 +2,7 @@ __author__ = "Gina HรคuรŸge " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" -from flask import jsonify, make_response, request +from flask import abort, jsonify, request from octoprint.access.permissions import Permissions from octoprint.server import NO_CONTENT, current_user, printer @@ -14,7 +14,7 @@ from octoprint.server.util.flask import get_json_command_from_request, no_firstr @no_firstrun_access def controlJob(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") valid_commands = {"start": [], "restart": [], "pause": [], "cancel": []} @@ -31,22 +31,23 @@ def controlJob(): with Permissions.PRINT.require(403): if command == "start": if activePrintjob: - return make_response( - "Printer already has an active print job, did you mean 'restart'?", + abort( 409, + description="Printer already has an active print job, did you mean 'restart'?", ) printer.start_print(tags=tags, user=user) elif command == "restart": if not printer.is_paused(): - return make_response( - "Printer does not have an active print job or is not paused", 409 + abort( + 409, + description="Printer does not have an active print job or is not paused", ) printer.start_print(tags=tags, user=user) elif command == "pause": if not activePrintjob: - return make_response( - "Printer is neither printing nor paused, 'pause' command cannot be performed", + abort( 409, + description="Printer is neither printing nor paused, 'pause' command cannot be performed", ) action = data.get("action", "toggle") if action == "toggle": @@ -56,17 +57,12 @@ def controlJob(): elif action == "resume": printer.resume_print(tags=tags, user=user) else: - return make_response( - "Unknown action '{}', allowed values for action parameter are 'pause', 'resume' and 'toggle'".format( - action - ), - 400, - ) + abort(400, description="Unknown action") elif command == "cancel": if not activePrintjob: - return make_response( - "Printer is neither printing nor paused, 'cancel' command cannot be performed", + abort( 409, + description="Printer is neither printing nor paused, 'cancel' command cannot be performed", ) printer.cancel_print(tags=tags, user=user) return NO_CONTENT diff --git a/src/octoprint/server/api/languages.py b/src/octoprint/server/api/languages.py index 9cac453bd..8c86b6386 100644 --- a/src/octoprint/server/api/languages.py +++ b/src/octoprint/server/api/languages.py @@ -2,7 +2,6 @@ __author__ = "Gina HรคuรŸge " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import logging import os import tarfile @@ -10,7 +9,7 @@ import zipfile from collections import defaultdict from os import scandir -from flask import jsonify, make_response, request +from flask import abort, jsonify, request from flask_babel import Locale from octoprint.access.permissions import Permissions @@ -44,7 +43,7 @@ def getInstalledLanguagePacks(): import yaml try: - with io.open(meta_path, "rt", encoding="utf-8") as f: + with open(meta_path, encoding="utf-8") as f: meta = yaml.safe_load(f) except Exception: logging.getLogger(__name__).exception("Could not load %s", meta_path) @@ -127,7 +126,7 @@ def uploadLanguagePack(): input_name + "." + settings().get(["server", "uploads", "nameSuffix"]) ) if input_upload_path not in request.values or input_upload_name not in request.values: - return make_response("No file included", 400) + abort(400, description="No file included") upload_name = request.values[input_upload_name] upload_path = request.values[input_upload_path] @@ -138,8 +137,9 @@ def uploadLanguagePack(): ) ) if not len(exts): - return make_response( - "File doesn't have a valid extension for a language pack archive", 400 + abort( + 400, + description="File doesn't have a valid extension for a language pack archive", ) target_path = settings().getBaseFolder("translations") @@ -149,7 +149,7 @@ def uploadLanguagePack(): elif zipfile.is_zipfile(upload_path): _unpack_uploaded_zipfile(upload_path, target_path) else: - return make_response("Neither zip file nor tarball included", 400) + abort(400, description="Neither zip file nor tarball included") return getInstalledLanguagePacks() diff --git a/src/octoprint/server/api/printer.py b/src/octoprint/server/api/printer.py index 8fc1f8d45..b892df317 100644 --- a/src/octoprint/server/api/printer.py +++ b/src/octoprint/server/api/printer.py @@ -4,8 +4,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import re -from flask import Response, jsonify, make_response, request -from werkzeug.exceptions import BadRequest +from flask import Response, abort, jsonify, request from octoprint.access.permissions import Permissions from octoprint.printer import UnknownScript @@ -21,7 +20,7 @@ from octoprint.settings import settings, valid_boolean_trues @Permissions.STATUS.require(403) def printerState(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") # process excludes excludes = [] @@ -71,7 +70,7 @@ def printerState(): @Permissions.CONTROL.require(403) def printerToolCommand(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") valid_commands = { "select": ["tool"], @@ -92,9 +91,7 @@ def printerToolCommand(): if command == "select": tool = data["tool"] if not isinstance(tool, str) or re.match(validation_regex, tool) is None: - return make_response("Invalid tool: %s" % tool, 400) - if not tool.startswith("tool"): - return make_response("Invalid tool for selection: %s" % tool, 400) + abort(400, description="tool is invalid") printer.change_tool(tool, tags=tags) @@ -106,11 +103,9 @@ def printerToolCommand(): validated_values = {} for tool, value in targets.items(): if re.match(validation_regex, tool) is None: - return make_response( - "Invalid target for setting temperature: %s" % tool, 400 - ) + abort(400, description="targets contains invalid tool") if not isinstance(value, (int, float)): - return make_response("Not a number for %s: %r" % (tool, value), 400) + abort(400, description="targets contains invalid value") validated_values[tool] = value # perform the actual temperature commands @@ -125,15 +120,9 @@ def printerToolCommand(): validated_values = {} for tool, value in offsets.items(): if re.match(validation_regex, tool) is None: - return make_response( - "Invalid target for setting temperature: %s" % tool, 400 - ) - if not isinstance(value, (int, float)): - return make_response("Not a number for %s: %r" % (tool, value), 400) - if not -50 <= value <= 50: - return make_response( - "Offset %s not in range [-50, 50]: %f" % (tool, value), 400 - ) + abort(400, description="offsets contains invalid tool") + if not isinstance(value, (int, float)) or not -50 <= value <= 50: + abort(400, description="offsets contains invalid value") validated_values[tool] = value # set the offsets @@ -143,22 +132,22 @@ def printerToolCommand(): elif command == "extrude": if printer.is_printing(): # do not extrude when a print job is running - return make_response("Printer is currently printing", 409) + abort(409, description="Printer is currently printing") amount = data["amount"] speed = data.get("speed", None) if not isinstance(amount, (int, float)): - return make_response("Not a number for extrusion amount: %r" % amount, 400) + abort(400, description="amount is invalid") printer.extrude(amount, speed=speed, tags=tags) elif command == "flowrate": factor = data["factor"] if not isinstance(factor, (int, float)): - return make_response("Not a number for flow rate: %r" % factor, 400) + abort(400, description="factor is invalid") try: printer.flow_rate(factor, tags=tags) - except ValueError as e: - return make_response("Invalid value for flow rate: %s" % str(e), 400) + except ValueError: + abort(400, description="factor is invalid") return NO_CONTENT @@ -168,7 +157,7 @@ def printerToolCommand(): @Permissions.STATUS.require(403) def printerToolState(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") return jsonify(_get_temperature_data(_keep_tools)) @@ -181,10 +170,10 @@ def printerToolState(): @Permissions.CONTROL.require(403) def printerBedCommand(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") if not printerProfileManager.get_current_or_default()["heatedBed"]: - return make_response("Printer does not have a heated bed", 409) + abort(409, description="Printer does not have a heated bed") valid_commands = {"target": ["target"], "offset": ["offset"]} command, data, response = get_json_command_from_request(request, valid_commands) @@ -199,7 +188,7 @@ def printerBedCommand(): # make sure the target is a number if not isinstance(target, (int, float)): - return make_response("Not a number: %r" % target, 400) + abort(400, description="target is invalid") # perform the actual temperature command printer.set_temperature("bed", target, tags=tags) @@ -209,10 +198,8 @@ def printerBedCommand(): offset = data["offset"] # make sure the offset is valid - if not isinstance(offset, (int, float)): - return make_response("Not a number: %r" % offset, 400) - if not -50 <= offset <= 50: - return make_response("Offset not in range [-50, 50]: %f" % offset, 400) + if not isinstance(offset, (int, float)) or not -50 <= offset <= 50: + abort(400, description="offset is invalid") # set the offsets printer.set_temperature_offset({"bed": offset}) @@ -225,10 +212,10 @@ def printerBedCommand(): @Permissions.STATUS.require(403) def printerBedState(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") if not printerProfileManager.get_current_or_default()["heatedBed"]: - return make_response("Printer does not have a heated bed", 409) + abort(409, description="Printer does not have a heated bed") data = _get_temperature_data(_keep_bed) if isinstance(data, Response): @@ -245,10 +232,10 @@ def printerBedState(): @Permissions.CONTROL.require(403) def printerChamberCommand(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") if not printerProfileManager.get_current_or_default()["heatedChamber"]: - return make_response("Printer does not have a heated chamber", 409) + abort(409, description="Printer does not have a heated chamber") valid_commands = {"target": ["target"], "offset": ["offset"]} command, data, response = get_json_command_from_request(request, valid_commands) @@ -263,7 +250,7 @@ def printerChamberCommand(): # make sure the target is a number if not isinstance(target, (int, float)): - return make_response("Not a number: %r" % target, 400) + abort(400, description="target is invalid") # perform the actual temperature command printer.set_temperature("chamber", target, tags=tags) @@ -273,10 +260,8 @@ def printerChamberCommand(): offset = data["offset"] # make sure the offset is valid - if not isinstance(offset, (int, float)): - return make_response("Not a number: %r" % offset, 400) - if not -50 <= offset <= 50: - return make_response("Offset not in range [-50, 50]: %f" % offset, 400) + if not isinstance(offset, (int, float)) or not -50 <= offset <= 50: + abort(400, description="offset is invalid") # set the offsets printer.set_temperature_offset({"chamber": offset}) @@ -289,10 +274,10 @@ def printerChamberCommand(): @Permissions.STATUS.require(403) def printerChamberState(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") if not printerProfileManager.get_current_or_default()["heatedChamber"]: - return make_response("Printer does not have a heated chamber", 409) + abort(409, description="Printer does not have a heated chamber") data = _get_temperature_data(_keep_chamber) if isinstance(data, Response): @@ -315,7 +300,7 @@ def printerPrintheadCommand(): if not printer.is_operational() or (printer.is_printing() and command != "feedrate"): # do not jog when a print job is running or we don't have a connection - return make_response("Printer is not operational or currently printing", 409) + abort(409, description="Printer is not operational or currently printing") tags = {"source:api", "api:printer.printhead"} @@ -328,9 +313,7 @@ def printerPrintheadCommand(): if axis in data: value = data[axis] if not isinstance(value, (int, float)): - return make_response( - "Not a number for axis %s: %r" % (axis, value), 400 - ) + abort(400, description="axis value is invalid") validated_values[axis] = value absolute = "absolute" in data and data["absolute"] in valid_boolean_trues @@ -345,7 +328,7 @@ def printerPrintheadCommand(): axes = data["axes"] for axis in axes: if axis not in valid_axes: - return make_response("Invalid axis: %s" % axis, 400) + abort(400, description="axis is invalid") validated_values.append(axis) # execute the home command @@ -354,11 +337,11 @@ def printerPrintheadCommand(): elif command == "feedrate": factor = data["factor"] if not isinstance(factor, (int, float)): - return make_response("Not a number for feed rate: %r" % factor, 400) + abort(400, description="factor is invalid") try: printer.feed_rate(factor, tags=tags) - except ValueError as e: - return make_response("Invalid value for feed rate: %s" % str(e), 400) + except ValueError: + abort(400, description="factor is invalid") return NO_CONTENT @@ -371,10 +354,10 @@ def printerPrintheadCommand(): @Permissions.CONTROL.require(403) def printerSdCommand(): if not settings().getBoolean(["feature", "sdSupport"]): - return make_response("SD support is disabled", 404) + abort(404, description="SD support is disabled") if not printer.is_operational() or printer.is_printing() or printer.is_paused(): - return make_response("Printer is not operational or currently busy", 409) + abort(409, description="Printer is not operational or currently busy") valid_commands = {"init": [], "refresh": [], "release": []} command, data, response = get_json_command_from_request(request, valid_commands) @@ -398,7 +381,7 @@ def printerSdCommand(): @Permissions.STATUS.require(403) def printerSdState(): if not settings().getBoolean(["feature", "sdSupport"]): - return make_response("SD support is disabled", 404) + abort(404, description="SD support is disabled") return jsonify(ready=printer.is_sd_ready()) @@ -411,27 +394,22 @@ def printerSdState(): @Permissions.CONTROL.require(403) def printerCommand(): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content type JSON", 400) + abort(400, description="Expected content type JSON") - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + data = request.get_json() if data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") if "command" in data and "commands" in data: - return make_response("'command' and 'commands' are mutually exclusive", 400) + abort(400, description="'command' and 'commands' are mutually exclusive") elif ("command" in data or "commands" in data) and "script" in data: - return make_response( - "'command'/'commands' and 'script' are mutually exclusive", 400 - ) + abort(400, description="'command'/'commands' and 'script' are mutually exclusive") elif not ("command" in data or "commands" in data or "script" in data): - return make_response("Need one of 'command', 'commands' or 'script'", 400) + abort(400, description="Need one of 'command', 'commands' or 'script'") parameters = {} if "parameters" in data: @@ -444,7 +422,7 @@ def printerCommand(): commands = [data["command"]] else: if not isinstance(data["commands"], (list, tuple)): - return make_response("'commands' needs to be a list", 400) + abort(400, description="commands is invalid") commands = data["commands"] commandsToSend = [] @@ -465,7 +443,7 @@ def printerCommand(): try: printer.script(script_name, context=context, tags=tags) except UnknownScript: - return make_response("Unknown script: {script_name}".format(**locals()), 404) + abort(404, description="Unknown script") return NO_CONTENT @@ -480,7 +458,7 @@ def getCustomControls(): def _get_temperature_data(preprocessor): if not printer.is_operational(): - return make_response("Printer is not operational", 409) + abort(409, description="Printer is not operational") tempData = printer.get_current_temperatures() diff --git a/src/octoprint/server/api/printer_profiles.py b/src/octoprint/server/api/printer_profiles.py index 149f383fb..55644eb45 100644 --- a/src/octoprint/server/api/printer_profiles.py +++ b/src/octoprint/server/api/printer_profiles.py @@ -5,8 +5,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import copy -from flask import jsonify, make_response, request, url_for -from werkzeug.exceptions import BadRequest +from flask import abort, jsonify, request, url_for from octoprint.access.permissions import Permissions from octoprint.printer.profile import CouldNotOverwriteError, InvalidProfileError @@ -56,18 +55,15 @@ def printerProfilesList(): @Permissions.SETTINGS.require(403) def printerProfilesAdd(): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") - try: - json_data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + json_data = request.get_json() if json_data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") if "profile" not in json_data: - return make_response("No profile included in request", 400) + abort(400, description="profile is missing") base_profile = printerProfileManager.get_default() if "basedOn" in json_data and isinstance(json_data["basedOn"], str): @@ -91,25 +87,20 @@ def printerProfilesAdd(): profile = dict_merge(base_profile, new_profile) if "id" not in profile: - return make_response("Profile does not contain mandatory 'id' field", 400) + abort(400, description="profile.id is missing") if "name" not in profile: - return make_response("Profile does not contain mandatory 'name' field", 400) + abort(400, description="profile.name is missing") try: saved_profile = printerProfileManager.save( profile, allow_overwrite=False, make_default=make_default, trigger_event=True ) except InvalidProfileError: - return make_response("Profile is invalid", 400) + abort(400, description="profile is invalid") except CouldNotOverwriteError: - return make_response( - "Profile {} already exists and overwriting was not allowed".format( - profile["id"] - ), - 400, - ) + abort(400, description="Profile already exists and overwriting was not allowed") except Exception as e: - return make_response("Could not save profile: %s" % str(e), 500) + abort(500, description="Could not save profile: %s" % str(e)) else: return jsonify({"profile": _convert_profile(saved_profile)}) @@ -120,7 +111,7 @@ def printerProfilesAdd(): def printerProfilesGet(identifier): profile = printerProfileManager.get(identifier) if profile is None: - return make_response("Unknown profile: %s" % identifier, 404) + abort(404) else: return jsonify(_convert_profile(profile)) @@ -131,13 +122,11 @@ def printerProfilesGet(identifier): def printerProfilesDelete(identifier): current_profile = printerProfileManager.get_current() if current_profile and current_profile["id"] == identifier: - return make_response( - "Cannot delete currently selected profile: {}".format(identifier), 409 - ) + abort(409, description="Cannot delete currently selected profile") default_profile = printerProfileManager.get_default() if default_profile and default_profile["id"] == identifier: - return make_response("Cannot delete default profile: {}".format(identifier), 409) + abort(409, description="Cannot delete default profile") printerProfileManager.remove(identifier, trigger_event=True) return NO_CONTENT @@ -148,18 +137,14 @@ def printerProfilesDelete(identifier): @Permissions.SETTINGS.require(403) def printerProfilesUpdate(identifier): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) - - try: - json_data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Expected content-type JSON") + json_data = request.get_json() if json_data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") if "profile" not in json_data: - return make_response("No profile included in request", 400) + abort(400, description="profile missing") profile = printerProfileManager.get(identifier) if profile is None: @@ -183,13 +168,11 @@ def printerProfilesUpdate(identifier): trigger_event=True, ) except InvalidProfileError: - return make_response("Profile is invalid", 400) + abort(400, description="profile is invalid") except CouldNotOverwriteError: - return make_response( - "Profile already exists and overwriting was not allowed", 400 - ) + abort(400, description="Profile already exists and overwriting was not allowed") except Exception as e: - return make_response("Could not save profile: %s" % str(e), 500) + abort(500, description="Could not save profile: %s" % str(e)) else: return jsonify({"profile": _convert_profile(saved_profile)}) diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 26d6fbd4c..2b737d14b 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -4,9 +4,8 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import logging -from flask import abort, jsonify, make_response, request +from flask import abort, jsonify, request from flask_login import current_user -from werkzeug.exceptions import BadRequest import octoprint.plugin import octoprint.util @@ -142,7 +141,10 @@ def getSettings(): "g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]), "autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"]), }, - "gcodeAnalysis": {"runAt": s.get(["gcodeAnalysis", "runAt"])}, + "gcodeAnalysis": { + "runAt": s.get(["gcodeAnalysis", "runAt"]), + "bedZ": s.getFloat(["gcodeAnalysis", "bedZ"]), + }, "serial": { "exclusive": s.getBoolean(["serial", "exclusive"]), "autoconnect": s.getBoolean(["serial", "autoconnect"]), @@ -361,22 +363,11 @@ def _get_plugin_settings(): @Permissions.SETTINGS.require(403) def setSettings(): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") - try: - data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) - - if data is None: - return make_response("Malformed JSON body in request", 400) - - if not isinstance(data, dict): - return make_response( - "Malformed request, need settings dictionary, " - "got a {} instead: {!r}".format(type(data).__name__, data), - 400, - ) + data = request.get_json() + if data is None or not isinstance(data, dict): + abort(400, description="Malformed JSON body in request") response = _saveSettings(data) if response: @@ -456,7 +447,7 @@ def _saveSettings(data): s.setBaseFolder(folder, future[folder]) except Exception: - return make_response("At least one of the configured folders is invalid", 400) + abort(400, description="At least one of the configured folders is invalid") if "api" in data: if "allowCrossOrigin" in data["api"]: @@ -589,6 +580,8 @@ def _saveSettings(data): if "gcodeAnalysis" in data: if "runAt" in data["gcodeAnalysis"]: s.set(["gcodeAnalysis", "runAt"], data["gcodeAnalysis"]["runAt"]) + if "bedZ" in data["gcodeAnalysis"]: + s.setBoolean(["gcodeAnalysis", "bedZ"], data["gcodeAnalysis"]["bedZ"]) if "serial" in data: if "autoconnect" in data["serial"]: diff --git a/src/octoprint/server/api/slicing.py b/src/octoprint/server/api/slicing.py index 12be70275..f2dd80b42 100644 --- a/src/octoprint/server/api/slicing.py +++ b/src/octoprint/server/api/slicing.py @@ -2,8 +2,7 @@ __author__ = "Gina HรคuรŸge " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" -from flask import jsonify, make_response, request, url_for -from werkzeug.exceptions import BadRequest +from flask import abort, jsonify, make_response, request, url_for from octoprint.access.permissions import Permissions from octoprint.server import slicingManager @@ -138,7 +137,7 @@ def slicingListSlicerProfiles(slicer): try: return jsonify(_getSlicingProfilesData(slicer, require_configured=configured)) except (UnknownSlicer, SlicerNotConfigured): - return make_response("Unknown slicer {slicer}".format(**locals()), 404) + abort(404) @api.route("/slicing//profiles/", methods=["GET"]) @@ -148,9 +147,9 @@ def slicingGetSlicerProfile(slicer, name): try: profile = slicingManager.load_profile(slicer, name, require_configured=False) except UnknownSlicer: - return make_response("Unknown slicer {slicer}".format(**locals()), 404) + abort(404) except UnknownProfile: - return make_response("Profile not found", 404) + abort(404) result = _getSlicingProfileData(slicer, name, profile) result["data"] = profile.data @@ -162,15 +161,11 @@ def slicingGetSlicerProfile(slicer, name): @Permissions.SETTINGS.require(403) def slicingAddSlicerProfile(slicer, name): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) - - try: - json_data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Expected content-type JSON") + json_data = request.get_json() if json_data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") data = {} display_name = None @@ -192,7 +187,7 @@ def slicingAddSlicerProfile(slicer, name): description=description, ) except UnknownSlicer: - return make_response("Unknown slicer {slicer}".format(**locals()), 404) + abort(404, description="Unknown slicer") result = _getSlicingProfileData(slicer, name, profile) r = make_response(jsonify(result), 201) @@ -205,24 +200,18 @@ def slicingAddSlicerProfile(slicer, name): @Permissions.SETTINGS.require(403) def slicingPatchSlicerProfile(slicer, name): if "application/json" not in request.headers["Content-Type"]: - return make_response("Expected content-type JSON", 400) + abort(400, description="Expected content-type JSON") try: profile = slicingManager.load_profile(slicer, name, require_configured=False) except UnknownSlicer: - return make_response("Unknown slicer {slicer}".format(**locals()), 404) + return abort(404) except UnknownProfile: - return make_response( - "Profile {name} for slicer {slicer} not found".format(**locals()), 404 - ) - - try: - json_data = request.get_json() - except BadRequest: - return make_response("Malformed JSON body in request", 400) + return abort(404) + json_data = request.get_json() if json_data is None: - return make_response("Malformed JSON body in request", 400) + abort(400, description="Malformed JSON body in request") data = {} display_name = None @@ -259,13 +248,13 @@ def slicingDelSlicerProfile(slicer, name): try: slicingManager.delete_profile(slicer, name) except UnknownSlicer: - return make_response("Unknown slicer {slicer}".format(**locals()), 404) + abort(404) except CouldNotDeleteProfile as e: - return make_response( - "Could not delete profile {profile} for slicer {slicer}: {cause}".format( - profile=name, slicer=slicer, cause=str(e.cause) - ), + abort( 500, + description="Could not delete profile for slicer: {cause}".format( + cause=str(e.cause) + ), ) return NO_CONTENT diff --git a/src/octoprint/server/api/system.py b/src/octoprint/server/api/system.py index b31a58ae0..bbe5576d0 100644 --- a/src/octoprint/server/api/system.py +++ b/src/octoprint/server/api/system.py @@ -7,7 +7,7 @@ import threading import psutil import sarge -from flask import jsonify, make_response, request, url_for +from flask import abort, jsonify, request, url_for from flask_babel import gettext from octoprint.access.permissions import Permissions @@ -84,7 +84,7 @@ def performSystemAction(): data = request.values if "action" not in data: - return make_response("action to perform is not defined", 400) + abort(400, description="action is missing") return executeSystemCommand("custom", data["action"]) @@ -108,7 +108,7 @@ def retrieveSystemCommandsForSource(source): elif source == "custom": specs = _get_custom_command_specs() else: - return make_response("Unknown system command source: {}".format(source), 404) + abort(404) return jsonify(_to_client_specs(specs)) @@ -120,18 +120,15 @@ def executeSystemCommand(source, command): logger = logging.getLogger(__name__) if command == "divider": - return make_response("Dividers cannot be executed", 400) + abort(400, description="Dividers cannot be executed") command_spec = _get_command_spec(source, command) if not command_spec: - return make_response("Command {}:{} not found".format(source, command), 404) + abort(404) if "command" not in command_spec: - return make_response( - "Command {}:{} does not define a command to execute, can't proceed".format( - source, command - ), - 500, + abort( + 500, description="Command does not define a command to execute, can't proceed" ) do_async = command_spec.get("async", False) @@ -145,16 +142,16 @@ def executeSystemCommand(source, command): ) ) else: - logger.info("Performing command for {}:{}".format(source, command)) + logger.info(f"Performing command for {source}:{command}") try: if "before" in command_spec and callable(command_spec["before"]): command_spec["before"]() except Exception as e: if not do_ignore: - error = 'Command "before" for {}:{} failed: {}'.format(source, command, e) + error = f'Command "before" for {source}:{command} failed: {e}' logger.warning(error) - return make_response(error, 500) + abort(500, description=error) try: @@ -191,13 +188,13 @@ def executeSystemCommand(source, command): try: execute() except CommandFailed as exc: - return make_response(exc.error, 500) + abort(500, exc.error) except Exception as e: if not do_ignore: - error = "Command for {}:{} failed: {}".format(source, command, e) + error = f"Command for {source}:{command} failed: {e}" logger.warning(error) - return make_response(error, 500) + abort(500, error) return NO_CONTENT @@ -300,7 +297,7 @@ def _get_custom_command_specs(): action = spec["action"] if action == "divider": dividers += 1 - action = "divider_{}".format(dividers) + action = f"divider_{dividers}" specs[action] = copied return specs diff --git a/src/octoprint/server/api/timelapse.py b/src/octoprint/server/api/timelapse.py index 7cb21e4ba..6440eaa84 100644 --- a/src/octoprint/server/api/timelapse.py +++ b/src/octoprint/server/api/timelapse.py @@ -6,7 +6,7 @@ import logging import os import threading -from flask import jsonify, make_response, request, url_for +from flask import abort, jsonify, request, url_for import octoprint.timelapse import octoprint.util as util @@ -177,9 +177,9 @@ def deleteTimelapse(filename): os.remove(full_path) except Exception as ex: logging.getLogger(__file__).exception( - "Error deleting timelapse file {}".format(full_path) + f"Error deleting timelapse file {full_path}" ) - return make_response("Unexpected error: {}".format(ex), 500) + abort(500, description=f"Unexpected error: {ex}") return getTimelapseData() @@ -205,8 +205,8 @@ def processUnrenderedTimelapseCommand(name): if command == "render": if printer.is_printing() or printer.is_paused(): - return make_response( - "Printer is currently printing, cannot render timelapse", 409 + abort( + 409, description="Printer is currently printing, cannot render timelapse" ) octoprint.timelapse.render_unrendered_timelapse(name) @@ -228,68 +228,56 @@ def setTimelapseConfig(): try: postRoll = int(data["postRoll"]) except ValueError: - return make_response( - "Invalid value for postRoll: %r" % data["postRoll"], 400 - ) + abort(400, description="postRoll is invalid") else: if postRoll >= 0: config["postRoll"] = postRoll else: - return make_response("Invalid value for postRoll: %d" % postRoll, 400) + abort(400, description="postRoll is invalid") if "fps" in data: try: fps = int(data["fps"]) except ValueError: - return make_response("Invalid value for fps: %r" % data["fps"], 400) + abort(400, description="fps is invalid") else: if fps > 0: config["fps"] = fps else: - return make_response("Invalid value for fps: %d" % fps, 400) + abort(400, description="fps is invalid") if "interval" in data: try: interval = int(data["interval"]) except ValueError: - return make_response( - "Invalid value for interval: %r" % data["interval"], 400 - ) + abort(400, description="interval is invalid") else: if interval > 0: config["options"]["interval"] = interval else: - return make_response("Invalid value for interval: %d" % interval, 400) + abort(400, description="interval is invalid") if "retractionZHop" in data: try: retractionZHop = float(data["retractionZHop"]) except ValueError: - return make_response( - "Invalid value for retraction Z-Hop: %r" % data["retractionZHop"], 400 - ) + abort(400, description="retractionZHop is invalid") else: if retractionZHop >= 0: config["options"]["retractionZHop"] = retractionZHop else: - return make_response( - "Invalid value for retraction Z-Hop: %f" % retractionZHop, 400 - ) + abort(400, description="retractionZHop is invalid") if "minDelay" in data: try: minDelay = float(data["minDelay"]) except ValueError: - return make_response( - "Invalid value for minimum delay: %r" % data["minDelay"], 400 - ) + abort(400, description="minDelay is invalid") else: if minDelay > 0: config["options"]["minDelay"] = minDelay else: - return make_response( - "Invalid value for minimum delay: %f" % minDelay, 400 - ) + abort(400, description="minDelay is invalid") if ( admin_permission.can() diff --git a/src/octoprint/server/util/__init__.py b/src/octoprint/server/util/__init__.py index b7bc9537e..68b6f0812 100644 --- a/src/octoprint/server/util/__init__.py +++ b/src/octoprint/server/util/__init__.py @@ -44,7 +44,7 @@ def loginFromApiKeyRequestHandler(): if loginUserFromApiKey(): _flask.g.login_via_apikey = True except InvalidApiKeyException: - return _flask.make_response("Invalid API key", 403) + _flask.abort(403) def loginFromAuthorizationHeaderRequestHandler(): @@ -55,7 +55,7 @@ def loginFromAuthorizationHeaderRequestHandler(): if loginUserFromAuthorizationHeader(): _flask.g.login_via_header = True except InvalidApiKeyException: - return _flask.make_response("Invalid API key", 403) + _flask.abort(403) class InvalidApiKeyException(Exception): @@ -117,7 +117,7 @@ def requireLoginRequestHandler(): user = flask_login.current_user if user is None or user.is_anonymous or not user.is_active: - return flask.make_response("Forbidden", 403) + _flask.abort(403) def corsRequestHandler(): @@ -318,7 +318,7 @@ def get_authorization_header(request): def get_plugin_hash(): from octoprint.plugin import plugin_manager - plugin_signature = lambda impl: "{}:{}".format(impl._identifier, impl._plugin_version) + plugin_signature = lambda impl: f"{impl._identifier}:{impl._plugin_version}" template_plugins = list( map( plugin_signature, diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index a7ee5e98f..6e0b66aad 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -5,7 +5,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" import functools -import io import logging import os import threading @@ -151,9 +150,7 @@ def enable_additional_translations(default_locale="en", additional_folders=None) ) break else: - logger.debug( - "No translations for locale {} in core folders".format(locale) - ) + logger.debug(f"No translations for locale {locale} in core folders") translations = translations.merge(core_translations) ctx.babel_translations = translations @@ -215,7 +212,7 @@ def fix_webassets_cache(): filename = os.path.join(self.directory, "%s" % hash) try: - f = io.open(filename, "rb") + f = open(filename, "rb") except OSError as e: if e.errno != errno.ENOENT: error_logger.exception( @@ -615,7 +612,7 @@ def _local_networks(): continue local_networks.add(network) - logger.debug("Added network {} to localNetworks".format(network)) + logger.debug(f"Added network {network} to localNetworks") if network.version == 4: network_v6 = network.ipv6() @@ -664,9 +661,7 @@ def passive_login(): def determine_user(u): if not u.is_anonymous and u.is_active: # known active user - logger.info( - "Passively logging in user {} from {}".format(u.get_id(), remote_address) - ) + logger.info(f"Passively logging in user {u.get_id()} from {remote_address}") elif ( settings().getBoolean(["accessControl", "autologinLocal"]) @@ -998,9 +993,7 @@ class PreemptiveCache: entries = cleanup_function(root, entries) if not entries: del all_data[root] - self._logger.debug( - "Removed root {} from preemptive cache".format(root) - ) + self._logger.debug(f"Removed root {root} from preemptive cache") elif len(entries) < old_count: all_data[root] = entries self._logger.debug( @@ -1018,7 +1011,7 @@ class PreemptiveCache: cache_data = None with self._lock: try: - with io.open(self.cachefile, "rt") as f: + with open(self.cachefile) as f: cache_data = yaml.safe_load(f) except OSError as e: import errno @@ -1026,7 +1019,7 @@ class PreemptiveCache: if e.errno != errno.ENOENT: raise except Exception: - self._logger.exception("Error while reading {}".format(self.cachefile)) + self._logger.exception(f"Error while reading {self.cachefile}") if cache_data is None: cache_data = {} @@ -1057,7 +1050,7 @@ class PreemptiveCache: allow_unicode=True, ) except Exception: - self._logger.exception("Error while writing {}".format(self.cachefile)) + self._logger.exception(f"Error while writing {self.cachefile}") def set_data(self, root, data): with self._lock: @@ -1106,12 +1099,12 @@ class PreemptiveCache: to_persist = copy.deepcopy(data) to_persist["_timestamp"] = time.time() to_persist["_count"] = 1 - self._logger.info("Adding entry for {} and {!r}".format(root, to_persist)) + self._logger.info(f"Adding entry for {root} and {to_persist!r}") else: to_persist["_timestamp"] = time.time() to_persist["_count"] = to_persist.get("_count", 0) + 1 self._logger.debug( - "Updating timestamp and counter for {} and {!r}".format(root, data) + f"Updating timestamp and counter for {root} and {data!r}" ) self.set_data(root, [to_persist] + other) @@ -1150,7 +1143,7 @@ def preemptively_cached(cache, data, unless=None): cache.record(data, unless=unless) except Exception: logging.getLogger(__name__).exception( - "Error while recording preemptive cache entry: {!r}".format(data) + f"Error while recording preemptive cache entry: {data!r}" ) return f(*args, **kwargs) @@ -1297,11 +1290,13 @@ def with_revalidation_checking( def decorator(f): @functools.wraps(f) def decorated_function(*args, **kwargs): + from octoprint.server import NOT_MODIFIED + lm = lastmodified_factory() etag = etag_factory(lm) if condition(lm, etag) and not unless(): - return make_response("Not Modified", 304) + return NOT_MODIFIED # generate response response = f(*args, **kwargs) @@ -1539,7 +1534,7 @@ def no_firstrun_access(func): octoprint.server.userManager is None or not octoprint.server.userManager.has_been_customized() ): - return flask.make_response("OctoPrint isn't setup yet", 403) + flask.abort(403) return func(*args, **kwargs) return decorated_view @@ -1561,9 +1556,7 @@ def firstrun_only_access(func): ): return func(*args, **kwargs) else: - return flask.make_response( - "OctoPrint is already setup, this resource is not longer available.", 403 - ) + flask.abort(403) return decorated_view @@ -1578,34 +1571,56 @@ def get_remote_address(request): def get_json_command_from_request(request, valid_commands): content_type = request.headers.get("Content-Type", None) if content_type is None or "application/json" not in content_type: - return None, None, make_response("Expected content-type JSON", 400) + flask.abort(400, description="Expected content-type JSON") data = request.get_json() if data is None: - return ( - None, - None, - make_response("Malformed JSON body or wrong content-type in request", 400), + flask.abort( + 400, description="Malformed JSON body or wrong content-type in request" ) if "command" not in data or data["command"] not in valid_commands: - return None, None, make_response("Expected valid command", 400) + flask.abort(400, description="command is invalid") command = data["command"] - for parameter in valid_commands[command]: - if parameter not in data: - return ( - None, - None, - make_response( - "Mandatory parameter %s missing for command %s" - % (parameter, command), - 400, - ), - ) + if any(map(lambda x: x not in data, valid_commands[command])): + flask.abort(400, description="Mandatory parameters missing") return command, data, None +def make_text_response(message, status): + """ + Helper to generate basic text responses. + + Response will have the provided message as body, the provided status code, and + a content type of "text/plain". + + Args: + message: The message in the response body + status: The HTTP status code + + Returns: + + """ + return make_response(message, status, {"Content-Type": "text/plain"}) + + +def make_api_error(message, status): + """ + Helper to generate API error responses in JSON format. + + Turns something like ``make_api_error("Not Found", 404)`` into a JSON response + with body ``{"error": "Not Found"}``. + + Args: + message: The error message to put into the response + status: The HTTP status code + + Returns: a flask response to return to the client + """ + return make_response(flask.jsonify(error=message), status) + + ##~~ Flask-Assets resolver with plugin asset support diff --git a/src/octoprint/server/util/sockjs.py b/src/octoprint/server/util/sockjs.py index 845810db6..ac6b33b9a 100644 --- a/src/octoprint/server/util/sockjs.py +++ b/src/octoprint/server/util/sockjs.py @@ -173,9 +173,9 @@ class PrinterStateConnection( def __str__(self): if self._remoteAddress: - return "{!r} connected to {}".format(self, self._remoteAddress) + return f"{self!r} connected to {self._remoteAddress}" else: - return "Unconnected {!r}".format(self) + return f"Unconnected {self!r}" def on_open(self, info): self._pluginManager.register_message_receiver(self.on_plugin_message) @@ -279,7 +279,7 @@ class PrinterStateConnection( self._on_login(user) else: self._logger.warning( - "Unknown user/session combo: {}:{}".format(user_id, user_session) + f"Unknown user/session combo: {user_id}:{user_session}" ) self._on_logout() @@ -437,9 +437,7 @@ class PrinterStateConnection( and hasattr(self._user, "session") and user.session == self._user.session ): - self._logger.info( - "User {} logged out, logging out on socket".format(user.get_id()) - ) + self._logger.info(f"User {user.get_id()} logged out, logging out on socket") self._on_logout() if stale: @@ -453,7 +451,7 @@ class PrinterStateConnection( def on_user_removed(self, userid): if self._user.get_id() == userid: - self._logger.info("User {} deleted, logging out on socket".format(userid)) + self._logger.info(f"User {userid} deleted, logging out on socket") self._on_logout() self._sendReauthRequired("removed") @@ -477,7 +475,7 @@ class PrinterStateConnection( proceed = proceed and hook(self, self._user) except Exception: self._logger.exception( - "Error processing register hook handler for plugin {}".format(name), + f"Error processing register hook handler for plugin {name}", extra={"plugin": name}, ) @@ -542,7 +540,7 @@ class PrinterStateConnection( proceed = proceed and hook(self, self._user, type, payload) except Exception: self._logger.exception( - "Error processing emit hook handler from plugin {}".format(name), + f"Error processing emit hook handler from plugin {name}", extra={"plugin": name}, ) @@ -585,7 +583,7 @@ class PrinterStateConnection( except Exception as e: if self._logger.isEnabledFor(logging.DEBUG): self._logger.exception( - "Could not send message to client {}".format(self._remoteAddress) + f"Could not send message to client {self._remoteAddress}" ) else: self._logger.warning( @@ -608,7 +606,7 @@ class PrinterStateConnection( hook(self, self._user) except Exception: self._logger.exception( - "Error processing authed hook handler for plugin {}".format(name), + f"Error processing authed hook handler for plugin {name}", extra={"plugin": name}, ) @@ -641,6 +639,6 @@ class PrinterStateConnection( hook(self, self._user) except Exception: self._logger.exception( - "Error processing authed hook handler for plugin {}".format(name), + f"Error processing authed hook handler for plugin {name}", extra={"plugin": name}, ) diff --git a/src/octoprint/server/util/tornado.py b/src/octoprint/server/util/tornado.py index 2c3c686e0..32ff80e25 100644 --- a/src/octoprint/server/util/tornado.py +++ b/src/octoprint/server/util/tornado.py @@ -1181,9 +1181,13 @@ class LargeResponseHandler( def compute_etag(self): if self._etag_generator is not None: - return self._etag_generator(self) + etag = self._etag_generator(self) else: - return self.get_content_version(self.absolute_path) + etag = str(self.get_content_version(self.absolute_path)) + + if not etag.endswith('"'): + etag = f'"{etag}"' + return etag # noinspection PyAttributeOutsideInit def get_content_type(self): @@ -1326,7 +1330,7 @@ class UrlProxyHandler( if not extension: return None - return "%s%s" % (self._basename, extension) + return f"{self._basename}{extension}" class StaticDataHandler( @@ -1369,7 +1373,7 @@ class DeprecatedEndpointHandler(CorsSupportMixin, tornado.web.RequestHandler): def _handle_method(self, *args, **kwargs): to_url = self._url.format(*args) self._logger.info( - "Redirecting deprecated endpoint {} to {}".format(self.request.path, to_url) + f"Redirecting deprecated endpoint {self.request.path} to {to_url}" ) self.redirect(to_url, permanent=True) @@ -1427,7 +1431,7 @@ class StaticZipBundleHandler(CorsSupportMixin, tornado.web.RequestHandler): if self._as_attachment: self.set_header( "Content-Disposition", - 'attachment; filename="{}"'.format(self.get_attachment_name()), + f'attachment; filename="{self.get_attachment_name()}"', ) import zipstream @@ -1572,7 +1576,7 @@ class SystemInfoBundleHandler(CorsSupportMixin, tornado.web.RequestHandler): self.set_header("Content-Type", "application/zip") self.set_header( "Content-Disposition", - 'attachment; filename="{}"'.format(get_systeminfo_bundle_name()), + f'attachment; filename="{get_systeminfo_bundle_name()}"', ) for chunk in z: diff --git a/src/octoprint/server/util/watchdog.py b/src/octoprint/server/util/watchdog.py index 3d0aa85dc..f060685e0 100644 --- a/src/octoprint/server/util/watchdog.py +++ b/src/octoprint/server/util/watchdog.py @@ -57,7 +57,7 @@ class GcodeWatchdogHandler(watchdog.events.PatternMatchingEventHandler): if not self._valid_path(path): continue - self._logger.info("Found {}, trying to add it".format(path)) + self._logger.info(f"Found {path}, trying to add it") self._upload(path) self._logger.info("... initial scan done.") @@ -147,7 +147,7 @@ class GcodeWatchdogHandler(watchdog.events.PatternMatchingEventHandler): # file is still there - that should only happen if something went wrong, so mark it as failed # noinspection PyBroadException try: - shutil.move(path, "{}.failed".format(path)) + shutil.move(path, f"{path}.failed") except Exception: # something went really wrong here.... but we can't do anything about it, so just log it self._logger.exception( @@ -190,7 +190,7 @@ class GcodeWatchdogHandler(watchdog.events.PatternMatchingEventHandler): last_size = new_size time.sleep(interval) - self._logger.debug("File at {} is stable, moving it".format(path)) + self._logger.debug(f"File at {path} is stable, moving it") self._upload(path) def _valid_path(self, path): diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index 3ef17873e..56128e40f 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -4,7 +4,6 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms import base64 import datetime -import io import logging import os import re @@ -104,7 +103,7 @@ def _preemptive_data( d.update(data) except Exception: _logger.exception( - "Error collecting data for preemptive cache from plugin {}".format(key) + f"Error collecting data for preemptive cache from plugin {key}" ) # add additional request data if we have any @@ -129,7 +128,7 @@ def _cache_key(ui, url=None, locale=None, additional_key_data=None): if locale is None: locale = g.locale.language if g.locale else "en" - k = "ui:{}:{}:{}".format(ui, url, locale) + k = f"ui:{ui}:{url}:{locale}" if callable(additional_key_data): try: ak = additional_key_data() @@ -160,7 +159,7 @@ def _add_additional_assets(hook): result += assets except Exception: _logger.exception( - "Error fetching theming CSS to include from plugin {}".format(name), + f"Error fetching theming CSS to include from plugin {name}", extra={"plugin": name}, ) return result @@ -273,7 +272,7 @@ def in_cache(): break except Exception: _logger.exception( - "Error while calling plugin {}, skipping it".format(plugin._identifier), + f"Error while calling plugin {plugin._identifier}, skipping it", extra={"plugin": plugin._identifier}, ) else: @@ -297,9 +296,7 @@ def in_cache(): ) return response elif util.flask.is_in_cache(key): - _logger.info( - "Found path {} in cache (key: {}), signaling as cached".format(path, key) - ) + _logger.info(f"Found path {path} in cache (key: {key}), signaling as cached") return response elif util.flask.is_cache_bypassed(key): _logger.info( @@ -309,9 +306,7 @@ def in_cache(): ) return response else: - _logger.debug( - "Path {} not yet cached (key: {}), signaling as missing".format(path, key) - ) + _logger.debug(f"Path {path} not yet cached (key: {key}), signaling as missing") return abort(404) @@ -619,7 +614,7 @@ def index(): if forced_view: # we have view forced by the preemptive cache - _logger.debug("Forcing rendering of view {}".format(forced_view)) + _logger.debug(f"Forcing rendering of view {forced_view}") if forced_view != "_default": plugin = pluginManager.get_plugin_info(forced_view, require_enabled=True) if plugin is not None and isinstance( @@ -706,7 +701,7 @@ def _get_render_kwargs(templates, plugin_names, plugin_vars, now): permissions = [permission.as_dict() for permission in Permissions.all()] filetypes = list(sorted(full_extension_tree().keys())) - extensions = list(map(lambda ext: ".{}".format(ext), get_all_extensions())) + extensions = list(map(lambda ext: f".{ext}", get_all_extensions())) # ~~ prepare full set of template vars for rendering @@ -1684,7 +1679,7 @@ def _get_translations(locale, domain): def messages_from_po(path, locale, domain): messages = {} - with io.open(path, mode="rt", encoding="utf-8") as f: + with open(path, mode="rt", encoding="utf-8") as f: catalog = read_po(f, locale=locale, domain=domain) for message in catalog: diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 62799dbc9..a8f4e9aff 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -22,7 +22,6 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms import copy import fnmatch -import io import logging import os import re @@ -257,6 +256,7 @@ default_settings = { "throttle_highprio": 0.0, "throttle_lines": 100, "runAt": "idle", # 'never', 'idle', 'always' + "bedZ": 0.0, }, "feature": { "temperatureGraph": True, @@ -410,7 +410,7 @@ default_settings = { "terminalFilters": [ { "name": "Suppress temperature messages", - "regex": r"(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+((P|B|N)\d+\s+)*)?(B|T\d*):\d+)", + "regex": r"(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+([PBN]\d+\s+)*)?([BCLPR]|T\d*):-?\d+)", }, { "name": "Suppress SD status messages", @@ -988,7 +988,7 @@ class Settings: def load(self, migrate=False): if os.path.exists(self._configfile) and os.path.isfile(self._configfile): - with io.open(self._configfile, "rt", encoding="utf-8", errors="replace") as f: + with open(self._configfile, encoding="utf-8", errors="replace") as f: try: self._config = yaml.safe_load(f) self._mtime = self.last_modified @@ -1029,11 +1029,9 @@ class Settings: try: overlay_config = self.load_overlay(path, migrate=migrate) self.add_overlay(overlay_config) - self._logger.info("Added config overlay from {}".format(path)) + self._logger.info(f"Added config overlay from {path}") except Exception: - self._logger.exception( - "Could not add config overlay from {}".format(path) - ) + self._logger.exception(f"Could not add config overlay from {path}") if os.path.isfile(overlay): process(overlay) @@ -1060,7 +1058,7 @@ class Settings: if isinstance(overlay, str): if os.path.exists(overlay) and os.path.isfile(overlay): - with io.open(overlay, "rt", encoding="utf-8", errors="replace") as f: + with open(overlay, encoding="utf-8", errors="replace") as f: config = yaml.safe_load(f) elif isinstance(overlay, dict): config = overlay @@ -1071,7 +1069,7 @@ class Settings: if not isinstance(config, dict): raise ValueError( - "Configuration data must be a dict but is a {}".format(config.__class__) + f"Configuration data must be a dict but is a {config.__class__}" ) if migrate: @@ -2393,7 +2391,7 @@ class Settings: preprocessors=None, error_on_path=False, *args, - **kwargs + **kwargs, ): if not path: if error_on_path: @@ -2665,7 +2663,7 @@ class SubSettings: if item in self.deprecated_access_methods: new = self.deprecated_access_methods[item] decorator = deprecated( - "{old} has been renamed to {new}".format(old=item, new=new), + f"{item} has been renamed to {new}", stacklevel=2, ) item = new @@ -2725,7 +2723,7 @@ def _validate_folder( if not os.path.exists(folder): if os.path.islink(folder): # broken symlink, see #2644 - raise OSError("Folder at {} appears to be a broken symlink".format(folder)) + raise OSError(f"Folder at {folder} appears to be a broken symlink") elif create: # non existing, but we are allowed to create it @@ -2733,7 +2731,7 @@ def _validate_folder( os.makedirs(folder) except Exception: if log_error: - logger.exception("Could not create {}".format(folder)) + logger.exception(f"Could not create {folder}") raise OSError( "Folder for type {} at {} does not exist and creation failed".format( type, folder @@ -2742,11 +2740,11 @@ def _validate_folder( else: # not extisting, not allowed to create it - raise OSError("No such folder: {}".format(folder)) + raise OSError(f"No such folder: {folder}") elif os.path.isfile(folder): # hardening against misconfiguration, see #1953 - raise OSError("Expected a folder at {} but found a file instead".format(folder)) + raise OSError(f"Expected a folder at {folder} but found a file instead") elif check_writable: # make sure we can also write into the folder @@ -2761,10 +2759,10 @@ def _validate_folder( # to determine whether things are *actually* writable testfile = os.path.join(folder, ".testballoon.txt") try: - with io.open(testfile, "wt", encoding="utf-8") as f: + with open(testfile, "wt", encoding="utf-8") as f: f.write("test") os.remove(testfile) except Exception: if log_error: - logger.exception("Could not write test file to {}".format(folder)) + logger.exception(f"Could not write test file to {folder}") raise OSError(error) diff --git a/src/octoprint/slicing/__init__.py b/src/octoprint/slicing/__init__.py index c22f74b7a..a005ff8fb 100644 --- a/src/octoprint/slicing/__init__.py +++ b/src/octoprint/slicing/__init__.py @@ -724,9 +724,7 @@ class SlicingManager: name = self._sanitize(name) - path = os.path.join( - self.get_slicer_profile_path(slicer), "{name}.profile".format(name=name) - ) + path = os.path.join(self.get_slicer_profile_path(slicer), f"{name}.profile") if not os.path.realpath(path).startswith(os.path.realpath(self._profile_path)): raise OSError( "Path to profile {name} tried to break out of allows sub path".format( diff --git a/src/octoprint/slicing/exceptions.py b/src/octoprint/slicing/exceptions.py index 7d0d68287..0036890bb 100644 --- a/src/octoprint/slicing/exceptions.py +++ b/src/octoprint/slicing/exceptions.py @@ -67,7 +67,7 @@ class SlicerNotConfigured(SlicerException): def __init__(self, slicer, *args, **kwargs): SlicerException.__init__(self, slicer, *args, **kwargs) - self.message = "Slicer not configured: {slicer}".format(slicer=slicer) + self.message = f"Slicer not configured: {slicer}" class UnknownSlicer(SlicerException): @@ -77,7 +77,7 @@ class UnknownSlicer(SlicerException): def __init__(self, slicer, *args, **kwargs): SlicerException.__init__(self, slicer, *args, **kwargs) - self.message = "No such slicer: {slicer}".format(slicer=slicer) + self.message = f"No such slicer: {slicer}" class ProfileException(Exception): diff --git a/src/octoprint/static/css/octoprint.css b/src/octoprint/static/css/octoprint.css index 70fc4e7ac..d92c920bc 100644 --- a/src/octoprint/static/css/octoprint.css +++ b/src/octoprint/static/css/octoprint.css @@ -1 +1 @@ -.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#bd362f;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-danger.active,.btn-danger.disabled,.btn-danger:active,.btn-danger:focus,.btn-danger:hover,.btn-danger[disabled]{color:#fff;background-color:#bd362f;*background-color:#a9302a}.btn-danger.active,.btn-danger:active{background-color:#942a25 \9}.btn-success{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#5bb75b;background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(to bottom,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#51a351;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-success.active,.btn-success.disabled,.btn-success:active,.btn-success:focus,.btn-success:hover,.btn-success[disabled]{color:#fff;background-color:#51a351;*background-color:#499249}.btn-success.active,.btn-success:active{background-color:#408140 \9}.btn-info{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#49afcd;background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(to bottom,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#2f96b4;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-info.active,.btn-info.disabled,.btn-info:active,.btn-info:focus,.btn-info:hover,.btn-info[disabled]{color:#fff;background-color:#2f96b4;*background-color:#2a85a0}.btn-info.active,.btn-info:active{background-color:#24748c \9}.btn-inverse{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#363636;background-image:-moz-linear-gradient(top,#444,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#444),to(#222));background-image:-webkit-linear-gradient(top,#444,#222);background-image:-o-linear-gradient(top,#444,#222);background-image:linear-gradient(to bottom,#444,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#222;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-inverse.active,.btn-inverse.disabled,.btn-inverse:active,.btn-inverse:focus,.btn-inverse:hover,.btn-inverse[disabled]{color:#fff;background-color:#222;*background-color:#151515}.btn-inverse.active,.btn-inverse:active{background-color:#080808 \9}button.btn,input[type=submit].btn{*padding-top:3px;*padding-bottom:3px}button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type=submit].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type=submit].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type=submit].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-link,.btn-link:active,.btn-link[disabled]{background-color:transparent;background-image:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-link{border-color:transparent;cursor:pointer;color:#08c;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-link:focus,.btn-link:hover{color:#005580;text-decoration:underline;background-color:transparent}.btn-link[disabled]:focus,.btn-link[disabled]:hover{color:#333;text-decoration:none}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.nowrap{white-space:nowrap}.actioncol{text-align:center;white-space:nowrap}.actioncol a{text-decoration:none;color:#000}.actioncol a.disabled{color:#ccc;cursor:default}#navbar .navbar-inner{background-color:#ebebeb;background-image:-moz-linear-gradient(top,#fff,#ccc);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#ccc));background-image:-webkit-linear-gradient(top,#fff,#ccc);background-image:-o-linear-gradient(top,#fff,#ccc);background-image:linear-gradient(to bottom,#fff,#ccc);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffcccccc', GradientType=0)}#navbar .navbar-inner .brand,#navbar .navbar-inner .nav>li>a{text-shadow:0 1px 0 #ccc;color:#333}#navbar .navbar-inner .brand .caret,#navbar .navbar-inner .nav>li>a .caret{border-bottom-color:#939393;border-top-color:#939393}#navbar .navbar-inner .brand:focus .caret,#navbar .navbar-inner .brand:hover .caret,#navbar .navbar-inner .nav>li>a:focus .caret,#navbar .navbar-inner .nav>li>a:hover .caret{border-bottom-color:#636363;border-top-color:#636363}#navbar .navbar-inner .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner .nav>li.dropdown.open>.dropdown-toggle{background-color:#e0e0e0;background-image:-moz-linear-gradient(top,#ccc,#fff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ccc),to(#fff));background-image:-webkit-linear-gradient(top,#ccc,#fff);background-image:-o-linear-gradient(top,#ccc,#fff);background-image:linear-gradient(to bottom,#ccc,#fff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffcccccc', endColorstr='#ffffffff', GradientType=0)}#navbar .navbar-inner .nav>li>a:hover{background-color:#dedede;background-image:-moz-linear-gradient(top,#f2f2f2,#bfbfbf);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#bfbfbf));background-image:-webkit-linear-gradient(top,#f2f2f2,#bfbfbf);background-image:-o-linear-gradient(top,#f2f2f2,#bfbfbf);background-image:linear-gradient(to bottom,#f2f2f2,#bfbfbf);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffbfbfbf', GradientType=0)}#navbar .navbar-inner.transparent{background-color:rgba(235,235,235,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(255,255,255,.6)),to(rgba(204,204,204,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99ffffff', endColorstr='#99cccccc', GradientType=0)}#navbar .navbar-inner.transparent .brand,#navbar .navbar-inner.transparent .nav>li>a{text-shadow:0 1px 0 #ccc;color:#333}#navbar .navbar-inner.transparent .brand .caret,#navbar .navbar-inner.transparent .nav>li>a .caret{border-bottom-color:#939393;border-top-color:#939393}#navbar .navbar-inner.transparent .brand:focus .caret,#navbar .navbar-inner.transparent .brand:hover .caret,#navbar .navbar-inner.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.transparent .nav>li>a:hover .caret{border-bottom-color:#636363;border-top-color:#636363}#navbar .navbar-inner.transparent .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.transparent .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(224,224,224,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(204,204,204,.6)),to(rgba(255,255,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99cccccc', endColorstr='#99ffffff', GradientType=0)}#navbar .navbar-inner.transparent .nav>li>a:hover{background-color:rgba(222,222,222,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(242,242,242,.6)),to(rgba(191,191,191,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f2f2f2', endColorstr='#99bfbfbf', GradientType=0)}#navbar .navbar-inner.red{background-color:#bb645f;background-image:-moz-linear-gradient(top,#e28e8a,#802420);background-image:-webkit-gradient(linear,0 0,0 100%,from(#e28e8a),to(#802420));background-image:-webkit-linear-gradient(top,#e28e8a,#802420);background-image:-o-linear-gradient(top,#e28e8a,#802420);background-image:linear-gradient(to bottom,#e28e8a,#802420);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe28e8a', endColorstr='#ff802420', GradientType=0)}#navbar .navbar-inner.red .brand,#navbar .navbar-inner.red .nav>li>a{text-shadow:0 1px 0 #d86761;color:#f2f2f2}#navbar .navbar-inner.red .brand .caret,#navbar .navbar-inner.red .nav>li>a .caret{border-bottom-color:#d89491;border-top-color:#d89491}#navbar .navbar-inner.red .brand:focus .caret,#navbar .navbar-inner.red .brand:hover .caret,#navbar .navbar-inner.red .nav>li>a:focus .caret,#navbar .navbar-inner.red .nav>li>a:hover .caret{border-bottom-color:#e5c3c1;border-top-color:#e5c3c1}#navbar .navbar-inner.red .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.red .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.red .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.red .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.red .nav>li.dropdown.open>.dropdown-toggle{background-color:#a74f4a;background-image:-moz-linear-gradient(top,#802420,#e28e8a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#802420),to(#e28e8a));background-image:-webkit-linear-gradient(top,#802420,#e28e8a);background-image:-o-linear-gradient(top,#802420,#e28e8a);background-image:linear-gradient(to bottom,#802420,#e28e8a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff802420', endColorstr='#ffe28e8a', GradientType=0)}#navbar .navbar-inner.red .nav>li>a:hover{background-color:#af5651;background-image:-moz-linear-gradient(top,#dd7a75,#6b1f1b);background-image:-webkit-gradient(linear,0 0,0 100%,from(#dd7a75),to(#6b1f1b));background-image:-webkit-linear-gradient(top,#dd7a75,#6b1f1b);background-image:-o-linear-gradient(top,#dd7a75,#6b1f1b);background-image:linear-gradient(to bottom,#dd7a75,#6b1f1b);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdd7a75', endColorstr='#ff6b1f1b', GradientType=0)}#navbar .navbar-inner.red.transparent{background-color:rgba(187,100,95,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(226,142,138,.6)),to(rgba(128,36,32,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99e28e8a', endColorstr='#99802420', GradientType=0)}#navbar .navbar-inner.red.transparent .brand,#navbar .navbar-inner.red.transparent .nav>li>a{text-shadow:0 1px 0 #d86761;color:#f2f2f2}#navbar .navbar-inner.red.transparent .brand .caret,#navbar .navbar-inner.red.transparent .nav>li>a .caret{border-bottom-color:#d89491;border-top-color:#d89491}#navbar .navbar-inner.red.transparent .brand:focus .caret,#navbar .navbar-inner.red.transparent .brand:hover .caret,#navbar .navbar-inner.red.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.red.transparent .nav>li>a:hover .caret{border-bottom-color:#e5c3c1;border-top-color:#e5c3c1}#navbar .navbar-inner.red.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.red.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.red.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.red.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.red.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(167,79,74,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(128,36,32,.6)),to(rgba(226,142,138,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99802420', endColorstr='#99e28e8a', GradientType=0)}#navbar .navbar-inner.red.transparent .nav>li>a:hover{background-color:rgba(175,86,81,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(221,122,117,.6)),to(rgba(107,31,27,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99dd7a75', endColorstr='#996b1f1b', GradientType=0)}#navbar .navbar-inner.orange{background-color:#e39665;background-image:-moz-linear-gradient(top,#f9c3a0,#c2530c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f9c3a0),to(#c2530c));background-image:-webkit-linear-gradient(top,#f9c3a0,#c2530c);background-image:-o-linear-gradient(top,#f9c3a0,#c2530c);background-image:linear-gradient(to bottom,#f9c3a0,#c2530c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9c3a0', endColorstr='#ffc2530c', GradientType=0)}#navbar .navbar-inner.orange .brand,#navbar .navbar-inner.orange .nav>li>a{text-shadow:0 1px 0 #f6a570;color:#f2f2f2}#navbar .navbar-inner.orange .brand .caret,#navbar .navbar-inner.orange .nav>li>a .caret{border-bottom-color:#f2b58d;border-top-color:#f2b58d}#navbar .navbar-inner.orange .brand:focus .caret,#navbar .navbar-inner.orange .brand:hover .caret,#navbar .navbar-inner.orange .nav>li>a:focus .caret,#navbar .navbar-inner.orange .nav>li>a:hover .caret{border-bottom-color:#f2d3bf;border-top-color:#f2d3bf}#navbar .navbar-inner.orange .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.orange .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.orange .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.orange .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.orange .nav>li.dropdown.open>.dropdown-toggle{background-color:#d88047;background-image:-moz-linear-gradient(top,#c2530c,#f9c3a0);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c2530c),to(#f9c3a0));background-image:-webkit-linear-gradient(top,#c2530c,#f9c3a0);background-image:-o-linear-gradient(top,#c2530c,#f9c3a0);background-image:linear-gradient(to bottom,#c2530c,#f9c3a0);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc2530c', endColorstr='#fff9c3a0', GradientType=0)}#navbar .navbar-inner.orange .nav>li>a:hover{background-color:#d98956;background-image:-moz-linear-gradient(top,#f8b488,#aa490a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f8b488),to(#aa490a));background-image:-webkit-linear-gradient(top,#f8b488,#aa490a);background-image:-o-linear-gradient(top,#f8b488,#aa490a);background-image:linear-gradient(to bottom,#f8b488,#aa490a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8b488', endColorstr='#ffaa490a', GradientType=0)}#navbar .navbar-inner.orange.transparent{background-color:rgba(227,150,101,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(249,195,160,.6)),to(rgba(194,83,12,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f9c3a0', endColorstr='#99c2530c', GradientType=0)}#navbar .navbar-inner.orange.transparent .brand,#navbar .navbar-inner.orange.transparent .nav>li>a{text-shadow:0 1px 0 #f6a570;color:#f2f2f2}#navbar .navbar-inner.orange.transparent .brand .caret,#navbar .navbar-inner.orange.transparent .nav>li>a .caret{border-bottom-color:#f2b58d;border-top-color:#f2b58d}#navbar .navbar-inner.orange.transparent .brand:focus .caret,#navbar .navbar-inner.orange.transparent .brand:hover .caret,#navbar .navbar-inner.orange.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.orange.transparent .nav>li>a:hover .caret{border-bottom-color:#f2d3bf;border-top-color:#f2d3bf}#navbar .navbar-inner.orange.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.orange.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.orange.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.orange.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.orange.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(216,128,71,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(194,83,12,.6)),to(rgba(249,195,160,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c2530c', endColorstr='#99f9c3a0', GradientType=0)}#navbar .navbar-inner.orange.transparent .nav>li>a:hover{background-color:rgba(217,137,86,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(248,180,136,.6)),to(rgba(170,73,10,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f8b488', endColorstr='#99aa490a', GradientType=0)}#navbar .navbar-inner.yellow{background-color:#e3d765;background-image:-moz-linear-gradient(top,#f9f0a0,#c2b00c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f9f0a0),to(#c2b00c));background-image:-webkit-linear-gradient(top,#f9f0a0,#c2b00c);background-image:-o-linear-gradient(top,#f9f0a0,#c2b00c);background-image:linear-gradient(to bottom,#f9f0a0,#c2b00c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f0a0', endColorstr='#ffc2b00c', GradientType=0)}#navbar .navbar-inner.yellow .brand,#navbar .navbar-inner.yellow .nav>li>a{text-shadow:0 1px 0 #c2b00c;color:#f2f2f2}#navbar .navbar-inner.yellow .brand .caret,#navbar .navbar-inner.yellow .nav>li>a .caret{border-bottom-color:#f2e88d;border-top-color:#f2e88d}#navbar .navbar-inner.yellow .brand:focus .caret,#navbar .navbar-inner.yellow .brand:hover .caret,#navbar .navbar-inner.yellow .nav>li>a:focus .caret,#navbar .navbar-inner.yellow .nav>li>a:hover .caret{border-bottom-color:#f2edbf;border-top-color:#f2edbf}#navbar .navbar-inner.yellow .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.yellow .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.yellow .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.yellow .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.yellow .nav>li.dropdown.open>.dropdown-toggle{background-color:#d8ca47;background-image:-moz-linear-gradient(top,#c2b00c,#f9f0a0);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c2b00c),to(#f9f0a0));background-image:-webkit-linear-gradient(top,#c2b00c,#f9f0a0);background-image:-o-linear-gradient(top,#c2b00c,#f9f0a0);background-image:linear-gradient(to bottom,#c2b00c,#f9f0a0);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc2b00c', endColorstr='#fff9f0a0', GradientType=0)}#navbar .navbar-inner.yellow .nav>li>a:hover{background-color:#d9cc56;background-image:-moz-linear-gradient(top,#f8ed88,#aa9a0a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f8ed88),to(#aa9a0a));background-image:-webkit-linear-gradient(top,#f8ed88,#aa9a0a);background-image:-o-linear-gradient(top,#f8ed88,#aa9a0a);background-image:linear-gradient(to bottom,#f8ed88,#aa9a0a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8ed88', endColorstr='#ffaa9a0a', GradientType=0)}#navbar .navbar-inner.yellow.transparent{background-color:rgba(227,215,101,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(249,240,160,.6)),to(rgba(194,176,12,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f9f0a0', endColorstr='#99c2b00c', GradientType=0)}#navbar .navbar-inner.yellow.transparent .brand,#navbar .navbar-inner.yellow.transparent .nav>li>a{text-shadow:0 1px 0 #c2b00c;color:#f2f2f2}#navbar .navbar-inner.yellow.transparent .brand .caret,#navbar .navbar-inner.yellow.transparent .nav>li>a .caret{border-bottom-color:#f2e88d;border-top-color:#f2e88d}#navbar .navbar-inner.yellow.transparent .brand:focus .caret,#navbar .navbar-inner.yellow.transparent .brand:hover .caret,#navbar .navbar-inner.yellow.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.yellow.transparent .nav>li>a:hover .caret{border-bottom-color:#f2edbf;border-top-color:#f2edbf}#navbar .navbar-inner.yellow.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.yellow.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.yellow.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.yellow.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.yellow.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(216,202,71,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(194,176,12,.6)),to(rgba(249,240,160,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c2b00c', endColorstr='#99f9f0a0', GradientType=0)}#navbar .navbar-inner.yellow.transparent .nav>li>a:hover{background-color:rgba(217,204,86,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(248,237,136,.6)),to(rgba(170,154,10,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f8ed88', endColorstr='#99aa9a0a', GradientType=0)}#navbar .navbar-inner.green{background-color:#98f064;background-image:-moz-linear-gradient(top,#c8ffa7,#50da00);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c8ffa7),to(#50da00));background-image:-webkit-linear-gradient(top,#c8ffa7,#50da00);background-image:-o-linear-gradient(top,#c8ffa7,#50da00);background-image:linear-gradient(to bottom,#c8ffa7,#50da00);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc8ffa7', endColorstr='#ff50da00', GradientType=0)}#navbar .navbar-inner.green .brand,#navbar .navbar-inner.green .nav>li>a{text-shadow:0 1px 0 #50da00;color:#333}#navbar .navbar-inner.green .brand .caret,#navbar .navbar-inner.green .nav>li>a .caret{border-bottom-color:#55992e;border-top-color:#55992e}#navbar .navbar-inner.green .brand:focus .caret,#navbar .navbar-inner.green .brand:hover .caret,#navbar .navbar-inner.green .nav>li>a:focus .caret,#navbar .navbar-inner.green .nav>li>a:hover .caret{border-bottom-color:#446630;border-top-color:#446630}#navbar .navbar-inner.green .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.green .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.green .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.green .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.green .nav>li.dropdown.open>.dropdown-toggle{background-color:#80e943;background-image:-moz-linear-gradient(top,#50da00,#c8ffa7);background-image:-webkit-gradient(linear,0 0,0 100%,from(#50da00),to(#c8ffa7));background-image:-webkit-linear-gradient(top,#50da00,#c8ffa7);background-image:-o-linear-gradient(top,#50da00,#c8ffa7);background-image:linear-gradient(to bottom,#50da00,#c8ffa7);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff50da00', endColorstr='#ffc8ffa7', GradientType=0)}#navbar .navbar-inner.green .nav>li>a:hover{background-color:#8ae655;background-image:-moz-linear-gradient(top,#b8ff8e,#47c100);background-image:-webkit-gradient(linear,0 0,0 100%,from(#b8ff8e),to(#47c100));background-image:-webkit-linear-gradient(top,#b8ff8e,#47c100);background-image:-o-linear-gradient(top,#b8ff8e,#47c100);background-image:linear-gradient(to bottom,#b8ff8e,#47c100);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffb8ff8e', endColorstr='#ff47c100', GradientType=0)}#navbar .navbar-inner.green.transparent{background-color:rgba(152,240,100,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(200,255,167,.6)),to(rgba(80,218,0,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c8ffa7', endColorstr='#9950da00', GradientType=0)}#navbar .navbar-inner.green.transparent .brand,#navbar .navbar-inner.green.transparent .nav>li>a{text-shadow:0 1px 0 #50da00;color:#333}#navbar .navbar-inner.green.transparent .brand .caret,#navbar .navbar-inner.green.transparent .nav>li>a .caret{border-bottom-color:#55992e;border-top-color:#55992e}#navbar .navbar-inner.green.transparent .brand:focus .caret,#navbar .navbar-inner.green.transparent .brand:hover .caret,#navbar .navbar-inner.green.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.green.transparent .nav>li>a:hover .caret{border-bottom-color:#446630;border-top-color:#446630}#navbar .navbar-inner.green.transparent .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.green.transparent .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.green.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.green.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.green.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(128,233,67,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(80,218,0,.6)),to(rgba(200,255,167,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#9950da00', endColorstr='#99c8ffa7', GradientType=0)}#navbar .navbar-inner.green.transparent .nav>li>a:hover{background-color:rgba(138,230,85,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(184,255,142,.6)),to(rgba(71,193,0,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99b8ff8e', endColorstr='#9947c100', GradientType=0)}#navbar .navbar-inner.blue{background-color:#2e63cc;background-image:-moz-linear-gradient(top,#4d88ff,#002b80);background-image:-webkit-gradient(linear,0 0,0 100%,from(#4d88ff),to(#002b80));background-image:-webkit-linear-gradient(top,#4d88ff,#002b80);background-image:-o-linear-gradient(top,#4d88ff,#002b80);background-image:linear-gradient(to bottom,#4d88ff,#002b80);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff4d88ff', endColorstr='#ff002b80', GradientType=0)}#navbar .navbar-inner.blue .brand,#navbar .navbar-inner.blue .nav>li>a{text-shadow:0 1px 0 #1a66ff;color:#f2f2f2}#navbar .navbar-inner.blue .brand .caret,#navbar .navbar-inner.blue .nav>li>a .caret{border-bottom-color:#799bdf;border-top-color:#799bdf}#navbar .navbar-inner.blue .brand:focus .caret,#navbar .navbar-inner.blue .brand:hover .caret,#navbar .navbar-inner.blue .nav>li>a:focus .caret,#navbar .navbar-inner.blue .nav>li>a:hover .caret{border-bottom-color:#b6c7e9;border-top-color:#b6c7e9}#navbar .navbar-inner.blue .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.blue .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.blue .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.blue .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.blue .nav>li.dropdown.open>.dropdown-toggle{background-color:#1f50b3;background-image:-moz-linear-gradient(top,#002b80,#4d88ff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#002b80),to(#4d88ff));background-image:-webkit-linear-gradient(top,#002b80,#4d88ff);background-image:-o-linear-gradient(top,#002b80,#4d88ff);background-image:linear-gradient(to bottom,#002b80,#4d88ff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff002b80', endColorstr='#ff4d88ff', GradientType=0)}#navbar .navbar-inner.blue .nav>li>a:hover{background-color:#1f55c2;background-image:-moz-linear-gradient(top,#37f,#026);background-image:-webkit-gradient(linear,0 0,0 100%,from(#37f),to(#026));background-image:-webkit-linear-gradient(top,#37f,#026);background-image:-o-linear-gradient(top,#37f,#026);background-image:linear-gradient(to bottom,#37f,#026);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3377ff', endColorstr='#ff002266', GradientType=0)}#navbar .navbar-inner.blue.transparent{background-color:rgba(46,99,204,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(77,136,255,.6)),to(rgba(0,43,128,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#994d88ff', endColorstr='#99002b80', GradientType=0)}#navbar .navbar-inner.blue.transparent .brand,#navbar .navbar-inner.blue.transparent .nav>li>a{text-shadow:0 1px 0 #1a66ff;color:#f2f2f2}#navbar .navbar-inner.blue.transparent .brand .caret,#navbar .navbar-inner.blue.transparent .nav>li>a .caret{border-bottom-color:#799bdf;border-top-color:#799bdf}#navbar .navbar-inner.blue.transparent .brand:focus .caret,#navbar .navbar-inner.blue.transparent .brand:hover .caret,#navbar .navbar-inner.blue.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.blue.transparent .nav>li>a:hover .caret{border-bottom-color:#b6c7e9;border-top-color:#b6c7e9}#navbar .navbar-inner.blue.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.blue.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.blue.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.blue.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.blue.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(31,80,179,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(0,43,128,.6)),to(rgba(77,136,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99002b80', endColorstr='#994d88ff', GradientType=0)}#navbar .navbar-inner.blue.transparent .nav>li>a:hover{background-color:rgba(31,85,194,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(51,119,255,.6)),to(rgba(0,34,102,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#993377ff', endColorstr='#99002266', GradientType=0)}#navbar .navbar-inner.violet{background-color:#9864f0;background-image:-moz-linear-gradient(top,#c8a7ff,#5000da);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c8a7ff),to(#5000da));background-image:-webkit-linear-gradient(top,#c8a7ff,#5000da);background-image:-o-linear-gradient(top,#c8a7ff,#5000da);background-image:linear-gradient(to bottom,#c8a7ff,#5000da);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc8a7ff', endColorstr='#ff5000da', GradientType=0)}#navbar .navbar-inner.violet .brand,#navbar .navbar-inner.violet .nav>li>a{text-shadow:0 1px 0 #a774ff;color:#f2f2f2}#navbar .navbar-inner.violet .brand .caret,#navbar .navbar-inner.violet .nav>li>a .caret{border-bottom-color:#b58df9;border-top-color:#b58df9}#navbar .navbar-inner.violet .brand:focus .caret,#navbar .navbar-inner.violet .brand:hover .caret,#navbar .navbar-inner.violet .nav>li>a:focus .caret,#navbar .navbar-inner.violet .nav>li>a:hover .caret{border-bottom-color:#d3bff5;border-top-color:#d3bff5}#navbar .navbar-inner.violet .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.violet .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.violet .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.violet .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.violet .nav>li.dropdown.open>.dropdown-toggle{background-color:#8043e9;background-image:-moz-linear-gradient(top,#5000da,#c8a7ff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5000da),to(#c8a7ff));background-image:-webkit-linear-gradient(top,#5000da,#c8a7ff);background-image:-o-linear-gradient(top,#5000da,#c8a7ff);background-image:linear-gradient(to bottom,#5000da,#c8a7ff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5000da', endColorstr='#ffc8a7ff', GradientType=0)}#navbar .navbar-inner.violet .nav>li>a:hover{background-color:#8a55e6;background-image:-moz-linear-gradient(top,#b88eff,#4700c1);background-image:-webkit-gradient(linear,0 0,0 100%,from(#b88eff),to(#4700c1));background-image:-webkit-linear-gradient(top,#b88eff,#4700c1);background-image:-o-linear-gradient(top,#b88eff,#4700c1);background-image:linear-gradient(to bottom,#b88eff,#4700c1);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffb88eff', endColorstr='#ff4700c1', GradientType=0)}#navbar .navbar-inner.violet.transparent{background-color:rgba(152,100,240,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(200,167,255,.6)),to(rgba(80,0,218,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c8a7ff', endColorstr='#995000da', GradientType=0)}#navbar .navbar-inner.violet.transparent .brand,#navbar .navbar-inner.violet.transparent .nav>li>a{text-shadow:0 1px 0 #a774ff;color:#f2f2f2}#navbar .navbar-inner.violet.transparent .brand .caret,#navbar .navbar-inner.violet.transparent .nav>li>a .caret{border-bottom-color:#b58df9;border-top-color:#b58df9}#navbar .navbar-inner.violet.transparent .brand:focus .caret,#navbar .navbar-inner.violet.transparent .brand:hover .caret,#navbar .navbar-inner.violet.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.violet.transparent .nav>li>a:hover .caret{border-bottom-color:#d3bff5;border-top-color:#d3bff5}#navbar .navbar-inner.violet.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.violet.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.violet.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.violet.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.violet.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(128,67,233,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(80,0,218,.6)),to(rgba(200,167,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#995000da', endColorstr='#99c8a7ff', GradientType=0)}#navbar .navbar-inner.violet.transparent .nav>li>a:hover{background-color:rgba(138,85,230,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(184,142,255,.6)),to(rgba(71,0,193,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99b88eff', endColorstr='#994700c1', GradientType=0)}#navbar .navbar-inner.black{background-color:#4f4f4f;background-image:-moz-linear-gradient(top,#787878,#121212);background-image:-webkit-gradient(linear,0 0,0 100%,from(#787878),to(#121212));background-image:-webkit-linear-gradient(top,#787878,#121212);background-image:-o-linear-gradient(top,#787878,#121212);background-image:linear-gradient(to bottom,#787878,#121212);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff787878', endColorstr='#ff121212', GradientType=0)}#navbar .navbar-inner.black .brand,#navbar .navbar-inner.black .nav>li>a{text-shadow:0 1px 0 #5e5e5e;color:#f2f2f2}#navbar .navbar-inner.black .brand .caret,#navbar .navbar-inner.black .nav>li>a .caret{border-bottom-color:#959595;border-top-color:#959595}#navbar .navbar-inner.black .brand:focus .caret,#navbar .navbar-inner.black .brand:hover .caret,#navbar .navbar-inner.black .nav>li>a:focus .caret,#navbar .navbar-inner.black .nav>li>a:hover .caret{border-bottom-color:#c4c4c4;border-top-color:#c4c4c4}#navbar .navbar-inner.black .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.black .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.black .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.black .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.black .nav>li.dropdown.open>.dropdown-toggle{background-color:#3b3b3b;background-image:-moz-linear-gradient(top,#121212,#787878);background-image:-webkit-gradient(linear,0 0,0 100%,from(#121212),to(#787878));background-image:-webkit-linear-gradient(top,#121212,#787878);background-image:-o-linear-gradient(top,#121212,#787878);background-image:linear-gradient(to bottom,#121212,#787878);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff121212', endColorstr='#ff787878', GradientType=0)}#navbar .navbar-inner.black .nav>li>a:hover{background-color:#424242;background-image:-moz-linear-gradient(top,#6b6b6b,#050505);background-image:-webkit-gradient(linear,0 0,0 100%,from(#6b6b6b),to(#050505));background-image:-webkit-linear-gradient(top,#6b6b6b,#050505);background-image:-o-linear-gradient(top,#6b6b6b,#050505);background-image:linear-gradient(to bottom,#6b6b6b,#050505);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff6b6b6b', endColorstr='#ff050505', GradientType=0)}#navbar .navbar-inner.black.transparent{background-color:rgba(79,79,79,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(120,120,120,.6)),to(rgba(18,18,18,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99787878', endColorstr='#99121212', GradientType=0)}#navbar .navbar-inner.black.transparent .brand,#navbar .navbar-inner.black.transparent .nav>li>a{text-shadow:0 1px 0 #5e5e5e;color:#f2f2f2}#navbar .navbar-inner.black.transparent .brand .caret,#navbar .navbar-inner.black.transparent .nav>li>a .caret{border-bottom-color:#959595;border-top-color:#959595}#navbar .navbar-inner.black.transparent .brand:focus .caret,#navbar .navbar-inner.black.transparent .brand:hover .caret,#navbar .navbar-inner.black.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.black.transparent .nav>li>a:hover .caret{border-bottom-color:#c4c4c4;border-top-color:#c4c4c4}#navbar .navbar-inner.black.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.black.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.black.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.black.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.black.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(59,59,59,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(18,18,18,.6)),to(rgba(120,120,120,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99121212', endColorstr='#99787878', GradientType=0)}#navbar .navbar-inner.black.transparent .nav>li>a:hover{background-color:rgba(66,66,66,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(107,107,107,.6)),to(rgba(5,5,5,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#996b6b6b', endColorstr='#99050505', GradientType=0)}#navbar .navbar-inner.white{background-color:#e9e9e9;background-image:-moz-linear-gradient(top,#fff,#c8c8c8);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#c8c8c8));background-image:-webkit-linear-gradient(top,#fff,#c8c8c8);background-image:-o-linear-gradient(top,#fff,#c8c8c8);background-image:linear-gradient(to bottom,#fff,#c8c8c8);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffc8c8c8', GradientType=0)}#navbar .navbar-inner.white .brand,#navbar .navbar-inner.white .nav>li>a{text-shadow:0 1px 0 #c8c8c8;color:#333}#navbar .navbar-inner.white .brand .caret,#navbar .navbar-inner.white .nav>li>a .caret{border-bottom-color:#919191;border-top-color:#919191}#navbar .navbar-inner.white .brand:focus .caret,#navbar .navbar-inner.white .brand:hover .caret,#navbar .navbar-inner.white .nav>li>a:focus .caret,#navbar .navbar-inner.white .nav>li>a:hover .caret{border-bottom-color:#626262;border-top-color:#626262}#navbar .navbar-inner.white .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.white .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.white .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.white .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.white .nav>li.dropdown.open>.dropdown-toggle{background-color:#dedede;background-image:-moz-linear-gradient(top,#c8c8c8,#fff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c8c8c8),to(#fff));background-image:-webkit-linear-gradient(top,#c8c8c8,#fff);background-image:-o-linear-gradient(top,#c8c8c8,#fff);background-image:linear-gradient(to bottom,#c8c8c8,#fff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc8c8c8', endColorstr='#ffffffff', GradientType=0)}#navbar .navbar-inner.white .nav>li>a:hover{background-color:#dcdcdc;background-image:-moz-linear-gradient(top,#f2f2f2,#bbb);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#bbb));background-image:-webkit-linear-gradient(top,#f2f2f2,#bbb);background-image:-o-linear-gradient(top,#f2f2f2,#bbb);background-image:linear-gradient(to bottom,#f2f2f2,#bbb);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffbbbbbb', GradientType=0)}#navbar .navbar-inner.white.transparent{background-color:rgba(233,233,233,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(255,255,255,.6)),to(rgba(200,200,200,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99ffffff', endColorstr='#99c8c8c8', GradientType=0)}#navbar .navbar-inner.white.transparent .brand,#navbar .navbar-inner.white.transparent .nav>li>a{text-shadow:0 1px 0 #c8c8c8;color:#333}#navbar .navbar-inner.white.transparent .brand .caret,#navbar .navbar-inner.white.transparent .nav>li>a .caret{border-bottom-color:#919191;border-top-color:#919191}#navbar .navbar-inner.white.transparent .brand:focus .caret,#navbar .navbar-inner.white.transparent .brand:hover .caret,#navbar .navbar-inner.white.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.white.transparent .nav>li>a:hover .caret{border-bottom-color:#626262;border-top-color:#626262}#navbar .navbar-inner.white.transparent .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.white.transparent .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.white.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.white.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.white.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(222,222,222,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(200,200,200,.6)),to(rgba(255,255,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c8c8c8', endColorstr='#99ffffff', GradientType=0)}#navbar .navbar-inner.white.transparent .nav>li>a:hover{background-color:rgba(220,220,220,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(242,242,242,.6)),to(rgba(187,187,187,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f2f2f2', endColorstr='#99bbbbbb', GradientType=0)}#navbar .navbar-inner .brand{padding:10px 20px 6px}#navbar .navbar-inner .brand span{padding-left:26px;background-size:20px 20px;background-repeat:no-repeat;display:inline-block;max-width:250px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:top;line-height:20px;height:24px}#navbar_login a.dropdown-toggle span{display:inline-block;max-width:100px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:top}.octoprint-container{margin-top:20px}.octoprint-container .tab-content{padding:9px 15px;border-left:1px solid #ddd;border-right:1px solid #ddd;border-bottom:1px solid #ddd;-webkit-border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px;border-bottom-right-radius:4px;-webkit-border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px;border-bottom-left-radius:4px}.octoprint-container .nav{margin-bottom:0}.octoprint-container .tab-content h1{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333;border:0;border-bottom:1px solid #e5e5e5;font-weight:400}.octoprint-container .accordion-heading .accordion-heading-button{float:right}.octoprint-container .accordion-heading .accordion-heading-button>a{display:inline-block;padding:8px 15px;font-size:14px;line-height:20px;color:#000;text-decoration:none;background:0 0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.octoprint-container .accordion-heading a.accordion-toggle{display:inline-block}.octoprint-container .accordion-heading [class*=" icon-"],.octoprint-container .accordion-heading [class^=icon-]{color:#000}.print-control .btn{padding-left:4px;padding-right:4px}.upload-buttons .btn{margin-right:0}table{table-layout:fixed}table .popover-title{text-overflow:ellipsis;word-break:break-all}table td,table th{overflow:hidden}table td.gcode_files_name,table th.gcode_files_name{text-overflow:ellipsis;text-align:left;white-space:nowrap}table td.gcode_files_action,table th.gcode_files_action{width:90px;text-align:center;white-space:nowrap}table td.gcode_files_action a,table th.gcode_files_action a{text-decoration:none;color:#000}table td.gcode_files_action a.disabled,table th.gcode_files_action a.disabled{color:#ccc;cursor:default}table td.timelapse_files_checkbox,table td.timelapse_unrendered_checkbox,table th.timelapse_files_checkbox,table th.timelapse_unrendered_checkbox{text-align:center;width:10px}table td.timelapse_files_checkbox input[type=checkbox],table td.timelapse_unrendered_checkbox input[type=checkbox],table th.timelapse_files_checkbox input[type=checkbox],table th.timelapse_unrendered_checkbox input[type=checkbox]{margin-top:0}table td.timelapse_files_name,table td.timelapse_unrendered_name,table th.timelapse_files_name,table th.timelapse_unrendered_name{text-overflow:ellipsis;text-align:left}table td.timelapse_files_size,table td.timelapse_unrendered_size,table th.timelapse_files_size,table th.timelapse_unrendered_size{text-align:right;width:55px}table td.timelapse_unrendered_count,table th.timelapse_unrendered_count{text-align:right;width:45px}table td.timelapse_files_action,table td.timelapse_unrendered_action,table th.timelapse_files_action,table th.timelapse_unrendered_action{width:60px;text-align:center;white-space:nowrap}table td.timelapse_files_action a,table td.timelapse_unrendered_action a,table th.timelapse_files_action a,table th.timelapse_unrendered_action a{text-decoration:none;color:#000}table td.timelapse_files_action a.disabled,table td.timelapse_unrendered_action a.disabled,table th.timelapse_files_action a.disabled,table th.timelapse_unrendered_action a.disabled{color:#ccc;cursor:default}table td.settings_users_name,table th.settings_users_name{text-overflow:ellipsis;text-align:left;width:100px}table td.settings_users_active,table th.settings_users_active{text-align:center;width:55px}table td table.settings_users_details_table,table th table.settings_users_details_table{font-size:.8em;margin-bottom:0}table td table.settings_users_details_table .settings_users_details_key,table th table.settings_users_details_table .settings_users_details_key{width:100px}table td table.settings_users_details_table td,table td table.settings_users_details_table th,table th table.settings_users_details_table td,table th table.settings_users_details_table th{border:0;padding:0}table td.settings_groups_default,table th.settings_groups_default{text-align:center;width:20px}table td.settings_groups_name,table th.settings_groups_name{width:180px}table td table.settings_groups_details_table,table th table.settings_groups_details_table{font-size:.8em;margin-bottom:0}table td table.settings_groups_details_table .settings_groups_details_key,table th table.settings_groups_details_table .settings_groups_details_key{width:100px}table td table.settings_groups_details_table td,table td table.settings_groups_details_table th,table th table.settings_groups_details_table td,table th table.settings_groups_details_table th{border:0;padding:0}table td.settings_groups_actions,table td.settings_users_actions,table th.settings_groups_actions,table th.settings_users_actions{width:60px;text-align:center;white-space:nowrap}table td.settings_groups_actions a,table td.settings_users_actions a,table th.settings_groups_actions a,table th.settings_users_actions a{text-decoration:none;color:#000}table td.settings_groups_actions a.disabled,table td.settings_users_actions a.disabled,table th.settings_groups_actions a.disabled,table th.settings_users_actions a.disabled{color:#ccc;cursor:default}table td.settings_accesscontrol_groups_list_checkbox,table td.settings_accesscontrol_permissions_list_checkbox,table td.settings_accesscontrol_subgroups_list_checkbox,table th.settings_accesscontrol_groups_list_checkbox,table th.settings_accesscontrol_permissions_list_checkbox,table th.settings_accesscontrol_subgroups_list_checkbox{width:20px}table td #settings-usersDialogAddUser,table td #settings-usersDialogEditUser,table th #settings-usersDialogAddUser,table th #settings-usersDialogEditUser{position:relative;top:50%;transform:translateY(-50%);margin-top:0!important}table td.settings_printerProfiles_profiles_name,table th.settings_printerProfiles_profiles_name{text-overflow:ellipsis;text-align:left}table td.settings_printerProfiles_profiles_model,table th.settings_printerProfiles_profiles_model{text-align:left;width:250px}table td.settings_printerProfiles_profiles_action,table th.settings_printerProfiles_profiles_action{width:80px;text-align:center;white-space:nowrap}table td.settings_printerProfiles_profiles_action a,table th.settings_printerProfiles_profiles_action a{text-decoration:none;color:#000}table td.settings_printerProfiles_profiles_action a.disabled,table th.settings_printerProfiles_profiles_action a.disabled{color:#ccc;cursor:default}#temperature-graph{height:350px;width:100%;background:url(../img/graph-background.png) center no-repeat}#temperature-table{table-layout:fixed;width:100%;margin-top:20px}#temperature-table td,#temperature-table th{line-height:25px}#temperature-table td.temperature_actual,#temperature-table td.temperature_offset,#temperature-table td.temperature_target,#temperature-table td.temperature_tool,#temperature-table th.temperature_actual,#temperature-table th.temperature_offset,#temperature-table th.temperature_target,#temperature-table th.temperature_tool{vertical-align:middle;text-align:center}#temperature-table td.temperature_actual form,#temperature-table td.temperature_offset form,#temperature-table td.temperature_target form,#temperature-table td.temperature_tool form,#temperature-table th.temperature_actual form,#temperature-table th.temperature_offset form,#temperature-table th.temperature_target form,#temperature-table th.temperature_tool form{margin:0}#temperature-table td.temperature_actual .dropdown-menu,#temperature-table td.temperature_offset .dropdown-menu,#temperature-table td.temperature_target .dropdown-menu,#temperature-table td.temperature_tool .dropdown-menu,#temperature-table th.temperature_actual .dropdown-menu,#temperature-table th.temperature_offset .dropdown-menu,#temperature-table th.temperature_target .dropdown-menu,#temperature-table th.temperature_tool .dropdown-menu{text-align:left}#temperature-table td.temperature_tool,#temperature-table th.temperature_tool{width:16%;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#temperature-table td.temperature_actual,#temperature-table th.temperature_actual{width:12%}#temperature-table td.temperature_target,#temperature-table th.temperature_target{width:42%;overflow:visible}#temperature-table td.temperature_offset,#temperature-table th.temperature_offset{width:30%}.tab-content,.tab-pane{overflow:visible}#speed_fill,#speed_innerWall,#speed_outerWall,#speed_support,#temp_newBedTemp,#temp_newTemp,#webcam_timelapse_fps,#webcam_timelapse_interval,#webcam_timelapse_postRoll,#webcam_timelapse_retractionZHop{text-align:right}ul.dropdown-menu li a{cursor:pointer}#connection_baudrates,#connection_ports,#connection_printers{width:100%}#offline_overlay,#reloadui_overlay{position:fixed;top:0;left:0;width:100%;height:100%;display:none}#offline_overlay{z-index:10002}#reloadui_overlay{z-index:10001}#offline_overlay_background,#reloadui_overlay_background{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#000;filter:alpha(opacity=50);-moz-opacity:.5;-khtml-opacity:.5;opacity:.5}#offline_overlay_wrapper,#reloadui_overlay_wrapper{position:absolute;top:0;bottom:0;left:0;right:0;padding-top:60px}#offline_overlay_wrapper .container,#reloadui_overlay_wrapper .container{margin:auto}#webcam_container{width:100%;position:relative;outline:0;background-color:#000}#webcam_container .keycontrol_overlay{position:absolute;left:10px;right:10px;bottom:10px;background:rgba(0,0,0,.5);font-size:85%;color:#fff;padding:0}#webcam_container .keycontrol_overlay kbd{border:1px solid #eee;border-radius:3px;margin-left:2px;margin-right:2px;font-size:90%;padding:2px;min-width:1em}#webcam_container .keycontrol_overlay .keycontrol_overlay_heading{position:relative;padding:10px;font-weight:700}#webcam_container .keycontrol_overlay .keycontrol_overlay_column{position:relative;width:45%;padding:10px;float:left}#webcam_container .nowebcam{position:absolute;top:0;left:0;right:0;bottom:0}#webcam_container .nowebcam .text{color:#fff;text-align:center;position:relative;margin:auto;width:80%;top:50%;transform:translateY(-50%);display:block}#webcam_container .nowebcam .text.webcam_loading{animation:pulsate 3s ease-out;animation-iteration-count:infinite}#webcam_container .webcam_rotated{position:relative;width:100%;padding-bottom:100%;pointer-events:none}#webcam_container .webcam_rotated .webcam_fixed_ratio{position:absolute;transform:rotate(-90deg);top:0;bottom:0;pointer-events:none}#webcam_container .webcam_rotated .webcam_fixed_ratio .webcam_fixed_ratio_inner{width:100%;height:100%;pointer-events:none}#webcam_container .webcam_unrotated .webcam_fixed_ratio{width:100%;pointer-events:none;padding-bottom:100%;position:relative}#webcam_container .webcam_unrotated .webcam_fixed_ratio.ratio43{padding-bottom:75%}#webcam_container .webcam_unrotated .webcam_fixed_ratio.ratio169{padding-bottom:56.25%}#webcam_container .webcam_unrotated .webcam_fixed_ratio.ratio1610{padding-bottom:62.5%}#webcam_container .webcam_unrotated .webcam_fixed_ratio .webcam_fixed_ratio_inner{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}#webcam_container img{width:100%;height:100%;object-fit:contain}#state_wrapper hr{margin:5px 0}#files .gcode_files .scroll-wrapper{overflow-x:hidden;overflow-y:scroll;height:306px;padding-right:2px}#files .gcode_files .entry{padding:5px;line-height:20px;border-bottom:1px solid #ddd;position:relative}#files .gcode_files .entry:hover{background-color:#f5f5f5}#files .gcode_files .entry .title{text-overflow:ellipsis;word-break:break-all;margin-right:30px}#files .gcode_files .entry .additionalInfo,#files .gcode_files .entry .internal,#files .gcode_files .entry .size,#files .gcode_files .entry .uploaded{font-size:85%;color:#999}#files .gcode_files .entry .uploaded [title]{cursor:help}#files .gcode_files .entry .internal{word-break:break-all}#files .gcode_files .entry .action-buttons{position:absolute;bottom:5px;right:5px}#files .gcode_files .entry .additionalInfo{padding-bottom:22px}@keyframes highlightframes{0%{background:#ff0}100%{background:0 0}}#files .gcode_files .entry.highlight{animation:highlightframes 2s}#files .gcode_files .back .back-path{white-space:nowrap}#files .gcode_files .back .back-path span{word-wrap:break-word;white-space:pre-line}#files .upload-buttons{margin-top:10px}#files .form-search{text-align:center;margin-bottom:5px!important}#control{overflow:hidden}#control .jog-panel{float:left;margin-right:19px}#control h1{text-align:left}#control .jog-panel>div{text-align:center}#control .jog-panel>div.distance{text-align:left}#control .jog-panel .slider{margin-bottom:10px}#control .box{width:30px;height:30px;margin-right:10px;margin-bottom:10px;padding-left:8px}#control .control-box{display:block;height:30px;margin-bottom:10px}#control .btn-group{margin-bottom:10px}#control .btn-group.distance>.btn{width:43px;padding:3px 0;height:30px}#control .slider-handle{width:14px;height:14px;margin-left:-7px;margin-top:-3px}#control .custom_section h1{cursor:pointer}#control .custom_section_horizontal>.custom_control{display:inline-block}#control .custom_section_vertical>.custom_control{display:block}#control .custom_control .slider{margin-left:10px;margin-right:10px;margin-bottom:2px}#control .pulsate_text_opacity{animation:pulsate_input 1s ease-out;animation-iteration-count:infinite}@keyframes pulsate_input{0%{color:#555}50%{color:rgba(85,85,85,.2)}100%{color:#555}}#term .terminal{margin-bottom:30px}#term .terminal #terminal-output,#term .terminal #terminal-output-lowfi{min-height:340px;margin-bottom:5px}#settings_dialog .aboutlink,#settings_dialog .systeminfolink{float:left}#settings_dialog_menu,#wizard_dialog_menu{margin-left:0}#wizard_firstrun_acl .acl_decision{margin-top:1em}#wizard_firstrun_end p,#wizard_firstrun_start p{margin-bottom:1.5em;line-height:1.5}#settings_appearance_managelanguagesdialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_appearance_managelanguagesdialog_emptylist{overflow:hidden;width:100%;height:300px;text-align:center;display:table}#settings_appearance_managelanguagesdialog_emptylist div{display:table-cell;vertical-align:middle}#about_authors ul,#about_sponsors ul{columns:3;-webkit-columns:3;-moz-columns:3}.footer ul{margin:0}.footer ul li{display:inline;margin-left:1em;font-size:85%}.footer ul li:first-child{margin-left:0}.footer ul li a{color:#555}.footer #footer_links,.footer #footer_version{max-width:50%}.ui-pnotify{position:fixed}.ui-pnotify .alert a{color:#c09853}.ui-pnotify .alert-danger a,.ui-pnotify .alert-error a{color:#b94a48}.ui-pnotify .alert-success a{color:#468847}.ui-pnotify .alert-info a{color:#3a87ad}.pnotify_additional_info .pnotify_more{font-size:85%}.text-right{text-align:right}.text-center{text-align:center}.text-block{display:block}.overflow_visible{overflow:visible!important}.clickable{cursor:pointer}.border_box{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none}textarea.block{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%}@keyframes pulsate{0%{opacity:.5}50%{opacity:1}100%{opacity:.5}}#drop_overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;display:none}#drop_overlay.in{display:block}#drop_overlay #drop_overlay_background{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#000;filter:alpha(opacity=50);-moz-opacity:.5;-khtml-opacity:.5;opacity:.5}#drop_overlay #drop_overlay_wrapper{position:absolute;top:0;bottom:0;left:0;right:0;padding-top:60px}#drop_overlay #drop_overlay_wrapper #drop,#drop_overlay #drop_overlay_wrapper #drop_background{position:absolute;top:0;left:0;margin-left:0;width:100%}#drop_overlay #drop_overlay_wrapper #drop_locally,#drop_overlay #drop_overlay_wrapper #drop_locally_background{position:absolute;top:0;left:50%;margin-left:-50%;width:50%;border-right:2px dashed #ccc}#drop_overlay #drop_overlay_wrapper #drop_sd,#drop_overlay #drop_overlay_wrapper #drop_sd_background{position:absolute;top:0;left:50%;margin-left:0;width:50%;border-left:2px dashed #ccc}#drop_overlay #drop_overlay_wrapper .dropzone{height:100%;z-index:10001;color:#fff;font-size:30px}#drop_overlay #drop_overlay_wrapper .dropzone i{font-size:50px}#drop_overlay #drop_overlay_wrapper .dropzone .text{display:block;text-align:center;line-height:40px;position:absolute;width:100%;bottom:5%;filter:alpha(opacity=100);-moz-opacity:1;-khtml-opacity:1;opacity:1}#drop_overlay #drop_overlay_wrapper .dropzone_background{width:50%;height:100%;background-color:#000;filter:alpha(opacity=25);-moz-opacity:.25;-khtml-opacity:.25;opacity:.25}#drop_overlay #drop_overlay_wrapper .dropzone_background.hover{background-color:#000;filter:alpha(opacity=50);-moz-opacity:.5;-khtml-opacity:.5;opacity:.5}#drop_overlay #drop_overlay_wrapper .dropzone_background.fade{-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-ms-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;opacity:1}.center{float:none;margin-left:auto;margin-right:auto}.flipH{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);transform:scaleX(-1)}.flipV{-webkit-transform:scaleY(-1);-moz-transform:scaleY(-1);-ms-transform:scaleY(-1);transform:scaleY(-1)}.flipH.flipV{-webkit-transform:scaleX(-1) scaleY(-1);-moz-transform:scaleX(-1) scaleY(-1);-ms-transform:scaleX(-1) scaleY(-1);transform:scaleX(-1) scaleY(-1)}.rotate90{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.ui-pnotify a{text-decoration:underline}.btn-mini .caret,.btn-small .caret{margin-top:8px}.dropdown-menu-right{right:0;left:auto}.slider .slider-selection{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.slider .slider-selection.active,.slider .slider-selection.disabled,.slider .slider-selection:active,.slider .slider-selection:focus,.slider .slider-selection:hover,.slider .slider-selection[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.slider .slider-selection.active,.slider .slider-selection:active{background-color:#039 \9}.slider.slider-disabled .slider-selection{background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.slider .slider-track{background-color:#f5f5f5;border:1px solid #e3e3e3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05)}.slider.slider-disabled .slider-track{background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.slider .slider-handle{display:inline-block;*display:inline;*zoom:1;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);padding:0;margin-bottom:0;opacity:1;filter:alpha(opacity=100)}.slider .slider-handle.active,.slider .slider-handle.disabled,.slider .slider-handle:active,.slider .slider-handle:focus,.slider .slider-handle:hover,.slider .slider-handle[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.slider .slider-handle.active,.slider .slider-handle:active{background-color:#ccc \9}.slider .slider-handle:first-child{*margin-left:0}.slider .slider-handle:focus,.slider .slider-handle:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.slider .slider-handle:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.slider .slider-handle.active,.slider .slider-handle:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.slider .slider-handle.disabled,.slider .slider-handle[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.slider .slider-handle.hide{display:none}.slider .slider-handle.round{-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}.modal.large{width:975px;margin-left:-487px}.full-sized-box{position:absolute;bottom:0;left:0;right:0;top:0;padding:15px}.full-sized-box .row-fluid{height:100%}@media (max-width:979px){.full-sized-box{position:static}}:root .full-sized-box,_::-webkit-full-page-media,_:future{position:static}.safari ::-webkit-scrollbar{width:10px}.safari ::-webkit-scrollbar-track{border-radius:8px;-webkit-border-radius:8px}.safari ::-webkit-scrollbar-thumb{-webkit-border-radius:10px;border-radius:10px;background:rgba(100,100,100,.8)}.scrollable{height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.pre-output span{display:block}.input-append .add-on.add-on-limited,.input-prepend .add-on.add-on-limited{overflow-x:hidden;text-overflow:ellipsis;width:inherit}.input-append .btn-group:first-child .btn:first-child,.input-prepend .btn-group:first-child .btn:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append .btn-group .btn:first-child,.input-prepend .btn-group .btn:first-child{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-append.input-block-level,.input-prepend.input-block-level{display:table}.input-append.input-block-level .add-on,.input-prepend.input-block-level .add-on{display:table-cell;width:1%}.input-append.input-block-level>input,.input-prepend.input-block-level>input{box-sizing:border-box;display:table;min-height:inherit;width:100%}.input-append.input-block-level :not(:last-child),.input-prepend.input-block-level :not(:last-child){border-right:0}.control-group.error .input-append .fileinput-button,.control-group.error .input-prepend .fileinput-button{border-color:#b94a48}.control-text{padding-top:5px;cursor:default}input[type=number]{text-align:right}input[type=number].input-nospin::-webkit-inner-spin-button,input[type=number].input-nospin::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input[type=number].input-nospin{-moz-appearance:textfield}.dropdown-menu li a.disabled,.dropdown-menu li a.disabled:active,.dropdown-menu li a.disabled:hover,.dropdown-menu li a.disabled:visited{background-color:transparent;background-image:none;color:#aaa;cursor:default}textarea.monospace{font-family:monospace}.progress-text,.progress-text-centered{position:relative}.progress-text .progress-text-back,.progress-text .progress-text-front,.progress-text-centered .progress-text-back,.progress-text-centered .progress-text-front{white-space:nowrap}.progress-text .progress-text-front,.progress-text-centered .progress-text-front{box-sizing:border-box;padding:0 10px;width:100%;display:block}.progress-text .progress-text-back,.progress-text-centered .progress-text-back{position:absolute;font-size:12px;line-height:20px;display:block;box-sizing:border-box;text-align:center;padding:0 10px}.progress-text .bar,.progress-text-centered .bar{position:absolute;overflow:hidden}.progress-text-centered .progress-text-front{position:absolute;font-size:12px;line-height:20px;display:block;text-align:center;color:#fff}.progress-text-centered .progress-text-back{width:100%}.search-query-with-clear{position:relative}.search-query-with-clear .search-clear{display:inline-block;color:#ccc;position:absolute;right:28px;height:20px;padding:4px 0;cursor:pointer;visibility:hidden}.search-query-with-clear.active-clear .search-query{padding-right:28px;width:192px}.search-query-with-clear.active-clear .search-clear{visibility:visible}.search-query-with-clear input::-ms-clear{display:none}.search-query-with-clear input[type=search]::-webkit-search-cancel-button,.search-query-with-clear input[type=search]::-webkit-search-decoration,.search-query-with-clear input[type=search]::-webkit-search-results-button,.search-query-with-clear input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}#navbar_login:not(.open) #login_dropdown_loggedout{display:block;z-index:-1;height:0;width:0;padding:0!important;overflow:hidden;border:0;box-shadow:none;left:-9999px}#navbar_login:not(.open) #login_dropdown_loggedout.hide{display:none}#loginForm{margin:0}#loginForm button{margin-top:20px}#page-container-loading{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#fff;z-index:12301}#page-container-loading .wrapper{position:absolute;top:0;bottom:0;left:0;right:0}#page-container-loading .wrapper .outer{display:table;width:100%;height:100%}#page-container-loading .wrapper .outer .inner{display:table-cell;vertical-align:middle}#page-container-loading .wrapper .outer .inner .content{text-align:center}#page-container-noscript{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#fff;z-index:12310}#page-container-noscript .wrapper{position:absolute;top:0;bottom:0;left:0;right:0}#page-container-noscript .wrapper .outer{display:table;width:100%;height:100%}#page-container-noscript .wrapper .outer .inner{display:table-cell;vertical-align:middle}#page-container-noscript .wrapper .outer .inner .content{text-align:center} \ No newline at end of file +.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#bd362f;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-danger.active,.btn-danger.disabled,.btn-danger:active,.btn-danger:focus,.btn-danger:hover,.btn-danger[disabled]{color:#fff;background-color:#bd362f;*background-color:#a9302a}.btn-danger.active,.btn-danger:active{background-color:#942a25 \9}.btn-success{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#5bb75b;background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(to bottom,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#51a351;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-success.active,.btn-success.disabled,.btn-success:active,.btn-success:focus,.btn-success:hover,.btn-success[disabled]{color:#fff;background-color:#51a351;*background-color:#499249}.btn-success.active,.btn-success:active{background-color:#408140 \9}.btn-info{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#49afcd;background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(to bottom,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#2f96b4;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-info.active,.btn-info.disabled,.btn-info:active,.btn-info:focus,.btn-info:hover,.btn-info[disabled]{color:#fff;background-color:#2f96b4;*background-color:#2a85a0}.btn-info.active,.btn-info:active{background-color:#24748c \9}.btn-inverse{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#363636;background-image:-moz-linear-gradient(top,#444,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#444),to(#222));background-image:-webkit-linear-gradient(top,#444,#222);background-image:-o-linear-gradient(top,#444,#222);background-image:linear-gradient(to bottom,#444,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#222;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-inverse.active,.btn-inverse.disabled,.btn-inverse:active,.btn-inverse:focus,.btn-inverse:hover,.btn-inverse[disabled]{color:#fff;background-color:#222;*background-color:#151515}.btn-inverse.active,.btn-inverse:active{background-color:#080808 \9}button.btn,input[type=submit].btn{*padding-top:3px;*padding-bottom:3px}button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type=submit].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type=submit].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type=submit].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-link,.btn-link:active,.btn-link[disabled]{background-color:transparent;background-image:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-link{border-color:transparent;cursor:pointer;color:#08c;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-link:focus,.btn-link:hover{color:#005580;text-decoration:underline;background-color:transparent}.btn-link[disabled]:focus,.btn-link[disabled]:hover{color:#333;text-decoration:none}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:"";line-height:0}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.nowrap{white-space:nowrap}.actioncol{text-align:center;white-space:nowrap}.actioncol a{text-decoration:none;color:#000}.actioncol a.disabled{color:#ccc;cursor:default}#navbar .navbar-inner{background-color:#ebebeb;background-image:-moz-linear-gradient(top,#fff,#ccc);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#ccc));background-image:-webkit-linear-gradient(top,#fff,#ccc);background-image:-o-linear-gradient(top,#fff,#ccc);background-image:linear-gradient(to bottom,#fff,#ccc);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffcccccc', GradientType=0)}#navbar .navbar-inner .brand,#navbar .navbar-inner .nav>li>a{text-shadow:0 1px 0 #ccc;color:#333}#navbar .navbar-inner .brand .caret,#navbar .navbar-inner .nav>li>a .caret{border-bottom-color:#939393;border-top-color:#939393}#navbar .navbar-inner .brand:focus .caret,#navbar .navbar-inner .brand:hover .caret,#navbar .navbar-inner .nav>li>a:focus .caret,#navbar .navbar-inner .nav>li>a:hover .caret{border-bottom-color:#636363;border-top-color:#636363}#navbar .navbar-inner .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner .nav>li.dropdown.open>.dropdown-toggle{background-color:#e0e0e0;background-image:-moz-linear-gradient(top,#ccc,#fff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ccc),to(#fff));background-image:-webkit-linear-gradient(top,#ccc,#fff);background-image:-o-linear-gradient(top,#ccc,#fff);background-image:linear-gradient(to bottom,#ccc,#fff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffcccccc', endColorstr='#ffffffff', GradientType=0)}#navbar .navbar-inner .nav>li>a:hover{background-color:#dedede;background-image:-moz-linear-gradient(top,#f2f2f2,#bfbfbf);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#bfbfbf));background-image:-webkit-linear-gradient(top,#f2f2f2,#bfbfbf);background-image:-o-linear-gradient(top,#f2f2f2,#bfbfbf);background-image:linear-gradient(to bottom,#f2f2f2,#bfbfbf);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffbfbfbf', GradientType=0)}#navbar .navbar-inner.transparent{background-color:rgba(235,235,235,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(255,255,255,.6)),to(rgba(204,204,204,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(255,255,255,.6),rgba(204,204,204,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99ffffff', endColorstr='#99cccccc', GradientType=0)}#navbar .navbar-inner.transparent .brand,#navbar .navbar-inner.transparent .nav>li>a{text-shadow:0 1px 0 #ccc;color:#333}#navbar .navbar-inner.transparent .brand .caret,#navbar .navbar-inner.transparent .nav>li>a .caret{border-bottom-color:#939393;border-top-color:#939393}#navbar .navbar-inner.transparent .brand:focus .caret,#navbar .navbar-inner.transparent .brand:hover .caret,#navbar .navbar-inner.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.transparent .nav>li>a:hover .caret{border-bottom-color:#636363;border-top-color:#636363}#navbar .navbar-inner.transparent .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.transparent .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(224,224,224,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(204,204,204,.6)),to(rgba(255,255,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(204,204,204,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99cccccc', endColorstr='#99ffffff', GradientType=0)}#navbar .navbar-inner.transparent .nav>li>a:hover{background-color:rgba(222,222,222,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(242,242,242,.6)),to(rgba(191,191,191,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(242,242,242,.6),rgba(191,191,191,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f2f2f2', endColorstr='#99bfbfbf', GradientType=0)}#navbar .navbar-inner.red{background-color:#bb645f;background-image:-moz-linear-gradient(top,#e28e8a,#802420);background-image:-webkit-gradient(linear,0 0,0 100%,from(#e28e8a),to(#802420));background-image:-webkit-linear-gradient(top,#e28e8a,#802420);background-image:-o-linear-gradient(top,#e28e8a,#802420);background-image:linear-gradient(to bottom,#e28e8a,#802420);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe28e8a', endColorstr='#ff802420', GradientType=0)}#navbar .navbar-inner.red .brand,#navbar .navbar-inner.red .nav>li>a{text-shadow:0 1px 0 #d86761;color:#f2f2f2}#navbar .navbar-inner.red .brand .caret,#navbar .navbar-inner.red .nav>li>a .caret{border-bottom-color:#d89491;border-top-color:#d89491}#navbar .navbar-inner.red .brand:focus .caret,#navbar .navbar-inner.red .brand:hover .caret,#navbar .navbar-inner.red .nav>li>a:focus .caret,#navbar .navbar-inner.red .nav>li>a:hover .caret{border-bottom-color:#e5c3c1;border-top-color:#e5c3c1}#navbar .navbar-inner.red .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.red .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.red .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.red .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.red .nav>li.dropdown.open>.dropdown-toggle{background-color:#a74f4a;background-image:-moz-linear-gradient(top,#802420,#e28e8a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#802420),to(#e28e8a));background-image:-webkit-linear-gradient(top,#802420,#e28e8a);background-image:-o-linear-gradient(top,#802420,#e28e8a);background-image:linear-gradient(to bottom,#802420,#e28e8a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff802420', endColorstr='#ffe28e8a', GradientType=0)}#navbar .navbar-inner.red .nav>li>a:hover{background-color:#af5651;background-image:-moz-linear-gradient(top,#dd7a75,#6b1f1b);background-image:-webkit-gradient(linear,0 0,0 100%,from(#dd7a75),to(#6b1f1b));background-image:-webkit-linear-gradient(top,#dd7a75,#6b1f1b);background-image:-o-linear-gradient(top,#dd7a75,#6b1f1b);background-image:linear-gradient(to bottom,#dd7a75,#6b1f1b);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdd7a75', endColorstr='#ff6b1f1b', GradientType=0)}#navbar .navbar-inner.red.transparent{background-color:rgba(187,100,95,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(226,142,138,.6)),to(rgba(128,36,32,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(226,142,138,.6),rgba(128,36,32,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99e28e8a', endColorstr='#99802420', GradientType=0)}#navbar .navbar-inner.red.transparent .brand,#navbar .navbar-inner.red.transparent .nav>li>a{text-shadow:0 1px 0 #d86761;color:#f2f2f2}#navbar .navbar-inner.red.transparent .brand .caret,#navbar .navbar-inner.red.transparent .nav>li>a .caret{border-bottom-color:#d89491;border-top-color:#d89491}#navbar .navbar-inner.red.transparent .brand:focus .caret,#navbar .navbar-inner.red.transparent .brand:hover .caret,#navbar .navbar-inner.red.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.red.transparent .nav>li>a:hover .caret{border-bottom-color:#e5c3c1;border-top-color:#e5c3c1}#navbar .navbar-inner.red.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.red.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.red.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.red.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.red.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(167,79,74,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(128,36,32,.6)),to(rgba(226,142,138,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(128,36,32,.6),rgba(226,142,138,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99802420', endColorstr='#99e28e8a', GradientType=0)}#navbar .navbar-inner.red.transparent .nav>li>a:hover{background-color:rgba(175,86,81,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(221,122,117,.6)),to(rgba(107,31,27,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(221,122,117,.6),rgba(107,31,27,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99dd7a75', endColorstr='#996b1f1b', GradientType=0)}#navbar .navbar-inner.orange{background-color:#e39665;background-image:-moz-linear-gradient(top,#f9c3a0,#c2530c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f9c3a0),to(#c2530c));background-image:-webkit-linear-gradient(top,#f9c3a0,#c2530c);background-image:-o-linear-gradient(top,#f9c3a0,#c2530c);background-image:linear-gradient(to bottom,#f9c3a0,#c2530c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9c3a0', endColorstr='#ffc2530c', GradientType=0)}#navbar .navbar-inner.orange .brand,#navbar .navbar-inner.orange .nav>li>a{text-shadow:0 1px 0 #f6a570;color:#f2f2f2}#navbar .navbar-inner.orange .brand .caret,#navbar .navbar-inner.orange .nav>li>a .caret{border-bottom-color:#f2b58d;border-top-color:#f2b58d}#navbar .navbar-inner.orange .brand:focus .caret,#navbar .navbar-inner.orange .brand:hover .caret,#navbar .navbar-inner.orange .nav>li>a:focus .caret,#navbar .navbar-inner.orange .nav>li>a:hover .caret{border-bottom-color:#f2d3bf;border-top-color:#f2d3bf}#navbar .navbar-inner.orange .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.orange .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.orange .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.orange .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.orange .nav>li.dropdown.open>.dropdown-toggle{background-color:#d88047;background-image:-moz-linear-gradient(top,#c2530c,#f9c3a0);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c2530c),to(#f9c3a0));background-image:-webkit-linear-gradient(top,#c2530c,#f9c3a0);background-image:-o-linear-gradient(top,#c2530c,#f9c3a0);background-image:linear-gradient(to bottom,#c2530c,#f9c3a0);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc2530c', endColorstr='#fff9c3a0', GradientType=0)}#navbar .navbar-inner.orange .nav>li>a:hover{background-color:#d98956;background-image:-moz-linear-gradient(top,#f8b488,#aa490a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f8b488),to(#aa490a));background-image:-webkit-linear-gradient(top,#f8b488,#aa490a);background-image:-o-linear-gradient(top,#f8b488,#aa490a);background-image:linear-gradient(to bottom,#f8b488,#aa490a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8b488', endColorstr='#ffaa490a', GradientType=0)}#navbar .navbar-inner.orange.transparent{background-color:rgba(227,150,101,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(249,195,160,.6)),to(rgba(194,83,12,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(249,195,160,.6),rgba(194,83,12,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f9c3a0', endColorstr='#99c2530c', GradientType=0)}#navbar .navbar-inner.orange.transparent .brand,#navbar .navbar-inner.orange.transparent .nav>li>a{text-shadow:0 1px 0 #f6a570;color:#f2f2f2}#navbar .navbar-inner.orange.transparent .brand .caret,#navbar .navbar-inner.orange.transparent .nav>li>a .caret{border-bottom-color:#f2b58d;border-top-color:#f2b58d}#navbar .navbar-inner.orange.transparent .brand:focus .caret,#navbar .navbar-inner.orange.transparent .brand:hover .caret,#navbar .navbar-inner.orange.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.orange.transparent .nav>li>a:hover .caret{border-bottom-color:#f2d3bf;border-top-color:#f2d3bf}#navbar .navbar-inner.orange.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.orange.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.orange.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.orange.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.orange.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(216,128,71,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(194,83,12,.6)),to(rgba(249,195,160,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(194,83,12,.6),rgba(249,195,160,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c2530c', endColorstr='#99f9c3a0', GradientType=0)}#navbar .navbar-inner.orange.transparent .nav>li>a:hover{background-color:rgba(217,137,86,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(248,180,136,.6)),to(rgba(170,73,10,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(248,180,136,.6),rgba(170,73,10,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f8b488', endColorstr='#99aa490a', GradientType=0)}#navbar .navbar-inner.yellow{background-color:#e3d765;background-image:-moz-linear-gradient(top,#f9f0a0,#c2b00c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f9f0a0),to(#c2b00c));background-image:-webkit-linear-gradient(top,#f9f0a0,#c2b00c);background-image:-o-linear-gradient(top,#f9f0a0,#c2b00c);background-image:linear-gradient(to bottom,#f9f0a0,#c2b00c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f0a0', endColorstr='#ffc2b00c', GradientType=0)}#navbar .navbar-inner.yellow .brand,#navbar .navbar-inner.yellow .nav>li>a{text-shadow:0 1px 0 #c2b00c;color:#f2f2f2}#navbar .navbar-inner.yellow .brand .caret,#navbar .navbar-inner.yellow .nav>li>a .caret{border-bottom-color:#f2e88d;border-top-color:#f2e88d}#navbar .navbar-inner.yellow .brand:focus .caret,#navbar .navbar-inner.yellow .brand:hover .caret,#navbar .navbar-inner.yellow .nav>li>a:focus .caret,#navbar .navbar-inner.yellow .nav>li>a:hover .caret{border-bottom-color:#f2edbf;border-top-color:#f2edbf}#navbar .navbar-inner.yellow .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.yellow .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.yellow .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.yellow .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.yellow .nav>li.dropdown.open>.dropdown-toggle{background-color:#d8ca47;background-image:-moz-linear-gradient(top,#c2b00c,#f9f0a0);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c2b00c),to(#f9f0a0));background-image:-webkit-linear-gradient(top,#c2b00c,#f9f0a0);background-image:-o-linear-gradient(top,#c2b00c,#f9f0a0);background-image:linear-gradient(to bottom,#c2b00c,#f9f0a0);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc2b00c', endColorstr='#fff9f0a0', GradientType=0)}#navbar .navbar-inner.yellow .nav>li>a:hover{background-color:#d9cc56;background-image:-moz-linear-gradient(top,#f8ed88,#aa9a0a);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f8ed88),to(#aa9a0a));background-image:-webkit-linear-gradient(top,#f8ed88,#aa9a0a);background-image:-o-linear-gradient(top,#f8ed88,#aa9a0a);background-image:linear-gradient(to bottom,#f8ed88,#aa9a0a);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8ed88', endColorstr='#ffaa9a0a', GradientType=0)}#navbar .navbar-inner.yellow.transparent{background-color:rgba(227,215,101,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(249,240,160,.6)),to(rgba(194,176,12,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(249,240,160,.6),rgba(194,176,12,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f9f0a0', endColorstr='#99c2b00c', GradientType=0)}#navbar .navbar-inner.yellow.transparent .brand,#navbar .navbar-inner.yellow.transparent .nav>li>a{text-shadow:0 1px 0 #c2b00c;color:#f2f2f2}#navbar .navbar-inner.yellow.transparent .brand .caret,#navbar .navbar-inner.yellow.transparent .nav>li>a .caret{border-bottom-color:#f2e88d;border-top-color:#f2e88d}#navbar .navbar-inner.yellow.transparent .brand:focus .caret,#navbar .navbar-inner.yellow.transparent .brand:hover .caret,#navbar .navbar-inner.yellow.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.yellow.transparent .nav>li>a:hover .caret{border-bottom-color:#f2edbf;border-top-color:#f2edbf}#navbar .navbar-inner.yellow.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.yellow.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.yellow.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.yellow.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.yellow.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(216,202,71,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(194,176,12,.6)),to(rgba(249,240,160,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(194,176,12,.6),rgba(249,240,160,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c2b00c', endColorstr='#99f9f0a0', GradientType=0)}#navbar .navbar-inner.yellow.transparent .nav>li>a:hover{background-color:rgba(217,204,86,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(248,237,136,.6)),to(rgba(170,154,10,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(248,237,136,.6),rgba(170,154,10,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f8ed88', endColorstr='#99aa9a0a', GradientType=0)}#navbar .navbar-inner.green{background-color:#98f064;background-image:-moz-linear-gradient(top,#c8ffa7,#50da00);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c8ffa7),to(#50da00));background-image:-webkit-linear-gradient(top,#c8ffa7,#50da00);background-image:-o-linear-gradient(top,#c8ffa7,#50da00);background-image:linear-gradient(to bottom,#c8ffa7,#50da00);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc8ffa7', endColorstr='#ff50da00', GradientType=0)}#navbar .navbar-inner.green .brand,#navbar .navbar-inner.green .nav>li>a{text-shadow:0 1px 0 #50da00;color:#333}#navbar .navbar-inner.green .brand .caret,#navbar .navbar-inner.green .nav>li>a .caret{border-bottom-color:#55992e;border-top-color:#55992e}#navbar .navbar-inner.green .brand:focus .caret,#navbar .navbar-inner.green .brand:hover .caret,#navbar .navbar-inner.green .nav>li>a:focus .caret,#navbar .navbar-inner.green .nav>li>a:hover .caret{border-bottom-color:#446630;border-top-color:#446630}#navbar .navbar-inner.green .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.green .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.green .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.green .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.green .nav>li.dropdown.open>.dropdown-toggle{background-color:#80e943;background-image:-moz-linear-gradient(top,#50da00,#c8ffa7);background-image:-webkit-gradient(linear,0 0,0 100%,from(#50da00),to(#c8ffa7));background-image:-webkit-linear-gradient(top,#50da00,#c8ffa7);background-image:-o-linear-gradient(top,#50da00,#c8ffa7);background-image:linear-gradient(to bottom,#50da00,#c8ffa7);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff50da00', endColorstr='#ffc8ffa7', GradientType=0)}#navbar .navbar-inner.green .nav>li>a:hover{background-color:#8ae655;background-image:-moz-linear-gradient(top,#b8ff8e,#47c100);background-image:-webkit-gradient(linear,0 0,0 100%,from(#b8ff8e),to(#47c100));background-image:-webkit-linear-gradient(top,#b8ff8e,#47c100);background-image:-o-linear-gradient(top,#b8ff8e,#47c100);background-image:linear-gradient(to bottom,#b8ff8e,#47c100);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffb8ff8e', endColorstr='#ff47c100', GradientType=0)}#navbar .navbar-inner.green.transparent{background-color:rgba(152,240,100,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(200,255,167,.6)),to(rgba(80,218,0,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(200,255,167,.6),rgba(80,218,0,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c8ffa7', endColorstr='#9950da00', GradientType=0)}#navbar .navbar-inner.green.transparent .brand,#navbar .navbar-inner.green.transparent .nav>li>a{text-shadow:0 1px 0 #50da00;color:#333}#navbar .navbar-inner.green.transparent .brand .caret,#navbar .navbar-inner.green.transparent .nav>li>a .caret{border-bottom-color:#55992e;border-top-color:#55992e}#navbar .navbar-inner.green.transparent .brand:focus .caret,#navbar .navbar-inner.green.transparent .brand:hover .caret,#navbar .navbar-inner.green.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.green.transparent .nav>li>a:hover .caret{border-bottom-color:#446630;border-top-color:#446630}#navbar .navbar-inner.green.transparent .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.green.transparent .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.green.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.green.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.green.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(128,233,67,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(80,218,0,.6)),to(rgba(200,255,167,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(80,218,0,.6),rgba(200,255,167,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#9950da00', endColorstr='#99c8ffa7', GradientType=0)}#navbar .navbar-inner.green.transparent .nav>li>a:hover{background-color:rgba(138,230,85,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(184,255,142,.6)),to(rgba(71,193,0,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(184,255,142,.6),rgba(71,193,0,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99b8ff8e', endColorstr='#9947c100', GradientType=0)}#navbar .navbar-inner.blue{background-color:#2e63cc;background-image:-moz-linear-gradient(top,#4d88ff,#002b80);background-image:-webkit-gradient(linear,0 0,0 100%,from(#4d88ff),to(#002b80));background-image:-webkit-linear-gradient(top,#4d88ff,#002b80);background-image:-o-linear-gradient(top,#4d88ff,#002b80);background-image:linear-gradient(to bottom,#4d88ff,#002b80);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff4d88ff', endColorstr='#ff002b80', GradientType=0)}#navbar .navbar-inner.blue .brand,#navbar .navbar-inner.blue .nav>li>a{text-shadow:0 1px 0 #1a66ff;color:#f2f2f2}#navbar .navbar-inner.blue .brand .caret,#navbar .navbar-inner.blue .nav>li>a .caret{border-bottom-color:#799bdf;border-top-color:#799bdf}#navbar .navbar-inner.blue .brand:focus .caret,#navbar .navbar-inner.blue .brand:hover .caret,#navbar .navbar-inner.blue .nav>li>a:focus .caret,#navbar .navbar-inner.blue .nav>li>a:hover .caret{border-bottom-color:#b6c7e9;border-top-color:#b6c7e9}#navbar .navbar-inner.blue .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.blue .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.blue .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.blue .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.blue .nav>li.dropdown.open>.dropdown-toggle{background-color:#1f50b3;background-image:-moz-linear-gradient(top,#002b80,#4d88ff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#002b80),to(#4d88ff));background-image:-webkit-linear-gradient(top,#002b80,#4d88ff);background-image:-o-linear-gradient(top,#002b80,#4d88ff);background-image:linear-gradient(to bottom,#002b80,#4d88ff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff002b80', endColorstr='#ff4d88ff', GradientType=0)}#navbar .navbar-inner.blue .nav>li>a:hover{background-color:#1f55c2;background-image:-moz-linear-gradient(top,#37f,#026);background-image:-webkit-gradient(linear,0 0,0 100%,from(#37f),to(#026));background-image:-webkit-linear-gradient(top,#37f,#026);background-image:-o-linear-gradient(top,#37f,#026);background-image:linear-gradient(to bottom,#37f,#026);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3377ff', endColorstr='#ff002266', GradientType=0)}#navbar .navbar-inner.blue.transparent{background-color:rgba(46,99,204,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(77,136,255,.6)),to(rgba(0,43,128,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(77,136,255,.6),rgba(0,43,128,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#994d88ff', endColorstr='#99002b80', GradientType=0)}#navbar .navbar-inner.blue.transparent .brand,#navbar .navbar-inner.blue.transparent .nav>li>a{text-shadow:0 1px 0 #1a66ff;color:#f2f2f2}#navbar .navbar-inner.blue.transparent .brand .caret,#navbar .navbar-inner.blue.transparent .nav>li>a .caret{border-bottom-color:#799bdf;border-top-color:#799bdf}#navbar .navbar-inner.blue.transparent .brand:focus .caret,#navbar .navbar-inner.blue.transparent .brand:hover .caret,#navbar .navbar-inner.blue.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.blue.transparent .nav>li>a:hover .caret{border-bottom-color:#b6c7e9;border-top-color:#b6c7e9}#navbar .navbar-inner.blue.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.blue.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.blue.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.blue.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.blue.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(31,80,179,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(0,43,128,.6)),to(rgba(77,136,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(0,43,128,.6),rgba(77,136,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99002b80', endColorstr='#994d88ff', GradientType=0)}#navbar .navbar-inner.blue.transparent .nav>li>a:hover{background-color:rgba(31,85,194,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(51,119,255,.6)),to(rgba(0,34,102,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(51,119,255,.6),rgba(0,34,102,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#993377ff', endColorstr='#99002266', GradientType=0)}#navbar .navbar-inner.violet{background-color:#9864f0;background-image:-moz-linear-gradient(top,#c8a7ff,#5000da);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c8a7ff),to(#5000da));background-image:-webkit-linear-gradient(top,#c8a7ff,#5000da);background-image:-o-linear-gradient(top,#c8a7ff,#5000da);background-image:linear-gradient(to bottom,#c8a7ff,#5000da);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc8a7ff', endColorstr='#ff5000da', GradientType=0)}#navbar .navbar-inner.violet .brand,#navbar .navbar-inner.violet .nav>li>a{text-shadow:0 1px 0 #a774ff;color:#f2f2f2}#navbar .navbar-inner.violet .brand .caret,#navbar .navbar-inner.violet .nav>li>a .caret{border-bottom-color:#b58df9;border-top-color:#b58df9}#navbar .navbar-inner.violet .brand:focus .caret,#navbar .navbar-inner.violet .brand:hover .caret,#navbar .navbar-inner.violet .nav>li>a:focus .caret,#navbar .navbar-inner.violet .nav>li>a:hover .caret{border-bottom-color:#d3bff5;border-top-color:#d3bff5}#navbar .navbar-inner.violet .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.violet .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.violet .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.violet .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.violet .nav>li.dropdown.open>.dropdown-toggle{background-color:#8043e9;background-image:-moz-linear-gradient(top,#5000da,#c8a7ff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5000da),to(#c8a7ff));background-image:-webkit-linear-gradient(top,#5000da,#c8a7ff);background-image:-o-linear-gradient(top,#5000da,#c8a7ff);background-image:linear-gradient(to bottom,#5000da,#c8a7ff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5000da', endColorstr='#ffc8a7ff', GradientType=0)}#navbar .navbar-inner.violet .nav>li>a:hover{background-color:#8a55e6;background-image:-moz-linear-gradient(top,#b88eff,#4700c1);background-image:-webkit-gradient(linear,0 0,0 100%,from(#b88eff),to(#4700c1));background-image:-webkit-linear-gradient(top,#b88eff,#4700c1);background-image:-o-linear-gradient(top,#b88eff,#4700c1);background-image:linear-gradient(to bottom,#b88eff,#4700c1);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffb88eff', endColorstr='#ff4700c1', GradientType=0)}#navbar .navbar-inner.violet.transparent{background-color:rgba(152,100,240,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(200,167,255,.6)),to(rgba(80,0,218,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(200,167,255,.6),rgba(80,0,218,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c8a7ff', endColorstr='#995000da', GradientType=0)}#navbar .navbar-inner.violet.transparent .brand,#navbar .navbar-inner.violet.transparent .nav>li>a{text-shadow:0 1px 0 #a774ff;color:#f2f2f2}#navbar .navbar-inner.violet.transparent .brand .caret,#navbar .navbar-inner.violet.transparent .nav>li>a .caret{border-bottom-color:#b58df9;border-top-color:#b58df9}#navbar .navbar-inner.violet.transparent .brand:focus .caret,#navbar .navbar-inner.violet.transparent .brand:hover .caret,#navbar .navbar-inner.violet.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.violet.transparent .nav>li>a:hover .caret{border-bottom-color:#d3bff5;border-top-color:#d3bff5}#navbar .navbar-inner.violet.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.violet.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.violet.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.violet.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.violet.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(128,67,233,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(80,0,218,.6)),to(rgba(200,167,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(80,0,218,.6),rgba(200,167,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#995000da', endColorstr='#99c8a7ff', GradientType=0)}#navbar .navbar-inner.violet.transparent .nav>li>a:hover{background-color:rgba(138,85,230,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(184,142,255,.6)),to(rgba(71,0,193,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(184,142,255,.6),rgba(71,0,193,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99b88eff', endColorstr='#994700c1', GradientType=0)}#navbar .navbar-inner.black{background-color:#4f4f4f;background-image:-moz-linear-gradient(top,#787878,#121212);background-image:-webkit-gradient(linear,0 0,0 100%,from(#787878),to(#121212));background-image:-webkit-linear-gradient(top,#787878,#121212);background-image:-o-linear-gradient(top,#787878,#121212);background-image:linear-gradient(to bottom,#787878,#121212);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff787878', endColorstr='#ff121212', GradientType=0)}#navbar .navbar-inner.black .brand,#navbar .navbar-inner.black .nav>li>a{text-shadow:0 1px 0 #5e5e5e;color:#f2f2f2}#navbar .navbar-inner.black .brand .caret,#navbar .navbar-inner.black .nav>li>a .caret{border-bottom-color:#959595;border-top-color:#959595}#navbar .navbar-inner.black .brand:focus .caret,#navbar .navbar-inner.black .brand:hover .caret,#navbar .navbar-inner.black .nav>li>a:focus .caret,#navbar .navbar-inner.black .nav>li>a:hover .caret{border-bottom-color:#c4c4c4;border-top-color:#c4c4c4}#navbar .navbar-inner.black .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.black .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.black .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.black .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.black .nav>li.dropdown.open>.dropdown-toggle{background-color:#3b3b3b;background-image:-moz-linear-gradient(top,#121212,#787878);background-image:-webkit-gradient(linear,0 0,0 100%,from(#121212),to(#787878));background-image:-webkit-linear-gradient(top,#121212,#787878);background-image:-o-linear-gradient(top,#121212,#787878);background-image:linear-gradient(to bottom,#121212,#787878);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff121212', endColorstr='#ff787878', GradientType=0)}#navbar .navbar-inner.black .nav>li>a:hover{background-color:#424242;background-image:-moz-linear-gradient(top,#6b6b6b,#050505);background-image:-webkit-gradient(linear,0 0,0 100%,from(#6b6b6b),to(#050505));background-image:-webkit-linear-gradient(top,#6b6b6b,#050505);background-image:-o-linear-gradient(top,#6b6b6b,#050505);background-image:linear-gradient(to bottom,#6b6b6b,#050505);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff6b6b6b', endColorstr='#ff050505', GradientType=0)}#navbar .navbar-inner.black.transparent{background-color:rgba(79,79,79,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(120,120,120,.6)),to(rgba(18,18,18,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(120,120,120,.6),rgba(18,18,18,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99787878', endColorstr='#99121212', GradientType=0)}#navbar .navbar-inner.black.transparent .brand,#navbar .navbar-inner.black.transparent .nav>li>a{text-shadow:0 1px 0 #5e5e5e;color:#f2f2f2}#navbar .navbar-inner.black.transparent .brand .caret,#navbar .navbar-inner.black.transparent .nav>li>a .caret{border-bottom-color:#959595;border-top-color:#959595}#navbar .navbar-inner.black.transparent .brand:focus .caret,#navbar .navbar-inner.black.transparent .brand:hover .caret,#navbar .navbar-inner.black.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.black.transparent .nav>li>a:hover .caret{border-bottom-color:#c4c4c4;border-top-color:#c4c4c4}#navbar .navbar-inner.black.transparent .brand span{background-image:url(../img/tentacle-20x20-light.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.black.transparent .brand span{background-image:url(../img/tentacle-20x20-light@2x.png)}}#navbar .navbar-inner.black.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.black.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.black.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(59,59,59,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(18,18,18,.6)),to(rgba(120,120,120,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(18,18,18,.6),rgba(120,120,120,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99121212', endColorstr='#99787878', GradientType=0)}#navbar .navbar-inner.black.transparent .nav>li>a:hover{background-color:rgba(66,66,66,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(107,107,107,.6)),to(rgba(5,5,5,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(107,107,107,.6),rgba(5,5,5,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#996b6b6b', endColorstr='#99050505', GradientType=0)}#navbar .navbar-inner.white{background-color:#e9e9e9;background-image:-moz-linear-gradient(top,#fff,#c8c8c8);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#c8c8c8));background-image:-webkit-linear-gradient(top,#fff,#c8c8c8);background-image:-o-linear-gradient(top,#fff,#c8c8c8);background-image:linear-gradient(to bottom,#fff,#c8c8c8);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffc8c8c8', GradientType=0)}#navbar .navbar-inner.white .brand,#navbar .navbar-inner.white .nav>li>a{text-shadow:0 1px 0 #c8c8c8;color:#333}#navbar .navbar-inner.white .brand .caret,#navbar .navbar-inner.white .nav>li>a .caret{border-bottom-color:#919191;border-top-color:#919191}#navbar .navbar-inner.white .brand:focus .caret,#navbar .navbar-inner.white .brand:hover .caret,#navbar .navbar-inner.white .nav>li>a:focus .caret,#navbar .navbar-inner.white .nav>li>a:hover .caret{border-bottom-color:#626262;border-top-color:#626262}#navbar .navbar-inner.white .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.white .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.white .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.white .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.white .nav>li.dropdown.open>.dropdown-toggle{background-color:#dedede;background-image:-moz-linear-gradient(top,#c8c8c8,#fff);background-image:-webkit-gradient(linear,0 0,0 100%,from(#c8c8c8),to(#fff));background-image:-webkit-linear-gradient(top,#c8c8c8,#fff);background-image:-o-linear-gradient(top,#c8c8c8,#fff);background-image:linear-gradient(to bottom,#c8c8c8,#fff);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc8c8c8', endColorstr='#ffffffff', GradientType=0)}#navbar .navbar-inner.white .nav>li>a:hover{background-color:#dcdcdc;background-image:-moz-linear-gradient(top,#f2f2f2,#bbb);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#bbb));background-image:-webkit-linear-gradient(top,#f2f2f2,#bbb);background-image:-o-linear-gradient(top,#f2f2f2,#bbb);background-image:linear-gradient(to bottom,#f2f2f2,#bbb);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2', endColorstr='#ffbbbbbb', GradientType=0)}#navbar .navbar-inner.white.transparent{background-color:rgba(233,233,233,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(255,255,255,.6)),to(rgba(200,200,200,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(255,255,255,.6),rgba(200,200,200,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99ffffff', endColorstr='#99c8c8c8', GradientType=0)}#navbar .navbar-inner.white.transparent .brand,#navbar .navbar-inner.white.transparent .nav>li>a{text-shadow:0 1px 0 #c8c8c8;color:#333}#navbar .navbar-inner.white.transparent .brand .caret,#navbar .navbar-inner.white.transparent .nav>li>a .caret{border-bottom-color:#919191;border-top-color:#919191}#navbar .navbar-inner.white.transparent .brand:focus .caret,#navbar .navbar-inner.white.transparent .brand:hover .caret,#navbar .navbar-inner.white.transparent .nav>li>a:focus .caret,#navbar .navbar-inner.white.transparent .nav>li>a:hover .caret{border-bottom-color:#626262;border-top-color:#626262}#navbar .navbar-inner.white.transparent .brand span{background-image:url(../img/tentacle-20x20.png)}@media (-webkit-min-device-pixel-ratio:2),(min-resolution:192dpi){#navbar .navbar-inner.white.transparent .brand span{background-image:url(../img/tentacle-20x20@2x.png)}}#navbar .navbar-inner.white.transparent .nav>li.dropdown.active>.dropdown-toggle,#navbar .navbar-inner.white.transparent .nav>li.dropdown.open.active>.dropdown-toggle,#navbar .navbar-inner.white.transparent .nav>li.dropdown.open>.dropdown-toggle{background-color:rgba(222,222,222,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(200,200,200,.6)),to(rgba(255,255,255,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(200,200,200,.6),rgba(255,255,255,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99c8c8c8', endColorstr='#99ffffff', GradientType=0)}#navbar .navbar-inner.white.transparent .nav>li>a:hover{background-color:rgba(220,220,220,.6);background-image:"../img/trans-background.png";background-image:-moz-linear-gradient(top,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-image:-webkit-gradient(linear,0 0,0 100%,from(rgba(242,242,242,.6)),to(rgba(187,187,187,.6))),url(../img/trans-background.png);background-image:-webkit-linear-gradient(top,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-image:-o-linear-gradient(top,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-image:linear-gradient(to bottom,rgba(242,242,242,.6),rgba(187,187,187,.6)),url(../img/trans-background.png);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#99f2f2f2', endColorstr='#99bbbbbb', GradientType=0)}#navbar .navbar-inner .brand{padding:10px 20px 6px}#navbar .navbar-inner .brand span{padding-left:26px;background-size:20px 20px;background-repeat:no-repeat;display:inline-block;max-width:250px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:top;line-height:20px;height:24px}#navbar_login a.dropdown-toggle span{display:inline-block;max-width:100px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:top}.octoprint-container{margin-top:20px}.octoprint-container .tab-content{padding:9px 15px;border-left:1px solid #ddd;border-right:1px solid #ddd;border-bottom:1px solid #ddd;-webkit-border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px;border-bottom-right-radius:4px;-webkit-border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px;border-bottom-left-radius:4px}.octoprint-container .nav{margin-bottom:0}.octoprint-container .tab-content h1{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333;border:0;border-bottom:1px solid #e5e5e5;font-weight:400}.octoprint-container .accordion-heading .accordion-heading-button{float:right}.octoprint-container .accordion-heading .accordion-heading-button>a{display:inline-block;padding:8px 15px;font-size:14px;line-height:20px;color:#000;text-decoration:none;background:0 0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.octoprint-container .accordion-heading a.accordion-toggle{display:inline-block}.octoprint-container .accordion-heading [class*=" icon-"],.octoprint-container .accordion-heading [class^=icon-]{color:#000}.print-control .btn{padding-left:4px;padding-right:4px}.upload-buttons .btn{margin-right:0}table{table-layout:fixed}table .popover-title{text-overflow:ellipsis;word-break:break-all}table td,table th{overflow:hidden}table td.gcode_files_name,table th.gcode_files_name{text-overflow:ellipsis;text-align:left;white-space:nowrap}table td.gcode_files_action,table th.gcode_files_action{width:90px;text-align:center;white-space:nowrap}table td.gcode_files_action a,table th.gcode_files_action a{text-decoration:none;color:#000}table td.gcode_files_action a.disabled,table th.gcode_files_action a.disabled{color:#ccc;cursor:default}table td.timelapse_files_checkbox,table td.timelapse_unrendered_checkbox,table th.timelapse_files_checkbox,table th.timelapse_unrendered_checkbox{text-align:center;width:10px}table td.timelapse_files_checkbox input[type=checkbox],table td.timelapse_unrendered_checkbox input[type=checkbox],table th.timelapse_files_checkbox input[type=checkbox],table th.timelapse_unrendered_checkbox input[type=checkbox]{margin-top:0}table td.timelapse_files_name,table td.timelapse_unrendered_name,table th.timelapse_files_name,table th.timelapse_unrendered_name{text-overflow:ellipsis;text-align:left}table td.timelapse_files_size,table td.timelapse_unrendered_size,table th.timelapse_files_size,table th.timelapse_unrendered_size{text-align:right;width:55px}table td.timelapse_unrendered_count,table th.timelapse_unrendered_count{text-align:right;width:45px}table td.timelapse_files_action,table td.timelapse_unrendered_action,table th.timelapse_files_action,table th.timelapse_unrendered_action{width:60px;text-align:center;white-space:nowrap}table td.timelapse_files_action a,table td.timelapse_unrendered_action a,table th.timelapse_files_action a,table th.timelapse_unrendered_action a{text-decoration:none;color:#000}table td.timelapse_files_action a.disabled,table td.timelapse_unrendered_action a.disabled,table th.timelapse_files_action a.disabled,table th.timelapse_unrendered_action a.disabled{color:#ccc;cursor:default}table td.settings_users_name,table th.settings_users_name{text-overflow:ellipsis;text-align:left;width:100px}table td.settings_users_active,table th.settings_users_active{text-align:center;width:55px}table td table.settings_users_details_table,table th table.settings_users_details_table{font-size:.8em;margin-bottom:0}table td table.settings_users_details_table .settings_users_details_key,table th table.settings_users_details_table .settings_users_details_key{width:100px}table td table.settings_users_details_table td,table td table.settings_users_details_table th,table th table.settings_users_details_table td,table th table.settings_users_details_table th{border:0;padding:0}table td.settings_groups_default,table th.settings_groups_default{text-align:center;width:20px}table td.settings_groups_name,table th.settings_groups_name{width:180px}table td table.settings_groups_details_table,table th table.settings_groups_details_table{font-size:.8em;margin-bottom:0}table td table.settings_groups_details_table .settings_groups_details_key,table th table.settings_groups_details_table .settings_groups_details_key{width:100px}table td table.settings_groups_details_table td,table td table.settings_groups_details_table th,table th table.settings_groups_details_table td,table th table.settings_groups_details_table th{border:0;padding:0}table td.settings_groups_actions,table td.settings_users_actions,table th.settings_groups_actions,table th.settings_users_actions{width:60px;text-align:center;white-space:nowrap}table td.settings_groups_actions a,table td.settings_users_actions a,table th.settings_groups_actions a,table th.settings_users_actions a{text-decoration:none;color:#000}table td.settings_groups_actions a.disabled,table td.settings_users_actions a.disabled,table th.settings_groups_actions a.disabled,table th.settings_users_actions a.disabled{color:#ccc;cursor:default}table td.settings_accesscontrol_groups_list_checkbox,table td.settings_accesscontrol_permissions_list_checkbox,table td.settings_accesscontrol_subgroups_list_checkbox,table th.settings_accesscontrol_groups_list_checkbox,table th.settings_accesscontrol_permissions_list_checkbox,table th.settings_accesscontrol_subgroups_list_checkbox{width:20px}table td #settings-usersDialogAddUser,table td #settings-usersDialogEditUser,table th #settings-usersDialogAddUser,table th #settings-usersDialogEditUser{position:relative;top:50%;transform:translateY(-50%);margin-top:0!important}table td.settings_printerProfiles_profiles_name,table th.settings_printerProfiles_profiles_name{text-overflow:ellipsis;text-align:left}table td.settings_printerProfiles_profiles_model,table th.settings_printerProfiles_profiles_model{text-align:left;width:250px}table td.settings_printerProfiles_profiles_action,table th.settings_printerProfiles_profiles_action{width:80px;text-align:center;white-space:nowrap}table td.settings_printerProfiles_profiles_action a,table th.settings_printerProfiles_profiles_action a{text-decoration:none;color:#000}table td.settings_printerProfiles_profiles_action a.disabled,table th.settings_printerProfiles_profiles_action a.disabled{color:#ccc;cursor:default}table td.settings_connectionProfiles_profiles_name,table th.settings_connectionProfiles_profiles_name{text-overflow:ellipsis;text-align:left}table td.settings_connectionProfiles_profiles_action,table th.settings_connectionProfiles_profiles_action{width:80px;text-align:center;white-space:nowrap}table td.settings_connectionProfiles_profiles_action a,table th.settings_connectionProfiles_profiles_action a{text-decoration:none;color:#000}table td.settings_connectionProfiles_profiles_action a.disabled,table th.settings_connectionProfiles_profiles_action a.disabled{color:#ccc;cursor:default}#temperature-graph{height:350px;width:100%;background:url(../img/graph-background.png) center no-repeat}#temperature-table{table-layout:fixed;width:100%;margin-top:20px}#temperature-table td,#temperature-table th{line-height:25px}#temperature-table td.temperature_actual,#temperature-table td.temperature_offset,#temperature-table td.temperature_target,#temperature-table td.temperature_tool,#temperature-table th.temperature_actual,#temperature-table th.temperature_offset,#temperature-table th.temperature_target,#temperature-table th.temperature_tool{vertical-align:middle;text-align:center}#temperature-table td.temperature_actual form,#temperature-table td.temperature_offset form,#temperature-table td.temperature_target form,#temperature-table td.temperature_tool form,#temperature-table th.temperature_actual form,#temperature-table th.temperature_offset form,#temperature-table th.temperature_target form,#temperature-table th.temperature_tool form{margin:0}#temperature-table td.temperature_actual .dropdown-menu,#temperature-table td.temperature_offset .dropdown-menu,#temperature-table td.temperature_target .dropdown-menu,#temperature-table td.temperature_tool .dropdown-menu,#temperature-table th.temperature_actual .dropdown-menu,#temperature-table th.temperature_offset .dropdown-menu,#temperature-table th.temperature_target .dropdown-menu,#temperature-table th.temperature_tool .dropdown-menu{text-align:left}#temperature-table td.temperature_tool,#temperature-table th.temperature_tool{width:16%;text-align:left;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#temperature-table td.temperature_actual,#temperature-table th.temperature_actual{width:12%}#temperature-table td.temperature_target,#temperature-table th.temperature_target{width:42%;overflow:visible}#temperature-table td.temperature_offset,#temperature-table th.temperature_offset{width:30%}.tab-content,.tab-pane{overflow:visible}#speed_fill,#speed_innerWall,#speed_outerWall,#speed_support,#temp_newBedTemp,#temp_newTemp,#webcam_timelapse_fps,#webcam_timelapse_interval,#webcam_timelapse_postRoll,#webcam_timelapse_retractionZHop{text-align:right}ul.dropdown-menu li a{cursor:pointer}#connection_baudrates,#connection_ports,#connection_printers{width:100%}#offline_overlay,#reloadui_overlay{position:fixed;top:0;left:0;width:100%;height:100%;display:none}#offline_overlay{z-index:10002}#reloadui_overlay{z-index:10001}#offline_overlay_background,#reloadui_overlay_background{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#000;filter:alpha(opacity=50);-moz-opacity:.5;-khtml-opacity:.5;opacity:.5}#offline_overlay_wrapper,#reloadui_overlay_wrapper{position:absolute;top:0;bottom:0;left:0;right:0;padding-top:60px}#offline_overlay_wrapper .container,#reloadui_overlay_wrapper .container{margin:auto}#webcam_container{width:100%;position:relative;outline:0;background-color:#000}#webcam_container .keycontrol_overlay{position:absolute;left:10px;right:10px;bottom:10px;background:rgba(0,0,0,.5);font-size:85%;color:#fff;padding:0}#webcam_container .keycontrol_overlay kbd{border:1px solid #eee;border-radius:3px;margin-left:2px;margin-right:2px;font-size:90%;padding:2px;min-width:1em}#webcam_container .keycontrol_overlay .keycontrol_overlay_heading{position:relative;padding:10px;font-weight:700}#webcam_container .keycontrol_overlay .keycontrol_overlay_column{position:relative;width:45%;padding:10px;float:left}#webcam_container .nowebcam{position:absolute;top:0;left:0;right:0;bottom:0}#webcam_container .nowebcam .text{color:#fff;text-align:center;position:relative;margin:auto;width:80%;top:50%;transform:translateY(-50%);display:block}#webcam_container .nowebcam .text.webcam_loading{animation:pulsate 3s ease-out;animation-iteration-count:infinite}#webcam_container .webcam_rotated{position:relative;width:100%;padding-bottom:100%;pointer-events:none}#webcam_container .webcam_rotated .webcam_fixed_ratio{position:absolute;transform:rotate(-90deg);top:0;bottom:0;pointer-events:none}#webcam_container .webcam_rotated .webcam_fixed_ratio .webcam_fixed_ratio_inner{width:100%;height:100%;pointer-events:none}#webcam_container .webcam_unrotated .webcam_fixed_ratio{width:100%;pointer-events:none;padding-bottom:100%;position:relative}#webcam_container .webcam_unrotated .webcam_fixed_ratio.ratio43{padding-bottom:75%}#webcam_container .webcam_unrotated .webcam_fixed_ratio.ratio169{padding-bottom:56.25%}#webcam_container .webcam_unrotated .webcam_fixed_ratio.ratio1610{padding-bottom:62.5%}#webcam_container .webcam_unrotated .webcam_fixed_ratio .webcam_fixed_ratio_inner{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none}#webcam_container img{width:100%;height:100%;object-fit:contain}#state_wrapper hr{margin:5px 0}#files .gcode_files .scroll-wrapper{overflow-x:hidden;overflow-y:scroll;height:306px;padding-right:2px}#files .gcode_files .entry{padding:5px;line-height:20px;border-bottom:1px solid #ddd;position:relative}#files .gcode_files .entry:hover{background-color:#f5f5f5}#files .gcode_files .entry .title{text-overflow:ellipsis;word-break:break-all;margin-right:30px}#files .gcode_files .entry .additionalInfo,#files .gcode_files .entry .internal,#files .gcode_files .entry .size,#files .gcode_files .entry .uploaded{font-size:85%;color:#999}#files .gcode_files .entry .uploaded [title]{cursor:help}#files .gcode_files .entry .internal{word-break:break-all}#files .gcode_files .entry .action-buttons{position:absolute;bottom:5px;right:5px}#files .gcode_files .entry .additionalInfo{padding-bottom:22px}@keyframes highlightframes{0%{background:#ff0}100%{background:0 0}}#files .gcode_files .entry.highlight{animation:highlightframes 2s}#files .gcode_files .back .back-path{white-space:nowrap}#files .gcode_files .back .back-path span{word-wrap:break-word;white-space:pre-line}#files .upload-buttons{margin-top:10px}#files .form-search{text-align:center;margin-bottom:5px!important}#control{overflow:hidden}#control .jog-panel{float:left;margin-right:19px}#control h1{text-align:left}#control .jog-panel>div{text-align:center}#control .jog-panel>div.distance{text-align:left}#control .jog-panel .slider{margin-bottom:10px}#control .box{width:30px;height:30px;margin-right:10px;margin-bottom:10px;padding-left:8px}#control .control-box{display:block;height:30px;margin-bottom:10px}#control .btn-group{margin-bottom:10px}#control .btn-group.distance>.btn{width:43px;padding:3px 0;height:30px}#control .slider-handle{width:14px;height:14px;margin-left:-7px;margin-top:-3px}#control .custom_section h1{cursor:pointer}#control .custom_section_horizontal>.custom_control{display:inline-block}#control .custom_section_vertical>.custom_control{display:block}#control .custom_control .slider{margin-left:10px;margin-right:10px;margin-bottom:2px}#control .pulsate_text_opacity{animation:pulsate_input 1s ease-out;animation-iteration-count:infinite}@keyframes pulsate_input{0%{color:#555}50%{color:rgba(85,85,85,.2)}100%{color:#555}}#term .terminal{margin-bottom:30px}#term .terminal #terminal-output,#term .terminal #terminal-output-lowfi{min-height:340px;margin-bottom:5px}#settings_dialog .aboutlink,#settings_dialog .systeminfolink{float:left}#settings_dialog_menu,#wizard_dialog_menu{margin-left:0}#wizard_firstrun_acl .acl_decision{margin-top:1em}#wizard_firstrun_end p,#wizard_firstrun_start p{margin-bottom:1.5em;line-height:1.5}#settings_appearance_managelanguagesdialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_appearance_managelanguagesdialog_emptylist{overflow:hidden;width:100%;height:300px;text-align:center;display:table}#settings_appearance_managelanguagesdialog_emptylist div{display:table-cell;vertical-align:middle}#about_authors ul,#about_sponsors ul{columns:3;-webkit-columns:3;-moz-columns:3}.footer ul{margin:0}.footer ul li{display:inline;margin-left:1em;font-size:85%}.footer ul li:first-child{margin-left:0}.footer ul li a{color:#555}.footer #footer_links,.footer #footer_version{max-width:50%}#connection_protocol_dialog .control-group,#connection_transport_dialog .control-group{position:relative}#connection_protocol_dialog .control-undo,#connection_transport_dialog .control-undo{position:absolute;top:5px;right:0;line-height:20px;text-decoration:none;color:#000}#connection_protocol_dialog .control-undo.disabled,#connection_transport_dialog .control-undo.disabled{color:#ccc;cursor:default}#connection_protocol_dialog .controls,#connection_transport_dialog .controls{padding-right:20px}.ui-pnotify{position:fixed}.ui-pnotify .alert a{color:#c09853}.ui-pnotify .alert-danger a,.ui-pnotify .alert-error a{color:#b94a48}.ui-pnotify .alert-success a{color:#468847}.ui-pnotify .alert-info a{color:#3a87ad}.pnotify_additional_info .pnotify_more{font-size:85%}.text-right{text-align:right}.text-center{text-align:center}.text-block{display:block}.overflow_visible{overflow:visible!important}.clickable{cursor:pointer}.border_box{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none}textarea.block{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%}@keyframes pulsate{0%{opacity:.5}50%{opacity:1}100%{opacity:.5}}#drop_overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:10000;display:none}#drop_overlay.in{display:block}#drop_overlay #drop_overlay_background{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#000;filter:alpha(opacity=50);-moz-opacity:.5;-khtml-opacity:.5;opacity:.5}#drop_overlay #drop_overlay_wrapper{position:absolute;top:0;bottom:0;left:0;right:0;padding-top:60px}#drop_overlay #drop_overlay_wrapper #drop,#drop_overlay #drop_overlay_wrapper #drop_background{position:absolute;top:0;left:0;margin-left:0;width:100%}#drop_overlay #drop_overlay_wrapper #drop_locally,#drop_overlay #drop_overlay_wrapper #drop_locally_background{position:absolute;top:0;left:50%;margin-left:-50%;width:50%;border-right:2px dashed #ccc}#drop_overlay #drop_overlay_wrapper #drop_sd,#drop_overlay #drop_overlay_wrapper #drop_sd_background{position:absolute;top:0;left:50%;margin-left:0;width:50%;border-left:2px dashed #ccc}#drop_overlay #drop_overlay_wrapper .dropzone{height:100%;z-index:10001;color:#fff;font-size:30px}#drop_overlay #drop_overlay_wrapper .dropzone i{font-size:50px}#drop_overlay #drop_overlay_wrapper .dropzone .text{display:block;text-align:center;line-height:40px;position:absolute;width:100%;bottom:5%;filter:alpha(opacity=100);-moz-opacity:1;-khtml-opacity:1;opacity:1}#drop_overlay #drop_overlay_wrapper .dropzone_background{width:50%;height:100%;background-color:#000;filter:alpha(opacity=25);-moz-opacity:.25;-khtml-opacity:.25;opacity:.25}#drop_overlay #drop_overlay_wrapper .dropzone_background.hover{background-color:#000;filter:alpha(opacity=50);-moz-opacity:.5;-khtml-opacity:.5;opacity:.5}#drop_overlay #drop_overlay_wrapper .dropzone_background.fade{-webkit-transition:all .3s ease-out;-moz-transition:all .3s ease-out;-ms-transition:all .3s ease-out;-o-transition:all .3s ease-out;transition:all .3s ease-out;opacity:1}.center{float:none;margin-left:auto;margin-right:auto}.flipH{-webkit-transform:scaleX(-1);-moz-transform:scaleX(-1);-ms-transform:scaleX(-1);transform:scaleX(-1)}.flipV{-webkit-transform:scaleY(-1);-moz-transform:scaleY(-1);-ms-transform:scaleY(-1);transform:scaleY(-1)}.flipH.flipV{-webkit-transform:scaleX(-1) scaleY(-1);-moz-transform:scaleX(-1) scaleY(-1);-ms-transform:scaleX(-1) scaleY(-1);transform:scaleX(-1) scaleY(-1)}.rotate90{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.ui-pnotify a{text-decoration:underline}.btn-mini .caret,.btn-small .caret{margin-top:8px}.dropdown-menu-right{right:0;left:auto}.slider .slider-selection{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.slider .slider-selection.active,.slider .slider-selection.disabled,.slider .slider-selection:active,.slider .slider-selection:focus,.slider .slider-selection:hover,.slider .slider-selection[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.slider .slider-selection.active,.slider .slider-selection:active{background-color:#039 \9}.slider.slider-disabled .slider-selection{background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.slider .slider-track{background-color:#f5f5f5;border:1px solid #e3e3e3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05)}.slider.slider-disabled .slider-track{background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.slider .slider-handle{display:inline-block;*display:inline;*zoom:1;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);padding:0;margin-bottom:0;opacity:1;filter:alpha(opacity=100)}.slider .slider-handle.active,.slider .slider-handle.disabled,.slider .slider-handle:active,.slider .slider-handle:focus,.slider .slider-handle:hover,.slider .slider-handle[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.slider .slider-handle.active,.slider .slider-handle:active{background-color:#ccc \9}.slider .slider-handle:first-child{*margin-left:0}.slider .slider-handle:focus,.slider .slider-handle:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.slider .slider-handle:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.slider .slider-handle.active,.slider .slider-handle:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.slider .slider-handle.disabled,.slider .slider-handle[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.slider .slider-handle.hide{display:none}.slider .slider-handle.round{-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}.modal.large{width:975px;margin-left:-487px}.full-sized-box{position:absolute;bottom:0;left:0;right:0;top:0;padding:15px}.full-sized-box .row-fluid{height:100%}@media (max-width:979px){.full-sized-box{position:static}}:root .full-sized-box,_::-webkit-full-page-media,_:future{position:static}.safari ::-webkit-scrollbar{width:10px}.safari ::-webkit-scrollbar-track{border-radius:8px;-webkit-border-radius:8px}.safari ::-webkit-scrollbar-thumb{-webkit-border-radius:10px;border-radius:10px;background:rgba(100,100,100,.8)}.scrollable{height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.pre-output span{display:block}.input-append .add-on.add-on-limited,.input-prepend .add-on.add-on-limited{overflow-x:hidden;text-overflow:ellipsis;width:inherit}.input-append .btn-group:first-child .btn:first-child,.input-prepend .btn-group:first-child .btn:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append .btn-group .btn:first-child,.input-prepend .btn-group .btn:first-child{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-append.input-block-level,.input-prepend.input-block-level{display:table}.input-append.input-block-level .add-on,.input-prepend.input-block-level .add-on{display:table-cell;width:1%}.input-append.input-block-level>input,.input-prepend.input-block-level>input{box-sizing:border-box;display:table;min-height:inherit;width:100%}.input-append.input-block-level :not(:last-child),.input-prepend.input-block-level :not(:last-child){border-right:0}.control-group.error .input-append .fileinput-button,.control-group.error .input-prepend .fileinput-button{border-color:#b94a48}.control-text{padding-top:5px;cursor:default}input[type=number]{text-align:right}input[type=number].input-nospin::-webkit-inner-spin-button,input[type=number].input-nospin::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input[type=number].input-nospin{-moz-appearance:textfield}.dropdown-menu li a.disabled,.dropdown-menu li a.disabled:active,.dropdown-menu li a.disabled:hover,.dropdown-menu li a.disabled:visited{background-color:transparent;background-image:none;color:#aaa;cursor:default}textarea.monospace{font-family:monospace}.progress-text,.progress-text-centered{position:relative}.progress-text .progress-text-back,.progress-text .progress-text-front,.progress-text-centered .progress-text-back,.progress-text-centered .progress-text-front{white-space:nowrap}.progress-text .progress-text-front,.progress-text-centered .progress-text-front{box-sizing:border-box;padding:0 10px;width:100%;display:block}.progress-text .progress-text-back,.progress-text-centered .progress-text-back{position:absolute;font-size:12px;line-height:20px;display:block;box-sizing:border-box;text-align:center;padding:0 10px}.progress-text .bar,.progress-text-centered .bar{position:absolute;overflow:hidden}.progress-text-centered .progress-text-front{position:absolute;font-size:12px;line-height:20px;display:block;text-align:center;color:#fff}.progress-text-centered .progress-text-back{width:100%}.search-query-with-clear{position:relative}.search-query-with-clear .search-clear{display:inline-block;color:#ccc;position:absolute;right:28px;height:20px;padding:4px 0;cursor:pointer;visibility:hidden}.search-query-with-clear.active-clear .search-query{padding-right:28px;width:192px}.search-query-with-clear.active-clear .search-clear{visibility:visible}.search-query-with-clear input::-ms-clear{display:none}.search-query-with-clear input[type=search]::-webkit-search-cancel-button,.search-query-with-clear input[type=search]::-webkit-search-decoration,.search-query-with-clear input[type=search]::-webkit-search-results-button,.search-query-with-clear input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}#navbar_login:not(.open) #login_dropdown_loggedout{display:block;z-index:-1;height:0;width:0;padding:0!important;overflow:hidden;border:0;box-shadow:none;left:-9999px}#navbar_login:not(.open) #login_dropdown_loggedout.hide{display:none}#loginForm{margin:0}#loginForm button{margin-top:20px}#page-container-loading{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#fff;z-index:12301}#page-container-loading .wrapper{position:absolute;top:0;bottom:0;left:0;right:0}#page-container-loading .wrapper .outer{display:table;width:100%;height:100%}#page-container-loading .wrapper .outer .inner{display:table-cell;vertical-align:middle}#page-container-loading .wrapper .outer .inner .content{text-align:center}#page-container-noscript{position:fixed;top:0;left:0;width:100%;height:100%;background-color:#fff;z-index:12310}#page-container-noscript .wrapper{position:absolute;top:0;bottom:0;left:0;right:0}#page-container-noscript .wrapper .outer{display:table;width:100%;height:100%}#page-container-noscript .wrapper .outer .inner{display:table-cell;vertical-align:middle}#page-container-noscript .wrapper .outer .inner .content{text-align:center} \ No newline at end of file diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 165c7c601..4aa750eac 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -410,7 +410,8 @@ $(function () { self.addTerminalFilter = function () { self.terminalFilters.push({ name: "New", - regex: "(Send:\\s+(N\\d+\\s+)?M105)|(Recv:\\s+(ok\\s+)?.*(B|T\\d*):\\d+)" + regex: + "(Send:\\s+(N\\d+\\s+)?M105)|(Recv:\\s+(ok\\s+([PBN]\\d+\\s+)*)?.*([BCLPR]|T\\d*):-?\\d+)" }); }; @@ -774,7 +775,7 @@ $(function () { $(".reload_nonconflicts", self.settingsUpdatedDialog).click(function (e) { e.preventDefault(); self.settingsUpdatedDialog.modal("hide"); - self.requestData(undefined, true); + self.requestData(true); return false; }); @@ -843,14 +844,14 @@ $(function () { self.requestData = function (local) { // handle old parameter format var callback = undefined; - if (arguments.length == 2 || _.isFunction(local)) { + if (arguments.length === 2 || _.isFunction(local)) { var exc = new Error(); log.warn( "The callback parameter of SettingsViewModel.requestData is deprecated, the method now returns a promise, please use that instead. Stacktrace:", exc.stack || exc.stacktrace || "" ); - if (arguments.length == 2) { + if (arguments.length === 2) { callback = arguments[0]; local = arguments[1]; } else { diff --git a/src/octoprint/timelapse.py b/src/octoprint/timelapse.py index 637a78859..3117f9384 100644 --- a/src/octoprint/timelapse.py +++ b/src/octoprint/timelapse.py @@ -5,7 +5,6 @@ import collections import datetime import fnmatch import glob -import io import logging import os import queue @@ -201,7 +200,7 @@ def delete_unrendered_timelapse(name): except Exception: if logging.getLogger(__name__).isEnabledFor(logging.DEBUG): logging.getLogger(__name__).exception( - "Error while processing file {} during cleanup".format(entry.name) + f"Error while processing file {entry.name} during cleanup" ) @@ -259,14 +258,12 @@ def delete_old_unrendered_timelapses(): except Exception: if logging.getLogger(__name__).isEnabledFor(logging.DEBUG): logging.getLogger(__name__).exception( - "Error while processing file {} during cleanup".format(entry.name) + f"Error while processing file {entry.name} during cleanup" ) for prefix in prefixes_to_clean: delete_unrendered_timelapse(prefix) - logging.getLogger(__name__).info( - "Deleted old unrendered timelapse {}".format(prefix) - ) + logging.getLogger(__name__).info(f"Deleted old unrendered timelapse {prefix}") def _create_render_start_handler(name, gcode=None): @@ -682,7 +679,7 @@ class Timelapse: ) self._image_number += 1 - self._logger.debug("Capturing image to {}".format(filename)) + self._logger.debug(f"Capturing image to {filename}") entry = { "type": self.__class__.QUEUE_ENTRY_TYPE_CAPTURE, "filename": filename, @@ -728,9 +725,7 @@ class Timelapse: eventManager().fire(Events.CAPTURE_START, {"file": filename}) try: - self._logger.debug( - "Going to capture {} from {}".format(filename, self._snapshot_url) - ) + self._logger.debug(f"Going to capture {filename} from {self._snapshot_url}") r = requests.get( self._snapshot_url, stream=True, @@ -739,18 +734,16 @@ class Timelapse: ) r.raise_for_status() - with io.open(filename, "wb") as f: + with open(filename, "wb") as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) f.flush() - self._logger.debug( - "Image {} captured from {}".format(filename, self._snapshot_url) - ) + self._logger.debug(f"Image {filename} captured from {self._snapshot_url}") except Exception as e: self._logger.exception( - "Could not capture image {} from {}".format(filename, self._snapshot_url) + f"Could not capture image {filename} from {self._snapshot_url}" ) self._capture_errors += 1 err = e @@ -993,7 +986,7 @@ class TimelapseRenderJob: postfix=self._postfix if self._postfix is not None else "", extension=extension, ) - temporary = os.path.join(self._output_dir, ".{}".format(output_name)) + temporary = os.path.join(self._output_dir, f".{output_name}") output = os.path.join(self._output_dir, output_name) for i in range(4): @@ -1034,7 +1027,7 @@ class TimelapseRenderJob: rotate=rotate, watermark=watermark, ) - self._logger.debug("Executing command: {}".format(command_str)) + self._logger.debug(f"Executing command: {command_str}") with self.render_job_lock: try: @@ -1075,7 +1068,7 @@ class TimelapseRenderJob: os.remove(temporary) except Exception: self._logger.warning( - "Could not delete temporary timelapse {}".format(temporary) + f"Could not delete temporary timelapse {temporary}" ) self._notify_callback("always", output) @@ -1155,7 +1148,7 @@ class TimelapseRenderJob: "-framerate", str(fps), "-i", - '"{}"'.format(input), + f'"{input}"', "-vcodec", videocodec, "-threads", @@ -1174,12 +1167,12 @@ class TimelapseRenderJob: ) if filter_string is not None: - logger.debug("Applying videofilter chain: {}".format(filter_string)) + logger.debug(f"Applying videofilter chain: {filter_string}") command.extend(["-vf", sarge.shell_quote(filter_string)]) # finalize command with output file - logger.debug("Rendering movie to {}".format(output)) - command.append('"{}"'.format(output)) + logger.debug(f"Rendering movie to {output}") + command.append(f'"{output}"') return " ".join(command) @@ -1204,7 +1197,7 @@ class TimelapseRenderJob: ### See unit tests in test/timelapse/test_timelapse_renderjob.py # apply pixel format - filters = ["format={}".format(pixfmt)] + filters = [f"format={pixfmt}"] # flip video if configured if hflip: @@ -1236,7 +1229,7 @@ class TimelapseRenderJob: def _notify_callback(self, callback, *args, **kwargs): """Notifies registered callbacks of type `callback`.""" - name = "_on_{}".format(callback) + name = f"_on_{callback}" method = getattr(self, name, None) if method is not None and callable(method): method(*args, **kwargs) diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index 84e94c7fb..4d6aa5118 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -10,7 +10,6 @@ import collections import contextlib import copy import glob -import io import logging import os import queue @@ -22,10 +21,11 @@ import threading import time import traceback import warnings +from collections.abc import Iterable, MutableMapping, Set from functools import wraps from typing import Union -import frozendict +from immutabledict import immutabledict from octoprint import UMASK from octoprint.util.connectivity import ConnectivityChecker # noqa: F401 @@ -338,9 +338,9 @@ def get_formatted_size(num): for x in ["B", "KB", "MB", "GB"]: if num < 1024: - return "%3.1f%s" % (num, x) + return f"{num:3.1f}{x}" num /= 1024 - return "%3.1f%s" % (num, "TB") + return "{:3.1f}{}".format(num, "TB") def is_allowed_file(filename, extensions): @@ -975,7 +975,7 @@ def dict_flatten(dictionary, prefix="", separator="."): result = {} for k, v in dictionary.items(): key = prefix + separator + k if prefix else k - if isinstance(v, collections.MutableMapping): + if isinstance(v, MutableMapping): result.update(dict_flatten(v, prefix=key, separator=separator)) else: result[key] = v @@ -1119,7 +1119,7 @@ class DefaultOrderedDict(collections.OrderedDict): # noinspection PyMethodOverriding def __repr__(self): - return "OrderedDefaultDict(%s, %s)" % ( + return "OrderedDefaultDict({}, {})".format( self.default_factory, collections.OrderedDict.__repr__(self), ) @@ -1257,7 +1257,7 @@ else: os.remove(self._path) except Exception as exc: logging.getLogger(__name__).warning( - "Could not delete temporary directory {}: {}".format(self.name, exc) + f"Could not delete temporary directory {self.name}: {exc}" ) def __enter__(self): @@ -1283,13 +1283,13 @@ def bom_aware_open(filename, encoding="ascii", mode="r", **kwargs): # these encodings might have a BOM, so let's see if there is one bom = getattr(codecs, potential_bom_attribute) - with io.open(filename, mode="rb") as f: + with open(filename, mode="rb") as f: header = f.read(4) if header.startswith(bom): encoding += "-sig" - return io.open(filename, encoding=encoding, mode=mode, **kwargs) + return open(filename, encoding=encoding, mode=mode, **kwargs) def is_hidden_path(path): @@ -1327,15 +1327,15 @@ glob_escape = deprecated( )(glob.escape) -def thaw_frozendict(obj): - if not isinstance(obj, (dict, frozendict.frozendict)): - raise ValueError("obj must be a dict or frozendict instance") +def thaw_immutabledict(obj): + if not isinstance(obj, (dict, immutabledict)): + raise ValueError("obj must be a dict or immutabledict instance") # only true love can thaw a frozen dict letitgo = {} for key, value in obj.items(): - if isinstance(value, (dict, frozendict.frozendict)): - letitgo[key] = thaw_frozendict(value) + if isinstance(value, (dict, immutabledict)): + letitgo[key] = thaw_immutabledict(value) else: letitgo[key] = copy.deepcopy(value) return letitgo @@ -1683,7 +1683,6 @@ class CountedEvent: class InvariantContainer: def __init__(self, initial_data=None, guarantee_invariant=None): - from collections.abc import Iterable from threading import RLock if guarantee_invariant is None: @@ -1778,7 +1777,7 @@ class TypedQueue(PrependableQueue): if item_type is not None: if item_type in self._lookup: raise TypeAlreadyInQueue( - item_type, "Type {} is already in queue".format(item_type) + item_type, f"Type {item_type} is already in queue" ) else: self._lookup.add(item_type) @@ -1799,7 +1798,7 @@ class TypedQueue(PrependableQueue): if item_type is not None: if item_type in self._lookup: raise TypeAlreadyInQueue( - item_type, "Type {} is already in queue".format(item_type) + item_type, f"Type {item_type} is already in queue" ) else: self._lookup.add(item_type) @@ -1897,12 +1896,12 @@ class protectedkeydict(collections.MutableMapping): def __setitem__(self, key, value): if key in self.protected_keys: - raise KeyError("Cannot set protected key {!r}".format(key)) + raise KeyError(f"Cannot set protected key {key!r}") self.data[key] = value def __delitem__(self, key): if key in self.protected_keys: - raise KeyError("Cannot delete protected key {!r}".format(key)) + raise KeyError(f"Cannot delete protected key {key!r}") def _get_item(self, key): if key not in self.protected_keys: @@ -1920,7 +1919,7 @@ class protectedkeydict(collections.MutableMapping): return value -class CaseInsensitiveSet(collections.Set): +class CaseInsensitiveSet(Set): """ Basic case insensitive set @@ -1963,7 +1962,7 @@ def fqfn(f): f.__self__.__class__.__module__, f.__self__.__class__.__name__, f.__name__ ) else: - return "{}.{}".format(f.__module__, f.__name__) + return f"{f.__module__}.{f.__name__}" def time_this( @@ -1971,33 +1970,38 @@ def time_this( expand_logtarget=False, message="{func} took {timing:.2f}ms", incl_func_args=False, + log_enter=False, + message_enter="Entering {func}...", ): def decorator(f): + func = fqfn(f) + + lt = logtarget + if expand_logtarget: + lt += "." + func + + logger = logging.getLogger(lt) + @wraps(f) def wrapper(*args, **kwargs): + data = {"func": func, "func_args": "?", "func_kwargs": "?"} + if incl_func_args and logger.isEnabledFor(logging.DEBUG): + data.update( + func_args=",".join(map(repr, args)), + func_kwargs=",".join( + map(lambda x: "{}={!r}".format(x[0], x[1]), kwargs.items()) + ), + ) + if log_enter: + logger.debug(message_enter.format(**data), extra=data) + start = time.time() try: return f(*args, **kwargs) finally: timing = (time.time() - start) * 1000 - func = fqfn(f) - - lt = logtarget - if expand_logtarget: - lt += "." + func - - logger = logging.getLogger(lt) if logger.isEnabledFor(logging.DEBUG): - data = {"func": func, "timing": timing} - if incl_func_args: - data.update( - func_args=",".join(map(repr, args)), - func_kwargs=",".join( - map( - lambda x: "{}={!r}".format(x[0], x[1]), kwargs.items() - ) - ), - ) + data.update(timing=timing) logger.debug(message.format(**data), extra=data) return wrapper diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 154255124..e0cee3e0d 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -158,9 +158,7 @@ Groups will be as follows: * ``es``: multiple E coordinates if present, to be parsed further with regex_e_positions """ -regex_e_positions = re.compile( - r"E(?P\d+):\s*(?P{float})".format(float=regex_float_pattern) -) +regex_e_positions = re.compile(fr"E(?P\d+):\s*(?P{regex_float_pattern})") """Regex for matching multiple E coordinates in a position report. Groups will be as follows: @@ -248,7 +246,7 @@ def baudrateList(candidates=None): candidates.insert(0, int(additional)) except Exception: _logger.warning( - "{} is not a valid additional baudrate, ignoring it".format(additional) + f"{additional} is not a valid additional baudrate, ignoring it" ) # blacklisted baudrates @@ -354,7 +352,7 @@ class TemperatureRecord: def set_custom(self, identifier, actual=None, target=None): if self.RESERVED_IDENTIFIER_REGEX.match(identifier): - raise ValueError("{} is a reserved identifier".format(identifier)) + raise ValueError(f"{identifier} is a reserved identifier") current = self._custom.get(identifier, (None, None)) self._custom[identifier] = self._to_new_tuple(current, actual, target) @@ -869,7 +867,7 @@ class MachineCom: def _to_logfile_with_terminal(self, message=None, level=logging.INFO): log = "Last lines in terminal:\n" + "\n".join( - map(lambda x: "| {}".format(x), list(self._terminal_log)) + map(lambda x: f"| {x}", list(self._terminal_log)) ) if message is not None: log = message + "\n| " + log @@ -942,7 +940,7 @@ class MachineCom: return "Offline after error" elif state == self.STATE_TRANSFERING_FILE: return "Transferring file to SD" - return "Unknown State ({})".format(self._state) + return f"Unknown State ({self._state})" def getErrorString(self): return self._errorValue @@ -1305,7 +1303,7 @@ class MachineCom: else: return None - additional_tags = {"plugin:{}".format(name)} + additional_tags = {f"plugin:{name}"} if len(retval) == 4: additional_tags |= set(retval[3]) @@ -1356,7 +1354,7 @@ class MachineCom: tags_to_use = tags | { "trigger:comm.send_gcode_script", "source:script", - "script:{}".format(scriptName), + f"script:{scriptName}", } for line in scriptLines: if ( @@ -1401,7 +1399,7 @@ class MachineCom: "Starting job on behalf of plugin {}".format(tag[7:]) ) elif "source:api" in tags: - self._logger.info("Starting job on behalf of user {}".format(user)) + self._logger.info(f"Starting job on behalf of user {user}") try: with self._jobLock: @@ -1435,7 +1433,7 @@ class MachineCom: if pos is not None and isinstance(pos, int) and pos > 0: self._currentFile.pos = pos self.sendCommand( - "M26 S{}".format(pos), + f"M26 S{pos}", part_of_job=True, tags=tags | { @@ -1650,7 +1648,7 @@ class MachineCom: "Cancelling job on behalf of plugin {}".format(tag[7:]) ) elif "source:api" in tags: - self._logger.info("Cancelling job on behalf of user {}".format(user)) + self._logger.info(f"Cancelling job on behalf of user {user}") if self.isStreaming(): # we are streaming, we handle cancelling that differently... @@ -1787,7 +1785,7 @@ class MachineCom: "Pausing/resuming job on behalf of plugin {}".format(tag[7:]) ) elif user: - self._logger.info("Pausing/resuming job on behalf of user {}".format(user)) + self._logger.info(f"Pausing/resuming job on behalf of user {user}") valid_paused_states = (self.STATE_PAUSED, self.STATE_PAUSING) valid_running_states = ( @@ -2005,7 +2003,7 @@ class MachineCom: tags = set() self.sendCommand( - "M110 N{}".format(number), + f"M110 N{number}", part_of_job=part_of_job, tags=tags | { @@ -2052,7 +2050,7 @@ class MachineCom: return except Exception: self._logger.exception( - "Error while processing temperatures in {}, skipping".format(name), + f"Error while processing temperatures in {name}, skipping", extra={"plugin": name}, ) @@ -2272,6 +2270,19 @@ class MachineCom: elif action_name == "disconnect": self._log("Disconnecting on request of the printer...") self._callback.on_comm_force_disconnect() + elif self._sdEnabled and action_name == "sd_inserted": + self._log("Printer reported SD card as inserted") + self._sdAvailable = True + self.refreshSdFiles() + self._callback.on_comm_sd_state_change(self._sdAvailable) + elif self._sdEnabled and action_name == "sd_ejected": + self._log("Printer reported SD card as ejected") + self._sdAvailable = False + self._sdFiles = [] + self._callback.on_comm_sd_state_change(self._sdAvailable) + elif self._sdEnabled and action_name == "sd_updated": + self._log("Printer reported a change on the SD card") + self.refreshSdFiles() else: for name, hook in self._printer_action_hooks.items(): try: @@ -2310,7 +2321,7 @@ class MachineCom: ##~~ SD file list # if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing - if self._sdFileList and "End file list" not in line: + if self._sdEnabled and self._sdFileList and "End file list" not in line: preprocessed_line = line fileinfo = preprocessed_line.split(None, 2) if len(fileinfo) == 3: @@ -2462,7 +2473,7 @@ class MachineCom: else: # multiple extruder coordinates provided, find current one self.last_position.e = ( - parsed.get("e{}".format(self._currentTool)) + parsed.get(f"e{self._currentTool}") if not self.isSdFileSelected() else None ) @@ -2590,7 +2601,7 @@ class MachineCom: if not self._firmware_info_received and firmware_name: firmware_name = firmware_name.strip() self._logger.info( - 'Printer reports firmware name "{}"'.format(firmware_name) + f'Printer reports firmware name "{firmware_name}"' ) if self._firmware_detection: @@ -2755,7 +2766,7 @@ class MachineCom: # we actually do send a T command here instead of just settings self._currentTool just in case # we had any scripts or plugins modify stuff due to the prior tool change self.sendCommand( - "T{}".format(fallback_tool), + f"T{fallback_tool}", tags={ "trigger:revert_invalid_tool", }, @@ -2770,140 +2781,145 @@ class MachineCom: ) ##~~ SD Card handling - elif ( - "SD init fail" in line - or "volume.init failed" in line - or "openRoot failed" in line - ): - self._sdAvailable = False - self._sdFiles = [] - self._callback.on_comm_sd_state_change(self._sdAvailable) - elif "SD card ok" in line and not self._sdAvailable: - self._sdAvailable = True - self.refreshSdFiles() - self._callback.on_comm_sd_state_change(self._sdAvailable) - elif "Begin file list" in line: - self._sdFiles = [] - self._sdFileList = True - elif "End file list" in line: - self._sdFileList = False - self._callback.on_comm_sd_files(self.getSdFiles()) - elif "SD printing byte" in line: - # answer to M27, at least on Marlin, Repetier and Sprinter: "SD printing byte %d/%d" - match = regex_sdPrintingByte.search(line) - if match: - try: - current = int(match.group("current")) - total = int(match.group("total")) - except Exception: - self._logger.exception("Error while parsing SD status report") - else: - if ( - current == total == 0 - and self.isSdPrinting() - and not self.isStarting() - and not self.isStarting() - and not self.isFinishing() - ): - # apparently not SD printing - some Marlin versions report it like that for some reason - self._consecutive_not_sd_printing += 1 - if ( - self._consecutive_not_sd_printing - > self._consecutive_not_sd_printing_maximum - ): - self.cancelPrint(external_sd=True) - - 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. - if ( - not self.isSdPrinting() - and current != total - and current > 0 - and self._currentFile - and current > self._currentFile.pos - ): - self.startPrint(external_sd=True) - - self._currentFile.pos = current - if self._currentFile.size == 0: - self._currentFile.size = total - - if not self._currentFile.done: - self._callback.on_comm_progress() - elif ( - "Not SD printing" in line - and self.isSdPrinting() - and not self.isStarting() - and not self.isFinishing() - ): - self._consecutive_not_sd_printing += 1 + elif self._sdEnabled: if ( - self._consecutive_not_sd_printing - > self._consecutive_not_sd_printing_maximum + "SD init fail" in line + or "volume.init failed" in line + or "openRoot failed" in line ): - # something went wrong, printer is reporting that we actually are not printing right now... - self.cancelPrint(external_sd=True) - elif "File opened" in line and not self._ignore_select: - # answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d" - match = regex_sdFileOpened.search(line) - if match: - name = match.group("name") - size = int(match.group("size")) - else: - name = "Unknown" - size = 0 - user = None + self._sdAvailable = False + self._sdFiles = [] + self._callback.on_comm_sd_state_change(self._sdAvailable) + elif "SD card ok" in line and not self._sdAvailable: + self._sdAvailable = True + self.refreshSdFiles() + self._callback.on_comm_sd_state_change(self._sdAvailable) + elif "Begin file list" in line: + self._sdFiles = [] + self._sdFileList = True + elif "End file list" in line: + self._sdFileList = False + self._callback.on_comm_sd_files(self.getSdFiles()) + elif "SD printing byte" in line: + # answer to M27, at least on Marlin, Repetier and Sprinter: "SD printing byte %d/%d" + match = regex_sdPrintingByte.search(line) + if match: + try: + current = int(match.group("current")) + total = int(match.group("total")) + except Exception: + self._logger.exception( + "Error while parsing SD status report" + ) + else: + if ( + current == total == 0 + and self.isSdPrinting() + and not self.isStarting() + and not self.isStarting() + and not self.isFinishing() + ): + # apparently not SD printing - some Marlin versions report it like that for some reason + self._consecutive_not_sd_printing += 1 + if ( + self._consecutive_not_sd_printing + > self._consecutive_not_sd_printing_maximum + ): + self.cancelPrint(external_sd=True) - if self._sdFileToSelect: - name = self._sdFileToSelect - user = self._sdFileToSelectUser + else: + self._consecutive_not_sd_printing = 0 + if self.isSdFileSelected(): - self._sdFileToSelect = None - self._sdFileToSelectUser = None + # 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. + if ( + not self.isSdPrinting() + and current != total + and current > 0 + and self._currentFile + and current > self._currentFile.pos + ): + self.startPrint(external_sd=True) - self._currentFile = PrintingSdFileInformation(name, size, user=user) - elif "File selected" in line: - if self._ignore_select: - self._ignore_select = False - elif self._currentFile is not None and self.isSdFileSelected(): - # final answer to M23, at least on Marlin, Repetier and Sprinter: "File selected" - self._callback.on_comm_file_selected( - self._currentFile.getFilename(), - self._currentFile.getFilesize(), - True, - user=self._currentFile.getUser(), + self._currentFile.pos = current + if self._currentFile.size == 0: + self._currentFile.size = total + + if not self._currentFile.done: + self._callback.on_comm_progress() + elif ( + "Not SD printing" in line + and self.isSdPrinting() + and not self.isStarting() + and not self.isFinishing() + ): + self._consecutive_not_sd_printing += 1 + if ( + self._consecutive_not_sd_printing + > self._consecutive_not_sd_printing_maximum + ): + # something went wrong, printer is reporting that we actually are not printing right now... + self.cancelPrint(external_sd=True) + elif "File opened" in line and not self._ignore_select: + # answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d" + match = regex_sdFileOpened.search(line) + if match: + name = match.group("name") + size = int(match.group("size")) + else: + name = "Unknown" + size = 0 + user = None + + if self._sdFileToSelect: + name = self._sdFileToSelect + user = self._sdFileToSelectUser + + self._sdFileToSelect = None + self._sdFileToSelectUser = None + + self._currentFile = PrintingSdFileInformation( + name, size, user=user ) - elif "Writing to file" in line and self.isStreaming(): - self._changeState(self.STATE_PRINTING) - elif "Done printing file" in line and self.isSdPrinting(): - # printer is reporting file finished printing - self._changeState(self.STATE_FINISHING) + elif "File selected" in line: + if self._ignore_select: + self._ignore_select = False + elif self._currentFile is not None and self.isSdFileSelected(): + # final answer to M23, at least on Marlin, Repetier and Sprinter: "File selected" + self._callback.on_comm_file_selected( + self._currentFile.getFilename(), + self._currentFile.getFilesize(), + True, + user=self._currentFile.getUser(), + ) + elif "Writing to file" in line and self.isStreaming(): + self._changeState(self.STATE_PRINTING) + elif "Done printing file" in line and self.isSdPrinting(): + # printer is reporting file finished printing + self._changeState(self.STATE_FINISHING) - self._currentFile.done = True - self._currentFile.pos = 0 + self._currentFile.done = True + self._currentFile.pos = 0 - self.sendCommand("M400", part_of_job=True) - self._callback.on_comm_print_job_done() + self.sendCommand("M400", part_of_job=True) + self._callback.on_comm_print_job_done() - def finalize(): - self._changeState(self.STATE_OPERATIONAL) + def finalize(): + self._changeState(self.STATE_OPERATIONAL) - self.sendCommand(SendQueueMarker(finalize), part_of_job=True) - self._continue_sending() - elif "Done saving file" in line: - if self._trigger_ok_for_m29: - # workaround for most versions of Marlin out in the wild - # not sending an ok after saving a file + self.sendCommand(SendQueueMarker(finalize), part_of_job=True) + self._continue_sending() + elif "Done saving file" in line: + if self._trigger_ok_for_m29: + # workaround for most versions of Marlin out in the wild + # not sending an ok after saving a file + self._handle_ok() + elif "File deleted" in line and line.strip().endswith("ok"): + # buggy Marlin version that doesn't send a proper line break after the "File deleted" statement, fixed in + # current versions self._handle_ok() - elif "File deleted" in line and line.strip().endswith("ok"): - # buggy Marlin version that doesn't send a proper line break after the "File deleted" statement, fixed in - # current versions - self._handle_ok() ##~~ Message handling self._callback.on_comm_message(line) @@ -3074,9 +3090,7 @@ class MachineCom: # now increment the timeout counter self._consecutive_timeouts += 1 - self._logger.debug( - "Now at {} consecutive timeouts".format(self._consecutive_timeouts) - ) + self._logger.debug(f"Now at {self._consecutive_timeouts} consecutive timeouts") if 0 < consecutive_max < self._consecutive_timeouts: # too many consecutive timeouts, we give up @@ -3133,7 +3147,7 @@ class MachineCom: def _perform_detection_step(self, init=False): def log(message): self._log(message) - self._logger.info("Serial detection: {}".format(message)) + self._logger.info(f"Serial detection: {message}") if init: port = self._port @@ -3191,7 +3205,7 @@ class MachineCom: ) ) self._logger.exception( - "Unexpected error while setting timeout {}".format(timeout) + f"Unexpected error while setting timeout {timeout}" ) else: self._do_send_without_checksum(b"", log=False) # new line to reset things @@ -3220,7 +3234,7 @@ class MachineCom: (p, b) = self._detection_candidates.pop(0) try: - log("Trying port {}, baudrate {}".format(p, b)) + log(f"Trying port {p}, baudrate {b}") if self._serial is None or self._serial.port != p: if not self._open_serial(p, b, trigger_errors=False): log( @@ -3243,9 +3257,7 @@ class MachineCom: b, get_exception_string() ) ) - self._logger.exception( - "Unexpected error while setting baudrate {}".format(b) - ) + self._logger.exception(f"Unexpected error while setting baudrate {b}") error_text = "No more candidates to test, and no working port/baudrate combination detected." self._trigger_error(error_text, "autodetect") @@ -3405,7 +3417,7 @@ class MachineCom: except Exception: interval = 2 self.sendCommand( - "M155 S{}".format(interval), + f"M155 S{interval}", tags={"trigger:comm.set_autoreport_temperature_interval"}, ) @@ -3416,7 +3428,7 @@ class MachineCom: except Exception: interval = 1 self.sendCommand( - "M27 S{}".format(interval), + f"M27 S{interval}", tags={"trigger:comm.set_autoreport_sdstatus_interval"}, ) @@ -3429,7 +3441,7 @@ class MachineCom: except Exception: interval = 2 self.sendCommand( - "M113 S{}".format(interval), + f"M113 S{interval}", tags={"trigger:comm.set_busy_protocol_interval"}, on_sent=callback, ) @@ -3601,7 +3613,7 @@ class MachineCom: def default(_, p, b, timeout): # connect to regular serial port self._dual_log( - "Connecting to port {}, baudrate {}".format(port, baudrate), + f"Connecting to port {port}, baudrate {baudrate}", level=logging.INFO, ) @@ -3841,8 +3853,8 @@ class MachineCom: try: self._log("Recv: {}".format(sanitize_ascii(ret))) except ValueError as e: - self._log("WARN: While reading last line: {}".format(e)) - self._log("Recv: {!r}".format(ret)) + self._log(f"WARN: While reading last line: {e}") + self._log(f"Recv: {ret!r}") if null_pos >= 0: self._logger.warning("Received line:") @@ -3925,8 +3937,8 @@ class MachineCom: line, tags={ "source:file", - "filepos:{}".format(pos), - "fileline:{}".format(lineno), + f"filepos:{pos}", + f"fileline:{lineno}", }, ) self._callback.on_comm_progress() @@ -4419,7 +4431,7 @@ class MachineCom: def _log_command_phase(self, phase, command, *args, **kwargs): if self._phaseLogger.isEnabledFor(logging.DEBUG): output_parts = [ - "phase: {}".format(phase), + f"phase: {phase}", "command: {}".format(to_unicode(command, errors="replace")), ] @@ -4494,8 +4506,8 @@ class MachineCom: hook_results, tags_to_add={ "source:rewrite", - "phase:{}".format(phase), - "plugin:{}".format(name), + f"phase:{phase}", + f"plugin:{name}", }, ) @@ -4598,7 +4610,7 @@ class MachineCom: ) # trigger built-in handler if available - handler = getattr(self, "_atcommand_{}_{}".format(atcommand, phase), None) + handler = getattr(self, f"_atcommand_{atcommand}_{phase}", None) if callable(handler): try: handler(atcommand, parameters, tags=tags) @@ -4931,7 +4943,7 @@ class MachineCom: wait=False, support_r=False, *args, - **kwargs + **kwargs, ): toolNum = self._currentTool toolMatch = regexes_parameters["intT"].search(cmd) @@ -4969,7 +4981,7 @@ class MachineCom: wait=False, support_r=False, *args, - **kwargs + **kwargs, ): match = regexes_parameters["floatS"].search(cmd) if not match and support_r: @@ -4997,7 +5009,7 @@ class MachineCom: wait=False, support_r=False, *args, - **kwargs + **kwargs, ): match = regexes_parameters["floatS"].search(cmd) if not match and support_r: @@ -5087,7 +5099,7 @@ class MachineCom: with self._line_mutex: self._logger.info( - "M110 detected, setting current line number to {}".format(newLineNumber) + f"M110 detected, setting current line number to {newLineNumber}" ) # send M110 command with new line number @@ -5115,9 +5127,7 @@ class MachineCom: for tool in range( self._printerProfileManager.get_current_or_default()["extruder"]["count"] ): - self._do_increment_and_send_with_checksum( - "M104 T{tool} S0".format(tool=tool).encode("ascii") - ) + self._do_increment_and_send_with_checksum(f"M104 T{tool} S0".encode("ascii")) if self._printerProfileManager.get_current_or_default()["heatedBed"]: self._do_increment_and_send_with_checksum(b"M140 S0") @@ -5222,10 +5232,10 @@ class MachineCom: if gcode in self._emergency_commands and gcode != "M112": return self._emergency_force_send( cmd, - "Force-sending {} to the printer".format(gcode), + f"Force-sending {gcode} to the printer", gcode=gcode, *args, - **kwargs + **kwargs, ) if ( @@ -5234,7 +5244,7 @@ class MachineCom: and "trigger:cancel" not in tags and "trigger:pause" not in tags ): - self._logger.info("Pausing print job due to command {}".format(gcode)) + self._logger.info(f"Pausing print job due to command {gcode}") self.setPause(True) if gcode in self._blocked_commands: @@ -5515,9 +5525,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation): """ with self._handle_mutex: if self._handle is None: - self._logger.warning( - "File {} is not open for reading".format(self._filename) - ) + self._logger.warning(f"File {self._filename} is not open for reading") return None, None, None try: @@ -5563,7 +5571,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation): def _report_stats(self): duration = time.monotonic() - self._start_time - self._logger.info("Finished in {:.3f} s.".format(duration)) + self._logger.info(f"Finished in {duration:.3f} s.") pass @@ -5731,7 +5739,7 @@ class SendQueue(PrependableQueue): if item_type is not None: if item_type in self._lookup: raise TypeAlreadyInQueue( - item_type, "Type {} is already in queue".format(item_type) + item_type, f"Type {item_type} is already in queue" ) else: self._lookup.add(item_type) @@ -5748,7 +5756,7 @@ class SendQueue(PrependableQueue): if item_type is not None: if item_type in self._lookup: raise TypeAlreadyInQueue( - item_type, "Type {} is already in queue".format(item_type) + item_type, f"Type {item_type} is already in queue" ) else: self._lookup.add(item_type) @@ -5879,11 +5887,7 @@ def convert_pause_triggers(configured_triggers): for t in triggers.keys(): if len(triggers[t]) > 0: result[t] = re.compile( - "|".join( - map( - lambda pattern: "({pattern})".format(pattern=pattern), triggers[t] - ) - ) + "|".join(map(lambda pattern: f"({pattern})", triggers[t])) ) return result @@ -6500,14 +6504,12 @@ def upload_cli(): def on_comm_file_transfer_started(self, filename, filesize, user=None): # transfer started, report - _logger.info( - "Started file transfer of {}, size {}B".format(filename, filesize) - ) + _logger.info(f"Started file transfer of {filename}, size {filesize}B") self.started = True def on_comm_file_transfer_done(self, filename): # transfer done, report, print stats and finish - _logger.info("Finished file transfer of {}".format(filename)) + _logger.info(f"Finished file transfer of {filename}") self.finished.set() def on_comm_state_change(self, state): diff --git a/src/octoprint/util/commandline.py b/src/octoprint/util/commandline.py index 809c8d26d..68b58b1ec 100644 --- a/src/octoprint/util/commandline.py +++ b/src/octoprint/util/commandline.py @@ -162,7 +162,7 @@ class CommandlineCaller: joined_command = " ".join(command) else: joined_command = command - self._logger.debug("Calling: {}".format(joined_command)) + self._logger.debug(f"Calling: {joined_command}") self.on_log_call(joined_command) delimiter = kwargs.get("delimiter", b"\n") @@ -200,9 +200,7 @@ class CommandlineCaller: if not p.commands[0].process: # the process might have been set to None in case of any exception - self._logger.error( - "Error while trying to run command {}".format(joined_command) - ) + self._logger.error(f"Error while trying to run command {joined_command}") return None, [], [] all_stdout = [] diff --git a/src/octoprint/util/connectivity.py b/src/octoprint/util/connectivity.py index 8059c90cf..eaa39267c 100644 --- a/src/octoprint/util/connectivity.py +++ b/src/octoprint/util/connectivity.py @@ -168,7 +168,7 @@ class ConnectivityChecker: "online": self.online, "enabled": self.enabled, "connection_ok": self._connection_working, - "connection_check": "{}:{}".format(self._host, self._port), + "connection_check": f"{self._host}:{self._port}", } if self._name: result.update( @@ -208,9 +208,7 @@ class ConnectivityChecker: if self._name: if connection_working: - self._logger.debug( - "Checking if we can resolve {}...".format(self._name) - ) + self._logger.debug(f"Checking if we can resolve {self._name}...") resolution_working = len(resolve_host(self._name)) > 0 else: resolution_working = False diff --git a/src/octoprint/util/dev.py b/src/octoprint/util/dev.py index 7100747cc..d3270a431 100644 --- a/src/octoprint/util/dev.py +++ b/src/octoprint/util/dev.py @@ -67,7 +67,7 @@ def log_duration(log=None, with_args=False): arguments = "".join([args_str, sep, kwargs_str]) else: arguments = "..." - context = "{name}({arguments})".format(name=f.__name__, arguments=arguments) + context = f"{f.__name__}({arguments})" with duration_log(context=context, log=log): return f(*args, **kwargs) diff --git a/src/octoprint/util/gcodeInterpreter.py b/src/octoprint/util/gcodeInterpreter.py index 33ec56344..fccdc25e9 100644 --- a/src/octoprint/util/gcodeInterpreter.py +++ b/src/octoprint/util/gcodeInterpreter.py @@ -143,11 +143,33 @@ class MinMax3D: >>> empty = MinMax3D() >>> empty.size == Vector3D(0.0, 0.0, 0.0) True + >>> weird = MinMax3D(min_z=-1.0) + >>> weird.record(Vector3D(2.0, 2.0, 2.0)) + >>> weird.record(Vector3D(1.0, 2.0, 3.0)) + >>> weird.min.z == -1.0 + True + >>> weird.size == Vector3D(1.0, 0.0, 4.0) + True """ - def __init__(self): - self.min = Vector3D(float("inf"), float("inf"), float("inf")) - self.max = Vector3D(-float("inf"), -float("inf"), -float("inf")) + def __init__( + self, + min_x=None, + min_y=None, + min_z=None, + max_x=None, + max_y=None, + max_z=None, + ): + min_x = min_x if min_x is not None else float("inf") + min_y = min_y if min_y is not None else float("inf") + min_z = min_z if min_z is not None else float("inf") + max_x = max_x if max_x is not None else -float("inf") + max_y = max_y if max_y is not None else -float("inf") + max_z = max_z if max_z is not None else -float("inf") + + self.min = Vector3D(min_x, min_y, min_z) + self.max = Vector3D(max_x, max_y, max_z) def record(self, coordinate): """ @@ -224,7 +246,9 @@ class gcode: offsets=None, max_extruders=10, g90_extruder=False, + bed_z=0.0, ): + self._minMax.min.z = bed_z if os.path.isfile(filename): self.filename = filename self._fileSize = os.stat(filename).st_size @@ -445,17 +469,17 @@ class gcode: x = getCodeFloat(line, "X") y = getCodeFloat(line, "Y") z = getCodeFloat(line, "Z") - center = Vector3D(0.0, 0.0, 0.0) + origin = Vector3D(0.0, 0.0, 0.0) if x is None and y is None and z is None: - pos = center + pos = origin else: pos = Vector3D(pos) if x is not None: - pos.x = center.x + pos.x = origin.x if y is not None: - pos.y = center.y + pos.y = origin.y if z is not None: - pos.z = center.z + pos.z = origin.z elif gcode == "G90": # Absolute position relativeMode = False if g90_extruder: diff --git a/src/octoprint/util/json/__init__.py b/src/octoprint/util/json/__init__.py index 5272c01a6..1d60b6b9a 100644 --- a/src/octoprint/util/json/__init__.py +++ b/src/octoprint/util/json/__init__.py @@ -5,7 +5,11 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms import collections import json -import frozendict +try: + from immutabledict import immutabledict +except ImportError: + # Python 2 + from frozendict import frozendict as immutabledict from octoprint.util import to_unicode @@ -42,5 +46,5 @@ class JsonEncoding: raise TypeError -JsonEncoding.add_encoder(frozendict.frozendict, lambda obj: dict(obj)) +JsonEncoding.add_encoder(immutabledict, lambda obj: dict(obj)) JsonEncoding.add_encoder(bytes, lambda obj: to_unicode(obj)) diff --git a/src/octoprint/util/net.py b/src/octoprint/util/net.py index 911ae2eea..8f9cd05ca 100644 --- a/src/octoprint/util/net.py +++ b/src/octoprint/util/net.py @@ -1,7 +1,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import logging import os import socket @@ -57,7 +56,7 @@ def get_lan_ranges(additional_private=None): _, prefix = prefix.split("/") addr = strip_interface_tag(address["addr"]) - return netaddr.IPNetwork("{}/{}".format(addr, prefix)) + return netaddr.IPNetwork(f"{addr}/{prefix}") subnets = [] @@ -260,7 +259,7 @@ def download_file(url, folder, max_length=None): path = os.path.abspath(os.path.join(folder, filename)) assert path.startswith(folder) - with io.open(path, "wb") as f: + with open(path, "wb") as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk) return path diff --git a/src/octoprint/util/pip.py b/src/octoprint/util/pip.py index d0013c09a..67f27cbb7 100644 --- a/src/octoprint/util/pip.py +++ b/src/octoprint/util/pip.py @@ -72,9 +72,7 @@ class PipCaller(CommandlineCaller): # add --no-use-wheel for versions that otherwise break if pip_version in cls.no_use_wheel and "--no-use-wheel" not in args: - logger.debug( - "Version {} needs --no-use-wheel to properly work.".format(pip_version) - ) + logger.debug(f"Version {pip_version} needs --no-use-wheel to properly work.") args.append("--no-use-wheel") # remove --user if it's present and a virtual env is detected @@ -333,7 +331,7 @@ class PipCaller(CommandlineCaller): with _cache_mutex: if not self.ignore_cache and pip_command_str in _cache["version"]: self._logger.debug( - "Using cached pip version information for {}".format(pip_command_str) + f"Using cached pip version information for {pip_command_str}" ) return _cache["version"][pip_command_str] @@ -347,7 +345,7 @@ class PipCaller(CommandlineCaller): if p.returncode != 0: self._logger.warning( - "Error while trying to run pip --version: {}".format(p.stderr.text) + f"Error while trying to run pip --version: {p.stderr.text}" ) return None, None @@ -383,7 +381,7 @@ class PipCaller(CommandlineCaller): ) return None, None - self._logger.info("Version of pip is {}".format(version_segment)) + self._logger.info(f"Version of pip is {version_segment}") result = pip_version, version_segment _cache["version"][pip_command_str] = result @@ -397,7 +395,7 @@ class PipCaller(CommandlineCaller): with _cache_mutex: if not self.ignore_cache and pip_command_str in _cache["setup"]: self._logger.debug( - "Using cached pip setup information for {}".format(pip_command_str) + f"Using cached pip setup information for {pip_command_str}" ) return _cache["setup"][pip_command_str] diff --git a/src/octoprint/util/piptestballoon/setup.py b/src/octoprint/util/piptestballoon/setup.py index a95966768..c0e26335d 100644 --- a/src/octoprint/util/piptestballoon/setup.py +++ b/src/octoprint/util/piptestballoon/setup.py @@ -26,9 +26,9 @@ virtual_env = hasattr(sys, "real_prefix") or ( writable = os.access(install_dir, os.W_OK) lines = [ - "PIP_INSTALL_DIR={}".format(install_dir), - "PIP_VIRTUAL_ENV={}".format(virtual_env), - "PIP_WRITABLE={}".format(writable), + f"PIP_INSTALL_DIR={install_dir}", + f"PIP_VIRTUAL_ENV={virtual_env}", + f"PIP_WRITABLE={writable}", ] # write to stdout diff --git a/src/octoprint/util/version.py b/src/octoprint/util/version.py index 792d66eb5..62e4bce58 100644 --- a/src/octoprint/util/version.py +++ b/src/octoprint/util/version.py @@ -106,7 +106,7 @@ def is_octoprint_compatible(*compatibility_entries, **kwargs): octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===") ): - octo_compat = ">={}".format(octo_compat) + octo_compat = f">={octo_compat}" s = pkg_resources.Requirement.parse("OctoPrint" + octo_compat) if octoprint_version in s: diff --git a/src/octoprint_client/__init__.py b/src/octoprint_client/__init__.py index 6b5fafb73..6ce5df44f 100644 --- a/src/octoprint_client/__init__.py +++ b/src/octoprint_client/__init__.py @@ -1,7 +1,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import json import time @@ -13,12 +12,12 @@ def build_base_url( https=False, httpuser=None, httppass=None, host=None, port=None, prefix=None ): protocol = "https" if https else "http" - httpauth = "{}:{}@".format(httpuser, httppass) if httpuser and httppass else "" + httpauth = f"{httpuser}:{httppass}@" if httpuser and httppass else "" host = host if host else "127.0.0.1" - port = ":{}".format(port) if port else ":5000" + port = f":{port}" if port else ":5000" prefix = prefix if prefix else "" - return "{}://{}{}{}{}".format(protocol, httpauth, host, port, prefix) + return f"{protocol}://{httpauth}{host}{port}{prefix}" class SocketTimeout(BaseException): @@ -287,14 +286,12 @@ class Client: import os if not os.path.isfile(file_path): - raise ValueError( - "{} cannot be uploaded since it is not a file".format(file_path) - ) + raise ValueError(f"{file_path} cannot be uploaded since it is not a file") if file_name is None: file_name = os.path.basename(file_path) - with io.open(file_path, "rb") as fp: + with open(file_path, "rb") as fp: if content_type: files = {"file": (file_name, fp, content_type)} else: @@ -411,7 +408,7 @@ class Client: class CustomSocketClient(SocketClient): def auth(self, username, key): - self.send({"auth": "{}:{}".format(username, key)}) + self.send({"auth": f"{username}:{key}"}) def throttle(self, factor): self.send({"throttle": factor}) diff --git a/src/octoprint_setuptools/__init__.py b/src/octoprint_setuptools/__init__.py index 682ee5d0a..80feb3acf 100644 --- a/src/octoprint_setuptools/__init__.py +++ b/src/octoprint_setuptools/__init__.py @@ -485,9 +485,9 @@ class PackTranslation(Command): print("Adding {entry_path} as {new_prefix}".format(**locals())) zip.write(entry_path, new_prefix) - meta_str = "last_update: {date}\n".format(date=now.isoformat()) + meta_str = f"last_update: {now.isoformat()}\n" if self.author: - meta_str += "author: {author}\n".format(author=self.author) + meta_str += f"author: {self.author}\n" zip_locale_root = self.__class__.pack_path_prefix + locale @@ -636,7 +636,7 @@ def create_plugin_setup_parameters( [package] + list( filter( - lambda x: x.startswith("{package}.".format(package=package)), + lambda x: x.startswith(f"{package}."), find_packages(where=source_folder, exclude=ignored_packages), ) ) diff --git a/tests/_fixups.py b/tests/_fixups.py deleted file mode 100644 index 1dac32bc3..000000000 --- a/tests/_fixups.py +++ /dev/null @@ -1,3 +0,0 @@ -import sys # noqa: F401 - -OPEN_SIGNATURE = "io.open" diff --git a/tests/cypress/util/util.js b/tests/cypress/util/util.js index 614dd6263..346b5a6dd 100644 --- a/tests/cypress/util/util.js +++ b/tests/cypress/util/util.js @@ -5,7 +5,7 @@ export const prepare_server = () => { cy.route("GET", "/api/settings").as("settings"); cy.route("GET", "/api/files?recursive=true").as("files"); cy.route("GET", "/plugin/softwareupdate/check").as("softwareupdate"); - cy.route("GET", "/api/plugin/pluginmanager").as("pluginmanager"); + cy.route("GET", "/plugin/pluginmanager/plugins").as("pluginmanager"); cy.route("POST", "/api/connection").as("connectionCommand"); cy.route("GET", "/api/connection").as("connectionDetails"); }; diff --git a/tests/filemanager/test_filemanager.py b/tests/filemanager/test_filemanager.py index 1b7edf9e9..adda019ce 100644 --- a/tests/filemanager/test_filemanager.py +++ b/tests/filemanager/test_filemanager.py @@ -7,8 +7,6 @@ import io import unittest import unittest.mock as mock -import _fixups - import octoprint.filemanager import octoprint.filemanager.storage.local import octoprint.filemanager.util @@ -394,7 +392,7 @@ class FileManagerTest(unittest.TestCase): mock_time.return_value = now self.local_storage.path_in_storage.return_value = path - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True): + with mock.patch("builtins.open", mock.mock_open(), create=True): self.file_manager.save_recovery_data( octoprint.filemanager.FileDestinations.LOCAL, path, pos ) @@ -430,7 +428,7 @@ class FileManagerTest(unittest.TestCase): mock_yaml_safe_dump.side_effect = RuntimeError - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True): + with mock.patch("builtins.open", mock.mock_open(), create=True): self.file_manager.save_recovery_data( octoprint.filemanager.FileDestinations.LOCAL, path, pos ) @@ -481,7 +479,7 @@ class FileManagerTest(unittest.TestCase): } text_data = yaml.dump(data) - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(read_data=text_data)) as m: + with mock.patch("builtins.open", mock.mock_open(read_data=text_data)) as m: # moved safe_load to here so we could mock up the return value properly with mock.patch("yaml.safe_load", return_value=data) as n: result = self.file_manager.get_recovery_data() diff --git a/tests/filemanager/test_localstorage.py b/tests/filemanager/test_localstorage.py index d7f8f7963..007dce3b1 100644 --- a/tests/filemanager/test_localstorage.py +++ b/tests/filemanager/test_localstorage.py @@ -2,7 +2,6 @@ __author__ = "Gina HรคuรŸge " __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import os import os.path import unittest @@ -24,7 +23,7 @@ class FileWrapper: blocksize = 65536 hash = hashlib.sha1() - with io.open(self.path, "rb") as f: + with open(self.path, "rb") as f: buffer = f.read(blocksize) while len(buffer) > 0: hash.update(buffer) @@ -830,7 +829,7 @@ class LocalStorageTest(unittest.TestCase): # prepare import yaml - with io.open(yaml_path, "wt") as f: + with open(yaml_path, "wt") as f: yaml.safe_dump(metadata, f) # migrate @@ -842,7 +841,7 @@ class LocalStorageTest(unittest.TestCase): import json - with io.open(json_path, "rt", encoding="utf-8") as f: + with open(json_path, encoding="utf-8") as f: json_metadata = json.load(f) self.assertDictEqual(metadata, json_metadata) diff --git a/tests/plugin/test_settings.py b/tests/plugin/test_settings.py index 28423508c..5bf0cf1ca 100644 --- a/tests/plugin/test_settings.py +++ b/tests/plugin/test_settings.py @@ -354,7 +354,7 @@ class SettingsTestCase(unittest.TestCase): self.settings.getBaseFolder.assert_called_once_with("logs") self.assertEqual( - "/some/folder/plugin_{key}.log".format(key=self.plugin_key), + f"/some/folder/plugin_{self.plugin_key}.log", path.replace(os.sep, "/"), ) @@ -367,7 +367,7 @@ class SettingsTestCase(unittest.TestCase): self.settings.getBaseFolder.assert_called_once_with("logs") self.assertEqual( - "/some/folder/plugin_{key}_mypostfix.log".format(key=self.plugin_key), + f"/some/folder/plugin_{self.plugin_key}_mypostfix.log", path.replace(os.sep, "/"), ) diff --git a/tests/plugins/pi_support/test_pi_support.py b/tests/plugins/pi_support/test_pi_support.py index 9e7baf5d5..f837d7ecb 100644 --- a/tests/plugins/pi_support/test_pi_support.py +++ b/tests/plugins/pi_support/test_pi_support.py @@ -1,7 +1,6 @@ import unittest import unittest.mock as mock -import _fixups import ddt from octoprint.util.platform import CLOSE_FDS @@ -19,23 +18,21 @@ class PiSupportTestCase(unittest.TestCase): # import _fixups - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True) as m: + with mock.patch("builtins.open", mock.mock_open(), create=True) as m: m.return_value.readline.return_value = OCTOPI_VERSION version = get_octopi_version() - m.assert_called_once_with("/etc/octopi_version", "rt", encoding="utf-8") + m.assert_called_once_with("/etc/octopi_version", encoding="utf-8") self.assertEqual(version, OCTOPI_VERSION) def test_get_proc_dt_model(self): from octoprint.plugins.pi_support import get_proc_dt_model - # import _fixups - - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True) as m: + with mock.patch("builtins.open", mock.mock_open(), create=True) as m: m.return_value.readline.return_value = DT_MODEL model = get_proc_dt_model() - m.assert_called_once_with("/proc/device-tree/model", "rt", encoding="utf-8") + m.assert_called_once_with("/proc/device-tree/model", encoding="utf-8") self.assertEqual(model, DT_MODEL) def test_get_vcgencmd_throttle_state(self): diff --git a/tests/settings/test_settings.py b/tests/settings/test_settings.py index 1457acb0b..dc8bd7b0a 100644 --- a/tests/settings/test_settings.py +++ b/tests/settings/test_settings.py @@ -10,7 +10,6 @@ Tests for OctoPrint's Settings class import contextlib import hashlib -import io import os import re import shutil @@ -27,11 +26,11 @@ import octoprint.settings @ddt.ddt class TestSettings(unittest.TestCase): def _load_yaml(self, fname): - with io.open(fname, "rt", encoding="utf-8") as f: + with open(fname, encoding="utf-8") as f: return yaml.safe_load(f) def _dump_yaml(self, fname, config): - with io.open(fname, "wt", encoding="utf-8") as f: + with open(fname, "wt", encoding="utf-8") as f: yaml.safe_dump(config, f) def setUp(self): @@ -182,7 +181,7 @@ class TestSettings(unittest.TestCase): # can switch to assertIsNone after 3.x upgrade. self.assertFalse( match_result, - "string matched and it shouldn't have: {!r}".format(terminal_string), + f"string matched and it shouldn't have: {terminal_string!r}", ) def test_temperature_regex_matches(self): @@ -208,7 +207,7 @@ class TestSettings(unittest.TestCase): # can switch to assertIsNotNone after 3.x upgrade. self.assertTrue( match_result, - "string did not match and it should have: {!r}".format(terminal_string), + f"string did not match and it should have: {terminal_string!r}", ) ##~~ test getters diff --git a/tests/test_daemon.py b/tests/test_daemon.py index 303d510a3..17b3823f1 100644 --- a/tests/test_daemon.py +++ b/tests/test_daemon.py @@ -1,8 +1,6 @@ import unittest import unittest.mock as mock -import _fixups - import octoprint.daemon @@ -104,7 +102,7 @@ class DaemonTest(unittest.TestCase): @mock.patch("sys.stdout") @mock.patch("sys.stderr") @mock.patch("os.devnull") - @mock.patch(_fixups.OPEN_SIGNATURE) + @mock.patch("builtins.open") @mock.patch("os.dup2") def test_redirect_io( self, mock_dup2, mock_open, mock_devnull, mock_stderr, mock_stdout, mock_stdin @@ -133,7 +131,7 @@ class DaemonTest(unittest.TestCase): self.assertListEqual( mock_open.mock_calls, [ - mock.call(mock_devnull, "rt", encoding="utf-8"), + mock.call(mock_devnull, encoding="utf-8"), mock.call(mock_devnull, "at+", encoding="utf-8"), mock.call(mock_devnull, "at+", encoding="utf-8"), ], @@ -402,15 +400,15 @@ class DaemonTest(unittest.TestCase): # test with mock.patch( - _fixups.OPEN_SIGNATURE, - mock.mock_open(read_data="{}\n".format(pid)), + "builtins.open", + mock.mock_open(read_data=f"{pid}\n"), create=True, ) as m: result = self.daemon.get_pid() # assert self.assertEqual(result, pid) - m.assert_called_once_with(self.pidfile, "rt", encoding="utf-8") + m.assert_called_once_with(self.pidfile, encoding="utf-8") def test_get_pid_ioerror(self): # setup @@ -418,12 +416,12 @@ class DaemonTest(unittest.TestCase): handle.__enter__.side_effect = IOError() # test - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True) as m: + with mock.patch("builtins.open", mock.mock_open(), create=True) as m: result = self.daemon.get_pid() # assert self.assertIsNone(result) - m.assert_called_once_with(self.pidfile, "rt", encoding="utf-8") + m.assert_called_once_with(self.pidfile, encoding="utf-8") def test_get_pid_valueerror(self): # setup @@ -431,41 +429,41 @@ class DaemonTest(unittest.TestCase): # test with mock.patch( - _fixups.OPEN_SIGNATURE, - mock.mock_open(read_data="{}\n".format(pid)), + "builtins.open", + mock.mock_open(read_data=f"{pid}\n"), create=True, ) as m: result = self.daemon.get_pid() # assert self.assertIsNone(result) - m.assert_called_once_with(self.pidfile, "rt", encoding="utf-8") + m.assert_called_once_with(self.pidfile, encoding="utf-8") def test_set_pid(self): # setup pid = "1234" # test - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True) as m: + with mock.patch("builtins.open", mock.mock_open(), create=True) as m: self.daemon.set_pid(pid) # assert m.assert_called_once_with(self.pidfile, "wt+", encoding="utf-8") handle = m() - handle.write.assert_called_once_with("{}\n".format(pid)) + handle.write.assert_called_once_with(f"{pid}\n") def test_set_pid_int(self): # setup pid = 1234 # test - with mock.patch(_fixups.OPEN_SIGNATURE, mock.mock_open(), create=True) as m: + with mock.patch("builtins.open", mock.mock_open(), create=True) as m: self.daemon.set_pid(pid) # assert m.assert_called_once_with(self.pidfile, "wt+", encoding="utf-8") handle = m() - handle.write.assert_called_once_with("{}\n".format(pid)) + handle.write.assert_called_once_with(f"{pid}\n") @mock.patch("os.path.isfile") @mock.patch("os.remove") diff --git a/tests/util/test_file_helpers.py b/tests/util/test_file_helpers.py index b05d7b455..e4d50259f 100644 --- a/tests/util/test_file_helpers.py +++ b/tests/util/test_file_helpers.py @@ -1,7 +1,6 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License" -import io import os import sys import unittest @@ -77,7 +76,7 @@ class BomAwareOpenTest(unittest.TestCase): def test_bom_aware_open_parameters_text_mode(self): """Tests that the parameters are propagated properly in text mode.""" - with mock.patch("io.open", wraps=io.open) as mock_open: + with mock.patch("builtins.open", wraps=open) as mock_open: with octoprint.util.bom_aware_open( self.filename_utf8_without_bom, mode="rt", @@ -522,7 +521,7 @@ class IsHiddenPathTest(unittest.TestCase): "path_always_hidden", ): path = getattr(self, attr) - with io.open(path, "wt+", encoding="utf-8") as f: + with open(path, "wt+", encoding="utf-8") as f: f.write(attr) if sys.platform == "win32": diff --git a/tests/util/test_misc.py b/tests/util/test_misc.py index 194fff0e5..07bfe6bdb 100644 --- a/tests/util/test_misc.py +++ b/tests/util/test_misc.py @@ -5,7 +5,12 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms import unittest import ddt -from frozendict import frozendict + +try: + from immutabledict import immutabledict +except ImportError: + # Python 2 + from frozendict import frozendict as immutabledict import octoprint.util @@ -63,31 +68,35 @@ class MiscTestCase(unittest.TestCase): self.assertEqual(actual, expected) @ddt.data( - (frozendict(a=1, b=2, c=3), {"a": 1, "b": 2, "c": 3}), + (immutabledict(a=1, b=2, c=3), {"a": 1, "b": 2, "c": 3}), ( - frozendict(a=1, b=2, c=frozendict(c1=1, c2=2)), + immutabledict(a=1, b=2, c=immutabledict(c1=1, c2=2)), {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2}}, ), ({"a": 1, "b": 2, "c": 3}, {"a": 1, "b": 2, "c": 3}), ( - {"a": 1, "b": 2, "c": frozendict(c1=1, c2=2)}, + {"a": 1, "b": 2, "c": immutabledict(c1=1, c2=2)}, {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2}}, ), ( - {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2, "c3": frozendict(c11=11, c12=12)}}, + { + "a": 1, + "b": 2, + "c": {"c1": 1, "c2": 2, "c3": immutabledict(c11=11, c12=12)}, + }, {"a": 1, "b": 2, "c": {"c1": 1, "c2": 2, "c3": {"c11": 11, "c12": 12}}}, ), ) @ddt.unpack - def test_unfreeze_frozendict(self, input, expected): - result = octoprint.util.thaw_frozendict(input) + def test_unfreeze_immutabledict(self, input, expected): + result = octoprint.util.thaw_immutabledict(input) self.assertIsInstance(result, dict) self.assertDictEqual(result, expected) @ddt.data(None, "invalid", 3, [1, 2], (3, 4)) - def test_unfreeze_frozendict_invalid(self, input): + def test_unfreeze_immutabledict_invalid(self, input): try: - octoprint.util.thaw_frozendict(input) + octoprint.util.thaw_immutabledict(input) self.fail("expected ValueError") except ValueError: # expected diff --git a/versioneer.py b/versioneer.py index 7c2305223..a2888abc5 100644 --- a/versioneer.py +++ b/versioneer.py @@ -501,7 +501,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): return None else: if verbose: - print("unable to find command, tried %s" % (commands,)) + print("unable to find command, tried {}".format(commands)) return None stdout = p.communicate()[0].strip() if sys.version_info[0] >= 3: @@ -650,11 +650,11 @@ def git_get_keywords(versionfile_abs): f = io.open(versionfile_abs, "rt", encoding="utf-8") for line in f.readlines(): if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) + mo = re.search(r'=\\s*"(.*)"', line) if mo: keywords["refnames"] = mo.group(1) if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) + mo = re.search(r'=\\s*"(.*)"', line) if mo: keywords["full"] = mo.group(1) f.close() @@ -686,7 +686,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". - tags = set(r for r in refs if re.search(r'\d', r)) + tags = set(r for r in refs if re.search(r'\\d', r)) if verbose: print("discarding '%%s', no digits" %% ",".join(refs-tags)) @@ -778,7 +778,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): if "-" in git_describe: # TAG-NUM-gHEX - mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) + mo = re.search(r'^(.+)-(\\d+)-g([0-9a-f]+)$', git_describe) if not mo: # unparseable. Maybe git-describe is misbehaving? pieces["error"] = ("unable to parse git-describe output: '%%s'" @@ -1379,7 +1379,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): if verbose: fmt = "tag '%s' doesn't start with prefix '%s'" print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( + pieces["error"] = "tag '{}' doesn't start with prefix '{}'".format( full_tag, tag_prefix, ) @@ -1609,7 +1609,7 @@ def write_to_version_file(filename, versions): with io.open(filename, "wt", encoding="utf-8") as f: f.write(SHORT_VERSION_PY % contents) - print("set %s to '%s'" % (filename, versions["version"])) + print("set {} to '{}'".format(filename, versions["version"])) def plus_or_dot(pieces): @@ -1884,7 +1884,7 @@ def get_versions(verbose=False): try: ver = versions_from_file(versionfile_abs) if verbose: - print("got version from file %s %s" % (versionfile_abs, ver)) + print("got version from file {} {}".format(versionfile_abs, ver)) return ver except NotThisMethod: pass