From 10a362388f3164e1aa29cbe62ae45a34a5809643 Mon Sep 17 00:00:00 2001 From: Liu jue Date: Thu, 8 May 2014 17:14:32 +0800 Subject: [PATCH] Fix the bug : reject/request event without complete description When someone reject/request a submit from obs by man made , he/she may do it without a complete description . So we can not get the "source project" from description , and it will cause a bug . So we use "source project" field in event directly . Change-Id: I9ab929760be146816e849f234433ee3f4621b4c5 Fixes: #1841 --- job_pre_release_obs.py | 45 ++++++++++----------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/job_pre_release_obs.py b/job_pre_release_obs.py index 1b3a8f4..d6b6a2b 100755 --- a/job_pre_release_obs.py +++ b/job_pre_release_obs.py @@ -183,42 +183,17 @@ def project_cleanup(backenddb, build, base_path, base_url, event_dict): """ request(SR) end of life, this founction should be called to delete the prerelease project """ - # Event is from project delted - if "project" in event_dict: - prerelease_project_name = event_dict.get("project") + # Event is from project delted or from request accepted/rejected + prerelease_project_name = event_dict.get("project") or\ + event_dict.get("sourceproject") - try: - target_project, time_stamp = \ - get_info_from_prerelease_project_name(prerelease_project_name) - except ValueError: - print "Can not get prerelease project info from project name," \ - "take no action to %s" % prerelease_project_name - return 0 - - else: # Event is from request accepted/rejected - target_project = event_dict.get("targetproject") - description = event_dict.get("description") - - # Get git tag name - git_tag = '' - - if description: - for line in description.split('\n'): - try: - key, value = line.split(':', 1) - if key == 'Tag': - git_tag = value - break - except ValueError: - pass - try: - time_stamp = git_tag.split('/')[2] - except IndexError, err: - raise LocalError("Parser tag error from SR description: %s," \ - "Error: %s" %(description, err)) - - prerelease_project_name = get_prerelease_project_name(target_project, - time_stamp) + try: + target_project, time_stamp = \ + get_info_from_prerelease_project_name(prerelease_project_name) + except ValueError: + print "Can not get prerelease project info from project name," \ + "take no action to %s" % prerelease_project_name + return 0 # Delete the prerelease project build.cleanup(prerelease_project_name, "Cleaned up by backend automaticly") -- 2.7.4