def __init__(self, dir): self.__base_url = 'http://www.prosoar.de/' self.__cmd_7zip = '7zr' self.__cmd_wget = 'wget' self.__dir = os.path.abspath(dir) self.__manifest = None if not os.path.exists(self.__dir): os.makedirs(self.__dir) subprocess.check_call([self.__cmd_wget, '-q', '-N', '-P', self.__dir, self.__base_url + 'checksums']) self.__checksums = {} for line in slurp(os.path.join(self.__dir, 'checksums')).split("\n"): line = line.strip() if line != '': line = line.split(None, 1) self.__checksums[line[1]] = line[0]
def __get_local_checksum(self, file): md5_path = file + '.md5' if os.path.exists(md5_path): return slurp(md5_path) if not os.path.isfile(file): return None md5 = hashlib.md5() file = open(file, 'rb') try: while True: data = file.read(0xFFFF) if not data: break md5.update(data) finally: file.close() md5 = md5.hexdigest() spew(md5_path, md5) return md5
def manifest(self): if not self.__manifest: self.__manifest = json.loads(slurp(self.retrieve('manifest'))) return self.__manifest