[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-tools] [PATCH 2/2] Cleanup bogus argument handling
The attached patch makes the argument handling within subcommand handlers more consistent. Now, subcommands don't modify the args list they're given, so that error handling can be the same for all commands. Signed-off-by: Dan Smith <danms@xxxxxxxxxx> diff -r a184de8302e3 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Mon Aug 29 17:26:24 2005 +++ b/tools/python/xen/xm/main.py Mon Aug 29 10:57:15 2005 @@ -173,8 +173,7 @@ from xen.xm import create # ugly hack because the opt parser apparently wants # the subcommand name just to throw it away! - args.insert(0,"bogus") - create.main(args) + create.main(["bogus"] + args) def xm_save(args): arg_check(args,2,"save") @@ -202,8 +201,7 @@ from xen.xm import migrate # ugly hack because the opt parser apparently wants # the subcommand name just to throw it away! - args.insert(0,"bogus") - migrate.main(args) + migrate.main(["bogus"] + args) def xm_list(args): use_long = 0 @@ -290,8 +288,7 @@ vcpuinfo) def xm_vcpu_list(args): - args.insert(0,"-v") - xm_list(args) + xm_list(["-v"] + args) def xm_destroy(args): arg_check(args,1,"destroy") @@ -299,33 +296,28 @@ from xen.xm import destroy # ugly hack because the opt parser apparently wants # the subcommand name just to throw it away! - args.insert(0,"bogus") - destroy.main(args) + destroy.main(["bogus"] + args) def xm_reboot(args): arg_check(args,1,"reboot") + from xen.xm import shutdown # ugly hack because the opt parser apparently wants # the subcommand name just to throw it away! - args.insert(0,"bogus") - args.insert(2,"-R") - from xen.xm import shutdown - shutdown.main(args) + shutdown.main(["bogus", "-R"] + args) def xm_shutdown(args): arg_check(args,1,"shutdown") + from xen.xm import shutdown # ugly hack because the opt parser apparently wants # the subcommand name just to throw it away! - args.insert(0,"bogus") - from xen.xm import shutdown - shutdown.main(args) + shutdown.main(["bogus"] + args) def xm_sysrq(args): from xen.xm import sysrq # ugly hack because the opt parser apparently wants # the subcommand name just to throw it away! - args.insert(0,"bogus") - sysrq.main(args) + sysrq.main(["bogus"] + args) def xm_pause(args): arg_check(args, 1, "pause") @@ -480,10 +472,11 @@ fn=set_true, default=0, use="Clear the contents of the Xen message buffer.") # Work around for gopts - args.insert(0,"bogus") - gopts.parse(args) - if not (1 <= len(args) <= 2): - err('Invalid arguments: ' + str(args)) + myargs = args + myargs.insert(0, "bogus") + gopts.parse(myargs) + if not (1 <= len(myargs) <= 2): + err('Invalid arguments: ' + str(myargs)) from xen.xend.XendClient import server if not gopts.vals.clear: @@ -730,8 +723,6 @@ sys.exit(1) except XendError, ex: if len(args) > 0: - if args[0] == "bogus": - args.remove("bogus") handle_xend_error(argv[1], args[0], ex) else: print "Unexpected error:", sys.exc_info()[0] -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@xxxxxxxxxx _______________________________________________ Xen-tools mailing list Xen-tools@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-tools
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |