From 4a0df19660830f69f7e761486b7bdf50b06a53f1 Mon Sep 17 00:00:00 2001 From: Michal Vyskocil Date: Wed, 18 Nov 2009 15:03:49 +0000 Subject: [PATCH] Make read of email adress from oscrc more robust Fix possible KeyError when mismatch of apiurl with or without ending slash. --- osc/commandline.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 3757cd33..3b5fd087 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4288,8 +4288,13 @@ Please submit there instead, or use --nodevelproject to force direct submission. user = conf.get_apiurl_usr(apiurl) - if conf.config['api_host_options'][apiurl].has_key('email'): - os.environ['mailaddr'] = conf.config['api_host_options'][apiurl]['email'] + # work with all combinations of URL with or withouth the ending slash + apiurl2 = apiurl[:-1] if apiurl[-1] == '/' else ("%s/" % apiurl) + host_opts = conf.config['api_host_options'].get(apiurl) or \ + conf.config['api_host_options'].get(apiurl2) + + if host_opts and host_opts.has_key('email'): + os.environ['mailaddr'] = host_opts['email'] else: try: os.environ['mailaddr'] = get_user_data(apiurl, user, 'email')[0]