Mailinglist Archive: opensuse-buildservice (250 mails)

< Previous Next >
Re: [opensuse-buildservice] [osc] question using osc in python
  • From: Marcus Hüwe <suse-tux@xxxxxx>
  • Date: Tue, 7 Apr 2009 12:22:40 +0200
  • Message-id: <20090407102240.GA3492@xxxxxxxxxxxxxxxxxxx>
On 2009-04-07 08:15:47 +0200, Jan-Simon Möller wrote:
If I create a new api definition in conf.config - how can I write it to disk ?

I start with:

from osc import conf, core


<now inserting new definition to conf.config['api_host_options'])

conf.config['api_host_options'][""]["http_headers";] = []
conf.config['api_host_options'][""]["user";] = "spock"
conf.config['api_host_options'][""]["pass";] = "ncc1701d"

Probably I can't see the wood for the trees - how can i write stuff to .oscrc
now ?

You have to do it via a OscConfigParser instance:

cp = conf.get_configParser()
cp.set('', 'user', 'foo')
cp.set('', 'password', 'bar')

# fp is file like object, comments=True means that your comments in ~/.oscrc
# be preserved
cp.write(fp, comments=True)

# finally rerun conf.get_config(*args)

While writing this I realized that this procedure is quite ugly. So either
we add an add_user(section, user, pass) method to the conf module or we
might turn the whole config stuff into an object which does all the magic
automatically (e.g. confobj['someoption'] = 'val1' stores it in the ~/.oscrc

To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups