def run(self, args): def warn_invalid(msg): print("the configuration is invalid, the argument parser got the" " following error:") print(msg) sandbox = SandBox() sandbox.root_dir = args.sandbox try: cmd_line = sandbox.get_configuration()["cmd_line"] except (TypeError, KeyError) as msg: warn_invalid(msg) return argument_parser = main(get_argument_parser=True) def error(message): raise SandBoxError(message) argument_parser.error = error try: args = argument_parser.parse_args(cmd_line[2:]) except SandBoxError as msg: warn_invalid(msg) return for k, v in vars(args).items(): if k in self.keys: print("%s = %s" % (k, v))
def run(self, args): sandbox = SandBox() sandbox.root_dir = args.sandbox cmd_line = sandbox.get_configuration()['cmd_line'] args_namespace = argparse.Namespace() args_namespace.python = cmd_line[0] argument_parser = main(get_argument_parser=True) def error(message): raise SandBoxError(message) argument_parser.error = error try: args = argument_parser.parse_args(cmd_line[2:]) except SandBoxError as msg: print('the configuration is invalid, the argument parser got the' 'following error:') print(msg) for k, v in vars(args).iteritems(): if k in self.keys: print('%s = %s' % (k, v))