Handle missing resource dirs

This commit is contained in:
nolash 2021-07-17 08:22:39 +02:00
parent 1361c18fbd
commit a14a9f4699
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 12 additions and 4 deletions

View File

@ -9,6 +9,7 @@ from xdg.BaseDirectory import (
xdg_data_dirs,
get_runtime_dir,
load_first_config,
save_config_path,
)
@ -27,14 +28,21 @@ class Environment:
base_config_dir = load_first_config('chaind')
self.runtime_dir = os.path.join(get_runtime_dir(), 'chaind')
self.data_dir = os.path.join(xdg_data_dirs[0], 'chaind')
self.config_dir = env.get('CONFINI_DIR', os.path.join(base_config_dir))
self.config_dir = env.get('CONFINI_DIR', base_config_dir)
if self.config_dir == None:
save_config_path('chaind')
self.config_dir = load_first_config('chaind')
self.session_runtime_dir = os.path.join(self.runtime_dir, self.session)
if domain:
self.runtime_dir = os.path.join(self.runtime_dir, domain)
os.makedirs(self.runtime_dir, exist_ok=True)
self.data_dir = os.path.join(self.data_dir, domain)
os.makedirs(self.data_dir, exist_ok=True)
self.config_dir = os.path.join(self.config_dir, domain)
os.makedirs(self.config_dir, exist_ok=True)
self.session_runtime_dir = os.path.join(self.runtime_dir, self.session)
os.makedirs(self.session_runtime_dir, exist_ok=True)
@property
def session(self):

View File

@ -1,5 +1,5 @@
chainlib>0.0.4,<=0.0.5
chainqueue>=0.0.3a1,<=.0.0.4
chainsyncer>0.0.4a1,<=0.0.5
chainlib>=0.0.5a4,<=0.0.5
chainqueue>=0.0.3a1,<=0.0.3
chainsyncer>=0.0.4a1,<=0.0.4
confini>=0.3.6rc3,<0.5.0
pyxdg~=0.26