Catch traceback caused by permissions errors during a local md5 sum

Fixes #6948
This commit is contained in:
James Cammarata 2014-04-14 12:36:54 -05:00
parent db36c41c3b
commit 2cc4ac2e75

View file

@ -590,12 +590,15 @@ def md5(filename):
return None return None
digest = _md5() digest = _md5()
blocksize = 64 * 1024 blocksize = 64 * 1024
infile = open(filename, 'rb') try:
block = infile.read(blocksize) infile = open(filename, 'rb')
while block:
digest.update(block)
block = infile.read(blocksize) block = infile.read(blocksize)
infile.close() while block:
digest.update(block)
block = infile.read(blocksize)
infile.close()
except IOError, e:
raise errors.AnsibleError("error while accessing the file %s, error was: %s" % (filename, e))
return digest.hexdigest() return digest.hexdigest()
def default(value, function): def default(value, function):