コード例 #1
0
ファイル: plugins.py プロジェクト: luis4ndre/unmanic
    def notify_site_of_plugin_install(self, plugin):
        """
        Notify the Unmanic.app site of the install.
        This is used for metric stats so that we can get a count of plugin downloads.

        :param plugin:
        :return:
        """
        # Post
        session = Session()
        uuid = session.get_installation_uuid()
        post_data = {
            "uuid": uuid,
            "plugin_id": plugin.get("id"),
            "author": plugin.get("author"),
            "version": plugin.get("version"),
        }
        try:
            repo_data = session.api_post(1, 'unmanic-plugin/install',
                                         post_data)
            if not repo_data.get('success'):
                session.register_unmanic(session.get_installation_uuid())
        except Exception as e:
            self._log("Exception while logging plugin install.",
                      str(e),
                      level="debug")
            return False
コード例 #2
0
ファイル: plugins.py プロジェクト: pianomanx/unmanic
 def fetch_remote_repo_data(self, repo_path):
     # Fetch remote JSON file
     session = Session()
     uuid = session.get_installation_uuid()
     post_data = {"uuid": uuid, "repo_url": repo_path}
     return session.api_post(1, 'unmanic-plugin-repo/uuid/{}'.format(uuid),
                             post_data)
コード例 #3
0
ファイル: plugins.py プロジェクト: luis4ndre/unmanic
    def update_plugin_repos(self):
        """
        Updates the local cached data of plugin repos

        :return:
        """
        plugins_directory = self.settings.get_plugins_path()
        if not os.path.exists(plugins_directory):
            os.makedirs(plugins_directory)
        success = True
        current_repos_list = self.get_plugin_repos()
        for repo in current_repos_list:
            repo_path = repo.get('path')
            repo_id = self.get_plugin_repo_id(repo_path)

            # If success, dump JSON to file
            # Else, log error and catch any exceptions
            pass
            # Try to fetch URL
            try:
                # Fetch remote JSON file
                session = Session()
                uuid = session.get_installation_uuid()
                post_data = {"uuid": uuid, "repo_url": repo_path}
                repo_data = session.api_post(
                    1, 'unmanic-plugin-repo/uuid/{}'.format(uuid), post_data)

                # Load JSON to python object
                # repo_data = json.loads(repo_json)
                self._log("Repo info {}.".format(repo_path),
                          repo_data,
                          level="info")

                # Dumb object to local JSON file
                repo_cache = self.get_repo_cache_file(repo_id)
                self._log("Repo cache file '{}'.".format(repo_cache),
                          level="info")
                with open(repo_cache, 'w') as f:
                    json.dump(repo_data, f, indent=4)

            except Exception as e:
                success = False
                self._log(
                    "Exception while updating repo {}.".format(repo_path),
                    str(e),
                    level="exception")
        return success