def go(users): # get all plugins plugins = {} print "get all plugins..." for usr in users: for pull in users[usr]['pull']: plugins[pull] = users[usr]['push'].split(',') print "plugins: ", plugins # prepare all data pull_contents = {} print "prepare all data..." for pull, pushs in plugins.items(): pull_key = 'pull.' + pull print "pull_key: ", pull_key pull_contents[pull_key] = {} pull_class = CONF.get(pull_key, None) print "pull_class: ", pull_class if pull_class: pull_class_obj = utils.import_class(pull_class) pull_clazz = pull_class_obj() for pull_plugin_key in pull_clazz.all_keys: print "pull_plugin_key: ", pull_plugin_key pull_content = pull_clazz(pull_plugin_key) pull_contents[pull_key][pull_plugin_key] = {} pull_contents[pull_key][pull_plugin_key]['content'] = pull_content for push in pushs: if push: push_key = 'push.' + push print "push_key: ", push_key to_method = getattr(pull_content, "to_"+push) pull_contents[pull_key][pull_plugin_key][push_key] = to_method() if not pull_contents: print "get empty content." return # push all data print "push all user data..." for usr in users: print "user: "******"pull_key: ", pull_key for plugin_key in users[usr]['pull'][pull]: for push in user_push: push_key = 'push.' + push print "push_key: ", push_key push_class = CONF.get(push_key, None) print "push_class: ", push_class if push_class: push_class_obj = utils.import_class(push_class) push_clazz = push_class_obj() push_clazz(pull_contents[pull_key][plugin_key][push_key])
def __init__(self, options=None, config_file=None): if config_file == None: self.configuration_file = find_config( os.path.abspath(os.path.dirname(__file__))) else: self.configuration_file = config_file # If no options have been provided, create an empty dict if not options: options = {} if not 'plugin_provider' in options: options['plugin_provider'] = \ utils.get_plugin_from_config(self.configuration_file) LOG.debug("Plugin location:%s", options['plugin_provider']) plugin_klass = utils.import_class(options['plugin_provider']) if not issubclass(plugin_klass, QuantumPluginBase): raise Exception("Configured Quantum plug-in " \ "didn't pass compatibility test") else: LOG.debug("Successfully imported Quantum plug-in." \ "All compatibility tests passed") self.plugin = plugin_klass()
returns the default defined in kwargs. """ for v in _vars: value = os.environ.get(v, None) if value: return value return kwargs.get('default', '') COMMAND_V2 = {} app_list = applications.split(',') for app in app_list: if app: cls = None cls = utils.import_class(app) COMMAND_V2.update(cls.COMMANDS) COMMANDS = {'2.0': COMMAND_V2} class HelpAction(argparse.Action): """Provide a custom action so the -h and --help options to the main app will print a list of the commands. The commands are determined by checking the CommandManager instance, passed in as the "default" value for the action. """ def __call__(self, parser, namespace, values, option_string=None): outputs = [] max_len = 0