plugins package

Submodules

plugins.manager module

filename

sppas.src.plugins.manager.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

The plugins manager: manage the list of plugins.

class plugins.manager.sppasPluginsManager[source]

Bases: threading.Thread

Class to manage the list of plugins into SPPAS.

__init__()[source]

Instantiate the sppasPluginsManager and load the current plugins.

append(plugin_folder)[source]

Append a plugin in the list of plugins.

It is supposed that the given plugin folder name is a folder of the plugin directory.

Parameters

plugin_folder – (str) The folder name of the plugin.

delete(plugin_id)[source]

Delete a plugin of the plugins directory.

Parameters

plugin_id – (str) Identifier of the plugin to delete.

get_plugin(plugin_id)[source]

Get the sppasPluginParam from a plugin identifier.

Returns

sppasPluginParam matching the plugin_id or None

get_plugin_ids()[source]

Get the list of plugin identifiers.

Returns

List of plugin identifiers.

install(plugin_archive, plugin_folder)[source]

Install a plugin into the plugin directory.

Parameters
  • plugin_archive – (str) File name of the plugin to be installed (ZIP).

  • plugin_folder – (str) Destination folder name of the plugin to be installed.

load()[source]

Load all installed plugins in the SPPAS directory.

A plugin is not loaded if:

  • a configuration file is not defined or corrupted,

  • the platform system of the command does not match.

run_plugin(plugin_id, file_names)[source]

Apply a given plugin on a list of files.

Parameters
  • plugin_id – (str) Identifier of the plugin to apply.

  • file_names – (list) List of files on which the plugin has to be applied.

set_progress(progress)[source]

Fix the progress system to be used while executing a plugin.

Parameters

progress – (TextProgress or ProcessProgressDialog)

plugins.plugin module

filename

sppas.src.plugins.plugin.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Data structure of one plugin of SPPAS.

class plugins.plugin.sppasPluginParam(directory, config_file)[source]

Bases: object

Class to represent the set of parameters of a plugin.

The set of parameters of a plugin is made of a directory name, a configuration file name and a sppasPluginParser. This latter allows to get all information related to the plugin from the configuration file name:

  • the plugin configuration: identifier, name, description and icon;

  • the commands for windows, macos and linux;

  • a set of options, each one containing at least an identifier,

and optionally a type, a value and a description text.

__init__(directory, config_file)[source]

Create a new sppasPluginParam instance.

Parameters
  • directory – (str) the directory where to find the plugin

  • config_file – (str) the file name of the plugin configuration

get_command()[source]

Get the appropriate command to execute the plugin.

get_descr()[source]

Get the short description of the plugin.

get_directory()[source]

Get the directory name of the plugin.

get_icon()[source]

Get the icon file name of the plugin.

get_key()[source]

Get the identifier of the plugin.

get_name()[source]

Get the name of the plugin.

get_option_from_key(key)[source]

Get an option from its key.

get_options()[source]

Get all the options.

parse()[source]

Parse the configuration file of the plugin.

reset()[source]

Reset all members to their default value.

set_options(options_dict)[source]

Fix the options.

plugins.pluginsexc module

filename

sppas.src.plugins.pluginexc.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Exceptions for plugins package.

exception plugins.pluginsexc.CommandExecError(command_name)[source]

Bases: OSError

:ERROR 4070:.

{command_name} is not a valid command on your operating system.

__init__(command_name)[source]
exception plugins.pluginsexc.CommandSystemError(current_system, supported_systems=[])[source]

Bases: OSError

:ERROR 4075:.

No command was defined for the system: {:s}. Supported systems of this plugin are: {:s}.

__init__(current_system, supported_systems=[])[source]
exception plugins.pluginsexc.OptionKeyError(key)[source]

Bases: KeyError

:ERROR 4080:.

No option with key {:s}.

__init__(key)[source]
exception plugins.pluginsexc.PluginArchiveFileError[source]

Bases: Exception

:ERROR 4020:.

Unsupported plugin file type.

__init__()[source]
exception plugins.pluginsexc.PluginArchiveIOError[source]

Bases: OSError

:ERROR 4024:.

Unsupported plugin file type.

__init__()[source]
exception plugins.pluginsexc.PluginConfigFileError[source]

Bases: OSError

:ERROR 4010:.

Missing plugin configuration file.

__init__()[source]
exception plugins.pluginsexc.PluginDuplicateError[source]

Bases: OSError

:ERROR 4030:.

A plugin with the same name is already existing in the plugins folder.

__init__()[source]
exception plugins.pluginsexc.PluginFolderError(plugin_folder)[source]

Bases: OSError

:ERROR 4050:.

No such plugin folder: {:s}.

__init__(plugin_folder)[source]
exception plugins.pluginsexc.PluginIdError(plugin_id)[source]

Bases: ValueError

:ERROR 4040:.

No plugin with identifier {plugin_id} is available.

__init__(plugin_id)[source]
exception plugins.pluginsexc.PluginKeyError[source]

Bases: KeyError

:ERROR 4060:.

A plugin with the same key is already existing or plugin already loaded.

__init__()[source]
exception plugins.pluginsexc.PluginOptionConfigFileError(section_name, option_name)[source]

Bases: ValueError

:ERROR 4016:.

Missing option {:s} in section {:s} of the configuration file.

__init__(section_name, option_name)[source]
exception plugins.pluginsexc.PluginSectionConfigFileError(section_name)[source]

Bases: ValueError

:ERROR 4014:.

Missing section {section_name} in the configuration file.

__init__(section_name)[source]

plugins.process module

filename

sppas.src.plugins.process.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Process to execute a plugin of SPPAS.

class plugins.process.sppasPluginProcess(plugin_param)[source]

Bases: object

Process one plugin (and only one).

__init__(plugin_param)[source]

Create a new sppasPluginProcess instance.

Parameters

plugin_param – (sppasPluginParam)

communicate()[source]

Wait for the process and get output messages (if any).

Returns

output message

is_running()[source]

Return True if the process is running.

run(filename)[source]

Execute the plugin in batch mode (ie don’t wait it to be finished).

Parameters

filename – (str) The file name of the file on which to apply

the plugin :returns: Process output message

stop()[source]

Terminate the process if it is running.

Module contents

filename

sppas.src.plugins.__init__.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Package for plugins of SPPAS.

plugins: access and manage external programs.

This package includes classes to manage external program to plug into SPPAS.

Example

>>> # Create a plugin manager (it will explore the installed plugins).
>>> manager = sppasPluginsManager()
>>> # Install a plugin
>>> plugin_id = manager.install(plugin_zip_filename,
>>>                             plugin_destination_folder_name)
>>> # Get a plugin
>>> p = manager.get_plugin(plugin_id)
>>> # Apply a plugin on a list of files
>>> message = manager.run_plugin(plugin_id, [some_filename1, some_filename2])
>>> print(message)
>>> # Delete an installed plugin
>>> manager.delete(plugin_id)

Requires the following other packages:

  • config

  • utils

  • structs

class plugins.sppasPluginParam(directory, config_file)[source]

Bases: object

Class to represent the set of parameters of a plugin.

The set of parameters of a plugin is made of a directory name, a configuration file name and a sppasPluginParser. This latter allows to get all information related to the plugin from the configuration file name:

  • the plugin configuration: identifier, name, description and icon;

  • the commands for windows, macos and linux;

  • a set of options, each one containing at least an identifier,

and optionally a type, a value and a description text.

__init__(directory, config_file)[source]

Create a new sppasPluginParam instance.

Parameters
  • directory – (str) the directory where to find the plugin

  • config_file – (str) the file name of the plugin configuration

get_command()[source]

Get the appropriate command to execute the plugin.

get_descr()[source]

Get the short description of the plugin.

get_directory()[source]

Get the directory name of the plugin.

get_icon()[source]

Get the icon file name of the plugin.

get_key()[source]

Get the identifier of the plugin.

get_name()[source]

Get the name of the plugin.

get_option_from_key(key)[source]

Get an option from its key.

get_options()[source]

Get all the options.

parse()[source]

Parse the configuration file of the plugin.

reset()[source]

Reset all members to their default value.

set_options(options_dict)[source]

Fix the options.

class plugins.sppasPluginProcess(plugin_param)[source]

Bases: object

Process one plugin (and only one).

__init__(plugin_param)[source]

Create a new sppasPluginProcess instance.

Parameters

plugin_param – (sppasPluginParam)

communicate()[source]

Wait for the process and get output messages (if any).

Returns

output message

is_running()[source]

Return True if the process is running.

run(filename)[source]

Execute the plugin in batch mode (ie don’t wait it to be finished).

Parameters

filename – (str) The file name of the file on which to apply

the plugin :returns: Process output message

stop()[source]

Terminate the process if it is running.

class plugins.sppasPluginsManager[source]

Bases: threading.Thread

Class to manage the list of plugins into SPPAS.

__init__()[source]

Instantiate the sppasPluginsManager and load the current plugins.

append(plugin_folder)[source]

Append a plugin in the list of plugins.

It is supposed that the given plugin folder name is a folder of the plugin directory.

Parameters

plugin_folder – (str) The folder name of the plugin.

delete(plugin_id)[source]

Delete a plugin of the plugins directory.

Parameters

plugin_id – (str) Identifier of the plugin to delete.

get_plugin(plugin_id)[source]

Get the sppasPluginParam from a plugin identifier.

Returns

sppasPluginParam matching the plugin_id or None

get_plugin_ids()[source]

Get the list of plugin identifiers.

Returns

List of plugin identifiers.

install(plugin_archive, plugin_folder)[source]

Install a plugin into the plugin directory.

Parameters
  • plugin_archive – (str) File name of the plugin to be installed (ZIP).

  • plugin_folder – (str) Destination folder name of the plugin to be installed.

load()[source]

Load all installed plugins in the SPPAS directory.

A plugin is not loaded if:

  • a configuration file is not defined or corrupted,

  • the platform system of the command does not match.

run_plugin(plugin_id, file_names)[source]

Apply a given plugin on a list of files.

Parameters
  • plugin_id – (str) Identifier of the plugin to apply.

  • file_names – (list) List of files on which the plugin has to be applied.

set_progress(progress)[source]

Fix the progress system to be used while executing a plugin.

Parameters

progress – (TextProgress or ProcessProgressDialog)