예제 #1
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("plugin_filepath",
                            type=str,
                            help="plugin filepath")
    arg_parser.add_argument("--force",
                            help="ignore some errors",
                            action="store_true")
    args = arg_parser.parse_args()
    echo_running("- Checking plugin file...")
    infos = get_plugin_info(args.plugin_filepath, mode="file")
    if not infos:
        echo_nok()
        sys.exit(1)
    echo_ok()
    name = infos['metadatas']['name']
    echo_running("- Installing plugin %s..." % name)
    try:
        install_plugin(args.plugin_filepath, ignore_errors=args.force)
    except MFUtilPluginAlreadyInstalled as e:
        echo_nok("already installed")
        sys.exit(1)
    except MFUtilPluginCantInstall as e:
        echo_nok()
        print(e)
        sys.exit(2)
    echo_ok()
예제 #2
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("plugin_filepath", type=str,
                            help="plugin filepath")
    arg_parser.add_argument("--force", help="ignore some errors",
                            action="store_true")
    args = arg_parser.parse_args()
    echo_running("- Checking plugin file...")
    infos = get_plugin_info(args.plugin_filepath, mode="file")
    if not infos:
        echo_nok()
        sys.exit(1)
    echo_ok()
    name = infos['metadatas']['name']
    echo_running("- Installing plugin %s..." % name)
    try:
        install_plugin(args.plugin_filepath, ignore_errors=args.force)
    except MFUtilPluginAlreadyInstalled as e:
        echo_nok("already installed")
        sys.exit(1)
    except MFUtilPluginCantInstall as e:
        echo_nok()
        print(e)
        sys.exit(2)
    echo_ok()
예제 #3
0
 def test_duplicate_install_plugin(self):
     tmp = build_plugin("%s/data/test_build_plugin" % TEST_DIRECTORY,
                        plugins_base_dir=self.base_path)
     self.assertTrue(tmp is not None)
     install_plugin(tmp, plugins_base_dir=self.base_path)
     try:
         install_plugin(tmp, plugins_base_dir=self.base_path)
         raise Exception("MFUtilPluginAlreadyInstalled not raised")
     except MFUtilPluginAlreadyInstalled:
         pass
예제 #4
0
 def test_install_plugin(self):
     tmp = build_plugin("%s/data/test_build_plugin" % TEST_DIRECTORY,
                        plugins_base_dir=self.base_path)
     self.assertTrue(tmp is not None)
     install_plugin(tmp, plugins_base_dir=self.base_path)
     tmp = get_plugin_info("bar", mode="name",
                           plugins_base_dir=self.base_path)
     self.assertTrue(tmp is not None)
     self.assertEquals(tmp['metadatas']['name'], 'bar')
     uninstall_plugin("bar", plugins_base_dir=self.base_path)
예제 #5
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("plugin_filepath", type=str,
                            help="plugin filepath")
    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()
    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("- Checking plugin file...")
    infos = get_plugin_info(args.plugin_filepath, mode="file",
                            plugins_base_dir=args.plugins_base_dir)
    if not infos:
        echo_nok()
        sys.exit(1)
    echo_ok()
    name = infos['metadatas']['name']
    echo_running("- Installing plugin %s..." % name)
    try:
        install_plugin(args.plugin_filepath, ignore_errors=args.force,
                       plugins_base_dir=args.plugins_base_dir)
    except MFUtilPluginAlreadyInstalled:
        echo_nok("already installed")
        sys.exit(1)
    except MFUtilPluginCantInstall as e:
        echo_nok()
        print(e)
        sys.exit(2)
    echo_ok()
    is_dangerous_plugin(name, plugins_base_dir=args.plugins_base_dir)
예제 #6
0
def u_plugin(typ, name, fil):
    echo_running("- Updating %s plugin: %s..." % (typ, name))
    uninstall_plugin(name)
    install_plugin(fil)
    echo_ok()
예제 #7
0
def i_plugin(typ, name, fil):
    echo_running("- Installing %s plugin: %s..." % (typ, name))
    install_plugin(fil)
    echo_ok()