def download(self): url, sha1 = self.exe["url"], self.exe["sha1"] self.filepath = os.path.join(deps_path, os.path.basename(url)) if not os.path.exists(self.filepath) or \ sha1_file(self.filepath) != sha1: subprocess.call(["wget", "-O", self.filepath, url]) if sha1_file(self.filepath) != sha1: log.error("The checksum of %s doesn't match!", self.name) raise DependencyError
def available(self, dependency): """Checks whether a dependency is available and whether its integrity is correct.""" self._load_config() if dependency not in self.repo: log.info('No such dependency: %s.', dependency) return False if self.bitsize_64 and 'filename64' in self.repo[dependency]: fname = self.repo[dependency]['filename64'] else: fname = self.repo[dependency]['filename'] filepath = os.path.join(self.deps_directory, 'files', fname) if not os.path.exists(filepath): return False sha1 = sha1_file(filepath) if sha1 != self.hashes[fname]: log.warning( 'File %s of dependency %r downloaded with ' 'an incorrect sha1.', fname, dependency) os.unlink(filepath) return False return True
def available(self, dependency): """Checks whether a dependency is available and whether its integrity is correct.""" self._load_config() if dependency not in self.repo: log.info('No such dependency: %s.', dependency) return False if self.bitsize_64 and 'filename64' in self.repo[dependency]: fname = self.repo[dependency]['filename64'] else: fname = self.repo[dependency]['filename'] filepath = os.path.join(self.deps_directory, 'files', fname) if not os.path.exists(filepath): return False sha1 = sha1_file(filepath) if sha1 != self.hashes[fname]: log.warning('File %s of dependency %r downloaded with ' 'an incorrect sha1.', fname, dependency) os.unlink(filepath) return False return True
def download(self): urls = [] if "urls" in self.exe: urls.extend(self.exe["urls"]) else: urls.append(self.exe["url"]) if "filename" in self.exe: self.filename = self.exe["filename"] else: for url in urls: self.filename = filename_from_url(url) break self.filepath = os.path.join(deps_path, self.filename) if (os.path.exists(self.filepath) and "sha1" in self.exe and sha1_file(self.filepath) == self.exe["sha1"]): return for url in urls: download_file(url, self.filepath) if not os.path.exists(self.filepath): continue if "version" in self.exe and self.exe["version"] == "latest": log.info( "Got latest version '{}' from '{}', no checksum available!" .format(self.filename, url)) break if sha1_file(self.filepath) == self.exe["sha1"]: log.info( "Got file '{}' from '{}', with matching checksum.".format( self.filename, url)) break else: log.warn("The checksum of '{}' from '{}' didn't match!".format( self.filename, url)) os.remove(self.filepath) if not os.path.exists(self.filepath): raise DependencyError
def download(self): urls = [] if "urls" in self.exe: urls.extend(self.exe["urls"]) else: urls.append(self.exe["url"]) if "filename" in self.exe: self.filename = self.exe["filename"] else: for url in urls: self.filename = filename_from_url(url) break self.filepath = os.path.join(deps_path, self.filename) if (os.path.exists(self.filepath) and "sha1" in self.exe and sha1_file(self.filepath) == self.exe["sha1"]): return for url in urls: download_file(url, self.filepath) if not os.path.exists(self.filepath): continue if "version" in self.exe and self.exe["version"] == "latest": log.info("Got latest version '{}' from '{}', no checksum available!".format(self.filename, url)) break if sha1_file(self.filepath) == self.exe["sha1"]: log.info("Got file '{}' from '{}', with matching checksum.".format(self.filename, url)) break else: log.warn("The checksum of '{}' from '{}' didn't match!".format(self.filename, url)) os.remove(self.filepath) if not os.path.exists(self.filepath): raise DependencyError