def oneoff_command(args): session = make_session() load_plugins(settings["plugin_dir"], service_name="grouper-ctl") oneoffs = Annex(BaseOneOff, [settings["oneoff_dir"]], raise_exceptions=True) for oneoff in oneoffs: oneoff.configure(service_name="grouper-ctl") if args.subcommand == "run": logging.info("running one-off with '{}'".format(sys.argv)) if args.dry_run: logging.warning("running in DRY RUN mode") else: logging.warning("NOT running in dry run mode") with wrapped_session(session, make_read_only=args.dry_run) as the_session: for oneoff in oneoffs: if oneoff.__class__.__name__ == args.classname: params = args.oneoff_arguments or [] params += [('dry_run', args.dry_run)] oneoff.run(the_session, **dict(params)) elif args.subcommand == "list": for oneoff in oneoffs: logging.info(oneoff.__class__.__name__)
def load_plugins(plugin_dir, service_name): """Load plugins from a directory""" global Plugins if Plugins: raise PluginsAlreadyLoaded("Plugins already loaded; can't load twice!") Plugins = Annex(BasePlugin, [plugin_dir], raise_exceptions=True) for plugin in Plugins: plugin.configure(service_name)
def load_plugins(base_plugin, plugin_dirs, plugin_module_paths, service_name): # type: (Type[T], List[str], List[str], str) -> List[T] """Load plugins from a list of directories and modules""" for plugin_dir in plugin_dirs: if not os.path.exists(plugin_dir): raise PluginsDirectoryDoesNotExist("{} doesn't exist".format(plugin_dir)) plugins = Annex( base_plugin=base_plugin, plugin_dirs=plugin_dirs, raise_exceptions=True, additional_plugin_callback=_load_plugin_modules(base_plugin, plugin_module_paths) ) for plugin in plugins: plugin.configure(service_name) return list(plugins)
def load_plugins(plugin_dir, plugin_module_paths, service_name): # type: (str, List[str], str) -> None """Load plugins from a directory""" global Plugins if Plugins: raise PluginsAlreadyLoaded("Plugins already loaded; can't load twice!") if plugin_dir: if not os.path.exists(plugin_dir): raise PluginsDirectoryDoesNotExist( "{} doesn't exist".format(plugin_dir)) plugin_dirs = [plugin_dir] else: plugin_dirs = [] Plugins = Annex( BasePlugin, plugin_dirs, raise_exceptions=True, additional_plugin_callback=load_plugin_modules(plugin_module_paths)) for plugin in Plugins: plugin.configure(service_name)
def load_plugins(plugin_dir): """Load plugins from a directory""" global Plugins if Plugins: raise PluginsAlreadyLoaded("Plugins already loaded; can't load twice!") Plugins = Annex(BasePlugin, [plugin_dir], raise_exceptions=True)