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

@ -37,6 +37,7 @@ class Extension( ext.Extension ):
schema['spotify_authorization_url'] = config.String()
schema['lastfm_authorization_url'] = config.String()
schema['genius_authorization_url'] = config.String()
schema['data_dir'] = config.String()
return schema
def setup(self, registry):

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 {}

View File

@ -5,3 +5,4 @@ locale = en_NZ
spotify_authorization_url = https://jamesbarnsley.co.nz/iris/auth_spotify.php
lastfm_authorization_url = https://jamesbarnsley.co.nz/iris/auth_lastfm.php
genius_authorization_url = https://jamesbarnsley.co.nz/iris/auth_genius.php
data_dir = $XDG_DATA_DIR/iris