In your application configure method, do something like:

def configure(self, configuration):
        for param in configuration['arguments']:
            if param.find('=') != -1:
key, value = param[:param.find('=')], param[param.find('=')+1:]
            else:
                key, value = param, ''

            if key == 'foo': self.foo = value
            elif key == 'bar': self.bar = value
            else:
raise RuntimeError('Unsupported configuration option: ' + param)

Then you can call your app as follows

./nox_core myapp=foo=1,bar=2



On Jan 11, 2009, at 10:43 PM, Brandon Heller wrote:

Where/what files should I look at for examples of the component model?

I guess I don't absolutely need cmd-line options - could build my test runner inside nox, rather than calling it a bunch of times.

Thanks,
Brandon


On Sun, Jan 11, 2009 at 10:40 PM, Martin Casado <[email protected]> wrote: This is because we embed python and don't use the internal python c api to pass the the command line args to python. Our rational for this was that apps should get their args through the component model (in config) rather than have to parse to original command line. However, passing the args to python is relatively simple if it something you'd fine useful.

.martin


On Jan 11, 2009, at 10:32 PM, Brandon Heller wrote:

Any idea why I get this error?

brand...@mvm-of1:~/nox/noxcore/build/src$ ./nox_core -i ptcp:6633 static_setup 1 2 3
NOX 0.4.0~core~beta (nox_core), compiled Jan  9 2009 15:09:46
Compiled with OpenFlow 0x97 (exp)
00001|nox|ERR:Cannot change the state of 'static_setup' to INSTALLED:
'static_setup' ran into an error:
cannot construct a Python module 'nox.coreapps.static_setup.static_setup': Traceback (most recent call last): File "./nox/coreapps/static_setup/static_setup.py", line 171, in instance
       return StaticSetup(ctxt)
File "./nox/coreapps/static_setup/static_setup.py", line 91, in __init__
       print(sys.argv)
   AttributeError: 'module' object has no attribute 'argv'

I've imported sys and am trying to print sys.argv to see the command line args.

Thanks,
Brandon
_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org



_______________________________________________
nox-dev mailing list
[email protected]
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to