Adding data_dir to contain Iris-specifc data (just commands library at this time)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,4 +12,5 @@ npm-debug.log
|
||||
.idea
|
||||
venv
|
||||
docker/mopidy.conf
|
||||
docker/data/
|
||||
docker-compose.yml
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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 {}
|
||||
|
||||
@ -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
|
||||
Reference in New Issue
Block a user