mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-12 23:56:13 +01:00
Factor api_host_options from get_apiurl_usr to access all host
specific options, not just the user.
This commit is contained in:
parent
f7d2a690f5
commit
6ded17ebf0
27
osc/conf.py
27
osc/conf.py
@ -149,18 +149,33 @@ def parse_apisrv_url(scheme, apisrv):
|
|||||||
else:
|
else:
|
||||||
return scheme, apisrv
|
return scheme, apisrv
|
||||||
|
|
||||||
|
def get_apiurl_api_host_options(apiurl):
|
||||||
|
"""
|
||||||
|
Returns all apihost specific options for the given apiurl, None if
|
||||||
|
no such specific optiosn exist.
|
||||||
|
"""
|
||||||
|
# FIXME: in A Better World (tm) there was a config object which
|
||||||
|
# knows this instead of having to extract it from a url where it
|
||||||
|
# had been mingled into before. But this works fine for now.
|
||||||
|
scheme, apisrv = parse_apisrv_url(None, apiurl)
|
||||||
|
return config['api_host_options'][apisrv]
|
||||||
|
|
||||||
def get_apiurl_usr(apiurl):
|
def get_apiurl_usr(apiurl):
|
||||||
"""
|
"""
|
||||||
returns the user for this host - if this host does not exist in the
|
returns the user for this host - if this host does not exist in the
|
||||||
internal api_host_options the default user is returned.
|
internal api_host_options the default user is returned.
|
||||||
"""
|
"""
|
||||||
|
# FIXME: maybe there should be defaults not just for the user but
|
||||||
|
# for all apihost specific options. The ConfigParser class
|
||||||
|
# actually even does this but for some reason we don't use it
|
||||||
|
# (yet?).
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
scheme, apisrv = parse_apisrv_url(None, apiurl)
|
try:
|
||||||
if config['api_host_options'].has_key(apisrv):
|
return get_apiurl_api_host_options(apiurl)['user']
|
||||||
return config['api_host_options'][apisrv]['user']
|
except KeyError:
|
||||||
else:
|
print >>sys.stderr, 'no specific section found in config file for host of [\'%s\'] - using default user: \'%s\'' \
|
||||||
print >>sys.stderr, 'section [\'%s\'] does not exist - using default user: \'%s\'' \
|
% (apiurl, config['user'])
|
||||||
% (apisrv, config['user'])
|
|
||||||
return config['user']
|
return config['user']
|
||||||
|
|
||||||
def init_basicauth(config):
|
def init_basicauth(config):
|
||||||
|
Loading…
Reference in New Issue
Block a user