示例#1
0
 def download_component(self, component):
     """Download an individual file from a runtime item"""
     file_path = os.path.join(RUNTIME_DIR, self.name, component["filename"])
     try:
         http.download_file(component["url"], file_path)
     except http.HTTPError:
         return
     return file_path
示例#2
0
 def download(self, slug, url):
     """Downloads the banner if not present"""
     if not url:
         return
     cache_path = os.path.join(self.dest_path, self.get_filename(slug))
     if not system.path_exists(cache_path):
         download_file(url, cache_path)
     return cache_path
示例#3
0
 def download_component(self, component):
     """Download an individual file from a runtime item"""
     file_path = os.path.join(settings.RUNTIME_DIR, self.name, component["filename"])
     try:
         http.download_file(component["url"], file_path)
     except http.HTTPError as ex:
         logger.error("Failed to download runtime component %s: %s", component, ex)
         return
     return file_path
示例#4
0
def fetch_dxvk_versions():
    """Get DXVK versions from GitHub"""
    dxvk_path = os.path.join(RUNTIME_DIR, "dxvk")
    if not os.path.isdir(dxvk_path):
        os.mkdir(dxvk_path)
    versions_path = os.path.join(dxvk_path, "dxvk_versions.json")
    return download_file(DXVK_RELEASES_URL, versions_path, overwrite=True)
示例#5
0
    def download(self):
        """Download DXVK to the local cache"""
        if self.is_available():
            logger.warning("DXVK already available at %s", self.dxvk_path)

        dxvk_url = self.get_dxvk_download_url()
        if not dxvk_url:
            logger.warning("Could not find a release for DXVK %s", self.version)
            return
        dxvk_archive_path = os.path.join(self.base_dir, os.path.basename(dxvk_url))
        download_file(dxvk_url, dxvk_archive_path, overwrite=True)
        if not system.path_exists(dxvk_archive_path) or not os.stat(dxvk_archive_path).st_size:
            logger.error("Failed to download DXVK %s", self.version)
            return
        extract_archive(dxvk_archive_path, self.dxvk_path, merge_single=True)
        os.remove(dxvk_archive_path)
示例#6
0
    def download(self):
        """Download component to the local cache"""
        if self.is_available():
            logger.warning("%s already available at %s", self.component, self.path)

        url = self.get_download_url()
        if not url:
            logger.warning("Could not find a release for %s %s", self.component, self.version)
            return
        archive_path = os.path.join(self.base_dir, os.path.basename(url))
        download_file(url, archive_path, overwrite=True)
        if not system.path_exists(archive_path) or not os.stat(archive_path).st_size:
            logger.error("Failed to download %s %s", self.component, self.version)
            return
        extract_archive(archive_path, self.path, merge_single=True)
        os.remove(archive_path)
示例#7
0
def fetch_dxvk_versions():
    """Get DXVK versions from GitHub"""
    dxvk_path = os.path.join(RUNTIME_DIR, "dxvk")
    if not os.path.isdir(dxvk_path):
        os.mkdir(dxvk_path)
    versions_path = os.path.join(dxvk_path, "dxvk_versions.json")
    logger.info("Downloading DXVK releases to %s", versions_path)
    return download_file(DXVK_RELEASES_URL, versions_path)
示例#8
0
 def download(self, slug, url):
     """Downloads the banner if not present"""
     if not url:
         return
     cache_path = os.path.join(self.dest_path, self.get_filename(slug))
     if system.path_exists(cache_path):
         return
     try:
         return download_file(url, cache_path)
     except HTTPError:
         return None
     return cache_path
示例#9
0
    def download(self):
        """Download component to the local cache; returns True if successful but False
        if the component could not be downloaded."""
        if self.is_available():
            logger.warning("%s already available at %s", self.component,
                           self.path)

        url = self.get_download_url()
        if not url:
            logger.warning("Could not find a release for %s %s",
                           self.component, self.version)
            return False
        archive_path = os.path.join(self.base_dir, os.path.basename(url))
        logger.info("Downloading %s to %s", url, archive_path)
        download_file(url, archive_path, overwrite=True)
        if not system.path_exists(archive_path) or not os.stat(
                archive_path).st_size:
            logger.error("Failed to download %s %s", self.component,
                         self.version)
            return False
        logger.info("Extracting %s to %s", archive_path, self.path)
        extract_archive(archive_path, self.path, merge_single=True)
        os.remove(archive_path)
        return True
示例#10
0
 def download(self, slug, url):
     """Downloads the banner if not present"""
     if not url:
         return
     cache_path = os.path.join(self.dest_path, self.get_filename(slug))
     if system.path_exists(cache_path, exclude_empty=True):
         return
     if system.path_exists(cache_path):
         cache_stats = os.stat(cache_path)
         # Empty files have a life time between 1 and 2 weeks, retry them after
         if time.time() - cache_stats.st_mtime < 3600 * 24 * random.choice(
                 range(7, 15)):
             return cache_path
         os.unlink(cache_path)
     try:
         return download_file(url, cache_path, raise_errors=True)
     except HTTPError as ex:
         logger.error("Failed to download %s: %s", url, ex)
示例#11
0
 def fetch_versions(self):
     """Get releases from GitHub"""
     if not os.path.isdir(self.base_dir):
         os.mkdir(self.base_dir)
     download_file(self.releases_url, self.versions_path, overwrite=True)