def _update_environment(args): env = [(name, value) for (name,value) in (e.split('=',1) for e in args.env)] for name, value in env: value = ' '.join(value.split()) os.environ[name] = value if args.env_file is not None: env = json.load(args.env_file) os.environ.update(confgen.dict_enc_for_env(env))
def main(): parser = argparse.ArgumentParser(description='confserver.py v%s - Config Generation Tool' % __version__, prog=os.path.basename(sys.argv[0])) parser.add_argument('--config', help='Project configuration settings', required=True) parser.add_argument('--kconfig', help='KConfig file with config item definitions', required=True) parser.add_argument('--sdkconfig-rename', help='File with deprecated Kconfig options', required=False) parser.add_argument('--env', action='append', default=[], help='Environment to set when evaluating the config file', metavar='NAME=VAL') parser.add_argument('--env-file', type=argparse.FileType('r'), help='Optional file to load environment variables from. Contents ' 'should be a JSON object where each key/value pair is a variable.') parser.add_argument('--version', help='Set protocol version to use on initial status', type=int, default=MAX_PROTOCOL_VERSION) args = parser.parse_args() if args.version < MIN_PROTOCOL_VERSION: print("Version %d is older than minimum supported protocol version %d. Client is much older than ESP-IDF version?" % (args.version, MIN_PROTOCOL_VERSION)) if args.version > MAX_PROTOCOL_VERSION: print("Version %d is newer than maximum supported protocol version %d. Client is newer than ESP-IDF version?" % (args.version, MAX_PROTOCOL_VERSION)) try: args.env = [(name,value) for (name,value) in (e.split("=",1) for e in args.env)] except ValueError: print("--env arguments must each contain =. To unset an environment variable, use 'ENV='") sys.exit(1) for name, value in args.env: os.environ[name] = value if args.env_file is not None: env = json.load(args.env_file) os.environ.update(confgen.dict_enc_for_env(env)) run_server(args.kconfig, args.config, args.sdkconfig_rename)