1
0
mirror of https://github.com/gryf/boxpy.git synced 2025-12-19 13:37:58 +01:00

Fixed case when there is no user data provided.

This commit is contained in:
2021-07-05 12:08:32 +02:00
parent be91f6b827
commit e5173c707d

18
box.py
View File

@@ -455,17 +455,23 @@ class Config:
return ''.join(x for x in name if x.isalnum() or x == '-') return ''.join(x for x in name if x.isalnum() or x == '-')
def _combine_cc(self): def _combine_cc(self):
"""
Read user custom cloud config (if present) and update config dict
"""
if not self.user_data:
LOG.debug("No user data has been provided")
return
if not os.path.exists(self.user_data):
LOG.warning("Provided user_data: '%s' doesn't exists",
self.user_data)
return
conf = yaml.safe_load(USER_DATA) conf = yaml.safe_load(USER_DATA)
# read user custom cloud config (if present) and update config dict
if self.user_data:
if os.path.exists(self.user_data):
with open(self.user_data) as fobj: with open(self.user_data) as fobj:
custom_conf = yaml.safe_load(fobj) custom_conf = yaml.safe_load(fobj)
conf = self._update(conf, custom_conf) conf = self._update(conf, custom_conf)
else:
LOG.warning("Provided user_data: '%s' doesn't exists",
self.user_data)
# update the attributes with data from read user cloud config # update the attributes with data from read user cloud config
for key, val in conf.get('boxpy_data', {}).items(): for key, val in conf.get('boxpy_data', {}).items():