def check_pics(rep): """ Verify picture checksums. Return names of corrupt & missing files. Arguments: rep -- Verify pictures in this repository. Returns: A 2-tuple containing a list over the corrupted and a list over the missing picture's filenames. """ corrupted = [] missing = [] with rep.connector.connected(): for pic in rep.index.pics(): try: with rep.connector.open(pic.filename, 'r') as buf: checksum = get_sha1(buf.read()) except (IOError, OSError): missing.append(pic.filename) else: if checksum != pic.checksum: corrupted.append(pic.filename) return corrupted, missing
def test_determinism(self): buf2 = copy.copy(self.buf) self.assertEqual(get_sha1(self.buf), get_sha1(buf2))
def test_sha1(self): self.assertEqual(get_sha1(self.buf), hashlib.sha1(self.buf).hexdigest())