Beispiel #1
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("name", type=str,
                            help="plugin name")
    arg_parser.add_argument("--force", help="ignore some errors",
                            action="store_true")
    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()
    name = args.name
    if inside_a_plugin_env():
        print("ERROR: Don't use plugins.install/uninstall inside a plugin_env")
        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)
    echo_running("- Uninstalling plugin %s..." % name)
    try:
        uninstall_plugin(name, ignore_errors=args.force,
                         plugins_base_dir=args.plugins_base_dir)
    except MFUtilPluginNotInstalled:
        echo_nok("not installed")
        sys.exit(1)
    except MFUtilPluginCantUninstall as e:
        echo_nok()
        print(e)
        sys.exit(2)
    echo_ok()
Beispiel #2
0
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))
Beispiel #3
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.parse_args()
    echo_running("- Creating plugins base...")
    try:
        init_plugins_base()
    except MFUtilPluginCantInit as e:
        echo_nok()
        print(e)
        sys.exit(1)
    if not is_plugins_base_initialized():
        echo_nok()
        sys.exit(1)
    echo_ok()
Beispiel #4
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    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()
    echo_running("- Creating plugins base...")
    try:
        init_plugins_base(args.plugins_base_dir)
    except MFUtilPluginCantInit as e:
        echo_nok()
        print(e)
        sys.exit(1)
    if not is_plugins_base_initialized():
        echo_nok()
        sys.exit(1)
    echo_ok()
Beispiel #5
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("--plugin-path",
                            default=".",
                            help="plugin directory path")
    arg_parser.add_argument("name", help="plugin name")
    args = arg_parser.parse_args()
    if not is_plugins_base_initialized():
        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)
    echo_running("- Devlinking plugin %s..." % args.name)
    try:
        develop_plugin(args.plugin_path, args.name)
    except MFUtilPluginAlreadyInstalled:
        echo_nok("already installed")
        sys.exit(1)
    echo_ok()
    is_dangerous_plugin(args.name)
Beispiel #6
0
 def test_is_plugins_base_initialized(self):
     self.assertTrue(is_plugins_base_initialized(self.base_path))