Re: passing multiple string to a command line option

Discussion in 'Python' started by Miki Tebeka, Oct 6, 2011.

  1. Miki Tebeka

    Miki Tebeka Guest

    As far as I see, the problem is not in the command line but in system.cpu.workload = process call tree.

    Without seeing the code of SimObject and params I can't tell much more.
     
    Miki Tebeka, Oct 6, 2011
    #1
    1. Advertising

  2. >Without seeing the code of SimObject and params I can't tell much more.

    >    File "/home/mahmood/gem5/src/python/m5/params.py", line 159, inconvert
    >      return self.ptype(value)


    following is part of params.py and I marked line 159.
    I didn't wrote this code so changing this may cause problem with other files.

    If there is an alternative for doing such thing "passing multiple strings to command line option", it is much better.

     # Regular parameter description.
    class ParamDesc(object):
        file_ext = 'ptype'

        def __init__(self, ptype_str, ptype, *args, **kwargs):
            self.ptype_str = ptype_str
            # remember ptype only if it is provided
            if ptype != None:
                self.ptype = ptype

            if args:
                if len(args) == 1:
                    self.desc = args[0]
                elif len(args) == 2:
                    self.default = args[0]
                    self.desc = args[1]
                else:
                    raise TypeError, 'too manyarguments'

            if kwargs.has_key('desc'):
                assert(not hasattr(self, 'desc'))
                self.desc = kwargs['desc']
                del kwargs['desc']

            if kwargs.has_key('default'):
                assert(not hasattr(self, 'default'))
                self.default = kwargs['default']
                del kwargs['default']

            if kwargs:
                raise TypeError, 'extra unknown kwargs %s' % kwargs

            ifnot hasattr(self, 'desc'):
                raise TypeError, 'desc attribute missing'

        def __getattr__(self, attr):
            if attr == 'ptype':
                ptype = SimObject.allClasses[self.ptype_str]
                assert isSimObjectClass(ptype)
                self.ptype = ptype
                return ptype

            raise AttributeError, "'%s' object has no attribute '%s'" % \
                  (type(self)..__name__, attr)

        def convert(self, value):
            if isinstance(value, proxy.BaseProxy):
                value.set_param_desc(self)
                return value
            if not hasattr(self, 'ptype') and isNullPointer(value):
                # deferred evaluation of SimObject; continue to defer if
                # we're just assigning a null pointer
                return value
            if isinstance(value, self.ptype):
                return value
            if isNullPointer(value) and isSimObjectClass(self.ptype):
                return value
            return self.ptype(value)             # LINE 159

        def cxx_predecls(self, code):
            self.ptype.cxx_predecls(code)

        def swig_predecls(self, code):
            self.ptype.swig_predecls(code)

        def cxx_decl(self, code):
            code('${{self.ptype.cxx_type}} ${{self.name}};')



    // Naderan *Mahmood;


    ----- Original Message -----
    From: Miki Tebeka <>
    To:
    Cc: python mailing list <>; Mahmood Naderan <>
    Sent: Thursday, October 6, 2011 9:55 PM
    Subject: Re: passing multiple string to a command line option

    As far as I see, the problem is not in the command line but in    system.cpu.workload = process call tree.

    Without seeing the code of SimObject and params I can't tell much more.
     
    Mahmood Naderan, Oct 6, 2011
    #2
    1. Advertising

  3. Miki Tebeka

    Miki Tebeka Guest

    Seems like self.ptype is a type that has __init__ with no arguments (other than self).

    You can add "print type(self.ptype)" as first line of "convert" to see what type it is (or place a breakpoint there).
     
    Miki Tebeka, Oct 7, 2011
    #3
  4. Miki Tebeka

    Miki Tebeka Guest

    Seems like self.ptype is a type that has __init__ with no arguments (other than self).

    You can add "print type(self.ptype)" as first line of "convert" to see what type it is (or place a breakpoint there).
     
    Miki Tebeka, Oct 7, 2011
    #4
  5. That print command generated a lot of errors. Since that error in my first post is related to the python code in simulator, I emailed them and consulted for help. Seems that it is going to be fixed....

    Thanks for your kindness :)

     
    // Naderan *Mahmood;


    ----- Original Message -----
    From: Miki Tebeka <>
    To:
    Cc: python mailing list <>; Miki Tebeka <>; Mahmood Naderan <>
    Sent: Friday, October 7, 2011 5:41 PM
    Subject: Re: passing multiple string to a command line option

    Seems like self.ptype is a type that has __init__ with no arguments (other than self).

    You can add "print type(self.ptype)" as first line of "convert" to see what type it is (or place a breakpoint there).
     
    Mahmood Naderan, Oct 7, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newsgroup - Ann

    simple question about command line option

    Newsgroup - Ann, Aug 6, 2003, in forum: C++
    Replies:
    2
    Views:
    380
    E. Robert Tisdale
    Aug 6, 2003
  2. SenthilVel
    Replies:
    1
    Views:
    3,522
    dd_fruend
    Aug 4, 2006
  3. Christopher Wood

    PYTHONSTARTUP and the -i command line option

    Christopher Wood, Jun 2, 2005, in forum: Python
    Replies:
    2
    Views:
    2,620
    Simon Percivall
    Jun 3, 2005
  4. Christoph Zwerschke

    Command line option -Q (floor division)

    Christoph Zwerschke, Mar 23, 2006, in forum: Python
    Replies:
    2
    Views:
    302
    Georg Brandl
    Mar 29, 2006
  5. Anthony Roy
    Replies:
    7
    Views:
    223
    A. Sinan Unur
    Mar 4, 2005
Loading...

Share This Page