From b6069c6946a2381dafbd58be0cfadc610f7cbbbd Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Tue, 21 Feb 2012 10:51:34 +0100 Subject: [PATCH] automatic fallback to maintenance request alternative would be to raise exception and have calling code implement the fallback --- osc/core.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/osc/core.py b/osc/core.py index 9d1a5a1e..3f8f0943 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3495,18 +3495,17 @@ def create_submit_request(apiurl, r = root.get('id') except urllib2.HTTPError, e: if e.headers.get('X-Opensuse-Errorcode') == "submit_request_rejected": - print "This project is just for releasing maintenance updates. Do you want to create a maintenance incident request instead? [y/n]" - if sys.stdin.read(1) == "y": - xpath = 'maintenance/maintains/@project = \'%s\'' % dst_project - res = search(apiurl, project_id=xpath) - root = res['project_id'] - project = root.find('project') - if project is None: - sys.exit('No maintenance project defined for target project on server.') - tproject = project.get('name') - r = create_maintenance_request(apiurl, src_project, [src_package], tproject, dst_project, src_update, message) + print "Project does not accept submit request, trying fallback to maintenance request ..." + xpath = 'maintenance/maintains/@project = \'%s\'' % dst_project + res = search(apiurl, project_id=xpath) + root = res['project_id'] + project = root.find('project') + if project is None: + raise oscerr.APIError("Server did not define a maintenance project, can't submit.") + tproject = project.get('name') + r = create_maintenance_request(apiurl, src_project, [src_package], tproject, dst_project, src_update, message) else: - raise + raise return r