def save(): # don't save if the configuration hasn't been loaded if _KEY_VERSION not in _configuration: return dirname = _os.path.dirname(_file_path) if not _path.isdir(dirname): try: _os.makedirs(dirname) except Exception: _log.error('failed to create %s', dirname) return False _cleanup(_configuration) try: with open(_file_path, 'w') as config_file: _json_save(_configuration, config_file, skipkeys=True, indent=2, sort_keys=True) if _log.isEnabledFor(_INFO): _log.info('saved %s to %s', _configuration, _file_path) return True except Exception as e: _log.error('failed to save to %s: %s', _file_path, e)
def save(): # don't save if the configuration hasn't been loaded if _KEY_VERSION not in _configuration: return dirname = _os.path.dirname(_file_path) if not _path.isdir(dirname): try: _os.makedirs(dirname) except: _log.error("failed to create %s", dirname) return False _cleanup(_configuration) try: with open(_file_path, 'w') as config_file: _json_save(_configuration, config_file, skipkeys=True, indent=2, sort_keys=True) if _log.isEnabledFor(_INFO): _log.info("saved %s to %s", _configuration, _file_path) return True except: _log.error("failed to save to %s", _file_path)