forked from platypush/platypush
- cfgfile should expand the home directory ~
- Don't fail hard if failed to create logs directory
This commit is contained in:
parent
c8f7eb30aa
commit
12557702dd
1 changed files with 8 additions and 4 deletions
|
@ -83,7 +83,12 @@ class Config(object):
|
||||||
if k == 'filename':
|
if k == 'filename':
|
||||||
logfile = os.path.expanduser(v)
|
logfile = os.path.expanduser(v)
|
||||||
logdir = os.path.dirname(logfile)
|
logdir = os.path.dirname(logfile)
|
||||||
os.makedirs(logdir, exist_ok=True)
|
try:
|
||||||
|
os.makedirs(logdir, exist_ok=True)
|
||||||
|
except Exception as e:
|
||||||
|
print('Unable to create logs directory {}: {}'.format(
|
||||||
|
logdir, str(e)))
|
||||||
|
|
||||||
v = logfile
|
v = logfile
|
||||||
del logging_config['stream']
|
del logging_config['stream']
|
||||||
elif k == 'level':
|
elif k == 'level':
|
||||||
|
@ -111,10 +116,9 @@ class Config(object):
|
||||||
|
|
||||||
|
|
||||||
def _read_config_file(self, cfgfile):
|
def _read_config_file(self, cfgfile):
|
||||||
if not os.path.isabs(cfgfile):
|
cfgfile = os.path.abspath(os.path.expanduser(cfgfile))
|
||||||
cfgfile = os.path.join(os.path.dirname(self._cfgfile), cfgfile)
|
|
||||||
|
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
with open(cfgfile, 'r') as fp:
|
with open(cfgfile, 'r') as fp:
|
||||||
file_config = yaml.safe_load(fp)
|
file_config = yaml.safe_load(fp)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue