Commit graph

76 commits

Author SHA1 Message Date
Gina Häußge
80bc82df55 Protect against broken packages in python env
As seen in https://groups.google.com/forum/#!msg/octoprint/DyXdqhR0U7c/kKMUsMmIBgAJ
a broken entry_points.txt in some arbitrary Python package installed in
the same python envrionment as OctoPrint can make our whole plugin
detection fail and hence interrupt regular server startup.

This adds better protection against such cases.
2017-11-10 11:14:50 +01:00
Gina Häußge
0afa854763 Support a centralized plugin blacklist (opt-in)
A centralized plugin blacklist read from plugins.octoprint.org on server
start now allows us to stop plugins from being loaded that are known to
cause severe issues with OctoPrint's regular operation.

Blacklist entries can be restricted for specific plugin versions &
OctoPrint versions, allowing for very granular control of any kind of
blocking.

Additionally users may disable blacklist processing in general (an
opt-in wizard and a new section in the settings have been added) and
at server start via the new --ignore-blacklist parameter available for
"octoprint serve" and "octoprint daemon".

If a plugin is blacklisted, OctoPrint will not even import the
plugin module in question (if only a plugin key is specified OR a key
and a version and the plugin's version is already known during import
time, which is the case for plugins loaded from entry points) or at the
very least stop the plugin from being enabled (if a plugin key and a
version is specified and the plugin's version is only known after
loading, which is the case for plugins loaded from directories).
2017-10-25 17:29:00 +02:00
Gina Häußge
f6c3e5991d PMGR: Detect if plugin needs printer reconnect 2017-06-28 10:30:35 +02:00
Gina Häußge
346f818707 PGMR: More general flexibility for os compat check
* Don't restrict the list of compatibility values to check against
    to only those we have mapped, also support unmapped more exotic
    ones.

  * Allow 1:1 check against sys.platform values (with startswith).
    Combined with the above that allows very granular compatibility
    modelling ("freebsd11", "freebsd12") if required.

  * Instead of only whitelisting ("linux", "freebsd") now also black
    listing is possible ("!windows").

    A detected os must match all provided whitelist elements (if the
    whitelist is empty that is considered always the case) and none of
    the backlist elements (if the blacklist is empty that is also
    considered always the case).

See the included unit tests for examples of how this works.
2017-04-07 09:18:37 +02:00
Gina Häußge
18e14aa412 Support "disabling unrecommended" for bundled plugins
* Extended plugin metadata by new property, only evaluated for bundled
    plugins.
  * Adjusted plugin manager to evaluate new metadata and add
    confirmation dialog with details when attempting to disable such
    a plugin.
2017-03-30 14:08:47 +02:00
Gina Häußge
1de307e15d Log version, safe mode & plugins to log on log roll over
We want to make sure that information is ALWAYS in each and every log.
2017-02-24 10:53:16 +01:00
Gina Häußge
97bf331307 Add safe mode that disables all third party plugins
Can be enabled either through new --safe command line
parameter or through server.startOnceInSafeMode in
config.yaml

When running in safe mode the plugin manager will
only allow to disable or uninstall third party plugins. Enabling
third party plugins or installing new plugins is disabled.

That will hopefully allow for more straightforward recovery
in case of a misbehaving plugin.
2016-11-18 13:02:16 +01:00
Gina Häußge
f7eb12a3ee Docs for {Reload|Restart}NeedingPlugin 2016-10-14 14:15:33 +02:00
Gina Häußge
9de78001dd Merge branch 'maintenance' into devel
# Conflicts:
#	CHANGELOG.md
#	docs/plugins/concepts.rst
#	src/octoprint/__init__.py
#	src/octoprint/server/__init__.py
#	src/octoprint/templates/javascripts.jinja2
#	src/octoprint/timelapse.py

Merge branch 'devel' into dev/wizard

# Conflicts:
#	octoprint_octobullet/__init__.py
#	octoprint_octobullet/templates/octobullet_settings.jinja2

Merge branch 'devel' into dev/wizard

# Conflicts:
#	octoprint_octobullet/__init__.py
#	octoprint_octobullet/templates/octobullet_settings.jinja2
2016-10-13 14:22:40 +02:00
Gina Häußge
1370c7a9cc Inject plugin_info object into plugin implementations as well 2016-10-13 12:03:05 +02:00
Gina Häußge
bccc706329 First throw at caching of API methods
Most caching is left to the client, by utilizing ETag and Last-Modified headers.

Where it was easily achievable, an additional server side miniature cache of intermediary
results was introduced (e.g. for the files). The regular cached decorator was not used
since it targets caching full responses, and the responses in question already contained
client request specific data. Caching "one step earlier" allows better usage of the cache here.

Also introduced a dependency on the scandir module, to get a bit of a performance boost
on os.walk and os.listdir (which have been replaced with scandir.walk and scandir.listdir
respectively). See https://github.com/benhoyt/scandir#background on why that made
sense.
2016-08-30 19:02:30 +02:00
MirceaDan
c33a9f9aa2 from __future__ import absolute_import, division, print_function
changed the behavior to import division and print to be consistent
across all app and similar with python 3.x
2016-07-15 00:16:58 -07:00
Gina Häußge
3893b700f6 Merge branch 'devel' into dev/settingsOverlays 2016-06-24 14:31:41 +02:00
Gina Häußge
f8a4d73c30 Also detect editable plugins installs as managable 2016-06-24 11:06:23 +02:00
Gina Häußge
4398931b5c Normalize paths for sub path testing in pluginmgr 2016-06-24 09:23:53 +02:00
Gina Häußge
c693bce761 Plugins with settings overlay need restart 2016-06-23 16:13:49 +02:00
Gina Häußge
19ff9ac664 Allow plugins to define settings overlays 2016-06-23 13:54:14 +02:00
Gina Häußge
ee185230a4 Refactored plugin docs + improved docs on sortables 2016-03-24 16:42:41 +01:00
Gina Häußge
780794c466 Merge branch 'development' of https://github.com/bwgan/OctoPrint into pr/bwgan/development
Conflicts:
	src/octoprint/daemon.py
2016-01-29 09:04:58 +01:00
bwgan
f8c0df4e78 Typo and spelling fixes
Fixes various spelling issues and typos.
2016-01-28 18:59:38 +00:00
Gina Häußge
be79cf289e Merge branch 'maintenance' into devel 2015-09-30 16:00:56 +02:00
Gina Häußge
5cc8ec5cc3 Better wording for plugin system startup & sorted plugin list of ALL plugins 2015-09-30 16:00:32 +02:00
Gina Häußge
28fc7d74f4 Made plugin marking in PluginManager more flexible
Now supports arbitrary markers for plugins. Also added a method
to check if a plugin was marked with a specified marker.
2015-09-30 13:33:25 +02:00
Gina Häußge
fbfac4b569 PluginManager also scans user site packages
In case the user site packages are not yet part of the used
working set OR the sys path and ENABLE_USER_SITE is true, the
manager will now make sure that the folder is searched for plugins
as well upon plugin reload.

This is necessary since Python will not automatically include the
user site directory upon firing up the program in case there's
nothing installed to it/it doesn't exist. If a plugin is installed
during run time with --user that will lead to it not being found,
which is undesirable. Hence run time manipulation of sys.path and
the workingset becomes necessary.
2015-09-30 13:30:39 +02:00
Gina Häußge
10db8c9577 PluginManager now marks plugins as managable
Managable currently pretty much only means "uninstallable".

Plugins are managable if their installation location is writable
and - if they are installed from an entry point and OctoPrint is
running in a virtual environment - within the bounds of the virtual
environment (because otherwise pip will not allow to uninstall).
2015-09-30 13:28:58 +02:00
Gina Häußge
19c8b8e905 Documented UiPlugin type and enhanced existing docs 2015-09-10 15:43:30 +02:00
Gina Häußge
38dabfc1c0 Only try to convert sorting_value to int if it's not None 2015-09-07 11:34:09 +02:00
Gina Häußge
8abf152d40 SorteablePlugin => SortablePlugin 2015-09-04 16:42:49 +02:00
Gina Häußge
e4dd4483d4 Sanity checking of the order data returned by plugins 2015-09-04 16:08:57 +02:00
Gina Häußge
89ccfae919 Fixed get_filtered_implementation again
Apparently, *args and named but optional arguments in combination are
more tricky to get right than they first appear.
2015-09-04 15:54:48 +02:00
Gina Häußge
5863f99b75 Always sort plugins by their identifier by default 2015-09-04 15:38:15 +02:00
Gina Häußge
2a52b6d1a2 Allow sorting of Startup and ShutdownPlugins 2015-09-04 15:01:35 +02:00
Gina Häußge
44c76fa70b Made hooks and templates sortable 2015-09-04 11:25:27 +02:00
Gina Häußge
0c54eaf176 Fix: Use Exception, not BaseException
Custom exception should be derived from Exception, not BaseException.

Not only is this specified in the python documentation, but also
tornado will be able to handle Exceptions in requests perfectly fine
and return an HTTP 500 for them, but crash hard (as in, server shut
down follows) for BaseExceptions.
(cherry picked from commit 29b047b)
2015-06-28 02:24:47 +02:00
Gina Häußge
29b047bf09 Fix: Use Exception, not BaseException
Custom exception should be derived from Exception, not BaseException.

Not only is this specified in the python documentation, but also
tornado will be able to handle Exceptions in requests perfectly fine
and return an HTTP 500 for them, but crash hard (as in, server shut
down follows) for BaseExceptions.
2015-06-28 02:19:28 +02:00
Gina Häußge
904a3cdaff super(...).method(...) => BaseClass.method(self, ...) 2015-06-19 15:25:37 +02:00
Gina Häußge
e55677da22 Plugin system now support pre/post implementation init methods 2015-06-19 11:09:08 +02:00
Gina Häußge
592cad5b99 Deprecated AppPlugin mixin and introduced octoprint.accesscontrol.appkey hook instead
Plugins implementing the mixin will automatically be migrated to providing the single mixin method as hook handler.
2015-06-09 18:50:55 +02:00
Gina Häußge
8696ce9291 Fix: Bundled plugins always take precedence over external ones 2015-06-09 13:54:21 +02:00
Gina Häußge
ba5e99c187 Use namedtuple for plugin.origin data structure and include package version 2015-06-03 10:44:27 +02:00
Gina Häußge
a42868d7eb Allow marking plugins as uninstalled
Sometimes they will still get discovered by python even though their packages have since been uninstalled.
This will also lead to them being reloaded after an uninstall and a subsequent plugin reload.

Marking them as uninstalled and not handing out uninstalled plugins when collecting them solves this.
2015-05-29 16:25:18 +02:00
Gina Häußge
2cfa3d9218 Refuse to enable plugins that utilize obsolete hooks
Since it cannot be reliably determined by the system if a hook is essential for a plugin's functionality or not, it makes more sense to just disable plugins that utilize obsolete hooks then risk running half working plugins.
2015-05-28 12:56:42 +02:00
Gina Häußge
4c7520efb9 New hook "octoprint.server.http.bodysize" and lifecycle support for restart needing hooks
The new hook allows extending the list of rules for maximum body sizes differing from the default of 100KB and can be used by plugins to allow uploads to them that exceed that file size.

Also extended the plugin manager to detect plugins that implement restart needing hooks (such as the above one) and handling those plugins the same as plugins containing implementations that inherit from octoprint.plugin.core.RestartNeedingPlugin
2015-05-11 15:47:40 +02:00
Gina Häußge
5e54f3a523 Persist package name for plugins loaded from entry point
This allows later deinstallation even if module and package name differ.
2015-04-27 18:43:00 +02:00
Gina Häußge
6bb4a3e28c Potential fix for the "No PKG-INFO found for package" issue 2015-04-16 18:37:03 +02:00
Gina Häußge
2aa31024e6 Finalizing first version of plugin lifecycle management 2015-04-14 17:55:46 +02:00
Gina Häußge
97aecdf4cf First throw at working plugin lifecycle management
Plugins may be enabled and disabled during runtime. If they are of types which allow hot loading, this will be done. Otherwise they will be marked as pending and updated after a restart. Same for installation and uninstallation.
2015-04-02 23:02:42 +02:00
Gina Häußge
f0b48a6b43 Merge branch 'devel' into dev/pluginLifecycleMgmt
Conflicts:
	src/octoprint/plugin/core.py
2015-04-01 11:55:48 +02:00
Gina Häußge
0ed8afd999 Fix: Validate plugins separately from constructor
Otherwise plugins that inject data via __plugin_init__ won't work properly
2015-04-01 11:54:11 +02:00
Gina Häußge
68fa2f9fa3 WIP 2015-04-01 11:51:08 +02:00