code refatoring and cache fixes
@@ -575,24 +575,29 @@ class ConfigurationManager(ConfigurationManagerSingleton):
for k, v in cat.items():
if v['type'] == 'script':
try:
+ cat[k]["value"] = ""
+ cat[k]["file"] = ""
+ if v['value'] is not None and v['value'] != "":
cat[k]["value"] = binascii.unhexlify(v['value'].encode('utf-8')).decode("utf-8")
except Exception as e:
_logger.warning(
"Got an issue while decoding config item: {} | {}".format(cat[k], str(e)))
pass
- if self._cacheManager.cache[category_name]['value'][k]:
- self._cacheManager.cache[category_name]['value'][k]['value'] = v['value']
-
script_dir = _FOGLAMP_DATA + '/scripts/' if _FOGLAMP_DATA else _FOGLAMP_ROOT + "/data/scripts/"
prefix_file_name = category_name.lower() + "_" + k.lower() + "_"
+
if not os.path.exists(script_dir):
os.makedirs(script_dir)
+ else:
_all_files = os.listdir(script_dir)
for name in _all_files:
if name.startswith(prefix_file_name) and name.endswith('.py'):
cat[k]["file"] = script_dir + name
+ if self._cacheManager.cache[category_name]['value'][k]:
+ self._cacheManager.cache[category_name]['value'][k]['value'] = cat[k]["value"]
+ self._cacheManager.cache[category_name]['value'][k]['file'] = cat[k]["file"]
return cat
except:
_logger.exception(
