Archived
This forum has been archived. Please start a new discussion on GitHub.
Python and parseCommandLineOptions
I am using IcePy-3.1.1 and I am trying to create an application that connects via a Foo.Proxy, and I want to be able to set the proxy string on the command line and have it override the config file. I tried to translate the C++ code from the "Parsing Properties" section of the manual into python, but ran into some problems.
One problem is that parseCommandLineOptions() does not return the remaining args.
The other problem is that the initialization data seems to be ignored. Here is my code:
Thanks in advance for your help.
-Edward
One problem is that parseCommandLineOptions() does not return the remaining args.
The other problem is that the initialization data seems to be ignored. Here is my code:
# config file Foo.Proxy = foo:tcp -p 12345
#foo.py import Ice,sys props = Ice.createProperties() args = props.parseCommandLineOptions("Foo", sys.argv) print "Command line: ", props.getPropertiesForPrefix("Foo") id = Ice.InitializationData() id.props = props ic = Ice.initialize(data=id) properties = ic.getProperties() proxy = properties.getProperty("Foo.Proxy") print "Proxy is ", proxyWhen I run it like this:
I get this output:C:\>foo.py --Foo.Proxy="hello"
So the command line values are not making it into the communicator properties.Command line: {'Foo.Proxy': 'hello'}
Proxy is foo:tcp -p 12345
Thanks in advance for your help.
-Edward
0
Comments
-
Hi,Edward Bishop wrote: »One problem is that parseCommandLineOptions() does not return the remaining args.The other problem is that the initialization data seems to be ignored.
id.properties = props
Take care,
- Mark0 -
Yep, that worked.
Thanks Mark!0