def main(): arg_parser = argparse.ArgumentParser(description=DESCRIPTION) arg_parser.add_argument("--raw", action="store_true", help="raw mode") arg_parser.add_argument("--json", action="store_true", help="json mode " "(not compatible with raw mode)") arg_parser.add_argument("--plugins-base-dir", type=str, default=None, help="can be use to set an alternate " "plugins-base-dir, if not set the value of " "MFMODULE_PLUGINS_BASE_DIR env var is used (or a " "hardcoded standard value).") args = arg_parser.parse_args() if args.json and args.raw: print("ERROR: json and raw options are mutually exclusives") sys.exit(1) if not is_plugins_base_initialized(args.plugins_base_dir): echo_bold("ERROR: the module is not initialized") echo_bold(" => start it once before installing your plugin") print() print("hint: you can use %s.start to do that" % MFMODULE_LOWERCASE) print() sys.exit(3) plugins = get_installed_plugins(plugins_base_dir=args.plugins_base_dir) json_output = [] table_data = [] table_data.append(["Name", "Version", "Release", "Home"]) for plugin in plugins: name = plugin['name'] release = plugin['release'] version = plugin['version'] home = plugin['home'] if args.raw: print("%s~~~%s~~~%s~~~%s" % (name, version, release, home)) elif args.json: json_output.append({ "name": name, "release": release, "version": version, "home": home }) else: table_data.append([name, version, release, home]) if not args.raw and not args.json: t = SingleTable(title="Installed plugins (%i)" % len(plugins), table_data=table_data) print(t.table) elif args.json: print(json.dumps(json_output, indent=4))
def main(): arg_parser = argparse.ArgumentParser(description=DESCRIPTION) arg_parser.add_argument("--raw", action="store_true", help="raw mode") args = arg_parser.parse_args() plugins = get_installed_plugins() if not args.raw: print("Installed plugins:") print() print("| %-25s | %-25s | %.25s" % ("NAME", "VERSION", "RELEASE")) print("-" * 75) for plugin in plugins: name = plugin['name'] release = plugin['release'] version = plugin['version'] if args.raw: print("%s~~~%s~~~%s" % (name, version, release)) else: print("| %-25s | %-25s | %.25s" % (name, version, release)) if not args.raw: print() print("Total: %i plugin(s)" % len(plugins))
def main(): arg_parser = argparse.ArgumentParser(description=DESCRIPTION) arg_parser.add_argument("--raw", action="store_true", help="raw mode") arg_parser.add_argument("--json", action="store_true", help="json mode " "(not compatible with raw mode)") args = arg_parser.parse_args() if args.json and args.raw: print("ERROR: json and raw options are mutually exclusives") sys.exit(1) plugins = get_installed_plugins() if not args.raw and not args.json: print("Installed plugins:") print() print("| %-25s | %-25s | %.25s" % ("NAME", "VERSION", "RELEASE")) print("-" * 75) json_output = [] for plugin in plugins: name = plugin['name'] release = plugin['release'] version = plugin['version'] home = plugin['home'] if args.raw: print("%s~~~%s~~~%s" % (name, version, release)) elif args.json: json_output.append({ "name": name, "release": release, "version": version, "home": home }) else: print("| %-25s | %-25s | %.25s" % (name, version, release)) if not args.raw and not args.json: print() print("Total: %i plugin(s)" % len(plugins)) elif args.json: print(json.dumps(json_output, indent=4))
from mfutil import mkdir_p_or_die, get_unique_hexa_identifier from mfutil import get_utc_unix_timestamp from mfutil.plugins import MFUtilPluginBaseNotInitialized from mfutil.plugins import get_installed_plugins from acquisition.utils import _set_custom_environment, \ get_plugin_step_directory_path, MODULE_RUNTIME_HOME, _get_tmp_filepath, \ _make_config_file_parser_class, _get_or_make_trash_dir from acquisition.stats import get_stats_client DEFAULT_STEP_LIMIT = 1000 DEFAULT_REDIS_HOST = "127.0.0.1" DEFAULT_REDIS_PORT = int(os.environ.get("MFDATA_REDIS_PORT", "1234")) DEBUG_PLUGIN_NAME = "debug" try: DEBUG_PLUGIN_INSTALLED = \ DEBUG_PLUGIN_NAME in [x['name'] for x in get_installed_plugins()] except MFUtilPluginBaseNotInitialized: DEBUG_PLUGIN_INSTALLED = False class AcquisitionStep(object): """Abstract class to describe an acquisition step. You have to override this class. Attributes: debug_mode_allowed (boolean): if True, the debug mode is allowed. stop_flag (boolean): if True, stop the daemon as soon as possible. unit_tests (boolean): if True, we are in unit tests mode. failure_policy (string): failure policy. args (Namespace): argparser Namespace object with parsed cli args.
def test_empty_installed_plugins(self): tmp = get_installed_plugins(self.base_path) self.assertEquals(len(tmp), 0)
def _get_plugins_home(): plugins = get_installed_plugins() return [x['home'] for x in plugins]