1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-26 12:12:11 +01:00

- all necessary auth-information are available in the 'auth_dict' (so there's no need to fool around with the ConfigParser...)

This commit is contained in:
Marcus Hüwe 2008-03-18 13:51:57 +00:00
parent 3c3e961f4e
commit 303e5dcffc

View File

@ -115,17 +115,16 @@ def parse_apisrv_url(scheme, 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
configfile the default user is returned. internal auth_dict the default user is returned.
""" """
import sys import sys
scheme, apisrv = parse_apisrv_url(None, apiurl) scheme, apisrv = parse_apisrv_url(None, apiurl)
cp = get_configParser() if config['auth_dict'].has_key(apisrv):
try: return config['auth_dict'][apisrv]['user']
return cp.get(apisrv, 'user') else:
except ConfigParser.NoSectionError:
print >>sys.stderr, 'section [\'%s\'] does not exist - using default user: \'%s\'' \ print >>sys.stderr, 'section [\'%s\'] does not exist - using default user: \'%s\'' \
% (apisrv, config['user']) % (apisrv, config['user'])
return config['user'] return config['user']
def init_basicauth(config): def init_basicauth(config):
"""initialize urllib2 with the credentials for Basic Authentication""" """initialize urllib2 with the credentials for Basic Authentication"""