I think the sub-parser feature of argparser might serve our purpose, but argparser is available starting version 2.7 of python.

--
Nilay


On Tue, 5 Jul 2011, Gabe Black wrote:

This seems like a fairly nasty hack, although I don't have a better
suggestion off hand. Hopefully one of the python gurus will comment.

Gabe

On 07/05/11 14:12, Lisa Hsu wrote:
Ok, thoughts on this quick fix that is not particularly pretty?

All ruby-specific options must follow a -- in the command line, like:

m5.opt configs/example/se.py --ruby -- --topology blah --foo bar.

In which case this patch to se.py will do it:

diff --git a/configs/example/se.py b/configs/example/se.py
--- a/configs/example/se.py
+++ b/configs/example/se.py
@@ -78,7 +78,7 @@

 if options.ruby:
     Ruby.define_options(parser)
-    (options, args) = parser.parse_args()
+    (options, args) = parser.parse_args(args)

 if args:
     print "Error: script doesn't take any positional arguments"

Other possible solutions will be more drastic, I think.  Does anyone have
any better ideas?

Lisa



On Tue, Jul 5, 2011 at 1:26 PM, Lisa Hsu <[email protected]> wrote:

If I recall, part of the reason why Ruby.define_parser(parser) wasn't done
by default was because there were some conflicts with option names or
something like that when running in M5 classic memory system mode. But I
don't recall exactly.

I've asked on the users list to find the exact command line to see if I can
replicate the problem.  Thanks for bringing this up Nilay.

Lisa


 On Mon, Jul 4, 2011 at 11:00 AM, Nilay Vaish <[email protected]> wrote:

As pointed out on the users list, the script se.py is broken. The
following changes would fix the script for the time being, but I think we
need some way to specify dependence between options. Does anyone have any
idea about this? As I understand, optparse does not support dependency
between options.

diff --git a/configs/example/se.py b/configs/example/se.py
--- a/configs/example/se.py
+++ b/configs/example/se.py
@@ -71,15 +71,12 @@
 parser.add_option("--output", default="", help="Redirect stdout to a
file.")
 parser.add_option("--errout", default="", help="Redirect stderr to a
file.")
 parser.add_option("--ruby", action="store_true")
+Ruby.define_options(parser)

 execfile(os.path.join(config_**root, "common", "Options.py"))

 (options, args) = parser.parse_args()

-if options.ruby:
-    Ruby.define_options(parser)
-    (options, args) = parser.parse_args()
-
 if args:
    print "Error: script doesn't take any positional arguments"
    sys.exit(1)


--
Nilay
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to