mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-05 10:58:07 +01:00
- fixed #521895 ('osc vc crashes'): only use and store proper apiurls this means no trailing slashes etc.
This commit is contained in:
parent
d2dee3c525
commit
9f8c7398b4
@ -157,7 +157,8 @@ def parse_apisrv_url(scheme, apisrv):
|
|||||||
if apisrv.startswith('http://') or apisrv.startswith('https://'):
|
if apisrv.startswith('http://') or apisrv.startswith('https://'):
|
||||||
return urlparse.urlsplit(apisrv)[0:2]
|
return urlparse.urlsplit(apisrv)[0:2]
|
||||||
elif scheme != None:
|
elif scheme != None:
|
||||||
return scheme, apisrv
|
# the split/join is needed to get a proper url (e.g. without a trailing slash)
|
||||||
|
return urlparse.urlsplit(urljoin(scheme, apisrv))[0:2]
|
||||||
else:
|
else:
|
||||||
from urllib2 import URLError
|
from urllib2 import URLError
|
||||||
msg = 'invalid apiurl \'%s\' (specify the protocol (http:// or https://))' % apisrv
|
msg = 'invalid apiurl \'%s\' (specify the protocol (http:// or https://))' % apisrv
|
||||||
@ -362,6 +363,7 @@ def get_config(override_conffile = None,
|
|||||||
raise oscerr.ConfigError(msg, conffile)
|
raise oscerr.ConfigError(msg, conffile)
|
||||||
|
|
||||||
config = dict(cp.items('general', raw=1))
|
config = dict(cp.items('general', raw=1))
|
||||||
|
config['apiurl'] = urljoin(*parse_apisrv_url(None, config['apiurl']))
|
||||||
|
|
||||||
# backward compatibility
|
# backward compatibility
|
||||||
if config.has_key('apisrv'):
|
if config.has_key('apisrv'):
|
||||||
|
@ -3283,10 +3283,12 @@ def store_read_package(dir):
|
|||||||
def store_read_apiurl(dir):
|
def store_read_apiurl(dir):
|
||||||
fname = os.path.join(dir, store, '_apiurl')
|
fname = os.path.join(dir, store, '_apiurl')
|
||||||
try:
|
try:
|
||||||
apiurl = open(fname).readlines()[0].strip()
|
url = open(fname).readlines()[0].strip()
|
||||||
|
# this is needed to get a proper apiurl
|
||||||
|
# (former osc versions may stored an apiurl with a trailing slash etc.)
|
||||||
|
apiurl = conf.urljoin(*conf.parse_apisrv_url(None, url))
|
||||||
except:
|
except:
|
||||||
apiurl = conf.config['apiurl']
|
apiurl = conf.config['apiurl']
|
||||||
#store_write_apiurl(dir, apiurl)
|
|
||||||
return apiurl
|
return apiurl
|
||||||
|
|
||||||
def store_write_string(dir, file, string):
|
def store_write_string(dir, file, string):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user