pyworkflow.plugin module

class pyworkflow.plugin.Domain[source]

Bases: object

Class to represent the application domain. It will allow to specify new objects, protocols, viewers and wizards through the registration of new plugins.

classmethod findClass(className)[source]

Find a class object given its name. The search will start with protocols and then with protocols.

classmethod findSubClasses(classDict, className)[source]

Find all subclasses of a give className.

classmethod findViewers(className, environment)[source]

Find the available viewers in this Domain for this class.

classmethod findWizards(protocol, environment)[source]

Find available wizards for this class, in this Domain. Params:

protocols: Protocol instance for which wizards will be search. environment: The environment name for wizards (e.g TKINTER)
a dict with the paramName and wizards for this class.
classmethod getMapperDict()[source]

Return a dictionary that can be used with subclasses of Mapper to store/retrieve objects (including protocols) defined in this Domain.

classmethod getModuleClasses(module)[source]
classmethod getName()[source]

Return the name of this Domain.

classmethod getObjects()[source]

Return all EMObject subclasses from all plugins for this domain.

classmethod getPlugin(name)[source]

Load a given plugin name.

classmethod getPlugins()[source]

Return existing plugins for this Domain.

classmethod getPreferredViewers(className)[source]

Find and import the preferred viewers for this class.

classmethod getProtocols()[source]

Return all Protocol subclasses from all plugins for this domain.

classmethod getViewers()[source]

Return all Viewer subclasses from all plugins for this domain.

classmethod getWizards()[source]

Return all Wizard subclasses from all plugins for this domain.

static importFromPlugin(module, objects=None, errorMsg='', doRaise=False)[source]
This method try to import either a list of objects from the
module/plugin or the whole module/plugin and returns what is imported if not fails. When the import fails (due to the plugin or the object is not found), it prints a common message + optional errorMsg; or it raise an error with the same message, if doRaise is True.

-> Usages:

# Import the whole plugin ‘plugin1’ as ‘plug1’ plug1 = importFromPlugin(‘plugin1’)

# Import a plugin’s module pl1Cons = importFromPlugin(‘plug1.constants’)

# Import a single class from a plugin’s module p1prot1 = importFromPlugin(‘plug1.protocols’, ‘prot1’)

# Import some classes from a plugin’s module, # the returned tuple has the same length of the second argument pt1, pt2, … = importFromPlugin(‘plugin1.protocols’,

[‘pt1’, ‘pt2’, …])
classmethod printInfo()[source]

Simple function (mainly for debugging) that prints basic information about this Domain.

classmethod refreshPlugin(name)[source]

Refresh a given plugin name.

classmethod registerPlugin(name)[source]

Register a new plugin. This function should only be called when creating a class with __metaclass__=PluginMeta that will trigger this.

class pyworkflow.plugin.Plugin[source]

Bases: object

classmethod defineBinaries(env)[source]

Define required binaries in the given Environment.

classmethod getActiveVersion(home=None, versions=None)[source]

Return the version of the binaries that are currently active. In the current implementation it will be inferred from the *_HOME variable, so it should contain the version number in it.

classmethod getCondaActivationCmd()[source]
classmethod getEnviron()[source]

Setup the environment variables needed to launch programs.

classmethod getHome(*paths)[source]

Return a path from the “home” of the package if the _homeVar is defined in the plugin.

classmethod getName()[source]
classmethod getPluginTemplateDir()[source]
classmethod getSupportedVersions()[source]

Return the list of supported binary versions.

classmethod getTemplates()[source]

Get the plugin templates from the templates directory. If more than one template is found or passed, a dialog is raised to choose one.

classmethod getUrl(protClass=None)[source]

Url for the plugin to point users to it

classmethod getVar(varName, defaultValue=None)[source]

Return the value of a given variable.

classmethod getVars()[source]

Return the value of a given variable.

classmethod validateInstallation()[source]

Check if the binaries are properly installed and if not, return a list with the error messages.

The default implementation will check if the _pathVars exists.

class pyworkflow.plugin.PluginInfo(name)[source]

Bases: object

Information related to a given plugin when it is installed via PIP