def __load_package_config(self, package_dir): self['package'] = {} for full_path, rel_dir, f in _walk_rel_dir(package_dir): if not f.endswith('.yml') and not f.endswith('.yaml'): continue pkg_name = os.path.splitext(f)[0] self['package'][os.path.join(rel_dir, pkg_name)] = load_config(full_path)
def __load_status(self, status_file): try: install_status = load_config(status_file) if not isinstance(install_status, dict): return {} return install_status except: return {}
def _config_from_file(config_file): try: loaded_data = load_config(config_file) if isinstance(loaded_data, dict): return loaded_data else: _logger.warn('Config file is not a dict: {0}'.format(config_file)) _logger.warn('Use empty dict instead') except ConfigError as e: _logger.debug('Load config file failed: {0}'.format(e)) _logger.debug('Use empty dict instead') return dict()
def _load_config_cepcenv(param): main_dir = param['package_path']['main_dir'] for fn in _CEPCENV_PACKAGE_CONFIG_FILENAME: full_path = os.path.join(main_dir, fn) if os.path.isfile(full_path): try: loaded_data = load_config(full_path) if isinstance(loaded_data, dict): return loaded_data except: pass return {} return {}
def __load_package_config(self, package_dir): self['package'] = {} for full_path, rel_dir, f in walk_rel_dir(package_dir): if not f.endswith('.yml') and not f.endswith('.yaml'): continue pkg_name = os.path.splitext(f)[0] try: self['package'][os.path.join( rel_dir, pkg_name)] = load_config(full_path) except ConfigError as e: _logger.warning( 'Fail to load package config file "{0}": {1}'.format( full_path, e))
def __load_config(self, config_scenario, config_release_path): config_dir = os.path.join(config_release_path['config_dir']) if not os.path.isdir(config_dir): raise ConfigReleaseError('Release version "{0}" not found'.format( config_scenario['version'])) for k in _AVAILABLE_RELEASE_CONFIG: config_file = os.path.join(config_dir, k + '.yml') try: self[k] = load_config(config_file) except ConfigError as e: _logger.warn('Fail to load config file "{0}": {1}'.format( config_file, e)) package_dir = os.path.join(config_dir, 'package') self.__load_package_config(package_dir)
def config_from_file(config_file): if not os.path.isfile(config_file): return {} try: loaded_data = load_config(config_file) if isinstance(loaded_data, dict): return loaded_data if loaded_data is not None: _logger.warning( 'Config file is not a dict, use empty dict instead: {0}'. format(config_file)) except ConfigError as e: _logger.warning( 'Load config file failed, use empty dict instead: {0}'.format( config_file)) return {}