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.

  • protocol – Protocol instance for which wizards will be search.

  • environment – The environment name for wizards (e.g TKINTER)

:return A dict with the paramName and wizards for the protocol passed.

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]
classmethod getPluginModule(name)[source]

Return the root of a plugin module initialized properly

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.

  • module – Module name to import

  • objects – Optional, string with objects to return present in module

  • errorMsg – Optional, extra error message to append to the main message.

  • doRaise – If True it will raise an exception instead of tolerating the import error


# 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.

classmethod viewersLoaded()[source]

Returns true if viewers have been already discovered

class pyworkflow.plugin.Plugin[source]

Bases: object

abstract classmethod defineBinaries(env)[source]

Define required binaries in the given Environment.

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

Returns 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]

Returns the conda activation command with && at the end if defined otherwise empty

abstract classmethod getEnviron()[source]

Set up 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 getSupportedVersions()[source]

Return the list of supported binary versions.


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.

inDevelMode() bool[source]

Returns true if code is not in python’s site-packages folder

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.