Exemple #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()
Exemple #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()
Exemple #3
0
 def test_develop_plugin(self):
     develop_plugin("%s/data/test_build_plugin" % TEST_DIRECTORY,
                    "bar", 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')
     self.assertEquals(tmp['metadatas']['version'], 'dev_link')
     self.assertEquals(tmp['metadatas']['release'], 'dev_link')
     uninstall_plugin("bar", plugins_base_dir=self.base_path)
Exemple #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)
Exemple #5
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("name_or_filepath", type=str,
                            help="installed plugin name (without version) or "
                            "full plugin filepath")
    arg_parser.add_argument("--just-home", action="store_true",
                            help="if set, just return plugin home")
    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()

    try:
        infos = get_plugin_info(args.name_or_filepath,
                                plugins_base_dir=args.plugins_base_dir)
    except MFUtilPluginBaseNotInitialized:
        print("ERROR: the module is not initialized", file=sys.stderr)
        print("       => start it once before installing your plugin",
              file=sys.stderr)
        print("", file=sys.stderr)
        print("hint: you can use %s.start to do that" % MFMODULE_LOWERCASE,
              file=sys.stderr)
        print("", file=sys.stderr)
        sys.exit(3)

    if infos is None:
        sys.exit(1)
    if args.just_home:
        print(infos['home'])
        sys.exit(0)

    print("Metadata:")
    print()
    print(infos['raw_metadata_output'])
    print()
    if "home" in infos:
        print("Installation home: %s" % infos['home'])
        print()
    print("List of files:")
    print()
    print(infos['raw_files_output'])
Exemple #6
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)
Exemple #7
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("name_or_filepath",
                            type=str,
                            help="installed plugin name (without version) or "
                            "full plugin filepath")
    args = arg_parser.parse_args()

    infos = get_plugin_info(args.name_or_filepath)
    if infos is None:
        sys.exit(1)

    print("Metadata:")
    print()
    print(infos['raw_metadata_output'])
    print()
    print("List of files:")
    print()
    print(infos['raw_files_output'])
Exemple #8
0
def main():
    arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
    arg_parser.add_argument("name_or_filepath",
                            type=str,
                            help="installed plugin name (without version) or "
                            "full plugin filepath")
    arg_parser.add_argument("--just-home",
                            action="store_true",
                            help="if set, just return plugin home")
    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()

    infos = get_plugin_info(args.name_or_filepath,
                            plugins_base_dir=args.plugins_base_dir)
    if infos is None:
        sys.exit(1)
    if args.just_home:
        print(infos['home'])
        sys.exit(0)

    print("Metadata:")
    print()
    print(infos['raw_metadata_output'])
    print()
    if "home" in infos:
        print("Installation home: %s" % infos['home'])
        print()
    print("List of files:")
    print()
    print(infos['raw_files_output'])
Exemple #9
0
    if len(candidates) == 0:
        logging.critical("can't find an installation file for plugin %s "
                         "in %s/share/plugins/" % (plugin, MODULE_HOME))
        sys.exit(1)
    selected_file = candidates[-1]
    selected_hash = get_plugin_hash(selected_file, mode="file")
    if not selected_hash:
        logging.critical("the selected file: %s for the plugin %s is not "
                         "correct" % (selected_file, plugin))
        sys.exit(1)
    if installed_hash is None:
        # not installed
        i_plugin("internal", plugin, selected_file)
    else:
        if selected_hash != installed_hash:
            installed_infos = get_plugin_info(plugin, mode="name")
            if installed_infos['metadatas']['release'] == "dev_link":
                continue
            # to update
            u_plugin("internal", plugin, selected_file)

for selected_file in external_plugins_to_check:
    infos = get_plugin_info(selected_file, mode="file")
    if not infos:
        continue
    name = infos['metadatas']['name']
    selected_hash = get_plugin_hash(selected_file, mode="file")
    installed_hash = get_plugin_hash(name, mode="name")
    if installed_hash is None:
        # not installed
        i_plugin("external", name, selected_file)
Exemple #10
0
 def test_not_installed_plugin_info(self):
     tmp = get_plugin_info("foo", mode="name",
                           plugins_base_dir=self.base_path)
     self.assertTrue(tmp is None)