aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-11-23 01:58:18 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-11-23 01:58:18 +0100
commit3bddc491d6c1c135ee937d1ba884f7cef4e4860c (patch)
treee0e5891c0bb4aa5e3dfd83e127fa455697933788
parent00f74bd822dda4b39ed439f53e0767283f85c5e5 (diff)
downloadallocbench-3bddc491d6c1c135ee937d1ba884f7cef4e4860c.tar.gz
allocbench-3bddc491d6c1c135ee937d1ba884f7cef4e4860c.zip
fix Benchmark and facter load functions
-rw-r--r--src/benchmark.py6
-rw-r--r--src/facter.py11
2 files changed, 9 insertions, 8 deletions
diff --git a/src/benchmark.py b/src/benchmark.py
index e1b598f..fc42763 100644
--- a/src/benchmark.py
+++ b/src/benchmark.py
@@ -193,12 +193,12 @@ class Benchmark:
if os.path.exists(filename + ".json"):
import json
filename += ".json"
- with open(filename, "w") as f:
+ with open(filename, "r") as f:
self.results = json.load(f)
- if os.path.exists(filename + ".save"):
+ elif os.path.exists(filename + ".save"):
import pickle
filename += ".save"
- with open(filename, "wb") as f:
+ with open(filename, "rb") as f:
self.results = pickle.load(f)
else:
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)
diff --git a/src/facter.py b/src/facter.py
index 4d0d6ac..c3c95cd 100644
--- a/src/facter.py
+++ b/src/facter.py
@@ -19,6 +19,7 @@
import ctypes
import datetime
+import errno
import json
import multiprocessing
import os
@@ -68,21 +69,21 @@ def store_facts(path=None):
def load_facts(path=None):
"""Load facts from file"""
if not path:
- filename = self.name
+ filename = "facts"
else:
if os.path.isdir(path):
filename = os.path.join(path, self.name)
else:
- filename = os.path.splitext(path)
+ filename = os.path.splitext(path)[0]
if os.path.exists(filename + ".json"):
filename += ".json"
- with open(filename, "w") as f:
+ with open(filename, "r") as f:
gv.facts = json.load(f)
- if os.path.exists(filename + ".save"):
+ elif os.path.exists(filename + ".save"):
import pickle
filename += ".save"
- with open(filename, "wb") as f:
+ with open(filename, "rb") as f:
gv.facts = pickle.load(f)
else:
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)