def get_sha(a_file):
try:<EOL><INDENT>BLOCKSIZE = <NUM_LIT><EOL>hasher = hashlib.sha1()<EOL>with io.open(a_file, "<STR_LIT:rb>") as fh:<EOL><INDENT>buf = fh.read(BLOCKSIZE)<EOL>while len(buf) > <NUM_LIT:0>:<EOL><INDENT>hasher.update(buf)<EOL>buf = fh.read(BLOCKSIZE)<EOL><DEDENT><DEDENT>the_hash = hasher.hexdigest()<EOL><DEDENT>except IOError:<EOL><INDENT>errmes = "<STR_LIT>".format(a_file)<EOL>sys.stdout.write(errmes)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>except:<EOL><INDENT>errmes = "<STR_LIT>"<EOL>sys.stdout.write(errmes)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>return the_hash<EOL>
Returns sha1 hash of the file supplied as an argument