def _parse_peer_config_section(self, peer_id, peer_config_section, peer_path): # we do not apply globals when parsing JSON - we just assume # the globals are already in the JSON config # TODO! apply them if parameter _apply_globals is set # and they are not present in the config peer_cfg, peer_parser = parse_peer_default_config( peer_id, peer_path, self.logger) config = peer_config_section if config: self.logger.info( "parsing _custom_ JSON config " "for peer %s. %s ", peer_id, str(config)) json_parser = peer_config_parser.parser("python") json_parser.parse(config, peer_cfg) self.config.set_peer_config(peer_id, peer_cfg) peer_sec = self.load[PEERS][peer_id] if CONFIG_SRCS in peer_sec: for src_name, src_id in peer_sec[CONFIG_SRCS].iteritems(): self.config.set_config_source(peer_id, src_name, src_id) if LAUNCH_DEPS in peer_sec: for dep_name, dep_id in peer_sec[LAUNCH_DEPS].iteritems(): self.config.set_launch_dependency(peer_id, dep_name, dep_id)
def parse_peer_default_config(peer_id, peer_program_path, logger=None, apply_globals=False): # print "Trying to find default config for {0}, path: {1}".format( # peer_id, peer_program_path) peer_parser = peer_config_parser.parser("ini") peer_cfg = peer_config.PeerConfig(peer_id) conf_path = default_config_path(peer_program_path) if apply_globals: for param, value in CONFIG_DEFAULTS.items(): peer_cfg.add_local_param(param, value) if conf_path: with codecs.open(conf_path, "r", "utf8") as f: if logger: logger.info("parsing default config " "for peer %s, %s ", peer_id, conf_path) peer_parser.parse(f, peer_cfg) return peer_cfg, peer_parser
def parse_peer_default_config(peer_id, peer_program_path, logger=None, apply_globals=False): # print "Trying to find default config for {0}, path: {1}".format( # peer_id, peer_program_path) peer_parser = peer_config_parser.parser("ini") peer_cfg = peer_config.PeerConfig(peer_id) conf_path = default_config_path(peer_program_path) if apply_globals: for param, value in CONFIG_DEFAULTS.iteritems(): peer_cfg.add_local_param(param, value) if conf_path: with codecs.open(conf_path, "r", "utf8") as f: if logger: logger.info("parsing default config " "for peer %s, %s ", peer_id, conf_path) peer_parser.parse(f, peer_cfg) return peer_cfg, peer_parser
def _parse_peer_config_section(self, peer_id, peer_config_section, peer_path): # we do not apply globals when parsing JSON - we just assume # the globals are already in the JSON config # TODO! apply them if parameter _apply_globals is set # and they are not present in the config peer_cfg, peer_parser = parse_peer_default_config( peer_id, peer_path, self.logger) config = peer_config_section if config: self.logger.info("parsing _custom_ JSON config " "for peer %s. %s ", peer_id, str(config)) json_parser = peer_config_parser.parser("python") json_parser.parse(config, peer_cfg) self.config.set_peer_config(peer_id, peer_cfg) peer_sec = self.load[PEERS][peer_id] if CONFIG_SRCS in peer_sec: for src_name, src_id in peer_sec[CONFIG_SRCS].items(): self.config.set_config_source(peer_id, src_name, src_id) if LAUNCH_DEPS in peer_sec: for dep_name, dep_id in peer_sec[LAUNCH_DEPS].items(): self.config.set_launch_dependency(peer_id, dep_name, dep_id)