conf¶
This is the osc conf module. It handles the configuration of osc
basic structures¶
Read osc configuration and store it in a dictionary
This module reads and parses oscrc. The resulting configuration is stored for later usage in a dictionary named ‘config’. The oscrc is kept mode 0600, so that it is not publically readable. This gives no real security for storing passwords. If in doubt, use your favourite keyring. Password is stored on ~/.config/osc/oscrc as bz2 compressed and base64 encoded, so that is fairly large and not to be recognized or remembered easily by an occasional spectator.
If information is missing, it asks the user questions.
After reading the config, urllib2 is initialized.
The configuration dictionary could look like this:
- {‘apisrv’: ‘https://api.opensuse.org/’,
‘user’: ‘joe’, ‘api_host_options’: {‘api.opensuse.org’: {‘user’: ‘joe’, ‘pass’: ‘secret’},
- ‘apitest.opensuse.org’: {‘user’: ‘joe’, ‘pass’: ‘secret’,
- ‘http_headers’:((‘Host’,’api.suse.de’),
- (‘User’,’faye’))},
‘foo.opensuse.org’: {‘user’: ‘foo’, ‘pass’: ‘foo’}},
‘build-cmd’: ‘/usr/bin/build’, ‘build-root’: ‘/abuild/oscbuild-%(repo)s-%(arch)s’, ‘packagecachedir’: ‘/var/cache/osbuild’, ‘su-wrapper’: ‘sudo’, }
-
class
osc.conf.APIHostOptionsEntry¶
-
osc.conf.add_section(filename, url, user, passwd, creds_mgr_descriptor=None, allow_http=None)¶ Add a section to config file for new api url.
-
osc.conf.apply_option_types(config, conffile='')¶ Return a copy of config dictionary with values converted to their expected types according to the enumerated option types (_boolean_opts, _integer_opts).
-
osc.conf.config_set_option(section, opt, val=None, delete=False, update=True, creds_mgr_descr=None, **kwargs)¶ Sets a config option. If val is not specified the current/default value is returned. If val is specified, opt is set to val and the new value is returned. If an option was modified get_config is called with
**kwargsunless update is set toFalse(override_conffiledefaults toconfig['conffile']). If val is not specified and delete isTruethen the option is removed from the config/reset to the default value.
-
osc.conf.extract_known_apiurl(url)¶ Return longest prefix of given url that is known apiurl, None if there is no known apiurl that is prefix of given url.
-
osc.conf.get_apiurl_api_host_options(apiurl)¶ Returns all apihost specific options for the given apiurl,
Noneif no such specific options exist.
-
osc.conf.get_apiurl_usr(apiurl)¶ returns the user for this host - if this host does not exist in the internal api_host_options the default user is returned.
-
osc.conf.get_config(override_conffile=None, override_apiurl=None, override_debug=None, override_http_debug=None, override_http_full_debug=None, override_traceback=None, override_post_mortem=None, override_no_keyring=None, override_verbose=None, overrides=None)¶ do the actual work (see module documentation)
-
osc.conf.get_configParser(conffile=None, force_read=False)¶ Returns an ConfigParser() object. After its first invocation the ConfigParser object is stored in a method attribute and this attribute is returned unless you pass force_read=True.
-
osc.conf.is_known_apiurl(url)¶ returns
Trueif url is a known apiurl
-
osc.conf.write_config(fname, cp)¶ write new configfile in a safe way
-
osc.conf.write_initial_config(conffile, entries, custom_template='', creds_mgr_descriptor=None)¶ write osc’s intial configuration file. entries is a dict which contains values for the config file (e.g. { ‘user’ : ‘username’, ‘pass’ : ‘password’ } ). custom_template is an optional configuration template.