Adding data_dir to contain Iris-specifc data (just commands library at this time)

This commit is contained in:
James Barnsley
2019-11-02 08:02:50 +13:00
parent 6e70c364d7
commit 6225201fc7
4 changed files with 7 additions and 8 deletions

View File

@ -62,9 +62,7 @@ class IrisCore(pykka.ThreadingActor):
# @return void
##
def save_to_file(self, dict, name):
# Build path to our special Iris folder
path = self.config['core'].get('cache_dir')+'/iris/'
path = self.config['iris'].get('data_dir')
# Create the folder if it doesn't yet exist
if not os.path.exists(path):
@ -72,7 +70,7 @@ class IrisCore(pykka.ThreadingActor):
# And now open the file, and drop in our dict
try:
with open(path + name + '.pkl', 'wb') as f:
with open(path + '/' + name + '.pkl', 'wb') as f:
pickle.dump(dict, f, pickle.HIGHEST_PROTOCOL)
except Exception:
return False
@ -85,12 +83,10 @@ class IrisCore(pykka.ThreadingActor):
# @return Dict
##
def load_from_file(self, name):
# Build path to our special Iris folder
path = self.config['core'].get('cache_dir')+'/iris/'
path = self.config['iris'].get('data_dir')
try:
with open(path + name + '.pkl', 'rb') as f:
with open(path + '/' + name + '.pkl', 'rb') as f:
return pickle.load(f)
except Exception:
return {}