def _inspect_file(self, id_, archive, dest, path): csum = util.gen_hash(path) content = {} if archive: ar_content = os.path.join(dest, 'content') if util.extract_archive(path, ar_content): for cur_path, dirs, files in os.walk(ar_content): subpath = cur_path[len(ar_content):].replace( '\\', '/').lstrip('/') if subpath != '': subpath += '/' for name in files: fpath = os.path.join(cur_path, name) # Don't generate checksums for symlinks. if not os.path.islink(fpath): content[subpath + name] = util.gen_hash(fpath) if name == 'mod.ini': self._inspect_mod_ini(os.path.join(cur_path, name), id_[0]) else: logging.error('Failed to extract "%s"!', os.path.basename(path)) return 'FAILED', None return csum, content
def check_hashes(self, path): alright = True for algo, filepath, chksum in self.hashes: try: mysum = gen_hash(ipath(os.path.join(path, filepath)), algo) except: logging.exception('Failed to computed checksum for "%s" with algorithm "%s"!', filepath, algo) continue if mysum != chksum.lower(): alright = False logging.warning('File "%s" has checksum "%s" but should have "%s"! Used algorithm: %s', filepath, mysum, chksum, algo) return alright
def check_hashes(self, path): alright = True for algo, filepath, chksum in self.hashes: try: mysum = gen_hash(ipath(os.path.join(path, filepath)), algo) except: logging.exception( 'Failed to computed checksum for "%s" with algorithm "%s"!', filepath, algo) continue if mysum != chksum.lower(): alright = False logging.warning( 'File "%s" has checksum "%s" but should have "%s"! Used algorithm: %s', filepath, mysum, chksum, algo) return alright