def setup_config(args): import os from iris.config import Configuration from iris.utils.sockets import guess_external_ip config = Configuration({ 'container': {} }) if 'IRIS_NODE_CONFIG' in os.environ: config.load_file(os.environ['IRIS_NODE_CONFIG'], sections=['registry', 'event_system', 'plugins']) config_file = args.get('--config') or '.iris.yml' config.load_file(config_file) config.source = config_file config.setdefault('container.ip', os.environ.get('IRIS_NODE_IP', '127.0.0.1')) ip = args.get('--ip') if args.get('--guess-external-ip'): if ip: print('cannot combine --ip and --guess-external-ip') return 1 ip = guess_external_ip() if ip: config.set('container.ip', ip) port = args.get('--port') if port: config.set('container.port', port) return config
def setup_config(args): import os from iris.config import Configuration from iris.utils.sockets import guess_external_ip config = Configuration({'container': {}}) if 'IRIS_NODE_CONFIG' in os.environ: config.load_file(os.environ['IRIS_NODE_CONFIG'], sections=['registry', 'event_system', 'plugins']) config_file = args.get('--config') or '.iris.yml' config.load_file(config_file) config.source = config_file config.setdefault('container.ip', os.environ.get('IRIS_NODE_IP', '127.0.0.1')) ip = args.get('--ip') if args.get('--guess-external-ip'): if ip: print('cannot combine --ip and --guess-external-ip') return 1 ip = guess_external_ip() if ip: config.set('container.ip', ip) port = args.get('--port') if port: config.set('container.port', port) return config
def setup_config(args): import os from iris.config import Configuration from iris.utils.sockets import guess_external_ip config = Configuration({"container": {}}) if "IRIS_NODE_CONFIG" in os.environ: config.load_file(os.environ["IRIS_NODE_CONFIG"], sections=["registry", "event_system", "plugins"]) config_file = args.get("--config") or ".iris.yml" config.load_file(config_file) config.source = config_file config.setdefault("container.ip", os.environ.get("IRIS_NODE_IP", "127.0.0.1")) ip = args.get("--ip") if args.get("--guess-external-ip"): if ip: print("cannot combine --ip and --guess-external-ip") return 1 ip = guess_external_ip() if ip: config.set("container.ip", ip) port = args.get("--port") if port: config.set("container.port", port) return config
def test_setdefault_without_previous_value(self): config = Configuration({ 'nested': {} }) config.setdefault('foo', 1) self.assertEqual(config.get('foo'), 1) config.setdefault('nested.foo', 2) self.assertEqual(config.get('nested.foo'), 2)