def _load_filesystem_plugins(self): # import logging # logging.basicConfig(level=logging.DEBUG) """Looks for *.yapsy-plugin files and loads them. It calls 'register' \ method for each plugin, which in turn registers with \ :class:`FilesystemDetector \ <rawdisk.filesystems.detector.FilesystemDetector>`. Note: Plugin search locations: * $(rawdisk package location)/plugins/filesystems * $(home dir)/.local/share/rawdisk/plugins/filesystems * /usr/local/share/rawdisk/plugins/filesystems * /usr/share/rawdisk/plugins/filesystems """ PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) # Load the plugins from the plugin directory. self.manager = PluginManagerSingleton.get() self.manager.setPluginPlaces(self.search_path) self.manager.setCategoriesFilter({ "Filesystem": IFilesystemPlugin, }) # Load plugins self.manager.collectPlugins() for pluginInfo in self.manager.getPluginsOfCategory("Filesystem"): self.fs_plugins.append(pluginInfo)
def load_filesystem_plugins(self): """Looks for *.yapsy-plugin files, loads them and returns a list of :class:`VersionedPluginInfo \ <yapsy.VersionedPluginManager.VersionedPluginInfo>` objects Note: Plugin search locations: * $(rawdisk package location)/plugins/filesystems * $(home dir)/.local/share/rawdisk/plugins/filesystems * /usr/local/share/rawdisk/plugins/filesystems * /usr/share/rawdisk/plugins/filesystems """ self.logger.info('Loading filesystem plugins') search_path = self.__get_fs_plugin_search_path() fs_plugins = [] PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) # Load the plugins from the plugin directory. plugin_manager = PluginManagerSingleton.get() plugin_manager.setPluginPlaces(search_path) plugin_manager.setCategoriesFilter({ "Filesystem": IFilesystemPlugin, }) # Load plugins plugin_manager.collectPlugins() for pluginInfo in plugin_manager.getPluginsOfCategory("Filesystem"): fs_plugins.append(pluginInfo) return fs_plugins
def _load_filesystem_plugins(self): """Looks for *.yapsy-plugin files and loads them. It calls 'register' \ method for each plugin, which in turn registers with \ :class:`FilesystemDetector \ <rawdisk.filesystems.detector.FilesystemDetector>`. Note: Plugin search locations: * $(rawdisk package location)/plugins/filesystems * $(home dir)/.local/share/rawdisk/plugins/filesystems * /usr/local/share/rawdisk/plugins/filesystems * /usr/share/rawdisk/plugins/filesystems """ PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) # Load the plugins from the plugin directory. self.manager = PluginManagerSingleton.get() self.manager.setPluginPlaces(self.search_path) self.manager.setCategoriesFilter({ "Filesystem": IFilesystemPlugin, }) # Load plugins self.manager.collectPlugins() for pluginInfo in self.manager.getPluginsOfCategory("Filesystem"): self.fs_plugins.append(pluginInfo)
def __init__ (self): """ Class initialiser """ # Get singleton instance PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) manager = PluginManagerSingleton.get() # A referrence for plugins to access the app manager.app = self # Set environment self.env = jinja2.Environment(loader=jinja2.FileSystemLoader("./template/"), **TEMPLATE_OPTIONS) # Set ArgParser self.parser = argparse.ArgumentParser(description='Simple Static Web Generator') self.parser.add_argument('--cache', dest='cache', action='store_true') # A referrence for plugins to access the env object # manager.env = self.env # Set plugin's directories path manager.setPluginPlaces(['plugins']) # Locates and Loads the plugins manager.collectPlugins()
def _init_plugin_engine(self): self.debug("Initializing plugin engine") places = [] if hasattr(self, '_plugin_dir'): # run_local.py will pass in a plugin directory places.append(self._plugin_dir) for path in xdg_data_dirs: path = os.path.join(path, self._package, "plugins") places.append(path) PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) manager = PluginManagerSingleton.get() manager.application = self manager.setConfigParser(self._config, self.write_config) manager.setPluginInfoExtension("plugin") manager.setPluginPlaces(places) #manager.setCategoriesFilter({ # "Application" : WindowPlugin, #}) manager.collectPlugins() #for info in manager.getPluginsOfCategory("Window"): for info in manager.getAllPlugins(): plugin = info.plugin_object plugin.application = self
def __init__(self): """ Initialize the PluginManager including: - plugin configuration directory - plugin search locations """ self.config_path = save_config_path("yasibo") self.config_file = os.path.join(self.config_path, "plugins.conf") places = [] [places.append(os.path.join(path, "yasibo", "plugins")) for path in xdg_data_dirs] # dev location places.append("%s/../plugins" % os.path.dirname(os.path.abspath(__file__))) PluginManagerSingleton.setBehaviour([ConfigurablePluginManager, VersionedPluginManager]) self.manager = PluginManagerSingleton.get() locator = self.manager.getPluginLocator() locator.setPluginInfoExtension("yasibo-plugin") self.manager.setPluginPlaces(places) self.config = SafeConfigParser() self.config.read(self.config_file) self.manager.setConfigParser(self.config, self.save) self.manager.collectPlugins() log.debug("Config file: %s" % self.config_file)
def __init__(self, plugin_dir=None): self.config = SafeConfigParser() config_path = save_config_path(self.APP_NAME) self.config_file = os.path.join(config_path, self.APP_NAME + ".conf") self.config.read(self.config_file) this_dir = os.path.abspath(os.path.dirname(__file__)) self.plugin_dir = plugin_dir or os.path.join(this_dir, self._default_dir) places = [ self.plugin_dir, ] [ places.append(os.path.join(path, self.APP_NAME, "evaluators")) for path in xdg_data_dirs ] PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) self.manager = PluginManagerSingleton.get() self.manager.setConfigParser(self.config, self.write_config) self.manager.setPluginInfoExtension("expr-plugin") self.manager.setPluginPlaces(places) self.manager.collectPlugins()
def __init__(self, win): self.app = win.app self.parent = win # Build a list of directories which may contain plugins. This will # include the 'plugins' folder where this file resides as well as every # directory in xdg.BaseDirectory.xdg_data_dirs. This way users can # install plugins in something like ~/.local/yapsy-gtk-example/plugins # but your installer could also install those plugins to something like # /usr/share/yapsy-gtk-example/plugins. You'll see Yapsy checking each # of these directories if logging is set to logging.DEBUG xdg_data_dirs = [ os.path.join(os.path.expanduser("~"), '.local', 'share') ] this_dir = os.path.abspath(self.app.FULL_PATH) plugin_dir = os.path.join(this_dir, 'data', 'plugins') places = [ plugin_dir, ] for path in xdg_data_dirs: places.append(os.path.join(path, self.app.APP_NAME, "plugins")) # The singleton versino of the Yapsy plugin manager is used rather than # passing around a PluginManager instance. Prior to getting the # singleton instance, some "plugin manager decorators" are installed to: # 1. Automatically save active and non-active plugins to the config file # 2. Ensure only the newest versions of plugins are used. # This call to setBehaviour() must occur before getting the singleton # instance. PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) # Get singleton instance manager = PluginManagerSingleton.get() # I like to give the manager a reference to the application class so # that plugins can connect to signals and access windows through # the manager singleton. manager.app = self.app manager.parent = self.parent # Give manager the config file and a callback function to call when it # changes the config (eg. when a plugin is activated or deactivated). manager.setConfigParser(self.app.config, self.app.config.write_settings) # Setup a file extension for plugin information files. In this it's # just ".plugin" but you may want to do something specific to your # application like ".myapp-plugin" manager.setPluginInfoExtension("gs-plugin") # Pass the manager the list of plugin directories manager.setPluginPlaces(places) # CollectPlugins is a shortcut for locatePlugins() and loadPlugins(). manager.collectPlugins()
def _loadPlugins(self): PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) manager = PluginManagerSingleton.get() manager.setPluginPlaces(self.pluginDirs) manager.setCategoriesFilter(pluginCategories) manager.collectPlugins()
def __init__(self, config: Config): PluginManagerSingleton.setBehaviour( [ConfigurablePluginManager, VersionedPluginManager] ) self._plugin_manager = PluginManagerSingleton.get() self._plugin_manager.setPluginPlaces(config.get_plugin_paths()) self._plugin_manager.setPluginInfoExtension("plugin") self._plugin_manager.setConfigParser(config.parser, config.save)
def __init__(self, win): self.app = win.app self.parent = win # Build a list of directories which may contain plugins. This will # include the 'plugins' folder where this file resides as well as every # directory in xdg.BaseDirectory.xdg_data_dirs. This way users can # install plugins in something like ~/.local/yapsy-gtk-example/plugins # but your installer could also install those plugins to something like # /usr/share/yapsy-gtk-example/plugins. You'll see Yapsy checking each # of these directories if logging is set to logging.DEBUG xdg_data_dirs = [os.path.join(os.path.expanduser("~"), '.local', 'share')] this_dir = os.path.abspath(self.app.FULL_PATH) plugin_dir = os.path.join(this_dir, 'data', 'plugins') places = [plugin_dir, ] for path in xdg_data_dirs: places.append(os.path.join(path, self.app.APP_NAME, "plugins")) # The singleton versino of the Yapsy plugin manager is used rather than # passing around a PluginManager instance. Prior to getting the # singleton instance, some "plugin manager decorators" are installed to: # 1. Automatically save active and non-active plugins to the config file # 2. Ensure only the newest versions of plugins are used. # This call to setBehaviour() must occur before getting the singleton # instance. PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) # Get singleton instance manager = PluginManagerSingleton.get() # I like to give the manager a reference to the application class so # that plugins can connect to signals and access windows through # the manager singleton. manager.app = self.app manager.parent = self.parent # Give manager the config file and a callback function to call when it # changes the config (eg. when a plugin is activated or deactivated). manager.setConfigParser(self.app.config, self.app.config.write_settings) # Setup a file extension for plugin information files. In this it's # just ".plugin" but you may want to do something specific to your # application like ".myapp-plugin" manager.setPluginInfoExtension("gs-plugin") # Pass the manager the list of plugin directories manager.setPluginPlaces(places) # CollectPlugins is a shortcut for locatePlugins() and loadPlugins(). manager.collectPlugins()
def create_plugin_manager(self): from yapsy.ConfigurablePluginManager import ConfigurablePluginManager from yapsy.PluginManager import PluginManagerSingleton from yapsy.VersionedPluginManager import VersionedPluginManager PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) return PluginManagerSingleton.get()
def __init__(self, configdir, profile=None): QtCore.QObject.__init__(self) self.firstrun = False PluginManagerSingleton.setBehaviour([ConfigurablePluginManager]) self.plugmanc = PluginManagerSingleton.get() locator = self.plugmanc.getPluginLocator() locator.setPluginInfoExtension("freeseer-plugin") self.configdir = configdir if profile: # Use profile if specified self.configfile = os.path.abspath( os.path.join(self.configdir, "profiles", profile, "plugin.conf")) else: self.configfile = os.path.abspath( os.path.join(self.configdir, "plugin.conf")) self.config = ConfigParser.ConfigParser() self.load() self.plugmanc.setConfigParser(self.config, self.save) # Get the path where the installed plugins are located on systems where # freeseer is installed. pluginpath = "%s/../plugins" % os.path.dirname( os.path.abspath(__file__)) self.plugmanc.setPluginPlaces([ pluginpath, os.path.expanduser("~/.freeseer/plugins"), "freeseer/plugins" ]) self.plugmanc.setCategoriesFilter({ "AudioInput": IAudioInput, "AudioMixer": IAudioMixer, "VideoInput": IVideoInput, "VideoMixer": IVideoMixer, "Output": IOutput }) self.plugmanc.collectPlugins() # If config was corrupt or did not exist, reset default plugins. if self.firstrun: self.set_default_plugins() for plugin in self.plugmanc.getAllPlugins(): plugin.plugin_object.set_plugman(self) log.debug("Plugin manager initialized.")
def load(self): PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ConfigurablePluginManager, ]) #OnlinePluginManager self.manager = PluginManagerSingleton.get() #~ if self.installpath: #~ self.manager.setInstallDir(self.installpath) self.manager.setConfigParser(self.configparser, self.configparser.save) self.manager.setPluginPlaces(self.loadpathes) self.manager.setPluginInfoExtension(self.extension) self.manager.setCategoriesFilter(self.categories) self.manager.collectPlugins()
def __init__(self, cfg): """ Initialise the plugin system. """ assert cfg self.cfg = cfg # Get plugin locations. plugin_search_path_b = self.cfg.get_config_str( "PluginSearchPath", default=b"/etc/rdiffweb/plugins") # Determine the search path searchpath = [] # Append core plugins directory (in bytes) path_b = pkg_resources.resource_filename('rdiffweb', b'plugins') # @UndefinedVariable searchpath.append(path_b) # Append user plugins directory plugin_locations = plugin_search_path_b.split(b',') searchpath.extend(plugin_locations) # Build the manager logger.debug("plugin search path [%s]" % (searchpath)) # Create the plugin manager. PluginManagerSingleton.setBehaviour([FilteredPluginManager]) self.manager = PluginManagerSingleton.get() # Sets plugins locations. plugin_locator = PluginLocator() self.manager.setPluginLocator(plugin_locator) plugin_locator.setPluginPlaces(searchpath) # Define categories self.manager.setCategoriesFilter({ IDatabase.CATEGORY: IDatabase, IDeamonPlugin.CATEGORY: IDeamonPlugin, ILocationsPagePlugin.CATEGORY: ILocationsPagePlugin, IPasswordStore.CATEGORY: IPasswordStore, IPreferencesPanelProvider.CATEGORY: IPreferencesPanelProvider, IUserChangeListener.CATEGORY: IUserChangeListener, }) # Set filter. self.manager.isPluginOk = self.is_plugin_enabled # Load all plugins self.manager.collectPlugins()
def setUp(self): """ init """ # create a config file self.config_file = self.CONFIG_FILE self.config_parser = ConfigParser() self.plugin_info = None # create the plugin manager PluginManagerSingleton.setBehaviour([ConfigurablePluginManager,VersionedPluginManager]) pluginManager = PluginManagerSingleton.get() pluginManager.setPluginPlaces(directories_list=[os.path.dirname(os.path.abspath(__file__))]) pluginManager.setPluginInfoExtension("yapsy-config-plugin") pluginManager.setConfigParser(self.config_parser,self.update_config) # load the plugins that may be found pluginManager.collectPlugins()
def loadPlugins(config, qEvents, qIrc): log.info('loading plugins from [%s]' % config.path) # logging.getLogger('yapsy').setLevel(logging.DEBUG) PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) manager = PluginManagerSingleton.get() manager.setPluginInfoExtension("plugin") manager.setPluginPlaces([os.path.abspath(config.path)]) manager.collectPlugins() plugins = {} for item in manager.getAllPlugins(): print item.name print item.plugin_object print item qPlugin = Queue() plugins[item.name.lower()] = (item, qPlugin) item.plugin_object.activate(qPlugin, qIrc) print "plugins loaded", qEvents while True: try: event = qEvents.get(False) if event is not None: target = event[0] if target == 'babble': for plugin in plugins: plugins[plugin][1].put(event) elif target == 'irc': for plugin in plugins: plugins[plugin][1].put(event) else: if target in plugins: plugins[target][1].put(event) except Empty: time.sleep(0.1) print "leaving loadPlgins"
def __init__(self, plugin_dir=None): self.config = SafeConfigParser() config_path = save_config_path(self.APP_NAME) self.config_file = os.path.join(config_path, self.APP_NAME + ".conf") self.config.read(self.config_file) this_dir = os.path.abspath(os.path.dirname(__file__)) self.plugin_dir = plugin_dir or os.path.join(this_dir, self._default_dir) places = [self.plugin_dir] [places.append(os.path.join(path, self.APP_NAME, "evaluators")) for path in xdg_data_dirs] PluginManagerSingleton.setBehaviour([ConfigurablePluginManager, VersionedPluginManager]) self.manager = PluginManagerSingleton.get() self.manager.setConfigParser(self.config, self.write_config) self.manager.setPluginInfoExtension("expr-plugin") self.manager.setPluginPlaces(places) self.manager.collectPlugins()
def loadPlugins(config, qEvents, qIrc): log.info("loading plugins from [%s]" % config.path) # logging.getLogger('yapsy').setLevel(logging.DEBUG) PluginManagerSingleton.setBehaviour([VersionedPluginManager]) manager = PluginManagerSingleton.get() manager.setPluginInfoExtension("plugin") manager.setPluginPlaces([os.path.abspath(config.path)]) manager.collectPlugins() plugins = {} for item in manager.getAllPlugins(): print item.name print item.plugin_object print item qPlugin = Queue() plugins[item.name.lower()] = (item, qPlugin) item.plugin_object.activate(qPlugin, qIrc) print "plugins loaded", qEvents while True: try: event = qEvents.get(False) if event is not None: target = event[0] if target == "babble": for plugin in plugins: plugins[plugin][1].put(event) elif target == "irc": for plugin in plugins: plugins[plugin][1].put(event) else: if target in plugins: plugins[target][1].put(event) except Empty: time.sleep(0.1) print "leaving loadPlgins"
def __init__(self, configdir, profile=None): QtCore.QObject.__init__(self) self.firstrun = False PluginManagerSingleton.setBehaviour([ConfigurablePluginManager]) self.plugmanc = PluginManagerSingleton.get() locator = self.plugmanc.getPluginLocator() locator.setPluginInfoExtension("freeseer-plugin") self.configdir = configdir if profile: # Use profile if specified self.configfile = os.path.abspath(os.path.join(self.configdir, "profiles", profile, "plugin.conf")) else: self.configfile = os.path.abspath(os.path.join(self.configdir, "plugin.conf")) self.config = ConfigParser.ConfigParser() self.load() self.plugmanc.setConfigParser(self.config, self.save) # Get the path where the installed plugins are located on systems where # freeseer is installed. pluginpath = "%s/../plugins" % os.path.dirname(os.path.abspath(__file__)) self.plugmanc.setPluginPlaces([pluginpath, os.path.expanduser("~/.freeseer/plugins"), "freeseer/plugins"]) self.plugmanc.setCategoriesFilter({ "AudioInput": IAudioInput, "AudioMixer": IAudioMixer, "VideoInput": IVideoInput, "VideoMixer": IVideoMixer, "Output": IOutput}) self.plugmanc.collectPlugins() # If config was corrupt or did not exist, reset default plugins. if self.firstrun: self.set_default_plugins() for plugin in self.plugmanc.getAllPlugins(): plugin.plugin_object.set_plugman(self) log.debug("Plugin manager initialized.")
def setUp(self): """ init """ # create a config file self.config_file = self.CONFIG_FILE self.config_parser = ConfigParser() self.plugin_info = None # create the plugin manager PluginManagerSingleton.setBehaviour( [ConfigurablePluginManager, VersionedPluginManager]) pluginManager = PluginManagerSingleton.get() pluginManager.setPluginPlaces( directories_list=[os.path.dirname(os.path.abspath(__file__))]) pluginManager.setPluginInfoExtension("yapsy-config-plugin") pluginManager.setConfigParser(self.config_parser, self.update_config) # load the plugins that may be found pluginManager.collectPlugins()
def initPlugins(self): if get_settings().get_plugins_enabled(): from yapsy.PluginManager import PluginManagerSingleton from lunchinator.plugin import NotificationPluginManager PluginManagerSingleton.setBehaviour([ NotificationPluginManager, ]) self.plugin_manager = PluginManagerSingleton.get() self.plugin_manager.app = self self.plugin_manager.setConfigParser(get_settings().get_config_file(), get_settings().write_config_to_hd) self.plugin_manager.setPluginPlaces(get_settings().get_plugin_dirs()) try: self.plugin_manager.collectPlugins() except: getCoreLogger().exception("problem when loading plugins") get_peer_actions().initialize() else: getCoreLogger().info("lunchinator initialised without plugins")
def load_filesystem_plugins(): # import logging # logging.basicConfig(level=logging.DEBUG) """Looks for *.yapsy-plugin files and loads them. It calls 'register' \ method for each plugin, which in turn registers with \ :class:`FilesystemDetector \ <rawdisk.filesystems.detector.FilesystemDetector>`. Note: Plugin search locations: * $(rawdisk package location)/plugins/filesystems * $(home dir)/.local/share/rawdisk/plugins/filesystems * /usr/local/share/rawdisk/plugins/filesystems * /usr/share/rawdisk/plugins/filesystems """ PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) # Load the plugins from the plugin directory. manager = PluginManagerSingleton.get() places = [os.path.join( os.path.dirname(rawdisk.__file__), "plugins/filesystems"), ] [places.append(os.path.join(path, APP_NAME, "plugins/filesystems")) for path in xdg_data_dirs] manager.setPluginPlaces(places) manager.setCategoriesFilter({ "Filesystem": IFilesystemPlugin, }) # Load plugins manager.collectPlugins() for pluginInfo in manager.getPluginsOfCategory("Filesystem"): pluginInfo.plugin_object.register()
import os from ConfigParser import SafeConfigParser from yapsy.PluginManager import PluginManagerSingleton from yapsy.ConfigurablePluginManager import ConfigurablePluginManager from yapsy.VersionedPluginManager import VersionedPluginManager from smartclock.plugins import pluginlib from smartclock.plugins.pluginfileanalyzerwithdocstring import PluginFileAnalyzerWithDocString # pylint: disable=line-too-long PluginManagerSingleton.setBehaviour( [ConfigurablePluginManager, VersionedPluginManager]) _manager = PluginManagerSingleton.get() class PluginManager(object): def __init__(self, conffile, plugin_places, debug=False): """Configures the PluginManager, loads plugins and settings.""" activate_plugins = not os.path.exists(conffile) or debug if debug: write_config = lambda: None else: write_config = lambda: self.write_config(parser, conffile) parser = SafeConfigParser() parser.read(conffile)
def _mangerInitialize(self): PluginManagerSingleton.setBehaviour([MultiprocessPluginManager, ConfigurablePluginManager, VersionedPluginManager]) self.manager = PluginManagerSingleton.get()
def prepPluginManager(self): PluginManagerSingleton.setBehaviour([VersionedPluginManager, ]) self.plugin_manager = PluginManagerSingleton.get() self.plugin_manager.setPluginPlaces(self.plugin_places)
def __init__(self): self._create_window() # Setup a ConfigParser which will be used by the Yapsy plugin manager to # remember which plugins are activated. The function # xdg.BaseDirectory.save_config_path() function is used to get the path # for the configuration file. You may want to instead iterate over the # xdg.BaseDirectory.xdg_config_dirs if your application installs default # configuration files into system directories. See # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html # for more information on the XDG specifications. self.config = SafeConfigParser() config_path = save_config_path(self.APP_NAME) self.config_file = os.path.join(config_path, self.APP_NAME + ".conf") logging.debug("Reading configuration file: %s" % self.config_file) self.config.read(self.config_file) # Build a list of directories which may contain plugins. This will # include the 'plugins' folder where this file resides as well as every # directory in xdg.BaseDirectory.xdg_data_dirs. This way users can # install plugins in something like ~/.local/yapsy-gtk-example/plugins # but your installer could also install those plugins to something like # /usr/share/yapsy-gtk-example/plugins. You'll see Yapsy checking each # of these directories if logging is set to logging.DEBUG this_dir = os.path.abspath(os.path.dirname(__file__)) plugin_dir = os.path.join(this_dir,'plugins') places = [plugin_dir,] [places.append(os.path.join(path, self.APP_NAME, "plugins")) for path in xdg_data_dirs] # The singleton versino of the Yapsy plugin manager is used rather than # passing around a PluginManager instance. Prior to getting the # singleton instance, some "plugin manager decorators" are installed to: # 1. Automatically save active and non-active plugins to the config file # 2. Ensure only the newest versions of plugins are used. # This call to setBehaviour() must occur before getting the singleton # instance. PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) # Get singleton instance manager = PluginManagerSingleton.get() # I like to give the manager a reference to the application class so # that plugins can connect to signals and access windows through # the manager singleton. manager.app = self # Give manager the config file and a callback function to call when it # changes the config (eg. when a plugin is activated or deactivated). manager.setConfigParser(self.config, self.write_config) # Setup a file extension for plugin information files. In this it's # just ".plugin" but you may want to do something specific to your # application like ".myapp-plugin" manager.setPluginInfoExtension("plugin") # Pass the manager the list of plugin directories manager.setPluginPlaces(places) # CollectPlugins is a shortcut for locatePlugins() and loadPlugins(). manager.collectPlugins() # Now that the plugins have been collected, the plugin widget can # be refreshed to display all installed plugins. self._plugin_list.refresh()
def prepPluginManager(self): PluginManagerSingleton.setBehaviour([ VersionedPluginManager, ]) self.plugin_manager = PluginManagerSingleton.get() self.plugin_manager.setPluginPlaces(self.plugin_places)
def __init__(self): self._create_window() # Setup a ConfigParser which will be used by the Yapsy plugin manager to # remember which plugins are activated. The function # xdg.BaseDirectory.save_config_path() function is used to get the path # for the configuration file. You may want to instead iterate over the # xdg.BaseDirectory.xdg_config_dirs if your application installs default # configuration files into system directories. See # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html # for more information on the XDG specifications. self.config = SafeConfigParser() config_path = save_config_path(self.APP_NAME) self.config_file = os.path.join(config_path, self.APP_NAME + ".conf") logging.debug("Reading configuration file: %s" % self.config_file) self.config.read(self.config_file) # Build a list of directories which may contain plugins. This will # include the 'plugins' folder where this file resides as well as every # directory in xdg.BaseDirectory.xdg_data_dirs. This way users can # install plugins in something like ~/.local/yapsy-gtk-example/plugins # but your installer could also install those plugins to something like # /usr/share/yapsy-gtk-example/plugins. You'll see Yapsy checking each # of these directories if logging is set to logging.DEBUG this_dir = os.path.abspath(os.path.dirname(__file__)) plugin_dir = os.path.join(this_dir, 'plugins') places = [ plugin_dir, ] [ places.append(os.path.join(path, self.APP_NAME, "plugins")) for path in xdg_data_dirs ] # The singleton versino of the Yapsy plugin manager is used rather than # passing around a PluginManager instance. Prior to getting the # singleton instance, some "plugin manager decorators" are installed to: # 1. Automatically save active and non-active plugins to the config file # 2. Ensure only the newest versions of plugins are used. # This call to setBehaviour() must occur before getting the singleton # instance. PluginManagerSingleton.setBehaviour([ ConfigurablePluginManager, VersionedPluginManager, ]) # Get singleton instance manager = PluginManagerSingleton.get() # I like to give the manager a reference to the application class so # that plugins can connect to signals and access windows through # the manager singleton. manager.app = self # Give manager the config file and a callback function to call when it # changes the config (eg. when a plugin is activated or deactivated). manager.setConfigParser(self.config, self.write_config) # Setup a file extension for plugin information files. In this it's # just ".plugin" but you may want to do something specific to your # application like ".myapp-plugin" manager.setPluginInfoExtension("plugin") # Pass the manager the list of plugin directories manager.setPluginPlaces(places) # CollectPlugins is a shortcut for locatePlugins() and loadPlugins(). manager.collectPlugins() # Now that the plugins have been collected, the plugin widget can # be refreshed to display all installed plugins. self._plugin_list.refresh()
import os from ConfigParser import SafeConfigParser from yapsy.PluginManager import PluginManagerSingleton from yapsy.ConfigurablePluginManager import ConfigurablePluginManager from yapsy.VersionedPluginManager import VersionedPluginManager from smartclock.plugins import pluginlib from smartclock.plugins.pluginfileanalyzerwithdocstring import PluginFileAnalyzerWithDocString # pylint: disable=line-too-long PluginManagerSingleton.setBehaviour( [ConfigurablePluginManager, VersionedPluginManager]) _manager = PluginManagerSingleton.get() class PluginManager(object): def __init__(self, conffile, plugin_places, debug=False): """Configures the PluginManager, loads plugins and settings.""" activate_plugins = not os.path.exists(conffile) or debug if debug: write_config = lambda: None else: write_config = lambda: self.write_config(parser, conffile) parser = SafeConfigParser() parser.read(conffile) _manager.setConfigParser(parser, write_config) # pylint: disable=maybe-no-member
def _mangerInitialize(self): PluginManagerSingleton.setBehaviour([ MultiprocessPluginManager, ConfigurablePluginManager, VersionedPluginManager ]) self.manager = PluginManagerSingleton.get()