Ejemplo n.º 1
0
    def load(self):
        if os.path.isfile(
                os.path.join(JustUpdateConstants.REPO_FOLDER, "archive",
                             f"metadata-{get_platform_name_short()}.ju")
        ) == False and os.path.isfile(
                os.path.join(
                    JustUpdateConstants.REPO_FOLDER, "deploy",
                    f"metadata-{get_platform_name_short()}.ju")) == False:
            logging.debug(
                f"No metadata for platform {get_platform_name_short()} found.")
            return {}

        # ok the metadata file most exist. Try to load it.
        # first see if there's one in deploy, if not, go for the one in archive.
        data = b""
        try:
            data = data_manager.open_file(
                os.path.join(JustUpdateConstants.REPO_FOLDER, "deploy",
                             f"metadata-{get_platform_name_short()}.ju"), "rb")
        except FileNotFoundError:
            data = data_manager.open_file(
                os.path.join(JustUpdateConstants.REPO_FOLDER, "archive",
                             f"metadata-{get_platform_name_short()}.ju"), "rb")
        data = data_manager.decompress(data)
        data = json.loads(data)
        return data
Ejemplo n.º 2
0
 def _load_metadata(self, bypass_metadata_cache_cache):
     md = ""
     try:
         md = self._download_metadata(
             "metadata-{}.ju".format(get_platform_name_short()),
             bypass_metadata_cache_cache)
     except requests.ConnectTimeout:
         return None
     except:
         raise
     md = data_manager.decompress(md)
     md = json.loads(md)
     metadata = MetaData()
     metadata.apply_metadata(md)
     return metadata