octoprint.plugin

This module represents OctoPrint’s plugin subsystem. This includes management and helper methods as well as the registered plugin types.

octoprint.plugin.plugin_manager(init=False, plugin_folders=None, plugin_bases=None, plugin_entry_points=None, plugin_disabled_list=None, plugin_sorting_order=None, plugin_blacklist=None, plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None, plugin_considered_bundled=None, plugin_validators=None, compatibility_ignored_list=None)

Factory method for initially constructing and consecutively retrieving the PluginManager singleton.

Parameters
  • init (boolean) – A flag indicating whether this is the initial call to construct the singleton (True) or not (False, default). If this is set to True and the plugin manager has already been initialized, a ValueError will be raised. The same will happen if the plugin manager has not yet been initialized and this is set to False.

  • plugin_folders (list) – A list of folders (as strings containing the absolute path to them) in which to look for potential plugin modules. If not provided this defaults to the configured plugins base folder and src/plugins within OctoPrint’s code base.

  • plugin_bases (list) – A list of recognized plugin base classes for which to look for provided implementations. If not provided this defaults to OctoPrintPlugin.

  • plugin_entry_points (list) – A list of entry points pointing to modules which to load as plugins. If not provided this defaults to the entry point octoprint.plugin.

  • plugin_disabled_list (list) – A list of plugin identifiers that are currently disabled. If not provided this defaults to all plugins for which enabled is set to False in the settings.

  • plugin_sorting_order (dict) – A dict containing a custom sorting orders for plugins. The keys are plugin identifiers, mapped to dictionaries containing the sorting contexts as key and the custom sorting value as value.

  • plugin_blacklist (list) – A list of plugin identifiers/identifier-requirement tuples that are currently blacklisted.

  • plugin_restart_needing_hooks (list) – A list of hook namespaces which cause a plugin to need a restart in order be enabled/disabled. Does not have to contain full hook identifiers, will be matched with startswith similar to logging handlers

  • plugin_obsolete_hooks (list) – A list of hooks that have been declared obsolete. Plugins implementing them will not be enabled since they might depend on functionality that is no longer available.

  • plugin_considered_bundled (list) – A list of plugin identifiers that are considered bundled plugins even if installed separately.

  • plugin_validators (list) – A list of additional plugin validators through which to process each plugin.

  • compatibility_ignored_list (list) – A list of plugin keys for which it will be ignored if they are flagged as incompatible. This is for development purposes only and should not be used in production.

Returns

A fully initialized PluginManager instance to be used for plugin

management tasks.

Return type

PluginManager

Raises

ValueErrorinit was True although the plugin manager was already initialized, or it was False although the plugin manager was not yet initialized.

octoprint.plugin.plugin_settings(plugin_key, defaults=None, get_preprocessors=None, set_preprocessors=None, settings=None)

Factory method for creating a PluginSettings instance.

Parameters
  • plugin_key (string) – The plugin identifier for which to create the settings instance.

  • defaults (dict) – The default settings for the plugin, if different from get_settings_defaults.

  • get_preprocessors (dict) – The getter preprocessors for the plugin.

  • set_preprocessors (dict) – The setter preprocessors for the plugin.

  • settings (octoprint.settings.Settings) – The settings instance to use.

Returns

A fully initialized PluginSettings instance to be used to access the plugin’s

settings

Return type

PluginSettings

octoprint.plugin.call_plugin(types, method, args=None, kwargs=None, callback=None, error_callback=None, sorting_context=None, initialized=True, manager=None)

Helper method to invoke the indicated method on all registered plugin implementations implementing the indicated types. Allows providing method arguments and registering callbacks to call in case of success and/or failure of each call which can be used to return individual results to the calling code.

Example:

def my_success_callback(name, plugin, result):
    print("{name} was called successfully and returned {result!r}".format(**locals()))

def my_error_callback(name, plugin, exc):
    print("{name} raised an exception: {exc!s}".format(**locals()))

octoprint.plugin.call_plugin(
    [octoprint.plugin.StartupPlugin],
    "on_startup",
    args=(my_host, my_port),
    callback=my_success_callback,
    error_callback=my_error_callback
)
Parameters
  • types (list) – A list of plugin implementation types to match against.

  • method (string) – Name of the method to call on all matching implementations.

  • args (tuple) – A tuple containing the arguments to supply to the called method. Optional.

  • kwargs (dict) – A dictionary containing the keyword arguments to supply to the called method. Optional.

  • callback (function) – A callback to invoke after an implementation has been called successfully. Will be called with the three arguments name, plugin and result. name will be the plugin identifier, plugin the plugin implementation instance itself and result the result returned from the method invocation.

  • error_callback (function) – A callback to invoke after the call of an implementation resulted in an exception. Will be called with the three arguments name, plugin and exc. name will be the plugin identifier, plugin the plugin implementation instance itself and exc the caught exception.

  • initialized (boolean) – Ignored.

  • manager (PluginManager or None) – The plugin manager to use. If not provided, the global plugin manager

class octoprint.plugin.PluginSettings(settings, plugin_key, defaults=None, get_preprocessors=None, set_preprocessors=None)

The PluginSettings class is the interface for plugins to their own or globally defined settings.

It provides some convenience methods for directly accessing plugin settings via the regular octoprint.settings.Settings interfaces as well as means to access plugin specific folder locations.

All getter and setter methods will ensure that plugin settings are stored in their correct location within the settings structure by modifying the supplied paths accordingly.

Parameters
  • settings (Settings) – The Settings instance on which to operate.

  • plugin_key (str) – The plugin identifier of the plugin for which to create this instance.

  • defaults (dict) – The plugin’s defaults settings, will be used to determine valid paths within the plugin’s settings structure

get(path, merged=False, asdict=False)

Retrieves a raw value from the settings for path, optionally merging the raw value with the default settings if merged is set to True.

Parameters
  • path (list, tuple) – The path for which to retrieve the value.

  • merged (boolean) – Whether to merge the returned result with the default settings (True) or not (False, default).

Returns

The retrieved settings value.

Return type

object

get_int(path, min=None, max=None)

Like get() but tries to convert the retrieved value to int. If min is provided and the retrieved value is less than it, it will be returned instead of the value. Likewise for max - it will be returned if the value is greater than it.

get_float(path, min=None, max=None)

Like get() but tries to convert the retrieved value to float. If min is provided and the retrieved value is less than it, it will be returned instead of the value. Likewise for max - it will be returned if the value is greater than it.

get_boolean(path)

Like get() but tries to convert the retrieved value to boolean.

set(path, value, force=False)

Sets the raw value on the settings for path.

Parameters
  • path (list, tuple) – The path for which to retrieve the value.

  • value (object) – The value to set.

  • force (boolean) – If set to True, the modified configuration will even be written back to disk if the value didn’t change.

set_int(path, value, force=False, min=None, max=None)

Like set() but ensures the value is an int through attempted conversion before setting it. If min and/or max are provided, it will also be ensured that the value is greater than or equal to min and less than or equal to max. If that is not the case, the limit value (min if less than that, max if greater than that) will be set instead.

set_float(path, value, force=False, min=None, max=None)

Like set() but ensures the value is an float through attempted conversion before setting it. If min and/or max are provided, it will also be ensured that the value is greater than or equal to min and less than or equal to max. If that is not the case, the limit value (min if less than that, max if greater than that) will be set instead.

set_boolean(path, value, force=False)

Like set() but ensures the value is an boolean through attempted conversion before setting it.

save(force=False, trigger_event=False)

Saves the settings to config.yaml if there are active changes. If force is set to True the settings will be saved even if there are no changes. Settings trigger_event to True will cause a SettingsUpdated event to get triggered.

Parameters
  • force (boolean) – Force saving to config.yaml even if there are no changes.

  • trigger_event (boolean) – Trigger the SettingsUpdated event on save.

add_overlay(overlay, at_end=False, key=None)

Adds a new config overlay for the plugin’s settings. Will return the overlay’s key in the map.

Parameters
  • overlay (dict) – Overlay dict to add

  • at_end (boolean) – Whether to add overlay at end or start (default) of config hierarchy

  • key (str) – Key to use to identify overlay. If not set one will be built based on the overlay’s hash

Return type

str

remove_overlay(key)

Removes an overlay from the settings based on its key. Return True if the overlay could be found and was removed, False otherwise.

Parameters

key (str) – The key of the overlay to remove

Return type

boolean

get_plugin_data_folder()

Deprecated since version 1.2.0: Replaced by get_plugin_data_folder()

get_plugin_logfile_path(postfix=None)

Retrieves the path to a logfile specifically for the plugin. If postfix is not supplied, the logfile will be named plugin_<plugin identifier>.log and located within the configured logs folder. If a postfix is supplied, the name will be plugin_<plugin identifier>_<postfix>.log at the same location.

Plugins may use this for specific logging tasks. For example, a SlicingPlugin might want to create a log file for logging the output of the slicing engine itself if some debug flag is set.

Parameters

postfix (str) – Postfix of the logfile for which to create the path. If set, the file name of the log file will be plugin_<plugin identifier>_<postfix>.log, if not it will be plugin_<plugin identifier>.log.

Returns

Absolute path to the log file, directly usable by the plugin.

Return type

str

global_get(path, **kwargs)

Getter for retrieving settings not managed by the plugin itself from the core settings structure. Use this to access global settings outside of your plugin.

Directly forwards to octoprint.settings.Settings.get().

global_get_basefolder(folder_type, **kwargs)

Retrieves a globally defined basefolder of the given folder_type. Directly forwards to octoprint.settings.Settings.getBaseFolder().

global_get_boolean(path, **kwargs)

Like global_get() but directly orwards to octoprint.settings.Settings.getBoolean().

global_get_float(path, **kwargs)

Like global_get() but directly forwards to octoprint.settings.Settings.getFloat().

global_get_int(path, **kwargs)

Like global_get() but directly forwards to octoprint.settings.Settings.getInt().

global_set(path, value, **kwargs)

Setter for modifying settings not managed by the plugin itself on the core settings structure. Use this to modify global settings outside of your plugin.

Directly forwards to octoprint.settings.Settings.set().

global_set_boolean(path, value, **kwargs)

Like global_set() but directly forwards to octoprint.settings.Settings.setBoolean().

global_set_float(path, value, **kwargs)

Like global_set() but directly forwards to octoprint.settings.Settings.setFloat().

global_set_int(path, value, **kwargs)

Like global_set() but directly forwards to octoprint.settings.Settings.setInt().

octoprint.plugin.core

In this module resides the core data structures and logic of the plugin system.

class octoprint.plugin.core.PluginManager(plugin_folders, plugin_bases, plugin_entry_points, logging_prefix=None, plugin_disabled_list=None, plugin_sorting_order=None, plugin_blacklist=None, plugin_restart_needing_hooks=None, plugin_obsolete_hooks=None, plugin_considered_bundled=None, plugin_validators=None, compatibility_ignored_list=None)

The PluginManager is the central component for finding, loading and accessing plugins provided to the system.

It is able to discover plugins both through possible file system locations as well as customizable entry points.

disable_plugin(name, plugin=None)

Disables a plugin

enable_plugin(name, plugin=None, initialize_implementation=True, startup=False)

Enables a plugin

get_filtered_implementations(f, *types, **kwargs)

Get all mixin implementations that implement all of the provided types and match the provided filter f.

Parameters
  • f (callable) – A filter function returning True for implementations to return and False for those to exclude.

  • types (one or more type) – The types a mixin implementation needs to implement in order to be returned.

Returns

A list of all found and matching implementations.

Return type

list

get_helpers(name, *helpers)

Retrieves the named helpers for the plugin with identifier name.

If the plugin is not available, returns None. Otherwise returns a dict with the requested plugin helper names mapped to the method - if a helper could not be resolved, it will be missing from the dict.

Parameters
  • name (str) – Identifier of the plugin for which to look up the helpers.

  • helpers (one or more str) – Identifiers of the helpers of plugin name to return.

Returns

A dictionary of all resolved helpers, mapped by their identifiers, or None if the plugin was not

registered with the system.

Return type

dict

get_hooks(hook)

Retrieves all registered handlers for the specified hook.

Parameters

hook (str) – The hook for which to retrieve the handlers.

Returns

A dict containing all registered handlers mapped by their plugin’s identifier.

Return type

dict

get_implementations(*types, **kwargs)

Get all mixin implementations that implement all of the provided types.

Parameters

types (one or more type) – The types a mixin implementation needs to implement in order to be returned.

Returns

A list of all found implementations

Return type

list

get_plugin(identifier, require_enabled=True)

Retrieves the module of the plugin identified by identifier. If the plugin is not registered or disabled and required_enabled is True (the default) None will be returned.

Parameters
  • identifier (str) – The identifier of the plugin to retrieve.

  • require_enabled (boolean) – Whether to only return the plugin if is enabled (True, default) or also if it’s disabled.

Returns

The requested plugin module or None

Return type

module

get_plugin_info(identifier, require_enabled=True)

Retrieves the PluginInfo instance identified by identifier. If the plugin is not registered or disabled and required_enabled is True (the default) None will be returned.

Parameters
  • identifier (str) – The identifier of the plugin to retrieve.

  • require_enabled (boolean) – Whether to only return the plugin if is enabled (True, default) or also if it’s disabled.

Returns

The requested PluginInfo or None

Return type

PluginInfo

static has_any_of_hooks(plugin, *hooks)

Tests if the plugin contains any of the provided hooks.

Uses octoprint.plugin.core.PluginManager.hook_matches_hooks().

Parameters
  • plugin – plugin to test hooks for

  • *hooks – hooks to test against

Returns

True if any of the plugin’s hooks match the provided hooks,

False otherwise.

Return type

(bool)

static has_any_of_mixins(plugin, *mixins)

Tests if the plugin has an implementation implementing any of the provided mixins.

Parameters
  • plugin – plugin for which to check the implementation

  • *mixins – mixins to test against

Returns

True if the plugin’s implementation implements any of the

provided mixins, False otherwise.

Return type

(bool)

has_obsolete_hooks(plugin)

Checks whether the plugin uses any obsolete hooks

has_restart_needing_hooks(plugin)

Checks whether the plugin has any hooks that need a restart on changes

has_restart_needing_implementation(plugin)

Checks whether the plugin’s implementation needs a restart on changes

static hook_matches_hooks(hook, *hooks)

Tests if hook matches any of the provided hooks to test for.

hook is expected to be an exact hook name.

hooks is expected to be a list containing one or more hook names or patterns. That can be either an exact hook name or an fnmatch.fnmatch() pattern.

Parameters
  • hook – the hook to test

  • hooks – the hook name patterns to test against

Returns

True if the hook matches any of the hooks, False otherwise.

Return type

(bool)

is_obsolete_hook(hook)

Checks whether a hook is obsolete

is_plugin_marked(name, flag)

Checks whether a plugin has been marked with a certain flag.

Parameters
  • name (str) – the plugin’s identifier

  • flag (str) – the flag to check

Returns

True if the plugin has been flagged, False otherwise

Return type

(boolean)

is_restart_needing_hook(hook)

Checks whether a hook needs a restart on changes

is_restart_needing_plugin(plugin)

Checks whether the plugin needs a restart on changes

mark_plugin(name, **flags)

Mark plugin name with an arbitrary number of flags.

Parameters
  • name (str) – plugin identifier

  • **flags (dict) – dictionary of flag names and values

property plugin_hooks

Returns: (dict) dictionary of registered hooks and their handlers

property plugins

Returns: (list) list of enabled and disabled registered plugins

register_message_receiver(client)

Registers a client for receiving plugin messages. The client needs to be a callable accepting two input arguments, plugin (the sending plugin’s identifier) and data (the message itself), and one optional keyword argument, permissions (an optional list of permissions to test against).

reload_plugins(startup=False, initialize_implementations=True, force_reload=None)

Reloads plugins, detecting newly added ones in the process.

Parameters
  • startup (boolean) – whether this is called during startup of the platform

  • initialize_implementations (boolean) – whether plugin implementations should be initialized

  • force_reload (list) – list of plugin identifiers which should be force reloaded

send_plugin_message(plugin, data, permissions=None)

Sends data in the name of plugin to all currently registered message receivers by invoking them with the three arguments.

Parameters
  • plugin (str) – The sending plugin’s identifier.

  • data (object) – The message.

  • permissions (list) – A list of permissions to test against in the client.

unregister_message_receiver(client)

Unregisters a client for receiving plugin messages.

class octoprint.plugin.core.PluginInfo(key, location, instance, name=None, version=None, description=None, author=None, url=None, license=None, parsed_metadata=None)

The PluginInfo class wraps all available information about a registered plugin.

This includes its meta data (like name, description, version, etc) as well as the actual plugin extensions like implementations, hooks and helpers.

It works on Python module objects and extracts the relevant data from those via accessing the control properties.

Parameters
  • key (str) – Identifier of the plugin

  • location (str) – Installation folder of the plugin

  • instance (module) – Plugin module instance - this may be None if the plugin has been blacklisted!

  • name (str) – Human readable name of the plugin

  • version (str) – Version of the plugin

  • description (str) – Description of the plugin

  • author (str) – Author of the plugin

  • url (str) – URL of the website of the plugin

  • license (str) – License of the plugin

property author

Author of the plugin. Will be taken from the author attribute of the plugin module as defined in attr_author if available, otherwise from the author supplied during construction. May be None.

Returns

Author of the plugin.

Return type

str or None

blacklisted

Whether the plugin is blacklisted.

bundled

Whether this plugin is bundled with OctoPrint.

property check

Method for pre-load check of plugin. Will be taken from the check attribute of the plugin module as defined in attr_check if available, otherwise a lambda always returning True is returned.

Returns

Check method for the plugin module which should return True if the plugin can be loaded, False

otherwise.

Return type

callable

property description

Description of the plugin. Will be taken from the description attribute of the plugin module as defined in attr_description if available, otherwise from the description supplied during construction. May be None.

Returns

Description of the plugin.

Return type

str or None

property disable

Method for disabling the plugin module. Will be taken from the disable attribute of the plugin module as defined in attr_disable if available, otherwise a no-operation lambda will be returned.

Returns

Disable method for the plugin module.

Return type

callable

property disabling_discouraged

Reason why disabling of this plugin is discouraged. Only evaluated for bundled plugins! Will be taken from the disabling_discouraged attribute of the plugin module as defined in attr_disabling_discouraged if available. False if unset or plugin not bundled.

Returns

Reason why disabling this plugin is discouraged (only for bundled plugins)

Return type

str or None

property enable

Method for enabling the plugin module. Will be taken from the enable attribute of the plugin module as defined in attr_enable if available, otherwise a no-operation lambda will be returned.

Returns

Enable method for the plugin module.

Return type

callable

enabled

Whether the plugin is enabled.

forced_disabled

Whether the plugin has been force disabled by the system, e.g. due to safe mode blacklisting.

get_hook(hook)
Parameters

hook (str) – Hook to return.

Returns

Handler for the requested hook or None if no handler is registered.

Return type

callable or None

get_implementation(*types)
Parameters

types (list) – List of Plugin sub classes the implementation needs to implement.

Returns

The plugin’s implementation if it matches all of the requested types, None otherwise.

Return type

object

property helpers

Helpers provided by the plugin. Will be taken from the helpers attribute of the plugin module as defined in attr_helpers if available, otherwise an empty list is returned.

Returns

Helpers provided by the plugin.

Return type

dict

property hidden

Hidden flag.

Returns

Whether the plugin should be flagged as hidden or not

Return type

bool

property hooks

Hooks provided by the plugin. Will be taken from the hooks attribute of the plugin module as defined in attr_hooks if available, otherwise an empty dictionary is returned.

Returns

Hooks provided by the plugin.

Return type

dict

property implementation

Implementation provided by the plugin. Will be taken from the implementation attribute of the plugin module as defined in attr_implementation if available, otherwise None is returned.

Returns

Implementation provided by the plugin.

Return type

object

incompatible

Whether this plugin has been detected as incompatible.

invalid_syntax

Whether invalid syntax was encountered while trying to load this plugin.

property license

License of the plugin. Will be taken from the license attribute of the plugin module as defined in attr_license if available, otherwise from the license supplied during construction. May be None.

Returns

License of the plugin.

Return type

str or None

property load

Method for loading the plugin module. Will be taken from the load attribute of the plugin module as defined in attr_load if available, otherwise a no-operation lambda will be returned.

Returns

Load method for the plugin module.

Return type

callable

loaded

Whether this plugin has been loaded.

long_str(show_bundled=False, bundled_strs=(' [B]', ''), show_location=False, location_str=' - {location}', show_enabled=False, enabled_strs=('* ', '  ', 'X ', 'C '))

Long string representation of the plugin’s information. Will return a string of the format <enabled><str(self)><bundled><location>.

enabled, bundled and location will only be displayed if the corresponding flags are set to True. The will be filled from enabled_str, bundled_str and location_str as follows:

enabled_str

a 4-tuple, the first entry being the string to insert when the plugin is enabled, the second entry the string to insert when it is not, the third entry the string when it is blacklisted and the fourth when it is incompatible.

bundled_str

a 2-tuple, the first entry being the string to insert when the plugin is bundled, the second entry the string to insert when it is not.

location_str

a format string (to be parsed with str.format), the {location} placeholder will be replaced with the plugin’s installation folder on disk.

Parameters
  • show_enabled (boolean) – whether to show the enabled part

  • enabled_strs (tuple) – the 2-tuple containing the two possible strings to use for displaying the enabled state

  • show_bundled (boolean) – whether to show the bundled part

  • bundled_strs (tuple) – the 2-tuple containing the two possible strings to use for displaying the bundled state

  • show_location (boolean) – whether to show the location part

  • location_str (str) – the format string to use for displaying the plugin’s installation location

Returns

The long string representation of the plugin as described above

Return type

str

property looks_like_plugin

Returns whether the plugin actually looks like a plugin (has control properties) or not.

managable

Whether this plugin can be managed by OctoPrint.

property name

Human readable name of the plugin. Will be taken from name attribute of the plugin module if available, otherwise from the name supplied during construction with a fallback to key.

Returns

Name of the plugin, fallback is the plugin’s identifier.

Return type

str

needs_restart

Whether this plugin needs a restart of OctoPrint after enabling/disabling.

origin

The origin from which this plugin was loaded, either a EntryPointOrigin, FolderOrigin or ModuleOrigin instance. Set during loading, initially None.

property parsed_metadata

The plugin metadata parsed from the plugin’s AST.

property privacypolicy

Privacy Policy URL of the plugin. Will be taken from the privacy policy attribute of the plugin module as defined in attr_privacypolicy if available. May be None.

Returns

Privacy Policy URL of the plugin.

Return type

str or None

property pythoncompat

Python compatibility string of the plugin module as defined in attr_pythoncompat if available, otherwise defaults to >=2.7,<3.

Returns

Python compatibility string of the plugin

Return type

str

property unload

Method for unloading the plugin module. Will be taken from the unload attribute of the plugin module as defined in attr_unload if available, otherwise a no-operation lambda will be returned.

Returns

Unload method for the plugin module.

Return type

callable

property url

Website URL for the plugin. Will be taken from the url attribute of the plugin module as defined in attr_url if available, otherwise from the url supplied during construction. May be None.

Returns

Website URL for the plugin.

Return type

str or None

validate(phase, additional_validators=None)

Validates the plugin for various validation phases.

phase can be one of before_import, before_load, after_load.

Used by PluginManager, should not be used elsewhere.

property version

Version of the plugin. Will be taken from the version attribute of the plugin module as defined in attr_version if available, otherwise from the version supplied during construction. May be None.

Returns

Version of the plugin.

Return type

str or None

class octoprint.plugin.core.Plugin

The parent class of all plugin implementations.

_identifier

The identifier of the plugin. Injected by the plugin core system upon initialization of the implementation.

_plugin_name

The name of the plugin. Injected by the plugin core system upon initialization of the implementation.

_plugin_version

The version of the plugin. Injected by the plugin core system upon initialization of the implementation.

_basefolder

The base folder of the plugin. Injected by the plugin core system upon initialization of the implementation.

_logger

The logger instance to use, with the logging name set to the PluginManager.logging_prefix of the PluginManager concatenated with _identifier. Injected by the plugin core system upon initialization of the implementation.

initialize()

Called by the plugin core after performing all injections. Override this to initialize your implementation.

on_plugin_disabled()

Called by the plugin core when the plugin was disabled. Override this to react to the event.

on_plugin_enabled()

Called by the plugin core when the plugin was enabled. Override this to react to the event.

class octoprint.plugin.core.RestartNeedingPlugin

Mixin for plugin types that need a restart after enabling/disabling them.

class octoprint.plugin.core.SortablePlugin

Mixin for plugin types that are sortable.

get_sorting_key(context=None)

Returns the sorting key to use for the implementation in the specified context.

May return None if order is irrelevant.

Implementations returning None will be ordered by plugin identifier after all implementations which did return a sorting key value that was not None sorted by that.

Parameters

context (str) – The sorting context for which to provide the sorting key value.

Returns

An integer signifying the sorting key value of the plugin

(sorting will be done ascending), or None if the implementation doesn’t care about calling order.

Return type

int or None

octoprint.plugin.types

This module bundles all of OctoPrint’s supported plugin implementation types as well as their common parent class, OctoPrintPlugin.

Please note that the plugin implementation types are documented in the section Available plugin mixins.

class octoprint.plugin.types.OctoPrintPlugin

Bases: Plugin

The parent class of all OctoPrint plugin mixins.

_plugin_manager

The PluginManager instance. Injected by the plugin core system upon initialization of the implementation.

_printer_profile_manager

The PrinterProfileManager instance. Injected by the plugin core system upon initialization of the implementation.

_event_bus

The EventManager instance. Injected by the plugin core system upon initialization of the implementation.

_analysis_queue

The AnalysisQueue instance. Injected by the plugin core system upon initialization of the implementation.

_slicing_manager

The SlicingManager instance. Injected by the plugin core system upon initialization of the implementation.

_file_manager

The FileManager instance. Injected by the plugin core system upon initialization of the implementation.

_printer

The PrinterInterface instance. Injected by the plugin core system upon initialization of the implementation.

_app_session_manager

The SessionManager instance. Injected by the plugin core system upon initialization of the implementation.

_plugin_lifecycle_manager

The LifecycleManager instance. Injected by the plugin core system upon initialization of the implementation.

_user_manager

The UserManager instance. Injected by the plugin core system upon initialization of the implementation.

_connectivity_checker

The ConnectivityChecker instance. Injected by the plugin core system upon initialization of the implementation.

_data_folder

Path to the data folder for the plugin to use for any data it might have to persist. Should always be accessed through get_plugin_data_folder() since that function will also ensure that the data folder actually exists and if not creating it before returning it. Injected by the plugin core system upon initialization of the implementation.

get_plugin_data_folder()

Retrieves the path to a data folder specifically for the plugin, ensuring it exists and if not creating it before returning it.

Plugins may use this folder for storing additional data they need for their operation.

on_plugin_pending_uninstall()

Called by the plugin manager when the plugin is pending uninstall. Override this to react to the event.

NOT called during plugin uninstalls triggered outside of OctoPrint!

class octoprint.plugin.types.ReloadNeedingPlugin

Bases: Plugin

Mixin for plugin types that need a reload of the UI after enabling/disabling them.