Commit 8565ab1e authored by Alan Taylor's avatar Alan Taylor

use with for hash creation file read

parent eadcb6a4
......@@ -99,9 +99,10 @@ def _nodes_to_assess(node_ips_specified):
elif cache_missing and bench_present:
# benchmark all the nodes given
nodes_to_benchmark = set(node_ips_specified)
hash_cached = hashlib.sha256(open(ds.FILENAME_BENCHMARK, 'rb').read()).hexdigest()
bench_cached = []
nodes_to_benchmark = set(node_ips_specified)
with open(ds.FILENAME_BENCHMARK, 'rb') as fbench:
hash_cached = hashlib.sha256(fbench.read()).hexdigest()
elif cache_present and bench_missing:
# can only continue if the cache contains all the nodes we have
......@@ -120,7 +121,8 @@ def _nodes_to_assess(node_ips_specified):
nodes_to_benchmark = set(node_ips_specified)
hash_cached, bench_cached = fio.benchmark_cache_read()
nodes_in_cache = {i[0] for i in bench_cached}
hash_current = hashlib.sha256(open(ds.FILENAME_BENCHMARK, 'rb').read()).hexdigest()
with open(ds.FILENAME_BENCHMARK, 'rb') as fbench:
hash_current = hashlib.sha256(fbench.read()).hexdigest()
if hash_cached == hash_current:
nodes_to_benchmark -= nodes_in_cache
......@@ -263,7 +265,8 @@ def display_bench_cache(nodes_specified):
elif cache_present and bench_present:
hash_cached, bench_cached = fio.benchmark_cache_read()
hash_current = hashlib.sha256(open(ds.FILENAME_BENCHMARK, 'rb').read()).hexdigest()
with open(ds.FILENAME_BENCHMARK, 'rb') as fbench:
hash_current = hashlib.sha256(fbench.read()).hexdigest()
if hash_cached != hash_current:
print('benchmark cache exists, but is invalid')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment