You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
533 B
26 lines
533 B
#!/usr/bin/python |
|
# Simple helper to split files into chunks and generate crc32 |
|
# checksums to help with file sharing debugging. |
|
|
|
import sys |
|
import zlib |
|
|
|
fileChunkSize = 60000 |
|
|
|
def main(fn): |
|
|
|
print "Splitting %s ..." % fn |
|
count = 0 |
|
with open(fn, "rb") as f: |
|
while True: |
|
chunk = f.read(fileChunkSize) |
|
count += 1 |
|
print count, zlib.crc32(chunk) & 0xffffffff |
|
if len(chunk) < fileChunkSize: |
|
break |
|
|
|
if __name__ == "__main__": |
|
args = sys.argv[1:] |
|
if not args: |
|
print "Usage %s: filename" % sys.argv[0] |
|
main(args[0]) |