Merge branch 'maintenance' into patch-2
This commit is contained in:
58 files changed
+1088
-631
No files matched your search
@@ -12,19 +12,19 @@ on:
|
||||
jobs:
|
||||
dispatch_releases:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'push'
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name != 'push'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
with:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
event-type: ${{ github.event_name }}
|
||||
event-type: ${{ github.event.action }}
|
||||
client-payload: '{"tag_name": "${{ github.event.release.tag_name }}"}'
|
||||
|
||||
dispatch_canary:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/maintenance'
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/maintenance'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
@@ -32,11 +32,11 @@ jobs:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
event-type: "canary"
|
||||
client-payload: '{"tag_name": "${{ github.sha }}"}'
|
||||
client-payload: '{"tag_name": "maintenance"}'
|
||||
|
||||
dispatch_bleeding:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/devel'
|
||||
if: github.repository == 'OctoPrint/OctoPrint' && github.event_name == 'push' && github.ref == 'refs/heads/devel'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
@@ -44,4 +44,4 @@ jobs:
|
||||
token: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||
repository: ${{ github.repository_owner }}/octoprint-docker
|
||||
event-type: "bleeding"
|
||||
client-payload: '{"tag_name": "${{ github.sha }}"}'
|
||||
client-payload: '{"tag_name": "devel"}'
|
||||
@@ -9,6 +9,7 @@ on:
|
||||
jobs:
|
||||
trigger:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'OctoPrint/OctoPrint'
|
||||
steps:
|
||||
- name: 🚀 Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v1
|
||||
|
||||
+6
-6
@@ -18,14 +18,14 @@ prerelease
|
||||
HEAD
|
||||
\(detached.*
|
||||
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.5.0
|
||||
# maintenance is currently the branch for preparation of maintenance release 1.6.0
|
||||
# so are any fix/... and improve/... branches
|
||||
maintenance 1.5.0 42769dad7dda3bc0c6c94e0e8ce832af9b14a565 pep440-dev
|
||||
fix/.* 1.5.0 42769dad7dda3bc0c6c94e0e8ce832af9b14a565 pep440-dev
|
||||
improve/.* 1.5.0 42769dad7dda3bc0c6c94e0e8ce832af9b14a565 pep440-dev
|
||||
maintenance 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
fix/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
improve/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
|
||||
|
||||
# staging/hotfix is the branch for preparation of the 1.5.2 hotfix release
|
||||
staging/hotfix 1.5.2 38256815ef6d6dd602e0fac949a17fbf8f30f838 pep440-dev
|
||||
# staging/hotfix is the branch for preparation of the 1.5.3 hotfix release
|
||||
staging/hotfix 1.5.3 e46e8fa17a1553cd0c228a4fa4cfd93e2a9bce7b pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.5.0rc4
|
||||
# so is regressionfix/...
|
||||
|
||||
@@ -130,6 +130,7 @@ date of first contribution):
|
||||
* [Sophist](https://github.com/Sophist-UK)
|
||||
* [Manuel McLure](https://github.com/ManuelMcLure)
|
||||
* ["j7126"](https://github.com/j7126)
|
||||
* ["jasonbcox"](https://github.com/jasonbcox)
|
||||
|
||||
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
|
||||
|
||||
+7
-2
@@ -251,5 +251,10 @@ Job information response
|
||||
* - ``state``
|
||||
- 1
|
||||
- String
|
||||
- A textual representation of the current state of the job, i.e. "Operational", "Printing", "Pausing", "Paused",
|
||||
"Cancelling", "Error" or "Offline".
|
||||
- A textual representation of the current state of the job or connection, e.g. "Operational", "Printing", "Pausing", "Paused",
|
||||
"Cancelling", "Error", "Offline", "Offline after error", "Opening serial connection", ... -- please note
|
||||
that this list is not exhaustive!
|
||||
* - ``error``
|
||||
- 0..1
|
||||
- String
|
||||
- Any error message for the job or connection, only set if there has been an error.
|
||||
@@ -30,7 +30,7 @@ Use the following settings to enable access control:
|
||||
userManager: octoprint.access.users.FilebasedUserManager
|
||||
|
||||
# The YAML user file to use. If left out defaults to users.yaml in the default configuration folder.
|
||||
userFile: /path/to/users.yaml
|
||||
userfile: /path/to/users.yaml
|
||||
|
||||
# If set to true, will automatically log on clients originating from any of the networks defined in
|
||||
# "localNetworks" as the user defined in "autologinAs". Defaults to false.
|
||||
|
||||
+191
-12
@@ -17,8 +17,17 @@ users out of the box.
|
||||
thus also cannot limit access to it. If an anonymous user correctly guesses the
|
||||
webcam URL, they will thus be able to see it.
|
||||
|
||||
If read-only access for anonymous users is enabled, anonymous users will have
|
||||
read-only access to the following parts of the UI:
|
||||
Upon first start a configuration wizard is provided which allows configuration
|
||||
of the first administrator account to be used for OctoPrint. After initial setup,
|
||||
you can then create more users and groups under Settings > Access Control for
|
||||
customisation of the granular permission system.
|
||||
|
||||
The predefined "Guests" group can be used to configure default permissions of anonymous
|
||||
users, that is those who have not logged in. By default, no permissions are granted to
|
||||
these users.
|
||||
|
||||
A predefined "Read-only Access" group with no users is configured which by default grants
|
||||
read-only access to the following parts of the UI to any users assigned to this group:
|
||||
|
||||
* printer state
|
||||
* available gcode files and stats (upload is disabled)
|
||||
@@ -30,25 +39,195 @@ read-only access to the following parts of the UI:
|
||||
* any components provided through plugins which are enabled for anonymous
|
||||
users
|
||||
|
||||
Logged in users without admin flag will be allowed to access everything besides the
|
||||
Settings and System Commands, which are admin-only.
|
||||
Another predefined "Operator" group is the default group for newly created users and
|
||||
by default gives access to all aspects of OctoPrint that involve regular printer
|
||||
operation. It matches the old "user" role from OctoPrint prior to 1.4.0.
|
||||
|
||||
Upon first start a configuration wizard is provided which allows configuration
|
||||
of the first administrator account to be used for OctoPrint. After initial setup,
|
||||
you can then create more users under Settings > Access Control for customisation of
|
||||
the granular permission system.
|
||||
Finally, the predefined "Admins" group gives full admin access to the platform. You should
|
||||
be careful of who you put into that. It matches the old "admin" role from OctoPrint prior
|
||||
to 1.4.0.
|
||||
|
||||
.. hint::
|
||||
|
||||
If you plan to have your OctoPrint instance accessible over the internet,
|
||||
**please use additional security measures** and ideally **don't make it accessible to
|
||||
everyone over the internet but instead use a VPN** or at the very least
|
||||
HTTP basic authentication on a layer above OctoPrint.
|
||||
HTTP basic authentication on a layer above OctoPrint. Unless you are using a VPN
|
||||
**please do not** enable any permissions for the Guest group or the auto-login feature
|
||||
described below.
|
||||
|
||||
A physical device that includes heaters and stepper motors really should not be
|
||||
publicly reachable by everyone with an internet connection, even with access
|
||||
control enabled.
|
||||
|
||||
.. _sec-features-access_control-autologin:
|
||||
|
||||
Autologin
|
||||
---------
|
||||
|
||||
While access control cannot be disabled as of OctoPrint 1.5+, the Autologin feature can
|
||||
be used to bypass authentication for hosts on the network(s) that you trust.
|
||||
|
||||
Starting with OctoPrint 1.5.0, OctoPrint makes enabled access control mandatory. This
|
||||
might be an inconvience for some who run OctoPrint in an isolated setup where a login is
|
||||
not required to ensure security, at a benefit for a huge number of users out there who
|
||||
continue to underestimate or simply ignore the risk of keeping their OctoPrint instance
|
||||
unsecured and then happily exposing it on the public internet.
|
||||
|
||||
That being said, even as far back as OctoPrint 1.0.0 (released in 2013) there has existed
|
||||
a way to have OctoPrint automatically log you in, if you connect from a trusted local
|
||||
network address. This functionality has not been exposed on the UI, and for now also won't
|
||||
be (to make it a bit harder to once again create an insecure setup for those who simply
|
||||
won't listen to common sense), but it's easy to set up with a bit of configuration
|
||||
editing.
|
||||
|
||||
When set up properly, it will make sure to automatically log you in as a configured user
|
||||
whenever you connect from a device on your local network. To get back pretty much the same
|
||||
behaviour as with disabled access control, you'll only need to create a single (admin)
|
||||
account and then set up autologin for it.
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
**Do not do this if you cannot trust EVERYONE on your local network.** And that really
|
||||
means mean everyone. If you ignore this and then someone takes over your OctoPrint
|
||||
instance, installs malware on it and makes your printer print an endless stream of
|
||||
benchies, that's on you.
|
||||
|
||||
.. _sec-features-access_control-autologin-gather_config_info:
|
||||
|
||||
Gather configuration information
|
||||
................................
|
||||
|
||||
You can configure Autologin via a plugin (the easy way), or manually (the hard way), but
|
||||
in either case you will need to specify which user should be automatically logged in, and
|
||||
which hosts are permitted access this way.
|
||||
|
||||
**Improperly setting this subnet option can lead to the compromise of your system, or even
|
||||
your entire network. Proceed with extreme caution.**
|
||||
|
||||
The subnet to use is usually the IP address range of your LAN, which sounds scary but
|
||||
actually isn't. Just `figure out your PC's IP address and subnet mask <https://lifehacker.com/how-to-find-your-local-and-external-ip-address-5833108>`_
|
||||
and then combine both with a / in between.
|
||||
|
||||
On OctoPi (or another Linux distribution) you can use the follwing command:
|
||||
|
||||
.. code-block::
|
||||
|
||||
ip route | grep -P 'eth0|wlan0' | awk '{print $1}'
|
||||
|
||||
Or, for IPv6, use this:
|
||||
|
||||
.. code-block::
|
||||
|
||||
ip -6 route | grep -P 'eth0|wlan0' | awk '{print $1}'
|
||||
|
||||
This will be what you set as the subnet in the plugin, or where it says
|
||||
``<yourAddressRange>`` below on the manual configuration instructions.
|
||||
|
||||
Example: Your PC has an IP address of ``192.168.23.42`` and a subnet mask of
|
||||
``255.255.255.0``. Your address range is ``192.168.23.42/255.255.255.0``.
|
||||
|
||||
.. _sec-features-access_control-autologin-plugin:
|
||||
|
||||
The easy way: Using the OctoPrint-AutoLoginConfig plugin
|
||||
........................................................
|
||||
|
||||
The easist way to configure AutoLogin is to install the
|
||||
`OctoPrint-AutoLoginConfig plugin <https://plugins.octoprint.org/plugins/autologin_config/>`_
|
||||
via the plugin manager.
|
||||
|
||||
Open its settings and follow the instructions on the screen.
|
||||
|
||||
.. _sec-features-access_control-autologin-manual:
|
||||
|
||||
The hard way: Manual editing of config.yaml
|
||||
...........................................
|
||||
|
||||
Preparation
|
||||
***********
|
||||
|
||||
First of all, read :ref:`the YAML primer <sec-configuration-yaml>`. You
|
||||
will have to edit OctoPrint's main configuration file, and thus should make sure
|
||||
you understand at least roughly how things work and that you should keep your
|
||||
hands off the Tab key. If you don't, you might break your config file, and
|
||||
while the steps include making a backup, this still can be easily avoided by
|
||||
learning about the DOs and DONTs first.
|
||||
|
||||
Then, take a look at :ref:`the docs on config.yaml <sec-configuration-config_yaml>`
|
||||
on where to find that central configuration file of OctoPrint.
|
||||
|
||||
Configuration
|
||||
*************
|
||||
|
||||
Ready? Let's do some editing then. I'll outline what to do and where first, and then
|
||||
further down there's also a dedicated list of steps for OctoPi specifically.
|
||||
|
||||
1. Shutdown OctoPrint
|
||||
2. Make a backup of your config.yaml
|
||||
3. Open it in a text editor (e.g. nano). Right at the very top it'll say something like
|
||||
this:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
accessControl:
|
||||
salt: aabbccddee1234523452345
|
||||
|
||||
Edit this, adding lines so it looks like this (making absolutely sure not to touch the
|
||||
salt line):
|
||||
|
||||
.. code-block:: yaml
|
||||
accessControl:
|
||||
salt: aabbccddee1234523452345
|
||||
autologinLocal: true
|
||||
autologinAs: "<yourUsername>"
|
||||
localNetworks:
|
||||
- "127.0.0.0/8"
|
||||
- "<yourAddressRange>"
|
||||
|
||||
4. Restart OctoPrint, check that everything works.
|
||||
|
||||
This will automatically log you in as the user you specified whenver you connect to
|
||||
OctoPrint from an address in the address range (e.g. a device on your local network).
|
||||
|
||||
OctoPi specific steps
|
||||
*********************
|
||||
|
||||
If you are running OctoPi you will have to SSH into your Raspberry Pi. Then issue
|
||||
the following commands:
|
||||
|
||||
1. ``sudo service octoprint stop``
|
||||
2. ``cp ~/.octoprint/config.yaml ~/.octoprint/config.yaml.back``
|
||||
3. ``nano ~/.octoprint/config.yaml, make the edits as described above``
|
||||
4. ``sudo service octoprint start``
|
||||
|
||||
If something went wrong, you can restore the config backup with
|
||||
|
||||
.. code-block::
|
||||
|
||||
cp ~/.octoprint/config.yaml.back ~/.octoprint/config.yaml
|
||||
|
||||
|
||||
If you are using a VPN and your setup ABSOLUTELY REQUIRES disabling internal OctoPrint access controls
|
||||
......................................................................................................
|
||||
|
||||
.. warning::
|
||||
|
||||
You probably shouldn't do this, EVER. There are usually other options. Don't even
|
||||
THINK about it, unless you have a VPN layer for security. Only consider proceeding
|
||||
with this configuration after exhausting ALL other possibilities, and even then, you
|
||||
should think long and hard about whether this is a good idea. You almost certainly
|
||||
don't need or want to do this.
|
||||
|
||||
While access controls can no longer be disabled in OctoPrint 1.5+, this can be
|
||||
approximated by an Autologin configuration that automatically logs in all users, that is
|
||||
by using subnets that match all possible IP addresses. By specifying the ``0.0.0.0/0``
|
||||
subnet (for IPv4) and ``::/0`` for IPv6 in the AutoLogin configuration, you can achieve
|
||||
this. This configuration is permitted, but highly, highly discouraged.
|
||||
|
||||
Please don't do this. You will almost certainly regret it. You alone are responsible for
|
||||
your actions.
|
||||
|
||||
.. _sec-features-access_control-hooks:
|
||||
|
||||
Available Extension Hooks
|
||||
@@ -67,7 +246,7 @@ See :ref:`here <sec-plugins-hook-permissions>`.
|
||||
|
||||
.. _sec-features-access_control-hooks-loginui:
|
||||
|
||||
octoprint.plugin.loginui.theming
|
||||
................................
|
||||
octoprint.theming.login
|
||||
.......................
|
||||
|
||||
See :ref:`here <sec-bundledplugins-loginui-hooks-theming>`.
|
||||
See :ref:`here <sec-plugins-hook-theming-dialog>`.
|
||||
@@ -1173,15 +1173,6 @@ octoprint.plugin.backup.additional_excludes
|
||||
|
||||
See :ref:`here <sec-bundledplugins-backup-hooks-excludes>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-loginui-theming:
|
||||
|
||||
octoprint.plugin.loginui.theming
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 1.4.0
|
||||
|
||||
See :ref:`here <sec-bundledplugins-loginui-hooks-theming>`.
|
||||
|
||||
.. _sec-plugins-hook-plugin-pluginmanager-reconnect:
|
||||
|
||||
octoprint.plugin.pluginmanager.reconnect_hooks
|
||||
|
||||
@@ -86,6 +86,7 @@ class FatalStartupError(Exception):
|
||||
def init_platform(
|
||||
basedir,
|
||||
configfile,
|
||||
overlays=None,
|
||||
use_logging_file=True,
|
||||
logging_file=None,
|
||||
logging_config=None,
|
||||
@@ -117,7 +118,7 @@ def init_platform(
|
||||
after_preinit_logging(**kwargs)
|
||||
|
||||
try:
|
||||
settings = init_settings(basedir, configfile)
|
||||
settings = init_settings(basedir, configfile, overlays=overlays)
|
||||
except Exception as ex:
|
||||
raise FatalStartupError("Could not initialize settings manager", cause=ex)
|
||||
kwargs["settings"] = settings
|
||||
@@ -220,13 +221,15 @@ def init_platform(
|
||||
)
|
||||
|
||||
|
||||
def init_settings(basedir, configfile):
|
||||
def init_settings(basedir, configfile, overlays=None):
|
||||
"""Inits the settings instance based on basedir and configfile to use."""
|
||||
|
||||
from octoprint.settings import InvalidSettings, settings
|
||||
|
||||
try:
|
||||
return settings(init=True, basedir=basedir, configfile=configfile)
|
||||
return settings(
|
||||
init=True, basedir=basedir, configfile=configfile, overlays=overlays
|
||||
)
|
||||
except InvalidSettings as e:
|
||||
raise FatalStartupError(str(e))
|
||||
|
||||
@@ -619,16 +622,17 @@ def init_pluginsystem(
|
||||
)
|
||||
|
||||
plugin_validators = []
|
||||
|
||||
if safe_mode:
|
||||
|
||||
def validator(phase, plugin_info):
|
||||
def safe_mode_validator(phase, plugin_info):
|
||||
if phase in ("before_import", "before_load", "before_enable"):
|
||||
plugin_info.safe_mode_victim = not plugin_info.bundled
|
||||
if not plugin_info.bundled:
|
||||
return False
|
||||
return True
|
||||
|
||||
plugin_validators.append(validator)
|
||||
plugin_validators.append(safe_mode_validator)
|
||||
|
||||
compatibility_ignored_list = settings.get(["plugins", "_forcedCompatible"])
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ def init_platform_for_cli(ctx):
|
||||
components = init_platform(
|
||||
get_ctx_obj_option(ctx, "basedir", None),
|
||||
get_ctx_obj_option(ctx, "configfile", None),
|
||||
overlays=get_ctx_obj_option(ctx, "overlays", None),
|
||||
safe_mode=True,
|
||||
)
|
||||
|
||||
@@ -180,8 +181,7 @@ def standard_options(hidden=False):
|
||||
"""
|
||||
Decorator to add the standard options shared among all "octoprint" commands.
|
||||
|
||||
Adds the options ``--basedir``, ``--config`` and ``--verbose``. If ``hidden``
|
||||
is set to ``True``, the options will be available on the command but not
|
||||
If ``hidden`` is set to ``True``, the options will be available on the command but not
|
||||
listed in its help page.
|
||||
"""
|
||||
|
||||
@@ -209,6 +209,16 @@ def standard_options(hidden=False):
|
||||
expose_value=False,
|
||||
help="Specify the config file to use.",
|
||||
),
|
||||
factory(
|
||||
"--overlay",
|
||||
"overlays",
|
||||
type=click.Path(),
|
||||
callback=set_ctx_obj_option,
|
||||
is_eager=True,
|
||||
multiple=True,
|
||||
expose_value=False,
|
||||
help="Specify additional config overlays to use.",
|
||||
),
|
||||
factory(
|
||||
"--verbose",
|
||||
"-v",
|
||||
|
||||
@@ -40,7 +40,7 @@ def _set_helper(settings, path, value, data_type=None):
|
||||
if name is not None:
|
||||
method = getattr(settings, name)
|
||||
|
||||
method(path, value)
|
||||
method(path, value, force=True)
|
||||
settings.save()
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ def config(ctx):
|
||||
ctx.obj.settings = init_settings(
|
||||
get_ctx_obj_option(ctx, "basedir", None),
|
||||
get_ctx_obj_option(ctx, "configfile", None),
|
||||
overlays=get_ctx_obj_option(ctx, "overlays", None),
|
||||
)
|
||||
except FatalStartupError as e:
|
||||
click.echo(str(e), err=True)
|
||||
|
||||
@@ -84,6 +84,7 @@ class OctoPrintPluginCommands(click.MultiCommand):
|
||||
self.settings = init_settings(
|
||||
get_ctx_obj_option(ctx, "basedir", None),
|
||||
get_ctx_obj_option(ctx, "configfile", None),
|
||||
overlays=get_ctx_obj_option(ctx, "overlays", None),
|
||||
)
|
||||
self.plugin_manager = init_pluginsystem(
|
||||
self.settings, safe_mode=get_ctx_obj_option(ctx, "safe_mode", False)
|
||||
|
||||
@@ -33,6 +33,7 @@ def run_server(
|
||||
safe_mode,
|
||||
ignore_blacklist,
|
||||
octoprint_daemon=None,
|
||||
overlays=None,
|
||||
):
|
||||
"""Initializes the environment and starts up the server."""
|
||||
|
||||
@@ -113,6 +114,7 @@ def run_server(
|
||||
components = init_platform(
|
||||
basedir,
|
||||
configfile,
|
||||
overlays=overlays,
|
||||
logging_file=logging_config,
|
||||
debug=debug,
|
||||
verbosity=verbosity,
|
||||
@@ -260,6 +262,7 @@ def enable_safemode(ctx, **kwargs):
|
||||
settings = init_settings(
|
||||
get_ctx_obj_option(ctx, "basedir", None),
|
||||
get_ctx_obj_option(ctx, "configfile", None),
|
||||
overlays=get_ctx_obj_option(ctx, "overlays", None),
|
||||
)
|
||||
except FatalStartupError as e:
|
||||
click.echo(str(e), err=True)
|
||||
@@ -297,6 +300,7 @@ def serve_command(ctx, **kwargs):
|
||||
verbosity = get_value("verbosity")
|
||||
safe_mode = "flag" if get_value("safe_mode") else None
|
||||
ignore_blacklist = get_value("ignore_blacklist")
|
||||
overlays = get_value("overlays")
|
||||
|
||||
if v4 and not host:
|
||||
host = "0.0.0.0"
|
||||
@@ -313,6 +317,7 @@ def serve_command(ctx, **kwargs):
|
||||
verbosity,
|
||||
safe_mode,
|
||||
ignore_blacklist,
|
||||
overlays=overlays,
|
||||
)
|
||||
|
||||
|
||||
@@ -350,6 +355,7 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
|
||||
basedir = get_value("basedir")
|
||||
configfile = get_value("configfile")
|
||||
overlays = get_value("overlays")
|
||||
verbosity = get_value("verbosity")
|
||||
safe_mode = "flag" if get_value("safe_mode") else None
|
||||
ignore_blacklist = get_value("ignore_blacklist")
|
||||
@@ -369,6 +375,7 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
pidfile,
|
||||
basedir,
|
||||
configfile,
|
||||
overlays,
|
||||
host,
|
||||
port,
|
||||
v6_only,
|
||||
@@ -383,6 +390,7 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
|
||||
self._basedir = basedir
|
||||
self._configfile = configfile
|
||||
self._overlays = overlays
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._v6_only = v6_only
|
||||
@@ -407,12 +415,14 @@ if sys.platform != "win32" and sys.platform != "darwin":
|
||||
self._safe_mode,
|
||||
self._ignore_blacklist,
|
||||
octoprint_daemon=self,
|
||||
overlays=self._overlays,
|
||||
)
|
||||
|
||||
octoprint_daemon = OctoPrintDaemon(
|
||||
pid,
|
||||
basedir,
|
||||
configfile,
|
||||
overlays,
|
||||
host,
|
||||
port,
|
||||
v6,
|
||||
|
||||
@@ -48,6 +48,7 @@ def user(ctx):
|
||||
settings = init_settings(
|
||||
get_ctx_obj_option(ctx, "basedir", None),
|
||||
get_ctx_obj_option(ctx, "configfile", None),
|
||||
overlays=get_ctx_obj_option(ctx, "overlays", None),
|
||||
)
|
||||
|
||||
group_manager_name = settings.get(["accessControl", "groupManager"])
|
||||
|
||||
@@ -9,7 +9,6 @@ import copy
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
import pylru
|
||||
@@ -21,12 +20,11 @@ except ImportError:
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
from emoji import demojize
|
||||
from past.builtins import basestring
|
||||
|
||||
import octoprint.filemanager
|
||||
from octoprint.util import atomic_write, is_hidden_path, time_this, to_bytes, to_unicode
|
||||
from octoprint.vendor.awesome_slugify import Slugify
|
||||
from octoprint.util.text import sanitize
|
||||
|
||||
|
||||
class StorageInterface(object):
|
||||
@@ -468,22 +466,6 @@ class LocalFileStorage(StorageInterface):
|
||||
This storage type implements :func:`path_on_disk`.
|
||||
"""
|
||||
|
||||
_UNICODE_VARIATIONS = re.compile("[\uFE00-\uFE0F]", re.U)
|
||||
|
||||
@classmethod
|
||||
def _no_unicode_variations(cls, text):
|
||||
return cls._UNICODE_VARIATIONS.sub("", text)
|
||||
|
||||
_SLUGIFY = Slugify()
|
||||
_SLUGIFY.safe_chars = "-_.()[] "
|
||||
|
||||
@classmethod
|
||||
def _slugify(cls, text):
|
||||
text = to_unicode(text)
|
||||
text = cls._no_unicode_variations(text)
|
||||
text = demojize(text, delimiters=("", ""))
|
||||
return cls._SLUGIFY(text)
|
||||
|
||||
def __init__(self, basefolder, create=False):
|
||||
"""
|
||||
Initializes a ``LocalFileStorage`` instance under the given ``basefolder``, creating the necessary folder
|
||||
@@ -1192,7 +1174,7 @@ class LocalFileStorage(StorageInterface):
|
||||
if "/" in name or "\\" in name:
|
||||
raise ValueError("name must not contain / or \\")
|
||||
|
||||
result = self._slugify(name).replace(" ", "_")
|
||||
result = sanitize(name, safe_chars="-_.()[] ").replace(" ", "_")
|
||||
if result and result != "." and result != ".." and result[0] == ".":
|
||||
# hidden files under *nix
|
||||
result = result[1:]
|
||||
|
||||
@@ -207,35 +207,12 @@ class PluginInfo(object):
|
||||
attr_implementation = "__plugin_implementation__"
|
||||
""" Module attribute from which to retrieve the plugin's provided mixin implementation. """
|
||||
|
||||
attr_implementations = "__plugin_implementations__"
|
||||
"""
|
||||
Module attribute from which to retrieve the plugin's provided implementations.
|
||||
|
||||
This deprecated attribute will only be used if a plugin does not yet offer :attr:`attr_implementation`. Only the
|
||||
first entry will be evaluated.
|
||||
|
||||
.. deprecated:: 1.2.0-dev-694
|
||||
|
||||
Use :attr:`attr_implementation` instead.
|
||||
"""
|
||||
|
||||
attr_helpers = "__plugin_helpers__"
|
||||
""" Module attribute from which to retrieve the plugin's provided helpers. """
|
||||
|
||||
attr_check = "__plugin_check__"
|
||||
""" Module attribute which to call to determine if the plugin can be loaded. """
|
||||
|
||||
attr_init = "__plugin_init__"
|
||||
"""
|
||||
Module attribute which to call when loading the plugin.
|
||||
|
||||
This deprecated attribute will only be used if a plugin does not yet offer :attr:`attr_load`.
|
||||
|
||||
.. deprecated:: 1.2.0-dev-720
|
||||
|
||||
Use :attr:`attr_load` instead.
|
||||
"""
|
||||
|
||||
attr_load = "__plugin_load__"
|
||||
""" Module attribute which to call when loading the plugin. """
|
||||
|
||||
@@ -323,7 +300,8 @@ class PluginInfo(object):
|
||||
|
||||
if phase == "before_import":
|
||||
result = (
|
||||
not self.forced_disabled
|
||||
self.looks_like_plugin
|
||||
and not self.forced_disabled
|
||||
and not self.blacklisted
|
||||
and not self.incompatible
|
||||
and not self.invalid_syntax
|
||||
@@ -331,54 +309,10 @@ class PluginInfo(object):
|
||||
)
|
||||
|
||||
elif phase == "before_load":
|
||||
# if the plugin still uses __plugin_init__, log a deprecation warning and move it to __plugin_load__
|
||||
if hasattr(self.instance, self.__class__.attr_init):
|
||||
if not hasattr(self.instance, self.__class__.attr_load):
|
||||
# deprecation warning
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"{name} uses deprecated control property __plugin_init__, use __plugin_load__ instead".format(
|
||||
name=self.key
|
||||
),
|
||||
DeprecationWarning,
|
||||
)
|
||||
|
||||
# move it
|
||||
init = getattr(self.instance, self.__class__.attr_init)
|
||||
setattr(self.instance, self.__class__.attr_load, init)
|
||||
|
||||
# delete __plugin_init__
|
||||
delattr(self.instance, self.__class__.attr_init)
|
||||
pass
|
||||
|
||||
elif phase == "after_load":
|
||||
# if the plugin still uses __plugin_implementations__, log a deprecation warning and put the first
|
||||
# item into __plugin_implementation__
|
||||
if hasattr(self.instance, self.__class__.attr_implementations):
|
||||
if not hasattr(self.instance, self.__class__.attr_implementation):
|
||||
# deprecation warning
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"{name} uses deprecated control property __plugin_implementations__, use __plugin_implementation__ instead - only the first implementation of {name} will be recognized".format(
|
||||
name=self.key
|
||||
),
|
||||
DeprecationWarning,
|
||||
)
|
||||
|
||||
# put first item into __plugin_implementation__
|
||||
implementations = getattr(
|
||||
self.instance, self.__class__.attr_implementations
|
||||
)
|
||||
if len(implementations) > 0:
|
||||
setattr(
|
||||
self.instance,
|
||||
self.__class__.attr_implementation,
|
||||
implementations[0],
|
||||
)
|
||||
|
||||
# delete __plugin_implementations__
|
||||
delattr(self.instance, self.__class__.attr_implementations)
|
||||
pass
|
||||
|
||||
if additional_validators is not None:
|
||||
for validator in additional_validators:
|
||||
@@ -731,9 +665,24 @@ class PluginInfo(object):
|
||||
|
||||
@property
|
||||
def parsed_metadata(self):
|
||||
"""The plugin metadata parsed from the plugin ``__init__.py``'s AST."""
|
||||
"""The plugin metadata parsed from the plugin's AST."""
|
||||
return self._cached_parsed_metadata
|
||||
|
||||
@property
|
||||
def control_properties(self):
|
||||
return [
|
||||
getattr(self.__class__, key)
|
||||
for key in dir(self.__class__)
|
||||
if key.startswith("attr_")
|
||||
]
|
||||
|
||||
@property
|
||||
def looks_like_plugin(self):
|
||||
"""
|
||||
Returns whether the plugin actually looks like a plugin (has control properties) or not.
|
||||
"""
|
||||
return self.parsed_metadata.get("has_control_properties", False)
|
||||
|
||||
def _parse_metadata(self):
|
||||
result = {}
|
||||
|
||||
@@ -764,6 +713,10 @@ class PluginInfo(object):
|
||||
assignments = list(
|
||||
filter(lambda x: isinstance(x, ast.Assign) and x.targets, root.body)
|
||||
)
|
||||
function_defs = list(
|
||||
filter(lambda x: isinstance(x, ast.FunctionDef) and x.name, root.body)
|
||||
)
|
||||
all_relevant = assignments + function_defs
|
||||
|
||||
def extract_target_ids(node):
|
||||
return list(
|
||||
@@ -773,6 +726,16 @@ class PluginInfo(object):
|
||||
)
|
||||
)
|
||||
|
||||
def extract_names(node):
|
||||
if isinstance(node, ast.Assign):
|
||||
return extract_target_ids(node)
|
||||
elif isinstance(node, ast.FunctionDef):
|
||||
return [
|
||||
node.name,
|
||||
]
|
||||
else:
|
||||
return []
|
||||
|
||||
for key in (
|
||||
self.__class__.attr_name,
|
||||
self.__class__.attr_version,
|
||||
@@ -811,6 +774,12 @@ class PluginInfo(object):
|
||||
|
||||
break
|
||||
|
||||
for a in reversed(all_relevant):
|
||||
targets = extract_names(a)
|
||||
if any(map(lambda x: x in targets, self.control_properties)):
|
||||
result["has_control_properties"] = True
|
||||
break
|
||||
|
||||
except SyntaxError:
|
||||
self._logger.exception(
|
||||
"Invalid syntax in {} for plugin {}".format(path, self.key)
|
||||
@@ -1015,11 +984,8 @@ class PluginManager(object):
|
||||
try:
|
||||
if entry.is_dir():
|
||||
init_py = os.path.join(entry.path, "__init__.py")
|
||||
init_pyc = os.path.join(entry.path, "__init__.pyc")
|
||||
|
||||
if not os.path.isfile(init_py) and not os.path.isfile(
|
||||
init_pyc
|
||||
):
|
||||
if not os.path.isfile(init_py):
|
||||
# neither does exist, we ignore this
|
||||
continue
|
||||
|
||||
@@ -1027,8 +993,8 @@ class PluginManager(object):
|
||||
|
||||
elif entry.is_file():
|
||||
key, ext = os.path.splitext(entry.name)
|
||||
if ext not in (".py", ".pyc") or key.startswith("__"):
|
||||
# neither py nor pyc, or starts with __ (like __init__), we ignore this
|
||||
if ext not in (".py",) or key.startswith("__"):
|
||||
# not py, or starts with __ (like __init__), we ignore this
|
||||
continue
|
||||
|
||||
else:
|
||||
@@ -1405,7 +1371,8 @@ class PluginManager(object):
|
||||
for name, plugin in added.items():
|
||||
try:
|
||||
if (
|
||||
not plugin.blacklisted
|
||||
plugin.looks_like_plugin
|
||||
and not plugin.blacklisted
|
||||
and not plugin.forced_disabled
|
||||
and not plugin.incompatible
|
||||
):
|
||||
@@ -1431,6 +1398,7 @@ class PluginManager(object):
|
||||
try:
|
||||
if (
|
||||
plugin.loaded
|
||||
and plugin.looks_like_plugin
|
||||
and not plugin.forced_disabled
|
||||
and not plugin.incompatible
|
||||
):
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
<a id="navbar_show_prompt" class="pull-right" style="display: none" href="javascript:void(0)" data-bind="click: function() { showPrompt(); }, visible: active() && !visible()" title="{{ _('Message from your printer')|edq }}">
|
||||
<i class="far fa-commenting-dots"></i>
|
||||
<i class="far fa-comment-dots"></i>
|
||||
</a>
|
||||
@@ -29,6 +29,7 @@ from octoprint.server.util.flask import (
|
||||
with_revalidation_checking,
|
||||
)
|
||||
from octoprint.util import count, monotonic_time, utmify
|
||||
from octoprint.util.text import sanitize
|
||||
|
||||
PY2 = sys.version_info[0] < 3
|
||||
|
||||
@@ -47,11 +48,6 @@ class AnnouncementPlugin(
|
||||
self._cached_channel_configs = None
|
||||
self._cached_channel_configs_mutex = threading.RLock()
|
||||
|
||||
from octoprint.vendor.awesome_slugify import Slugify
|
||||
|
||||
self._slugify = Slugify()
|
||||
self._slugify.safe_chars = "-_."
|
||||
|
||||
# Additional permissions hook
|
||||
|
||||
def get_additional_permissions(self):
|
||||
@@ -366,14 +362,14 @@ class AnnouncementPlugin(
|
||||
if config is None or "url" not in config or "name" not in config:
|
||||
# strip invalid entries
|
||||
continue
|
||||
result[self._slugify(key)] = config
|
||||
result[sanitize(key)] = config
|
||||
self._cached_channel_configs = result
|
||||
return self._cached_channel_configs
|
||||
|
||||
def _get_channel_config(self, key, force=False):
|
||||
"""Retrieve specific channel config for channel."""
|
||||
|
||||
safe_key = self._slugify(key)
|
||||
safe_key = sanitize(key)
|
||||
return self._get_channel_configs(force=force).get(safe_key)
|
||||
|
||||
def _fetch_all_channels_async(self, force=False):
|
||||
@@ -524,7 +520,7 @@ class AnnouncementPlugin(
|
||||
def _get_channel_cache_path(self, key):
|
||||
"""Retrieve cache path for channel key."""
|
||||
|
||||
safe_key = self._slugify(key)
|
||||
safe_key = sanitize(key)
|
||||
return os.path.join(self.get_plugin_data_folder(), "{}.cache".format(safe_key))
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ $(function () {
|
||||
5
|
||||
);
|
||||
|
||||
self.unread = ko.observable();
|
||||
self.unread = ko.observable(false);
|
||||
self.hiddenChannels = [];
|
||||
self.channelNotifications = {};
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import octoprint.plugin
|
||||
from octoprint.access import ADMIN_GROUP
|
||||
from octoprint.access.permissions import Permissions
|
||||
from octoprint.events import Events
|
||||
from octoprint.plugin.core import FolderOrigin
|
||||
from octoprint.server import NO_CONTENT
|
||||
from octoprint.server.util.flask import no_firstrun_access
|
||||
from octoprint.settings import default_settings
|
||||
@@ -51,18 +50,13 @@ import sarge
|
||||
from flask_babel import gettext
|
||||
|
||||
from octoprint.settings import valid_boolean_trues
|
||||
from octoprint.util.text import sanitize
|
||||
|
||||
UNKNOWN_PLUGINS_FILE = "unknown_plugins_from_restore.json"
|
||||
|
||||
BACKUP_FILE_PREFIX = "octoprint-backup"
|
||||
|
||||
BACKUP_DATE_TIME_FMT = "%Y%m%d-%H%M%S"
|
||||
|
||||
|
||||
def build_backup_filename():
|
||||
return "{}-{}.zip".format(BACKUP_FILE_PREFIX, time.strftime(BACKUP_DATE_TIME_FMT))
|
||||
|
||||
|
||||
class BackupPlugin(
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
@@ -174,7 +168,7 @@ class BackupPlugin(
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_BACKUP_ACCESS.require(403)
|
||||
def create_backup(self):
|
||||
backup_file = build_backup_filename()
|
||||
backup_file = self._build_backup_filename(settings=self._settings)
|
||||
|
||||
data = flask.request.json
|
||||
exclude = data.get("exclude", [])
|
||||
@@ -490,7 +484,7 @@ class BackupPlugin(
|
||||
if path is not None:
|
||||
datafolder, backup_file = os.path.split(os.path.abspath(path))
|
||||
else:
|
||||
backup_file = build_backup_filename()
|
||||
backup_file = self._build_backup_filename(settings=settings)
|
||||
datafolder = os.path.join(settings.getBaseFolder("data"), "backup")
|
||||
|
||||
if not os.path.isdir(datafolder):
|
||||
@@ -985,22 +979,16 @@ class BackupPlugin(
|
||||
)
|
||||
|
||||
# add list of installed plugins
|
||||
plugins = []
|
||||
plugin_folder = settings.global_get_basefolder("plugins")
|
||||
for plugin in plugin_manager.plugins.values():
|
||||
if plugin.bundled or (
|
||||
isinstance(plugin.origin, FolderOrigin)
|
||||
and plugin.origin.folder == plugin_folder
|
||||
):
|
||||
# ignore anything bundled or from the plugins folder we already include in the backup
|
||||
continue
|
||||
|
||||
plugins.append(
|
||||
{"key": plugin.key, "name": plugin.name, "url": plugin.url}
|
||||
helpers = plugin_manager.get_helpers(
|
||||
"pluginmanager", "generate_plugins_json"
|
||||
)
|
||||
if helpers and "generate_plugins_json" in helpers:
|
||||
plugins = helpers["generate_plugins_json"](
|
||||
settings=settings, plugin_manager=plugin_manager
|
||||
)
|
||||
|
||||
if len(plugins):
|
||||
zip.writestr("plugin_list.json", json.dumps(plugins))
|
||||
if len(plugins):
|
||||
zip.writestr("plugin_list.json", json.dumps(plugins))
|
||||
|
||||
shutil.move(temporary_path, final_path)
|
||||
|
||||
@@ -1290,6 +1278,17 @@ class BackupPlugin(
|
||||
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def _build_backup_filename(cls, settings):
|
||||
if settings.global_get(["appearance", "name"]) == "":
|
||||
backup_prefix = "octoprint"
|
||||
else:
|
||||
backup_prefix = settings.global_get(["appearance", "name"])
|
||||
backup_prefix = sanitize(backup_prefix)
|
||||
return "{}-backup-{}.zip".format(
|
||||
backup_prefix, time.strftime(BACKUP_DATE_TIME_FMT)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _restore_supported(cls, settings):
|
||||
return (
|
||||
|
||||
@@ -47,6 +47,8 @@ from octoprint.util.version import (
|
||||
is_python_compatible,
|
||||
)
|
||||
|
||||
from . import exceptions
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
@@ -401,6 +403,22 @@ class PluginManagerPlugin(
|
||||
)
|
||||
)
|
||||
|
||||
@octoprint.plugin.BlueprintPlugin.route("/export", methods=["GET"])
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_PLUGINMANAGER_MANAGE.require(403)
|
||||
def export_plugin_list(self):
|
||||
import json
|
||||
|
||||
import flask
|
||||
|
||||
plugins = self.generate_plugins_json(self._settings, self._plugin_manager)
|
||||
|
||||
return flask.Response(
|
||||
json.dumps(plugins),
|
||||
mimetype="text/plain",
|
||||
headers={"Content-Disposition": 'attachment; filename="plugin_list.json"'},
|
||||
)
|
||||
|
||||
def is_blueprint_protected(self):
|
||||
return False
|
||||
|
||||
@@ -633,21 +651,32 @@ class PluginManagerPlugin(
|
||||
)
|
||||
|
||||
else:
|
||||
self._logger.error(
|
||||
"{} is neither an archive nor a python file, can't install that.".format(
|
||||
source
|
||||
)
|
||||
raise exceptions.InvalidPackageFormat()
|
||||
except requests.exceptions.HTTPError as e:
|
||||
self._logger.error("Could not fetch plugin from server, got {}".format(e))
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not fetch plugin from server, got {}".format(e),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
except exceptions.InvalidPackageFormat:
|
||||
self._logger.error(
|
||||
"{} is neither an archive nor a python file, can't install that.".format(
|
||||
source
|
||||
)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from {}, was neither "
|
||||
"a plugin archive nor a single file plugin".format(source),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from {}, was neither "
|
||||
"a plugin archive nor a single file plugin".format(source),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
finally:
|
||||
if folder is not None:
|
||||
folder.cleanup()
|
||||
@@ -671,11 +700,19 @@ class PluginManagerPlugin(
|
||||
and not self._settings.get_boolean(["ignore_throttled"])
|
||||
):
|
||||
# currently throttled, we refuse to run
|
||||
return make_response(
|
||||
"System is currently throttled, refusing to install "
|
||||
"anything due to possible stability issues",
|
||||
409,
|
||||
error_msg = (
|
||||
"System is currently throttled, refusing to install anything"
|
||||
" due to possible stability isssues"
|
||||
)
|
||||
self._logger.error(error_msg)
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": error_msg,
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
try:
|
||||
# Py3
|
||||
@@ -745,11 +782,20 @@ class PluginManagerPlugin(
|
||||
"Looks like the plugin was already installed. Forcing a reinstall."
|
||||
)
|
||||
force = True
|
||||
except Exception:
|
||||
self._logger.exception("Could not install plugin from %s" % source)
|
||||
return make_response(
|
||||
"Could not install plugin from URL, see the log for more details", 500
|
||||
)
|
||||
except Exception as e:
|
||||
self._logger.exception("Could not install plugin from {}".format(source))
|
||||
self._logger.exception("Reason: {}".format(repr(e)))
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from {}, see the log for more details".format(
|
||||
source
|
||||
),
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
else:
|
||||
if force:
|
||||
# We don't use --upgrade here because that will also happily update all our dependencies - we'd rather
|
||||
@@ -757,16 +803,21 @@ class PluginManagerPlugin(
|
||||
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]
|
||||
try:
|
||||
returncode, stdout, stderr = self._call_pip(pip_args)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
self._logger.exception(
|
||||
"Could not install plugin from {}".format(source)
|
||||
)
|
||||
return make_response(
|
||||
"Could not install plugin from source {}, see the log for more details".format(
|
||||
self._logger.exception("Reason: {}".format(repr(e)))
|
||||
result = {
|
||||
"result": False,
|
||||
"source": source,
|
||||
"source_type": source_type,
|
||||
"reason": "Could not install plugin from source {}, see the log for more details".format(
|
||||
source
|
||||
),
|
||||
500,
|
||||
)
|
||||
}
|
||||
self._send_result_notification("install", result)
|
||||
return result
|
||||
|
||||
try:
|
||||
result_line = list(
|
||||
@@ -1057,6 +1108,9 @@ class PluginManagerPlugin(
|
||||
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)
|
||||
)
|
||||
os.remove(pyc_file)
|
||||
|
||||
else:
|
||||
@@ -1752,6 +1806,24 @@ class PluginManagerPlugin(
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def generate_plugins_json(
|
||||
settings, plugin_manager, ignore_bundled=True, ignore_plugins_folder=True
|
||||
):
|
||||
plugins = []
|
||||
plugin_folder = settings.getBaseFolder("plugins")
|
||||
for plugin in plugin_manager.plugins.values():
|
||||
if (ignore_bundled and plugin.bundled) or (
|
||||
ignore_plugins_folder
|
||||
and isinstance(plugin.origin, octoprint.plugin.core.FolderOrigin)
|
||||
and plugin.origin.folder == plugin_folder
|
||||
):
|
||||
# ignore bundled or from the plugins folder already included in the backup
|
||||
continue
|
||||
|
||||
plugins.append({"key": plugin.key, "name": plugin.name, "url": plugin.url})
|
||||
return plugins
|
||||
|
||||
def _to_external_plugin(self, plugin):
|
||||
return {
|
||||
"key": plugin.key,
|
||||
@@ -1895,3 +1967,8 @@ def __plugin_load__():
|
||||
"octoprint.events.register_custom_events": _register_custom_events,
|
||||
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions,
|
||||
}
|
||||
|
||||
global __plugin_helpers__
|
||||
__plugin_helpers__ = {
|
||||
"generate_plugins_json": __plugin_implementation__.generate_plugins_json,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
class InvalidPackageFormat(Exception):
|
||||
pass
|
||||
@@ -1 +1,2 @@
|
||||
#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name .prop,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name .prop{white-space:nowrap}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:400px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .meta{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .stats .prop{white-space:nowrap}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
|
||||
#settings_plugin_pluginmanager_navbar{position:-webkit-sticky;position:sticky;top:0;padding-bottom:1px;border-bottom:1px solid #ddd;background:white}#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name .prop,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name .prop{white-space:nowrap}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px !important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px;padding-right:10px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty{overflow:hidden;width:100%;height:400px;background-image:url("../img/repo_unavailable.png");text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .meta{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .stats .prop{white-space:nowrap}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:bold}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:bold;color:#990000}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#990000}#settings_plugin_pluginmanager_workingdialog_output .call{color:#000099}
|
||||
/*# sourceMappingURL=pluginmanager.css.map */
|
||||
@@ -1,12 +1,19 @@
|
||||
#settings_plugin_pluginmanager {
|
||||
}
|
||||
|
||||
#settings_plugin_pluginmanager_navbar {
|
||||
position: -webkit-sticky; /* Safari, according to the internet */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
padding-bottom: 1px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
background: white;
|
||||
}
|
||||
|
||||
#settings_plugin_pluginmanager_pluginlist {
|
||||
display: block;
|
||||
width: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 2px;
|
||||
margin-bottom: 1em;
|
||||
|
||||
|
||||
@@ -52,35 +52,73 @@
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="settings_plugin_pluginmanager_plugins">
|
||||
{{ pluginmanager_printing() }}
|
||||
{{ pluginmanager_nopip() }}
|
||||
{{ pluginmanager_safemode() }}
|
||||
{{ pluginmanager_throttled() }}
|
||||
{{ pluginmanager_requesterror() }}
|
||||
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Installed Plugins') }}</h3>
|
||||
|
||||
<div style="margin-bottom: 1em" class="clearfix">
|
||||
<input type="text" class="input-block search-query pull-left" data-bind="value: listingSearchQuery, valueUpdate: 'input'" placeholder="{{ _('Search...')|edq }}">
|
||||
<div id="settings_plugin_pluginmanager_navbar">
|
||||
{{ pluginmanager_printing() }}
|
||||
{{ pluginmanager_nopip() }}
|
||||
{{ pluginmanager_safemode() }}
|
||||
{{ pluginmanager_throttled() }}
|
||||
{{ pluginmanager_requesterror() }}
|
||||
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('bundled'); plugins.removeFilter('3rdparty'); }, css: {active: !_.contains(plugins.currentFilters(), 'bundled') && !_.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show both bundled and third-party plugins')|edq }}">All</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('bundled') }, css: {active: _.contains(plugins.currentFilters(), 'bundled')}" title="{{ _('Show only bundled plugins')|edq }}">{{ _('Bundled') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('3rdparty') }, css: {active: _.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show only third-party plugins')|edq }}">{{ _('3rd party') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: $root.showRepository"><i class="fas fa-plus"></i> {{ _('Get More') }}</button>
|
||||
<a class="btn btn-small" href="/plugin/pluginmanager/export"><i class="fas fa-download"></i> {{ _('Export') }}</a>
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
|
||||
<a class="btn btn-small" data-toggle="collapse" href="#pluginmanager_info" title="{{ _('Info') }}"><i class="fas fa-lg fa-info-circle text-info" data-bind="css: {'text-error': noticeCount() > 0, 'text-info': noticeCount() <=0 }"></i></a>
|
||||
</div>
|
||||
<div id="pluginmanager_info" class="collapse" data-bind="css: {'in': noticeCount() > 0}">
|
||||
<div class="muted" data-bind="visible: pipAvailable()">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="fas toggle-arrow fa-caret-right"></i> Using pip of "<span data-bind="text: pipPython"></span>", Version <span data-bind="text: pipVersion"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
Installation directory: <span data-bind="text: pipInstallDir"></span> ("--user" flag: <span data-bind="text: pipUseUserString"></span>)<br />
|
||||
Virtual environment: <span data-bind="text: pipVirtualEnvString"></span><br />
|
||||
<span data-bind="visible: pipAdditionalArgs">Additional Arguments: <span data-bind="text: pipAdditionalArgs"></span></span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('enabled'); plugins.removeFilter('disabled'); }, css: {active: !_.contains(plugins.currentFilters(), 'enabled') && !_.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show both enabled and disabled plugins')|edq }}">All</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('enabled') }, css: {active: _.contains(plugins.currentFilters(), 'enabled')}" title="{{ _('Show only enabled plugins')|edq }}">{{ _('Enabled') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('disabled') }, css: {active: _.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show only disabled plugins')|edq }}">{{ _('Disabled') }}</button>
|
||||
|
||||
<div class="muted">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="toggle-arrow fas fa-caret-right"></i> <span data-bind="text: noticeCountText, css: {'text-error': noticeCount() > 0, 'text-info': noticeCount() <=0 }"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
<!-- ko if: noticeCount() > 0 --><a href="javascript:void(0)" data-bind="click: function() { reshowNotices(); }">{{ _('Reshow current notices') }}</a> ·<!-- /ko -->
|
||||
<a href="javascript:void(0)" data-bind="click: function() { refreshNotices(); }">{{ _('Refresh notices from repository') }}</a>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Installed Plugins') }}</h3>
|
||||
|
||||
<div style="margin-bottom: 1em" class="clearfix">
|
||||
<input type="text" class="input-block search-query pull-left" data-bind="value: listingSearchQuery, valueUpdate: 'input'" placeholder="{{ _('Search...')|edq }}">
|
||||
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('bundled'); plugins.removeFilter('3rdparty'); }, css: {active: !_.contains(plugins.currentFilters(), 'bundled') && !_.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show both bundled and third-party plugins')|edq }}">All</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('bundled') }, css: {active: _.contains(plugins.currentFilters(), 'bundled')}" title="{{ _('Show only bundled plugins')|edq }}">{{ _('Bundled') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('3rdparty') }, css: {active: _.contains(plugins.currentFilters(), '3rdparty')}" title="{{ _('Show only third-party plugins')|edq }}">{{ _('3rd party') }}</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.removeFilter('enabled'); plugins.removeFilter('disabled'); }, css: {active: !_.contains(plugins.currentFilters(), 'enabled') && !_.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show both enabled and disabled plugins')|edq }}">All</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('enabled') }, css: {active: _.contains(plugins.currentFilters(), 'enabled')}" title="{{ _('Show only enabled plugins')|edq }}">{{ _('Enabled') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { plugins.addFilter('disabled') }, css: {active: _.contains(plugins.currentFilters(), 'disabled')}" title="{{ _('Show only disabled plugins')|edq }}">{{ _('Disabled') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings_plugin_pluginmanager_pluginlist">
|
||||
<table class="table table-striped table-hover table-condensed table-hover">
|
||||
<thead>
|
||||
@@ -112,43 +150,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-block" data-bind="click: $root.showRepository">{{ _('Get More...') }}</button>
|
||||
|
||||
<div class="muted" data-bind="visible: pipAvailable()">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="fas toggle-arrow fa-caret-right"></i> Using pip of "<span data-bind="text: pipPython"></span>", Version <span data-bind="text: pipVersion"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
Installation directory: <span data-bind="text: pipInstallDir"></span> ("--user" flag: <span data-bind="text: pipUseUserString"></span>)<br />
|
||||
Virtual environment: <span data-bind="text: pipVirtualEnvString"></span><br />
|
||||
<span data-bind="visible: pipAdditionalArgs">Additional Arguments: <span data-bind="text: pipAdditionalArgs"></span></span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="muted">
|
||||
<div>
|
||||
<small>
|
||||
<a href="javascript:void(0)" class="muted" onclick="$(this).children('i.toggle-arrow').toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')">
|
||||
<i class="toggle-arrow fas fa-caret-right"></i> <span data-bind="text: noticeCountText"></span>
|
||||
</a>
|
||||
</small>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<small>
|
||||
<!-- ko if: noticeCount() > 0 --><a href="javascript:void(0)" data-bind="click: function() { reshowNotices(); }">{{ _('Reshow current notices') }}</a> ·<!-- /ko -->
|
||||
<a href="javascript:void(0)" data-bind="click: function() { refreshNotices(); }">{{ _('Refresh notices from repository') }}</a>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="settings_plugin_pluginmanager_cleanup">
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.requestData({refresh_orphans: true}) }" title="{{ _('Refresh')|edq }}"><i class="fas fa-sync"></i></button>
|
||||
|
||||
@@ -92,7 +92,7 @@ class SoftwareUpdatePlugin(
|
||||
self._environment_ready = threading.Event()
|
||||
|
||||
self._storage_sufficient = True
|
||||
self.storage_info = {}
|
||||
self._storage_info = {}
|
||||
|
||||
self._console_logger = None
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:700}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:700;color:#666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#900}#settings_plugin_softwareupdate_workingdialog_output .call{color:#009}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:700;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}div.swupdate-advanced{margin-bottom:5px}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:bold}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:bold;color:#666666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#990000}#settings_plugin_softwareupdate_workingdialog_output .call{color:#000099}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:bold;color:#990000}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
/*# sourceMappingURL=softwareupdate.css.map */
|
||||
@@ -1,13 +1,15 @@
|
||||
#settings_plugin_softwareupdate_updatelist {
|
||||
display: block;
|
||||
width: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
padding-right: 2px;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
div.swupdate-advanced {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
td.settings_plugin_softwareupdate_column_update {
|
||||
width: 16px;
|
||||
|
||||
|
||||
@@ -71,11 +71,22 @@
|
||||
{% endtrans %}</div>
|
||||
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-primary" data-bind="click: function() { $root.updateAll(); }, enable: enableUpdate, css: {disabled: !enableUpdate}"><i class="fas fa-spinner fa-spin" data-bind="visible: updateInProgress"></i> {{ _('Update all') }}</button>
|
||||
<button class="btn" data-bind="click: function() { $root.performCheck(true, false, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fas fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Check for updates') }}</button>
|
||||
<button class="btn btn-small" data-bind="click: function() { $root.showPluginSettings(); }" title="{{ _('Plugin Configuration')|edq }}"><i class="fas fa-wrench"></i></button>
|
||||
</div>
|
||||
|
||||
<h3>{{ _('Current versions') }}</h3>
|
||||
|
||||
<div class="swupdate-advanced">
|
||||
<div><small><a href="javascript:void(0)" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fas fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<small class="muted" style="display: block">{{ _('Last cache refresh:') }} <span data-bind="text: cacheTimestampText"></span></small>
|
||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fas fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
||||
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.updateAll(true); }, enable: enableUpdate() && !checking(), css: {disabled: !enableUpdate() || checking()}"><i class="fas fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update all (even if no new versions are available)') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings_plugin_softwareupdate_updatelist">
|
||||
<table class="table table-striped table-hover table-condensed table-hover">
|
||||
<tbody data-bind="foreach: versions.paginatedItems">
|
||||
@@ -99,17 +110,8 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary btn-block" data-bind="click: function() { $root.updateAll(); }, enable: enableUpdate, css: {disabled: !enableUpdate}"><i class="fas fa-spinner fa-spin" data-bind="visible: updateInProgress"></i> {{ _('Update all') }}</button>
|
||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, false, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fas fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Check for update now') }}</button>
|
||||
|
||||
<div>
|
||||
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fas fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<small class="muted" style="display: block">{{ _('Last cache refresh:') }} <span data-bind="text: cacheTimestampText"></span></small>
|
||||
<button class="btn btn-block" data-bind="click: function() { $root.performCheck(true, true, true); }, enable: !checking(), css: {disabled: checking()}"><i class="fas fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force check for update (overrides cache used for update checks)') }}</button>
|
||||
<button class="btn btn-block btn-danger" data-bind="visible: CONFIG_DEBUG, click: function() { $root.updateAll(true); }, enable: enableUpdate() && !checking(), css: {disabled: !enableUpdate() || checking()}"><i class="fas fa-spinner fa-spin" data-bind="visible: checking"></i> {{ _('Force update all (even if no new versions are available)') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="settings_plugin_softwareupdate_configurationdialog" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
|
||||
@@ -241,7 +241,8 @@ class TrackingPlugin(
|
||||
return
|
||||
|
||||
uptime = int(monotonic_time() - self._startup_time)
|
||||
self._track("ping", octoprint_uptime=uptime)
|
||||
printer_state = self._printer.get_state_id()
|
||||
self._track("ping", octoprint_uptime=uptime, printer_state=printer_state)
|
||||
|
||||
def _track_pong(self):
|
||||
if not self._settings.get_boolean(["events", "pong"]):
|
||||
|
||||
@@ -9,8 +9,14 @@
|
||||
</p>
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="javascript:void(0)" class="btn span6" data-bind="click: function() { if(!setup()){disableUsage()}}, enable: !setup(), css: {disabled: setup()}"><i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === false"></i> {{ _('Disable Anonymous Usage Tracking') }}</a>
|
||||
<a href="javascript:void(0)" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enableUsage()}}, enable: !setup(), css: {disabled: setup()}"><i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === true"></i> {{ _('Enable Anonymous Usage Tracking') }}</a>
|
||||
<a href="javascript:void(0)" class="btn span6" data-bind="click: function() { if(!setup() || decision()){disableUsage()}}, enable: !setup() || decision(), css: {disabled: setup() && !decision()}">
|
||||
<i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === false"></i>
|
||||
{{ _('Disable Anonymous Usage Tracking') }}
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="btn btn-primary span6" data-bind="click: function() { if(!setup() || !decision()){enableUsage()}}, enable: !setup() || !decision(), css: {disabled: setup() && decision}">
|
||||
<i class="fas fa-spinner fa-spin" style="display: none" data-bind="visible: active() && decision() === true"></i>
|
||||
{{ _('Enable Anonymous Usage Tracking') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="tracking_decision" style="display: none" data-bind="visible: setup()">
|
||||
|
||||
@@ -202,7 +202,7 @@ class VirtualPrinter(object):
|
||||
|
||||
self._received_lines = 0
|
||||
self._resend_every_n = 0
|
||||
self._calculate_resend_every_n(self._settings.get(["resend_ratio"]))
|
||||
self._calculate_resend_every_n(self._settings.get_int(["resend_ratio"]))
|
||||
|
||||
self._dont_answer = False
|
||||
|
||||
@@ -1091,7 +1091,7 @@ class VirtualPrinter(object):
|
||||
if key == "S":
|
||||
pass
|
||||
else:
|
||||
self._virtual_eeprom.eeprom["advanced"]["params"][material_no][
|
||||
self._virtual_eeprom.eeprom["material"]["params"][material_no][
|
||||
key
|
||||
] = float(value)
|
||||
|
||||
@@ -1137,7 +1137,7 @@ class VirtualPrinter(object):
|
||||
config = self._virtual_eeprom.eeprom["material"]
|
||||
lines = []
|
||||
for material in ["0", "1"]:
|
||||
line = "echo: " + config["command"] + "S" + material
|
||||
line = "echo: " + config["command"] + " S" + material
|
||||
for param, saved_value in config["params"][material].items():
|
||||
line = line + " " + param + str(saved_value)
|
||||
lines.append(line)
|
||||
|
||||
@@ -18,6 +18,7 @@ import time
|
||||
from frozendict import frozendict
|
||||
from past.builtins import basestring, long
|
||||
|
||||
import octoprint.util.json
|
||||
from octoprint import util as util
|
||||
from octoprint.events import Events, eventManager
|
||||
from octoprint.filemanager import FileDestinations, NoSuchStorage, valid_file_type
|
||||
@@ -147,7 +148,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
on_get_resends=self._updateResendDataCallback,
|
||||
)
|
||||
self._stateMonitor.reset(
|
||||
state=self._dict(text=self.get_state_string(), flags=self._getStateFlags()),
|
||||
state=self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
),
|
||||
job_data=self._dict(
|
||||
file=self._dict(name=None, path=None, size=None, origin=None, date=None),
|
||||
estimatedPrintTime=None,
|
||||
@@ -272,7 +277,13 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
try:
|
||||
additional = hook(initial=initial)
|
||||
if additional and isinstance(additional, dict):
|
||||
octoprint.util.json.dump({name: additional})
|
||||
plugin_data[name] = additional
|
||||
except ValueError:
|
||||
self._logger.exception(
|
||||
"Invalid additional data from plugin {}".format(name),
|
||||
extra={"plugin": name},
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"Error while retrieving additional data from plugin {}, blacklisting it for further loops".format(
|
||||
@@ -790,6 +801,12 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
else:
|
||||
return self._comm.getStateId(state=state)
|
||||
|
||||
def get_error(self):
|
||||
if self._comm is None:
|
||||
return ""
|
||||
else:
|
||||
return self._comm.getErrorString()
|
||||
|
||||
def get_current_data(self, *args, **kwargs):
|
||||
return util.thaw_frozendict(self._stateMonitor.get_current_data())
|
||||
|
||||
@@ -1043,13 +1060,15 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._currentZ = currentZ
|
||||
self._stateMonitor.set_current_z(self._currentZ)
|
||||
|
||||
def _setState(self, state, state_string=None):
|
||||
def _setState(self, state, state_string=None, error_string=None):
|
||||
if state_string is None:
|
||||
state_string = self.get_state_string()
|
||||
if error_string is None:
|
||||
error_string = self.get_error()
|
||||
|
||||
self._state = state
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=state_string, flags=self._getStateFlags())
|
||||
self._dict(text=state_string, flags=self._getStateFlags(), error=error_string)
|
||||
)
|
||||
|
||||
payload = {
|
||||
@@ -1419,8 +1438,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
oldState = self._state
|
||||
|
||||
state_string = None
|
||||
error_string = None
|
||||
if self._comm is not None:
|
||||
state_string = self._comm.getStateString()
|
||||
error_string = self._comm.getErrorString()
|
||||
|
||||
if oldState in (comm.MachineCom.STATE_PRINTING,):
|
||||
# if we were still printing and went into an error state, mark the print as failed
|
||||
@@ -1481,7 +1502,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._printerProfileManager.deselect()
|
||||
eventManager().fire(Events.DISCONNECTED)
|
||||
|
||||
self._setState(state, state_string=state_string)
|
||||
self._setState(state, state_string=state_string, error_string=error_string)
|
||||
|
||||
def on_comm_message(self, message):
|
||||
"""
|
||||
@@ -1512,7 +1533,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
def on_comm_sd_state_change(self, sdReady):
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=self.get_state_string(), flags=self._getStateFlags())
|
||||
self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
)
|
||||
)
|
||||
|
||||
def on_comm_sd_files(self, files):
|
||||
@@ -1544,7 +1569,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
|
||||
self._setJobData(full_path, size, sd, user=user)
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=self.get_state_string(), flags=self._getStateFlags())
|
||||
self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
)
|
||||
)
|
||||
|
||||
self._create_estimator()
|
||||
@@ -1591,7 +1620,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
printTimeLeft=0,
|
||||
)
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=self.get_state_string(), flags=self._getStateFlags())
|
||||
self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
)
|
||||
)
|
||||
|
||||
eventManager().fire(Events.PRINT_DONE, payload)
|
||||
@@ -1628,7 +1661,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
else:
|
||||
self._updateProgressData()
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=self.get_state_string(), flags=self._getStateFlags())
|
||||
self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
)
|
||||
)
|
||||
|
||||
def on_comm_print_job_cancelling(self, firmware_error=None, user=None):
|
||||
@@ -1744,7 +1781,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._setJobData(remote_filename, filesize, True, user=user)
|
||||
self._updateProgressData(completion=0.0, filepos=0, printTime=0)
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=self.get_state_string(), flags=self._getStateFlags())
|
||||
self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
)
|
||||
)
|
||||
|
||||
def on_comm_file_transfer_done(
|
||||
@@ -1771,7 +1812,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._setJobData(None, None, None)
|
||||
self._updateProgressData()
|
||||
self._stateMonitor.set_state(
|
||||
self._dict(text=self.get_state_string(), flags=self._getStateFlags())
|
||||
self._dict(
|
||||
text=self.get_state_string(),
|
||||
flags=self._getStateFlags(),
|
||||
error=self.get_error(),
|
||||
)
|
||||
)
|
||||
|
||||
def on_comm_file_transfer_failed(self, local_filename, remote_filename, elapsed):
|
||||
|
||||
@@ -79,10 +79,12 @@ def controlJob():
|
||||
@Permissions.STATUS.require(403)
|
||||
def jobState():
|
||||
currentData = printer.get_current_data()
|
||||
return jsonify(
|
||||
{
|
||||
"job": currentData["job"],
|
||||
"progress": currentData["progress"],
|
||||
"state": currentData["state"]["text"],
|
||||
}
|
||||
)
|
||||
response = {
|
||||
"job": currentData["job"],
|
||||
"progress": currentData["progress"],
|
||||
"state": currentData["state"]["text"],
|
||||
}
|
||||
if currentData["state"]["error"]:
|
||||
response["error"] = currentData["state"]["error"]
|
||||
|
||||
return jsonify(**response)
|
||||
@@ -9,6 +9,7 @@ import logging
|
||||
|
||||
from flask import abort, jsonify, make_response, request
|
||||
from flask_login import current_user
|
||||
from past.builtins import basestring
|
||||
from werkzeug.exceptions import BadRequest
|
||||
|
||||
import octoprint.plugin
|
||||
@@ -932,6 +933,8 @@ def _saveSettings(data):
|
||||
for name, script in data["scripts"]["gcode"].items():
|
||||
if name == "snippets":
|
||||
continue
|
||||
if not isinstance(script, basestring):
|
||||
continue
|
||||
s.saveScript(
|
||||
"gcode", name, script.replace("\r\n", "\n").replace("\r", "\n")
|
||||
)
|
||||
|
||||
@@ -5,7 +5,6 @@ __author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__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 json
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
@@ -27,7 +26,7 @@ from octoprint.access.permissions import Permissions
|
||||
from octoprint.access.users import LoginStatusListener
|
||||
from octoprint.events import Events
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util.json import JsonEncoding
|
||||
from octoprint.util.json import dump as json_dump
|
||||
|
||||
|
||||
class ThreadSafeSession(octoprint.vendor.sockjs.tornado.session.Session):
|
||||
@@ -67,11 +66,7 @@ class ThreadSafeSession(octoprint.vendor.sockjs.tornado.session.Session):
|
||||
class JsonEncodingSessionWrapper(wrapt.ObjectProxy):
|
||||
def send_message(self, msg, stats=True, binary=False):
|
||||
self.send_jsonified(
|
||||
json.dumps(
|
||||
octoprint.vendor.sockjs.tornado.util.bytes_to_str(msg),
|
||||
separators=(",", ":"),
|
||||
default=JsonEncoding.encode,
|
||||
),
|
||||
json_dump(octoprint.vendor.sockjs.tornado.util.bytes_to_str(msg)),
|
||||
stats,
|
||||
)
|
||||
|
||||
|
||||
@@ -616,14 +616,16 @@ def index():
|
||||
if plugin is not None and isinstance(
|
||||
plugin.implementation, octoprint.plugin.UiPlugin
|
||||
):
|
||||
permissions = plugin.get_ui_permissions()
|
||||
permissions = plugin.implementation.get_ui_permissions()
|
||||
response = require_login(*permissions)
|
||||
if not response:
|
||||
response = plugin_view(plugin.implementation)
|
||||
if _logger.isEnabledFor(logging.DEBUG) and isinstance(
|
||||
response, Response
|
||||
):
|
||||
response.headers["X-Ui-Plugin"] = plugin._identifier
|
||||
response.headers[
|
||||
"X-Ui-Plugin"
|
||||
] = plugin.implementation._identifier
|
||||
else:
|
||||
response = require_login(*default_permissions)
|
||||
if not response:
|
||||
|
||||
@@ -24,6 +24,7 @@ __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 fnmatch
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
@@ -47,6 +48,11 @@ try:
|
||||
except ImportError:
|
||||
from collections import KeysView
|
||||
|
||||
try:
|
||||
from os import scandir
|
||||
except ImportError:
|
||||
from scandir import scandir
|
||||
|
||||
from octoprint.util import (
|
||||
CaseInsensitiveSet,
|
||||
atomic_write,
|
||||
@@ -60,7 +66,7 @@ _APPNAME = "OctoPrint"
|
||||
_instance = None
|
||||
|
||||
|
||||
def settings(init=False, basedir=None, configfile=None):
|
||||
def settings(init=False, basedir=None, configfile=None, overlays=None):
|
||||
"""
|
||||
Factory method for initially constructing and consecutively retrieving the :class:`~octoprint.settings.Settings`
|
||||
singleton.
|
||||
@@ -75,6 +81,7 @@ def settings(init=False, basedir=None, configfile=None):
|
||||
``~/Library/Application Support/OctoPrint`` on MacOS.
|
||||
configfile (str): Path of the configuration file (``config.yaml``) to work on. If not set the default will
|
||||
be used: ``<basedir>/config.yaml`` for ``basedir`` as defined above.
|
||||
overlays (list): List of paths to config overlays to put between default settings and config.yaml
|
||||
|
||||
Returns:
|
||||
Settings: The fully initialized :class:`Settings` instance.
|
||||
@@ -89,7 +96,9 @@ def settings(init=False, basedir=None, configfile=None):
|
||||
|
||||
else:
|
||||
if init:
|
||||
_instance = Settings(configfile=configfile, basedir=basedir)
|
||||
_instance = Settings(
|
||||
configfile=configfile, basedir=basedir, overlays=overlays
|
||||
)
|
||||
else:
|
||||
raise ValueError("Settings not initialized yet")
|
||||
|
||||
@@ -133,6 +142,7 @@ default_settings = {
|
||||
"disconnectOnErrors": True,
|
||||
"ignoreErrorsFromFirmware": False,
|
||||
"terminalLogSize": 20,
|
||||
"lastLineBufferSize": 50,
|
||||
"logResends": True,
|
||||
"supportResendsWithoutOk": "detect",
|
||||
"logPositionOnPause": True,
|
||||
@@ -211,7 +221,7 @@ default_settings = {
|
||||
"onlineCheck": {
|
||||
"enabled": None,
|
||||
"interval": 15 * 60, # 15 min
|
||||
"host": "8.8.8.8",
|
||||
"host": "1.1.1.1",
|
||||
"port": 53,
|
||||
"name": "octoprint.org",
|
||||
},
|
||||
@@ -355,7 +365,11 @@ default_settings = {
|
||||
"plugin_pi_support",
|
||||
],
|
||||
"usersettings": ["access", "interface"],
|
||||
"wizard": ["plugin_backup", "plugin_corewizard_acl"],
|
||||
"wizard": [
|
||||
"plugin_backup",
|
||||
"plugin_corewizard_acl",
|
||||
"plugin_corewizard_onlinecheck",
|
||||
],
|
||||
"about": [
|
||||
"about",
|
||||
"plugin_pi_support",
|
||||
@@ -658,14 +672,18 @@ class Settings(object):
|
||||
|
||||
OVERLAY_KEY = "__overlay__"
|
||||
|
||||
def __init__(self, configfile=None, basedir=None):
|
||||
def __init__(self, configfile=None, basedir=None, overlays=None):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._basedir = None
|
||||
|
||||
if overlays is None:
|
||||
overlays = []
|
||||
|
||||
assert isinstance(default_settings, dict)
|
||||
|
||||
self._map = HierarchicalChainMap({}, default_settings)
|
||||
self.load_overlays(overlays)
|
||||
|
||||
self._config = None
|
||||
self._dirty = False
|
||||
@@ -1012,6 +1030,34 @@ class Settings(object):
|
||||
|
||||
self._forget_hashes()
|
||||
|
||||
def load_overlays(self, overlays, migrate=True):
|
||||
for overlay in overlays:
|
||||
if not os.path.exists(overlay):
|
||||
continue
|
||||
|
||||
def process(path):
|
||||
try:
|
||||
overlay_config = self.load_overlay(path, migrate=migrate)
|
||||
self.add_overlay(overlay_config)
|
||||
self._logger.info("Added config overlay from {}".format(path))
|
||||
except Exception:
|
||||
self._logger.exception(
|
||||
"Could not add config overlay from {}".format(path)
|
||||
)
|
||||
|
||||
if os.path.isfile(overlay):
|
||||
process(overlay)
|
||||
|
||||
elif os.path.isdir(overlay):
|
||||
for entry in scandir(overlay):
|
||||
name = entry.name
|
||||
path = entry.path
|
||||
|
||||
if is_hidden_path(path) or not fnmatch.fnmatch(name, "*.yaml"):
|
||||
continue
|
||||
|
||||
process(path)
|
||||
|
||||
def load_overlay(self, overlay, migrate=True):
|
||||
config = None
|
||||
|
||||
|
||||
@@ -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-repeaLine truncated
|
||||
.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,0.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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*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:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.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:hover,.btn:focus{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:thin dotted #333;outline:5px auto -webkit-focus-ring-color;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.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.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,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;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btnLine truncated
|
||||
@@ -228,12 +228,15 @@ $(function () {
|
||||
[
|
||||
// printer states
|
||||
gettext("Offline"),
|
||||
gettext("Offline after error"),
|
||||
gettext("Error"),
|
||||
gettext("Opening serial connection"),
|
||||
gettext("Detecting serial connection"),
|
||||
gettext("Connecting"),
|
||||
gettext("Operational"),
|
||||
gettext("Starting"),
|
||||
gettext("Starting print from SD"),
|
||||
gettext("Starting to send file to SD"),
|
||||
gettext("Printing from SD"),
|
||||
gettext("Sending file to SD"),
|
||||
gettext("Printing"),
|
||||
|
||||
@@ -1130,7 +1130,10 @@ $(function () {
|
||||
return false;
|
||||
}
|
||||
|
||||
var success = entry["name"].toLocaleLowerCase().indexOf(query) > -1;
|
||||
var success =
|
||||
(entry["display"] &&
|
||||
entry["display"].toLocaleLowerCase().indexOf(query) > -1) ||
|
||||
entry["name"].toLocaleLowerCase().indexOf(query) > -1;
|
||||
if (!success && entry["type"] === "folder" && entry["children"]) {
|
||||
return _.any(entry["children"], recursiveSearch);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ $(function () {
|
||||
self.access = parameters[2];
|
||||
|
||||
self.stateString = ko.observable(undefined);
|
||||
self.errorString = ko.observable(undefined);
|
||||
self.hasErrorString = ko.pureComputed(function () {
|
||||
return !!self.errorString();
|
||||
});
|
||||
|
||||
self.resendCount = ko.observable(0);
|
||||
self.resendTotalTransmitted = ko.observable(0);
|
||||
@@ -243,10 +247,6 @@ $(function () {
|
||||
|
||||
self.userString = ko.pureComputed(function () {
|
||||
var user = self.user();
|
||||
if (!CONFIG_ACCESS_CONTROL || user === "_dummy") {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (user === "_api") {
|
||||
user = "API client";
|
||||
}
|
||||
@@ -291,6 +291,7 @@ $(function () {
|
||||
var prevPaused = self.isPaused();
|
||||
|
||||
self.stateString(gettext(data.text));
|
||||
self.errorString(data.error);
|
||||
self.isErrorOrClosed(data.flags.closedOrError);
|
||||
self.isOperational(data.flags.operational);
|
||||
self.isPaused(data.flags.paused);
|
||||
|
||||
@@ -406,7 +406,7 @@ $(function () {
|
||||
self.addTerminalFilter = function () {
|
||||
self.terminalFilters.push({
|
||||
name: "New",
|
||||
regex: "(Send: (Nd+s+)?M105)|(Recv:s+(oks+)?.*(B|Td*):d+)"
|
||||
regex: "(Send:\\s+(N\\d+\\s+)?M105)|(Recv:\\s+(ok\\s+)?.*(B|T\\d*):\\d+)"
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1010,7 +1010,7 @@ ul.dropdown-menu li a {
|
||||
}
|
||||
|
||||
#footer_version,
|
||||
#footer_link {
|
||||
#footer_links {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
<legend>{{ _('Global API Key') }}</legend>
|
||||
<div class="alert">
|
||||
<p>{% trans %}
|
||||
The global API key should best not be used anymore. It's one single key that gives full admin access to
|
||||
your whole OctoPrint instance. Instead of using it you should create individual Application Keys for
|
||||
It is recommended to no longer use the global API key as it's one single key that gives full admin access
|
||||
to your whole OctoPrint instance. <strong>It will be removed in OctoPrint 2.0</strong>.
|
||||
Instead of using the global key you should create individual Application Keys for
|
||||
your third party clients. That way they get permissions matching the user account used for key
|
||||
creation and you can also revoke access to one app without having to change the keys for all other apps.
|
||||
It's also recommended to create a user account without admin access and use that for third
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<span title="{{ _('Current printer state')|edq }}">{{ _('State') }}</span>: <strong data-test-id="state-string" data-bind="text: stateString"></strong><br>
|
||||
<span data-bind="visible: hasErrorString" class="text-error"><span data-test-id="error-string" data-bind="text: errorString"></span><br></span>
|
||||
<span data-bind="visible: isOperational"><span title="{{ _('Count of resend requests, transmitted lines and resend ratio')|edq }}">{{ _('Resend ratio') }}</span>: <strong data-bind="css: {'text-error': resendRatioCritical}"><span title="{{ _('resend requests') | edq }}" data-bind="text: formatHuman(resendCount())"></span> / <span title="{{ _('transmitted lines') | edq }}" data-bind="text: formatHuman(resendTotalTransmitted())"></span> (<span title="{{ _('resend ratio') }}" data-bind="text: resendRatio"></span>%) <a href="https://faq.octoprint.org/communication-errors" target="_blank" class="text-error" data-bind="visible: resendRatioCritical"><i class="fas fa-question-circle"></i></a></strong><br></span>
|
||||
<hr>
|
||||
<span title="{{ _('Name of file currently selected for printing')|edq }}">{{ _('File') }}</span>: <strong data-bind="text: filedisplay, attr: {title: filepath}"></strong> <strong data-bind="visible: sd">(SD)</strong><br>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="controls">
|
||||
<p>{% trans %}
|
||||
Define a check interval, a host and a port to check against. If you don't know what to set here, the
|
||||
default values (using Google's DNS server) should work. If you have concerns about using
|
||||
default values (using Cloudflare's DNS server) should work. If you have concerns about using
|
||||
that, define the IP and port of a different online server that you trust and that has a high
|
||||
availability.
|
||||
{% endtrans %}</p>
|
||||
|
||||
@@ -449,7 +449,7 @@ def get_fully_qualified_classname(o):
|
||||
return module + "." + o.__class__.__name__
|
||||
|
||||
|
||||
def get_exception_string():
|
||||
def get_exception_string(fmt="{type}: '{message}' @ {file}:{function}:{line}"):
|
||||
"""
|
||||
Retrieves the exception info of the last raised exception and returns it as a string formatted as
|
||||
``<exception type>: <exception message> @ <source file>:<function name>:<line number>``.
|
||||
@@ -458,14 +458,15 @@ def get_exception_string():
|
||||
string: The formatted exception information.
|
||||
"""
|
||||
|
||||
locationInfo = traceback.extract_tb(sys.exc_info()[2])[0]
|
||||
return "%s: '%s' @ %s:%s:%d" % (
|
||||
str(sys.exc_info()[0].__name__),
|
||||
str(sys.exc_info()[1]),
|
||||
os.path.basename(locationInfo[0]),
|
||||
locationInfo[2],
|
||||
locationInfo[1],
|
||||
)
|
||||
location_info = traceback.extract_tb(sys.exc_info()[2])[0]
|
||||
exception = {
|
||||
"type": str(sys.exc_info()[0].__name__),
|
||||
"message": str(sys.exc_info()[1]),
|
||||
"file": os.path.basename(location_info[0]),
|
||||
"function": location_info[2],
|
||||
"line": location_info[1],
|
||||
}
|
||||
return fmt.format(**exception)
|
||||
|
||||
|
||||
@deprecated(
|
||||
@@ -1654,6 +1655,24 @@ class CountedEvent(object):
|
||||
|
||||
self._internal_set(value)
|
||||
|
||||
@property
|
||||
def min(self):
|
||||
return self._min
|
||||
|
||||
@min.setter
|
||||
def min(self, val):
|
||||
with self._mutex:
|
||||
self._min = val
|
||||
|
||||
@property
|
||||
def max(self):
|
||||
return self._max
|
||||
|
||||
@max.setter
|
||||
def max(self, val):
|
||||
with self._mutex:
|
||||
self._max = val
|
||||
|
||||
@property
|
||||
def is_set(self):
|
||||
return self._event.is_set
|
||||
|
||||
@@ -590,7 +590,8 @@ class MachineCom(object):
|
||||
),
|
||||
}
|
||||
|
||||
self._lastLines = deque([], 50)
|
||||
last_line_count = settings().getInt(["serial", "lastLineBufferSize"])
|
||||
self._lastLines = deque([], last_line_count)
|
||||
self._lastCommError = None
|
||||
self._lastResendNumber = None
|
||||
self._currentResendCount = 0
|
||||
@@ -949,9 +950,9 @@ class MachineCom(object):
|
||||
elif state == self.STATE_CLOSED:
|
||||
return "Offline"
|
||||
elif state == self.STATE_ERROR:
|
||||
return "Error: {}".format(self.getErrorString())
|
||||
return "Error"
|
||||
elif state == self.STATE_CLOSED_WITH_ERROR:
|
||||
return "Offline (Error: {})".format(self.getErrorString())
|
||||
return "Offline after error"
|
||||
elif state == self.STATE_TRANSFERING_FILE:
|
||||
return "Transferring file to SD"
|
||||
return "Unknown State ({})".format(self._state)
|
||||
@@ -3841,7 +3842,7 @@ class MachineCom(object):
|
||||
"Please see https://faq.octoprint.org/serialerror for possible reasons of this.",
|
||||
level=logging.ERROR,
|
||||
)
|
||||
self._errorValue = get_exception_string()
|
||||
self._errorValue = get_exception_string(fmt="{type}: {message}")
|
||||
self.close(is_error=True)
|
||||
return None
|
||||
|
||||
@@ -4712,7 +4713,7 @@ class MachineCom(object):
|
||||
"Please see https://faq.octoprint.org/serialerror for possible reasons of this.",
|
||||
level=logging.INFO,
|
||||
)
|
||||
self._errorValue = get_exception_string()
|
||||
self._errorValue = get_exception_string(fmt="{type}: {message}")
|
||||
self.close(is_error=True)
|
||||
break
|
||||
except Exception as ex:
|
||||
@@ -4729,7 +4730,7 @@ class MachineCom(object):
|
||||
"Please see https://faq.octoprint.org/serialerror for possible reasons of this.",
|
||||
level=logging.INFO,
|
||||
)
|
||||
self._errorValue = get_exception_string()
|
||||
self._errorValue = get_exception_string(fmt="{type}: {message}")
|
||||
self.close(is_error=True)
|
||||
break
|
||||
|
||||
|
||||
@@ -6,12 +6,22 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
|
||||
|
||||
import collections
|
||||
import json
|
||||
|
||||
import frozendict
|
||||
|
||||
from octoprint.util import to_unicode
|
||||
|
||||
|
||||
def dump(obj):
|
||||
return json.dumps(
|
||||
obj,
|
||||
separators=(",", ":"),
|
||||
default=JsonEncoding.encode,
|
||||
allow_nan=False,
|
||||
)
|
||||
|
||||
|
||||
class JsonEncoding(object):
|
||||
|
||||
encoders = collections.OrderedDict()
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import re
|
||||
|
||||
from emoji import demojize
|
||||
|
||||
from octoprint.util import to_unicode
|
||||
from octoprint.vendor.awesome_slugify import Slugify
|
||||
|
||||
_UNICODE_VARIATIONS = re.compile("[\uFE00-\uFE0F]", re.U)
|
||||
_SLUGIFIES = {}
|
||||
|
||||
|
||||
def sanitize(text, safe_chars="-_.", demoji=True):
|
||||
"""
|
||||
Sanitizes text by running it through slugify and optionally emoji translating.
|
||||
|
||||
Examples:
|
||||
|
||||
>>> sanitize("Hello World!") # doctest: +ALLOW_UNICODE
|
||||
'Hello-World'
|
||||
>>> sanitize("Hello World!", safe_chars="-_. ") # doctest: +ALLOW_UNICODE
|
||||
'Hello World'
|
||||
>>> sanitize("\u2764") # doctest: +ALLOW_UNICODE
|
||||
'red_heart'
|
||||
>>> sanitize("\u2764\ufe00") # doctest: +ALLOW_UNICODE
|
||||
'red_heart'
|
||||
>>> sanitize("\u2764", demoji=False) # doctest: +ALLOW_UNICODE
|
||||
''
|
||||
|
||||
Args:
|
||||
text: the text to sanitize
|
||||
safe_chars: characters to consider safe and to keep after sanitization
|
||||
emoji: whether to also convert emoji to text
|
||||
|
||||
Returns: the sanitized text
|
||||
"""
|
||||
slugify = _SLUGIFIES.get(safe_chars)
|
||||
if slugify is None:
|
||||
slugify = Slugify()
|
||||
slugify.safe_chars = safe_chars
|
||||
_SLUGIFIES[safe_chars] = slugify
|
||||
|
||||
text = to_unicode(text)
|
||||
if demoji:
|
||||
text = remove_unicode_variations(text)
|
||||
text = demojize(text, delimiters=("", ""))
|
||||
return slugify(text)
|
||||
|
||||
|
||||
def remove_unicode_variations(text):
|
||||
return _UNICODE_VARIATIONS.sub("", text)
|
||||
Generated
+261
-254
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,7 @@
|
||||
"cypress-file-upload": "^4.0.7",
|
||||
"cypress-plugin-retries": "^1.5.2",
|
||||
"cypress-terminal-report": "^1.4.1",
|
||||
"cypress-wait-until": "^1.7.1"
|
||||
"cypress-wait-until": "^1.7.1",
|
||||
"ini": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -814,12 +814,6 @@ class LocalStorageTest(unittest.TestCase):
|
||||
self.assertEqual(expected_path, actual_path)
|
||||
self.assertEqual(expected_name, actual_name)
|
||||
|
||||
@data(("test", "test"), ("\u2764", "red_heart"), ("\u2764\ufe00", "red_heart"))
|
||||
@unpack
|
||||
def test_slugify(self, input, expected):
|
||||
output = LocalFileStorage._slugify(input)
|
||||
self.assertEqual(output, expected)
|
||||
|
||||
def _add_and_verify_file(
|
||||
self, path, expected_path, file_object, links=None, overwrite=False, display=None
|
||||
):
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
|
||||
class TestAssetPlugin(octoprint.plugin.AssetPlugin):
|
||||
pass
|
||||
|
||||
|
||||
__plugin_name__ = "Asset Plugin"
|
||||
__plugin_description__ = "Test asset plugin"
|
||||
__plugin_implementation__ = TestAssetPlugin()
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
@@ -1,21 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
|
||||
class TestDeprecatedAssetPlugin(octoprint.plugin.AssetPlugin):
|
||||
pass
|
||||
|
||||
|
||||
class TestSecondaryDeprecatedAssetPlugin(octoprint.plugin.AssetPlugin):
|
||||
pass
|
||||
|
||||
|
||||
__plugin_name__ = "Deprecated Plugin"
|
||||
__plugin_description__ = "Test deprecated plugin"
|
||||
__plugin_implementations__ = [
|
||||
TestDeprecatedAssetPlugin(),
|
||||
TestSecondaryDeprecatedAssetPlugin(),
|
||||
]
|
||||
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
print("I'm not a plugin")
|
||||
@@ -68,6 +68,18 @@ class PluginTestCase(unittest.TestCase):
|
||||
os.path.dirname(os.path.realpath(__file__)), "_plugins"
|
||||
)
|
||||
|
||||
# prepare compiled files
|
||||
import py_compile
|
||||
|
||||
py_compile.compile(
|
||||
os.path.join(self.plugin_folder, "asset_plugin.py"),
|
||||
os.path.join(self.plugin_folder, "asset_plugin_2.pyc"),
|
||||
)
|
||||
py_compile.compile(
|
||||
os.path.join(self.plugin_folder, "not_a_plugin.py"),
|
||||
os.path.join(self.plugin_folder, "not_a_plugin_either.pyc"),
|
||||
)
|
||||
|
||||
plugin_folders = [self.plugin_folder]
|
||||
plugin_bases = [octoprint.plugin.OctoPrintPlugin]
|
||||
plugin_entry_points = None
|
||||
@@ -93,6 +105,7 @@ class PluginTestCase(unittest.TestCase):
|
||||
|
||||
def test_plugin_loading(self):
|
||||
self.assertEqual(7, len(self.plugin_manager.enabled_plugins))
|
||||
self.assertEqual(8, len(self.plugin_manager.plugins))
|
||||
self.assertEqual(2, len(self.plugin_manager.plugin_hooks))
|
||||
self.assertEqual(4, len(self.plugin_manager.plugin_implementations))
|
||||
self.assertEqual(3, len(self.plugin_manager.plugin_implementations_by_type))
|
||||
@@ -137,7 +150,7 @@ class PluginTestCase(unittest.TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
# TestDeprecatedAssetPlugin, NOT TestSecondaryDeprecatedAssetPlugin
|
||||
# TestAssetPlugin
|
||||
self.assertTrue(
|
||||
octoprint.plugin.AssetPlugin
|
||||
in self.plugin_manager.plugin_implementations_by_type
|
||||
@@ -258,7 +271,8 @@ class PluginTestCase(unittest.TestCase):
|
||||
octoprint.plugin.AssetPlugin
|
||||
)
|
||||
self.assertListEqual(
|
||||
["deprecated_plugin"], list(map(lambda x: x._identifier, implementations))
|
||||
["asset_plugin"],
|
||||
list(map(lambda x: x._identifier, implementations)),
|
||||
)
|
||||
|
||||
def test_get_filtered_implementations(self):
|
||||
@@ -305,12 +319,13 @@ class PluginTestCase(unittest.TestCase):
|
||||
client1.on_plugin_message.assert_called_once_with(plugin, data, permissions=None)
|
||||
client2.on_plugin_message.assert_called_once_with(plugin, data, permissions=None)
|
||||
|
||||
def test_validate_plugin(self):
|
||||
self.assertTrue("deprecated_plugin" in self.plugin_manager.enabled_plugins)
|
||||
def test_broken_plugin(self):
|
||||
self.assertTrue("not_a_plugin" in self.plugin_manager.plugins)
|
||||
|
||||
plugin = self.plugin_manager.enabled_plugins["deprecated_plugin"]
|
||||
self.assertTrue(hasattr(plugin.instance, plugin.__class__.attr_implementation))
|
||||
self.assertFalse(hasattr(plugin.instance, plugin.__class__.attr_implementations))
|
||||
plugin = self.plugin_manager.plugins["not_a_plugin"]
|
||||
self.assertFalse(plugin.looks_like_plugin)
|
||||
self.assertFalse(plugin.loaded)
|
||||
self.assertFalse(plugin.enabled)
|
||||
|
||||
@ddt.data(
|
||||
(
|
||||
|
||||
Reference in new issue
Block a user