Mercurial > hg
changeset 1924:46fb38ef9a91
add md5sum.py required by fix in previous changeset
author | Peter van Dijk <peter@dataloss.nl> |
---|---|
date | Tue, 21 Feb 2006 22:32:17 +0100 |
parents | 7d83a351a936 |
children | c71420b186b0 |
files | tests/md5sum.py |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/md5sum.py Tue Feb 21 22:32:17 2006 +0100 @@ -0,0 +1,25 @@ +#! /usr/bin/env python +import sys +import os +import md5 + +for filename in sys.argv[1:]: + try: + fp = open(filename, 'rb') + except IOError, msg: + sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) + sys.exit(1) + + m = md5.new() + try: + while 1: + data = fp.read(8192) + if not data: + break + m.update(data) + except IOError, msg: + sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) + sys.exit(1) + sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) + +sys.exit(0)