mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-24 13:54:16 +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:
commit
596f3cb272
@ -359,30 +359,31 @@ def get_hash_of_dirs(directory, verbose = 0, raw = 0, n = 40):
|
|||||||
files.sort()
|
files.sort()
|
||||||
|
|
||||||
for names in files:
|
for names in files:
|
||||||
if verbose == 1:
|
if names.endswith('.xml')
|
||||||
print 'Hashing', names
|
if verbose == 1:
|
||||||
filepath = os.path.join(root, names)
|
print 'Hashing', names
|
||||||
try:
|
filepath = os.path.join(root, names)
|
||||||
f1 = open(filepath, 'rU')
|
try:
|
||||||
except:
|
f1 = open(filepath, 'rU')
|
||||||
# You can't open the file for some reason
|
except:
|
||||||
continue
|
# You can't open the file for some reason
|
||||||
|
continue
|
||||||
|
|
||||||
# Compute file hash. Same as running "sha1sum <file>".
|
# Compute file hash. Same as running "sha1sum <file>".
|
||||||
f1hash = hashlib.sha1()
|
f1hash = hashlib.sha1()
|
||||||
while 1:
|
while 1:
|
||||||
# Read file in as little chunks
|
# Read file in as little chunks
|
||||||
buf = f1.read(4096)
|
buf = f1.read(4096)
|
||||||
if not buf:
|
if not buf:
|
||||||
break
|
break
|
||||||
f1hash.update(buf)
|
f1hash.update(buf)
|
||||||
f1.close()
|
f1.close()
|
||||||
|
|
||||||
if verbose == 1:
|
if verbose == 1:
|
||||||
print 'Hash is', f1hash.hexdigest()
|
print 'Hash is', f1hash.hexdigest()
|
||||||
|
|
||||||
# Append the hex representation of the current file's hash into the cumulative hash
|
# Append the hex representation of the current file's hash into the cumulative hash
|
||||||
SHAhash.update(f1hash.hexdigest())
|
SHAhash.update(f1hash.hexdigest())
|
||||||
|
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user