예제 #1
0
def prepare_plugin_repos_list():
    """
    Return a list of plugin repos available to download from

    :return:
    """
    return_repos = []

    plugins = PluginsHandler()
    # Fetch the data again from the database
    current_repos = plugins.get_plugin_repos()

    # Remove the default plugin repo from the list
    default_repo = plugins.get_default_repo()
    for repo in current_repos:
        if not repo.get("path").startswith(default_repo):
            return_repos.append(repo)

    # Append metadata from repo cache files
    for repo in return_repos:
        repo_path = repo.get('path')
        repo_id = plugins.get_plugin_repo_id(repo_path)
        repo_data = plugins.read_repo_data(repo_id)
        repo_metadata = repo_data.get('repo', {})
        repo['id'] = repo_metadata.get('id')
        repo['icon'] = repo_metadata.get('icon')
        repo['name'] = repo_metadata.get('name')

    return return_repos
예제 #2
0
    def get_repo_list(self):
        try:
            plugins = PluginsHandler()
            # Fetch the data again from the database
            current_repos = plugins.get_plugin_repos()

            # Remove the default plugin repo from the list
            return_repos = []
            default_repo = plugins.get_default_repo()
            for repo in current_repos:
                if not repo.get("path").startswith(default_repo):
                    return_repos.append(repo)

            # Return success
            self.write(json.dumps({"success": True, "repos": return_repos}))
        except Exception as e:
            tornado.log.app_log.exception(
                "Exception in fetching the current repo list - {}".format(
                    str(e)),
                exc_info=True)

            # Return failure
            self.write(json.dumps({"success": False}))