From 917064a1e6ffa66a6c203516509657d711bf2a02 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Mon, 17 Mar 2014 17:05:38 +0200 Subject: Fixed crash when rejecting broken package To obtain revision create_sr code queries source package and crashes when source is broken with ObsError: cat't query source from project : HTTP Error 400: service gbs failed This makes it impossible to reject broken submissions. This change catches exeption and tries to avoid querying the source by providing revision 1 to create_sr API. As for rejecting it doesn't matter much which revision to reject it should be safe. Fixes: #1687 Change-Id: I21b9dda32686c94bfb8e81201424b3e7e7f128b5 Signed-off-by: Ed Bartosh Reviewed-on: https://otctools.jf.intel.com/review/10674 Tested-by: OTC Tools Tester --- repa/common.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/repa/common.py b/repa/common.py index b161077..02ec146 100644 --- a/repa/common.py +++ b/repa/common.py @@ -91,8 +91,20 @@ def accept_or_reject(obs, submission, state, target, comment=''): for pkg in obs.get_source_packages(project): # Create SR - reqid = obs.create_sr(project, pkg, str(meta['obs_target_prj']), - message=str(message)) + try: + reqid = obs.create_sr(project, pkg, str(meta['obs_target_prj']), + message=str(message)) + except RepaException: + if state == 'declined': + # Broken sources. Try to avoid queryng source by + # providing revision 1. It always exists and it doesn't + # matter which revision to reject. + reqid = obs.create_sr(project, pkg, + str(meta['obs_target_prj']), + message=str(message), revision=1) + else: + raise + print 'package %s: created SR %s' % (pkg, reqid) # and immediately set its state -- cgit v1.2.3