1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

Merged in james-duley/librepilot/LP-111_UAVO_hash_only_xml_files (pull request #159)

LP-111 UAVO hash only xml files
This commit is contained in:
Philippe Renon 2016-01-24 13:55:04 +01:00
commit 596f3cb272

View File

@ -359,30 +359,31 @@ def get_hash_of_dirs(directory, verbose = 0, raw = 0, n = 40):
files.sort()
for names in files:
if verbose == 1:
print 'Hashing', names
filepath = os.path.join(root, names)
try:
f1 = open(filepath, 'rU')
except:
# You can't open the file for some reason
continue
if names.endswith('.xml')
if verbose == 1:
print 'Hashing', names
filepath = os.path.join(root, names)
try:
f1 = open(filepath, 'rU')
except:
# You can't open the file for some reason
continue
# Compute file hash. Same as running "sha1sum <file>".
f1hash = hashlib.sha1()
while 1:
# Read file in as little chunks
buf = f1.read(4096)
if not buf:
break
f1hash.update(buf)
f1.close()
# Compute file hash. Same as running "sha1sum <file>".
f1hash = hashlib.sha1()
while 1:
# Read file in as little chunks
buf = f1.read(4096)
if not buf:
break
f1hash.update(buf)
f1.close()
if verbose == 1:
print 'Hash is', f1hash.hexdigest()
if verbose == 1:
print 'Hash is', f1hash.hexdigest()
# Append the hex representation of the current file's hash into the cumulative hash
SHAhash.update(f1hash.hexdigest())
# Append the hex representation of the current file's hash into the cumulative hash
SHAhash.update(f1hash.hexdigest())
except:
import traceback