From dd448618c8a752a2be6effa89caba17889d30ccc Mon Sep 17 00:00:00 2001 From: hyokeun Date: Wed, 9 Jan 2019 11:39:20 +0900 Subject: [PATCH] [BuildMonitor] Do not process if post_project_id is illegal Change-Id: I46729f3fac3d4c6df1cf2cfc1763bbd47aba7f26 --- job_buildmonitor.py | 480 +++++++++++++++++++++------------------------------- 1 file changed, 189 insertions(+), 291 deletions(-) diff --git a/job_buildmonitor.py b/job_buildmonitor.py index b451dcc..10e3936 100644 --- a/job_buildmonitor.py +++ b/job_buildmonitor.py @@ -88,7 +88,7 @@ def bm_disconnect_db(): #=============================================================================== # for remote trigger from TRBS to PRE/POST def bm_remote_jenkins_build_job(remote_data): - print '[%s] remote data(%s)\n' % (__file__, remote_data) + print 'remote data(%s)\n' % (remote_data) remote_jenkins_build_job(os.getenv('PUBLIC_JENKINS_URL'), \ os.getenv('PUBLIC_JENKINS_USER'), \ os.getenv('PUBLIC_JENKINS_PW'), \ @@ -98,7 +98,7 @@ def bm_remote_jenkins_build_job(remote_data): %(base64.b64encode(json.dumps(remote_data)))) def bm_remote_jenkins_build_job_by_file(job, remote_data): - print '[%s] remote data(%s)\n' % (__file__, remote_data) + print 'remote data(%s)\n' % (remote_data) with open('TRIGGER_INFO_FILE', 'w') as f: f.write(base64.b64encode(json.dumps(remote_data))) @@ -117,28 +117,25 @@ def bm_remote_jenkins_build_job_by_file(job, remote_data): # [job_submit.py] def get_src_proj_lst(bm_src_prj_lst): - print '[%s] enter get_src_proj_lst\n' % (__file__) + print 'enter get_src_proj_lst\n' if not os.getenv("DROPPED_PRERELEASE_PROJECTS"): - print '[%s] no DROPPED_PRERELEASE_PROJECTS!!\n' % (__file__) + print 'no DROPPED_PRERELEASE_PROJECTS!!\n' return bm_src_prj_lst prefix = 'home:prerelease:' dropped_prj_lst = os.getenv("DROPPED_PRERELEASE_PROJECTS").split(',') - #print '[%s] dropped_prj_lst(%s)\n' % (__file__, dropped_prj_lst) - print '[%s] bm_src_prj_lst (%s)\n' % (__file__, bm_src_prj_lst) + print 'bm_src_prj_lst (%s)\n' % (bm_src_prj_lst) removed_lst = [] for each_src_proj in bm_src_prj_lst: for each_dropped_proj in dropped_prj_lst: - #print '[%s] each_src_proj(%s), each_dropped_proj(%s)\n' \ - # % (__file__, each_src_proj, each_dropped_proj) if each_src_proj.startswith(prefix + each_dropped_proj): removed_lst.append(each_src_proj) break # do remove - print '[%s] removed_lst(%s), do remove!!\n' % (__file__, removed_lst) + print 'removed_lst(%s), do remove!!\n' % (removed_lst) bm_src_prj_lst = [x for x in bm_src_prj_lst if x not in removed_lst] return bm_src_prj_lst @@ -155,36 +152,33 @@ def transform_date(date): return dd[0]+' '+dd[1] def sr_submit_for_sr_status(bm_git_tag): - print '[%s] enter sr_submit_for_sr_status\n' % (__file__) + print 'enter sr_submit_for_sr_status\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) if curr_sr_status_id == INVALID_ID: query = "INSERT INTO sr_status (sr, status, submit_time) VALUES(%s, %s, %s)" query_data = (bm_git_tag, 'C', datetime.strptime(bm_git_tag[-15:], '%Y%m%d.%H%M%S')) buildmonitor_db.do_query(query, query_data) else: - print '[%s] Already existing sr_status_id(%s) skip INSERT sr_stage\n' \ - % (__file__, curr_sr_status_id) + print 'Already existing sr_status_id(%s) skip INSERT sr_stage\n' \ + % (curr_sr_status_id) def sr_submit_for_sr_commit(commit_date, commit_msg, submit_date, submit_msg, submitter, git_tag, gerrit_project, gerrit_newrev, gerrit_account_name, obs_package_name, status): - print '[%s] enter sr_submit_for_sr_commit\n' % (__file__) + print 'enter sr_submit_for_sr_commit\n' # get current_sr_status_id (should be here, after sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) obs_pkg_name = obs_package_name bm_submitter = submitter.replace('<', '').replace('>', '') - #print '[%s] bm_submitter(%s)' % (__file__, bm_submitter) query = "INSERT INTO sr_commit (sr_status_id, git_repository," \ "obs_package_name, git_commit_id, git_commit_date, " \ @@ -199,13 +193,12 @@ def sr_submit_for_sr_commit(commit_date, commit_msg, submit_date, submit_msg, def start_pre_build_for_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, pre_build_project_id): - print '[%s] enter start_pre_build_for_sr_stage\n' % (__file__) + print 'enter start_pre_build_for_sr_stage\n' # get current_sr_status_id (should be here after sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) ### [SR_SUBMIT] end stage : SR submit info_stage_id = SR_SUBMIT @@ -224,7 +217,7 @@ def start_pre_build_for_sr_stage(git_tag, bm_start_datetime, def sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime, bm_end_datetime, pre_build_project_id): - print '[%s] enter sr_submit_for_sr_stage\n' % (__file__) + print 'enter sr_submit_for_sr_stage\n' ### [SR_SUBMIT] SR submit info_stage_id = SR_SUBMIT @@ -236,23 +229,17 @@ def sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime, def package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, bm_src_project_lst): - print '[%s] enter package_build_for_sr_detail_sr_stage\n' % (__file__) + print 'enter package_build_for_sr_detail_sr_stage\n' # get current_sr_status_id (should be here after sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) - - # Wait 60 seconds to find the info_project_id - #print '[%s] wait 60 sec\n' % (__file__) - #sleep(60) ### for sr_status_detail & sr_stage # bm_src_project_lst is needed for multi profile - print '[%s] bm_src_project_lst(%s)\n' % (__file__, bm_src_project_lst) + print 'bm_src_project_lst(%s)\n' % (bm_src_project_lst) for bm_src_project in bm_src_project_lst: - #print '[%s] bm_src_project(%s)\n' % (__file__, bm_src_project) # get info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -261,27 +248,26 @@ def package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] info_project_id(%s), pre_build_project_id(%s)\n' \ - % (__file__, info_project_id, pre_build_project_id) + print 'info_project_id(%s), pre_build_project_id(%s)\n' \ + % (info_project_id, pre_build_project_id) # defensive code for the duplicated build_project_id if pre_build_project_id == INVALID_ID: - print '[%s] cannot find build_project_id!! Adding NOW!!\n' % (__file__) + print 'cannot find build_project_id!! Adding NOW!!\n' query = "INSERT INTO build_project (info_project_id, status) VALUES(%s, %s)" query_data = (info_project_id, 'C') buildmonitor_db.do_query(query, query_data) query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s][After] info_project_id(%s), pre_build_project_id(%s)\n' \ - % (__file__, info_project_id, pre_build_project_id) + print '[After] info_project_id(%s), pre_build_project_id(%s)\n' \ + % (info_project_id, pre_build_project_id) # get sr_status_detail_id for checking group submit query = "SELECT id FROM sr_status_detail WHERE sr_status_id = %s " \ "AND pre_build_project_id = %s" query_data = (curr_sr_status_id, pre_build_project_id) sr_status_detail_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] sr_status_detail_id(%s)\n' % (__file__, sr_status_detail_id) if sr_status_detail_id == INVALID_ID: # get pre_build_project_id @@ -304,8 +290,8 @@ def package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, pre_build_project_id) else: # clear the existing tables (sr_stage & build_snapshot) - print '[%s] Already existing sr_status_id(%s)!! clear the related tables\n' \ - % (__file__, sr_status_detail_id) + print 'Already existing sr_status_id(%s)!! clear the related tables\n' \ + % (sr_status_detail_id) query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND build_project_id = %s" query_data = (curr_sr_status_id, pre_build_project_id) buildmonitor_db.do_query(query, query_data) @@ -338,13 +324,12 @@ def package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, # [job_pre_release_obs.py] def update_fail_status_for_sr_stage(project, bm_git_tag): - print '[%s] enter update_fail_status_for_sr_stage\n' % (__file__) + print 'enter update_fail_status_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id (%s)\n' % (__file__, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -374,7 +359,7 @@ def update_fail_status_for_sr_stage(project, bm_git_tag): sr_stage_status, curr_build_project_id) buildmonitor_db.do_query(query, query_data) - print '[%s] This is [Base] project!! All stages are done\n' % (__file__) + print 'This is [Base] project!! All stages are done\n' else: sr_stage_status = 'F' @@ -410,7 +395,7 @@ def update_comment(sr, comment): buildmonitor_db.do_query(query, query_data) def start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bBuildFail, BuildFailReason): - print '[%s] enter start_pre_create_snapshot_for_sr_stage\n' % (__file__) + print 'enter start_pre_create_snapshot_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" @@ -425,7 +410,7 @@ def start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetim query_data = (curr_info_project_id,) curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] bBuildFail(%s)\n' % (__file__, bBuildFail) + print 'bBuildFail(%s)\n' % (bBuildFail) if bBuildFail == True: info_stage_status = 'F' if BuildFailReason == 'Cycles': @@ -451,15 +436,14 @@ def start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetim bm_start_datetime, 'R', curr_build_project_id) buildmonitor_db.do_query(query, query_data) else: - print '[%s] Build failed!! skip [3] stage start\n' \ - % (__file__) + print 'Build failed!! skip [3] stage start\n' # Update notice for cyclic dependency. if info_stage_status == 'C': update_comment(bm_git_tag, "ERROR! This SR bring about cyclic dependency!") def start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime): - print '[%s] enter start_pre_create_snapshot_for_build_snapshot\n' % (__file__) + print 'enter start_pre_create_snapshot_for_build_snapshot\n' # get pre_info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -468,8 +452,6 @@ def start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_d query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (pre_info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] pre_info_project_id(%s), pre_build_project_id(%s)\n' \ - # % (__file__, pre_info_project_id, pre_build_project_id) ### to check duplicate build_snapshot_id query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" @@ -482,8 +464,7 @@ def start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_d query_data = (pre_build_project_id, bm_start_datetime, 'R') buildmonitor_db.do_query(query, query_data) else: - print '[%s] duplicated build_snapshot_id!! skip insert & clear tables\n' \ - % (__file__) + print 'duplicated build_snapshot_id!! skip insert & clear tables\n' ### clear build_snapshot_package & build_image tables query = "DELETE FROM build_snapshot_package WHERE build_snapshot_id = %s" @@ -525,7 +506,7 @@ def create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arc bm_trg_count, bm_pkg_count, BM_PKG_LIMIT): - print '[%s] enter create_snapshot_packages_for_build_snapshot_package\n' % (__file__) + print 'enter create_snapshot_packages_for_build_snapshot_package\n' # get pre_info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -534,14 +515,11 @@ def create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arc query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (pre_info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] pre_info_project_id(%s), pre_build_project_id(%s)\n' \ - # % (__file__, pre_info_project_id, pre_build_project_id) # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (pre_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) # bulk insert query = "INSERT INTO build_snapshot_package (build_snapshot_id, repository, " \ @@ -551,8 +529,6 @@ def create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arc query_list = [] for each_pkg_name, each_pkg_mdate, each_pkg_size in zip(bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst): timestamp = datetime.fromtimestamp(each_pkg_mdate) - #print '[%s] each_pkg_name(%s), timestamp(%s), each_pkg_size(%s)' \ - # % (__file__, each_pkg_name, timestamp, each_pkg_size) query_list.append((curr_build_snapshot_id, bm_repo, bm_arch, each_pkg_name, timestamp, each_pkg_size, bm_pkg_url)) @@ -560,7 +536,7 @@ def create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arc def end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bm_end_datetime): - print '[%s] enter end_pre_create_snapshot_for_sr_stage\n' % (__file__) + print 'enter end_pre_create_snapshot_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" @@ -587,8 +563,8 @@ def end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, if 'base' in project.lower(): ### [PRE_IMAGE] stage end : [pre] image creation sr_stage_status = 'S' - print '[%s] This is [Base] project!! sr_stage_status(%s)\n' \ - % (__file__, sr_stage_status) + print 'This is [Base] project!! sr_stage_status(%s)\n' \ + % (sr_stage_status) else: ### [PRE_IMAGE] stage start : [pre] image creation sr_stage_status = 'R' @@ -603,7 +579,7 @@ def end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, def end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, bm_snapshot_url, bm_snapshot_num, bm_end_datetime): - print '[%s] enter end_pre_create_snapshot_for_build_snapshot\n' % (__file__) + print 'enter end_pre_create_snapshot_for_build_snapshot\n' # get pre_info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -612,8 +588,6 @@ def end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (pre_info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] pre_info_project_id(%s), pre_build_project_id(%s)\n' \ - # % (__file__, pre_info_project_id, pre_build_project_id) ### for build_snapshot query = "UPDATE build_snapshot SET snapshot_name = %s, snapshot_url = %s, " \ @@ -626,7 +600,7 @@ def end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, # [job_imager.py] def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot_name): - print '[%s] enter update_fail_create_image_for_sr_stage\n' % (__file__) + print 'enter update_fail_create_image_for_sr_stage\n' bm_prj_name = fields["project"] bm_split_data = fields["project"].split(':')[-1] @@ -634,8 +608,6 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot bm_git_tag = 'submit/' + bm_prj_name.split(":submit:")[-1].replace(':', '/') bm_url = os.path.join(fields.get('url_pub_base', ''), fields['repo_path'], fields['images_path']) - #print '[%s] bm_prj_name(%s), bm_split_data(%s), bm_git_tag(%s), bm_url(%s)\n' \ - # % (__file__, bm_prj_name, bm_split_data, bm_git_tag, bm_url) bm_end_datetime = datetime.now() bm_repo = fields["repo"] @@ -646,8 +618,6 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s][pre_build] info_stage_id(%s), query_data(%s), curr_sr_status_id(%s)\n' \ - # % (__file__, info_stage_id, query_data, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -682,18 +652,19 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' % (post_build_project_id) + if post_build_project_id == 0: + print 'NULL id - Not updating POST_IMAGE stage' + return # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] multi_sr_status_id(%s)\n' \ - # % (__file__, multi_sr_status_id) ### [POST_IMAGE] stage end : [POST] image creation for each_sr_status_id in multi_sr_status_id: - print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) + print 'each_sr_status_id(%s)\n' % (each_sr_status_id) if each_sr_status_id == 0: print 'each_sr_status_id is zero!! skip updating the sr_stage\n' @@ -709,7 +680,7 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot def create_image_for_build_image(fields, bm_start_datetime, bm_end_datetime, bm_snapshot_name, bm_img_size): - print '[%s] enter create_image_for_build_image\n' % (__file__) + print 'enter create_image_for_build_image\n' bm_repository = fields['repo'] bm_device_name = fields['name'] @@ -718,14 +689,11 @@ def create_image_for_build_image(fields, bm_start_datetime, else: bm_status = 'S' bm_url = fields['url'] - #print '[%s] bm_repository(%s), bm_device_name(%s), bm_status(%s), bm_url(%s)\n' \ - # % (__file__, bm_repository, bm_device_name, bm_status, bm_url) # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s" query_data = (bm_snapshot_name,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) ### for build_image #TODO: Update it if exists @@ -753,20 +721,17 @@ def create_image_for_build_image(fields, bm_start_datetime, # [job_post_image.py] def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name): - print '[%s] enter end_create_image_for_sr_stage project(%s)\n' % (__file__, project) + print 'enter end_create_image_for_sr_stage project(%s)\n' % (project) bm_end_datetime = datetime.now() if project.startswith("home:prerelease:") or project.startswith("home:trbs:"): bm_git_tag = 'submit/' + project.split(":submit:")[-1].replace(':', '/') - #print '[%s] bm_git_tag(%s)\n' % (__file__, bm_git_tag) # [pre_build] get current_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s][pre_build] query_data(%s), curr_sr_status_id(%s)\n' \ - # % (__file__, query_data, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -784,14 +749,13 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name): query = "SELECT status FROM build_image WHERE build_snapshot_id = %s" query_data = (curr_build_snapshot_id,) multi_build_image_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - print '[%s] multi_build_image_status(%s)\n' % (__file__, multi_build_image_status) + print 'multi_build_image_status(%s)\n' % (multi_build_image_status) isFailed = 0 for each_build_image_status in multi_build_image_status: - #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status) if each_build_image_status and each_build_image_status[0] == 'F': isFailed = 1 - print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed) + print 'isFailed(%s)!! skip updating the sr_stage\n' % (isFailed) if isFailed == 0: ### [PRE_IMAGE] stage : [pre] image creation @@ -806,7 +770,7 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name): query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' % (post_build_project_id) # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" @@ -816,26 +780,26 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name): query = "SELECT status FROM build_image WHERE build_snapshot_id = %s" query_data = (curr_build_snapshot_id,) multi_build_image_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - print '[%s] multi_build_image_status(%s)\n' % (__file__, multi_build_image_status) + print 'multi_build_image_status(%s)\n' % (multi_build_image_status) isFailed = 0 for each_build_image_status in multi_build_image_status: - #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status) if each_build_image_status and each_build_image_status[0] == 'F': isFailed = 1 - print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed) + print 'isFailed(%s)!! skip updating the sr_stage\n' % (isFailed) if isFailed == 0: + if post_build_project_id == 0: + print 'NULL id - Not updating POST_SNAP/POST_IMAGE stage' + return # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] curr_info_project_id(%s), post_build_project_id(%d), multi_sr_status_id(%s)\n' \ - # % (__file__, curr_info_project_id, post_build_project_id, multi_sr_status_id) ### [POST_SNAP/POST_IMAGE] stage end : [POST] snapshot & image creation for each_sr_status_id in multi_sr_status_id: - print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) + print 'each_sr_status_id(%s)\n' % (each_sr_status_id) if each_sr_status_id == 0: print 'each_sr_status_id is zero!! skip updating the sr_stage\n' @@ -859,13 +823,12 @@ def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name): def sr_accept_for_sr_stage(bm_src_prj_name, bm_target_prj_name, bm_start_datetime, bm_end_datetime, bm_git_tag): - print '[%s] enter sr_accept_for_sr_stage\n' % (__file__) + print 'enter sr_accept_for_sr_stage\n' # get current_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -898,8 +861,8 @@ def sr_accept_for_sr_stage(bm_src_prj_name, bm_target_prj_name, "ORDER BY id desc LIMIT 1" query_data = (bm_target_prj_name,) last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] last_bpid_of_build_snapshot(%s)\n' \ - % (__file__, last_bpid_of_build_snapshot) + print 'last_bpid_of_build_snapshot(%s)\n' \ + % (last_bpid_of_build_snapshot) # get post_build_project_id query = "SELECT bp.id " \ @@ -909,13 +872,13 @@ def sr_accept_for_sr_stage(bm_src_prj_name, bm_target_prj_name, "ORDER BY id LIMIT 1" query_data = (curr_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' \ - % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' \ + % (post_build_project_id) # use the prev last_bpid if there is no post_build_project_id if post_build_project_id == 0: - print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ - (__file__, post_build_project_id, last_bpid_of_build_snapshot) + print 'post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (post_build_project_id, last_bpid_of_build_snapshot) post_build_project_id = last_bpid_of_build_snapshot ### [POST_BUILD] stage start : [post] package build @@ -929,13 +892,12 @@ def sr_accept_for_sr_stage(bm_src_prj_name, bm_target_prj_name, def sr_reject_for_sr_stage(bm_src_prj_name, bm_start_datetime, bm_end_datetime, bm_git_tag): - print '[%s] enter sr_reject_for_sr_stage\n' % (__file__) + print 'enter sr_reject_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -956,7 +918,7 @@ def sr_reject_for_sr_stage(bm_src_prj_name, bm_start_datetime, def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, bm_end_datetime, bm_git_tag): - print '[%s] enter sr_accept_reject_for_sr_status_detail\n' % (__file__) + print 'enter sr_accept_reject_for_sr_status_detail\n' obs_req_no = event_fields['id'] obs_req_comment = truncate_msg(event_fields['description']) @@ -965,13 +927,9 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, obs_req_status = obs_req_status.upper() bm_src_prj_name = event_fields['sourceproject'] bm_target_prj_name = event_fields['targetproject'] - #print '[%s] obs_req_no(%s), obs_req_comment(%s), obs_req_date(%s), obs_req_status(%s)\n' \ - # % (__file__, obs_req_no, obs_req_comment, obs_req_date, obs_req_status) - #print '[%s] bm_src_prj_name(%s), bm_target_prj_name(%s), bm_git_tag(%s)\n' \ - # % (__file__, bm_src_prj_name, bm_target_prj_name, bm_git_tag) if obs_req_status == 'ACCEPTED': - print '[%s][ACCEPTED] obs_req_status(%s)\n' % (__file__, obs_req_status) + print '[ACCEPTED] obs_req_status(%s)\n' % (obs_req_status) # get pre_info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -980,8 +938,6 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (pre_info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] pre_info_project_id(%d), pre_build_project_id(%s)\n' \ - # % (__file__, pre_info_project_id, pre_build_project_id) # get post_info_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -997,8 +953,8 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, "ORDER BY id desc LIMIT 1" query_data = (bm_target_prj_name,) last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] last_bpid_of_build_snapshot(%s)\n' \ - % (__file__, last_bpid_of_build_snapshot) + print 'last_bpid_of_build_snapshot(%s)\n' \ + % (last_bpid_of_build_snapshot) # get post_build_project_id query = "SELECT bp.id " \ @@ -1008,13 +964,13 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, "ORDER BY id LIMIT 1" query_data = (post_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' \ - % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' \ + % (post_build_project_id) # use the prev last_bpid if there is no post_build_project_id if post_build_project_id == 0: - print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ - (__file__, post_build_project_id, last_bpid_of_build_snapshot) + print 'post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (post_build_project_id, last_bpid_of_build_snapshot) post_build_project_id = last_bpid_of_build_snapshot ### for sr_status_detail @@ -1030,8 +986,8 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, bm_start_datetime, bm_end_datetime, bm_git_tag) elif obs_req_status == 'DECLINED': - print '[%s][DECLINED] obs_req_status(%s)\n' \ - % (__file__, obs_req_status) + print '[DECLINED] obs_req_status(%s)\n' \ + % (obs_req_status) # get info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -1057,27 +1013,25 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, # [job_create_snapshot.py] def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name): - print '[%s] enter update_fail_create_snapshot_for_sr_stage\n' % (__file__) + print 'enter update_fail_create_snapshot_for_sr_stage\n' # get post_build_project_id by using bm_snapshot_name query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' % (post_build_project_id) # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] multi_sr_status_id(%s)\n' \ - # % (__file__, multi_sr_status_id) # Skip updating the fail status if Base project if 'base' in bm_snapshot_name.lower(): sr_stage_status = 'S' for each_sr_status_id in multi_sr_status_id: - print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) + print 'each_sr_status_id(%s)\n' % (each_sr_status_id) if each_sr_status_id == 0: print 'each_sr_status_id is zero!! skip updating the sr_stage\n' @@ -1098,13 +1052,13 @@ def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name): query_data = (each_sr_status_id[0], info_stage_id, sr_stage_status, post_build_project_id) buildmonitor_db.do_query(query, query_data) - print '[%s] This is [Base] project!! All stages are done\n' % (__file__) + print 'This is [Base] project!! All stages are done\n' else: sr_stage_status = 'F' for each_sr_status_id in multi_sr_status_id: - print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) + print 'each_sr_status_id(%s)\n' % (each_sr_status_id) if each_sr_status_id == 0: print 'each_sr_status_id is zero!! skip updating the sr_stage\n' @@ -1118,7 +1072,7 @@ def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name): buildmonitor_db.do_query(query, query_data) def start_create_snapshot_for_sr_stage(project, bm_start_datetime): - print '[%s] enter start_create_snapshot_for_sr_stage\n' % (__file__) + print 'enter start_create_snapshot_for_sr_stage\n' # get post_info_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -1134,8 +1088,8 @@ def start_create_snapshot_for_sr_stage(project, bm_start_datetime): "ORDER BY id desc LIMIT 1" query_data = (project,) last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] last_bpid_of_build_snapshot(%s)\n' \ - % (__file__, last_bpid_of_build_snapshot) + print 'last_bpid_of_build_snapshot(%s)\n' \ + % (last_bpid_of_build_snapshot) # get post_build_project_id query = "SELECT bp.id " \ @@ -1145,25 +1099,23 @@ def start_create_snapshot_for_sr_stage(project, bm_start_datetime): "ORDER BY id LIMIT 1" query_data = (post_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' \ - % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' \ + % (post_build_project_id) # use the prev last_bpid if there is no post_build_project_id if post_build_project_id == 0: - print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ - (__file__, post_build_project_id, last_bpid_of_build_snapshot) + print 'post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (post_build_project_id, last_bpid_of_build_snapshot) post_build_project_id = last_bpid_of_build_snapshot # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] post_info_project_id(%s), post_build_project_id(%d), multi_sr_status_id(%s)\n' \ - # % (__file__, post_info_project_id, post_build_project_id, multi_sr_status_id) ### [POST_BUILD] end / [POST_SNAP/POST_IMAGE] start : [post] snapshot creation for each_sr_status_id in multi_sr_status_id: - print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) + print 'each_sr_status_id(%s)\n' % (each_sr_status_id) if each_sr_status_id == 0: print 'each_sr_status_id is zero!! skip updating the sr_stage\n' @@ -1250,7 +1202,7 @@ def update_build_snapshot_status_info(build_project_id, snapshot_name): def start_create_snapshot_for_post_build_snapshot(project, bm_snapshot_name, bm_start_datetime): - print '[%s] enter start_create_snapshot_for_post_build_snapshot\n' % (__file__) + print 'enter start_create_snapshot_for_post_build_snapshot\n' # get post_info_project_id query = "SELECT id FROM info_project WHERE project_name = %s ORDER BY id DESC LIMIT 1" @@ -1266,8 +1218,8 @@ def start_create_snapshot_for_post_build_snapshot(project, bm_snapshot_name, "ORDER BY id desc LIMIT 1" query_data = (project,) last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] last_bpid_of_build_snapshot(%s)\n' \ - % (__file__, last_bpid_of_build_snapshot) + print 'last_bpid_of_build_snapshot(%s)\n' \ + % (last_bpid_of_build_snapshot) # get post_build_project_id query = "SELECT bp.id " \ @@ -1277,13 +1229,13 @@ def start_create_snapshot_for_post_build_snapshot(project, bm_snapshot_name, "ORDER BY id LIMIT 1" query_data = (post_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' \ - % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' \ + % (post_build_project_id) # use the prev last_bpid if there is no post_build_project_id if post_build_project_id == 0: - print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ - (__file__, post_build_project_id, last_bpid_of_build_snapshot) + print 'post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (post_build_project_id, last_bpid_of_build_snapshot) post_build_project_id = last_bpid_of_build_snapshot # insert new post_build_project_id @@ -1301,13 +1253,13 @@ def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst): - print '[%s] enter create_snapshot_packages_for_post_build_snapshot_package\n' % (__file__) + print 'enter create_snapshot_packages_for_post_build_snapshot_package\n' # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s" query_data = (bm_snapshot_name,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) + print 'curr_build_snapshot_id(%s)\n' % (curr_build_snapshot_id) # bulk insert @@ -1319,8 +1271,6 @@ def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, for each_pkg_name, each_pkg_mdate, each_pkg_size in zip(bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst): timestamp = datetime.fromtimestamp(each_pkg_mdate) # post build - #print '[%s] curr_build_snapshot_id(%s), each_pkg_name(%s), timestamp(%s), each_pkg_size(%s)\n' \ - # % (__file__, curr_build_snapshot_id, each_pkg_name, timestamp, each_pkg_size) query_list.append((curr_build_snapshot_id, bm_repo, bm_arch, each_pkg_name, timestamp, each_pkg_size, bm_pkg_url)) @@ -1329,7 +1279,7 @@ def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name, bm_start_datetime, bm_end_datetime): - print '[%s] enter end_create_snapshot_create_images_for_sr_stage\n' % (__file__) + print 'enter end_create_snapshot_create_images_for_sr_stage\n' ### [POST_SNAP/POST_IMAGE] end : [post] snapshot creation / [post] image creation @@ -1337,17 +1287,15 @@ def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name, query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) + print 'post_build_project_id(%s)\n' % (post_build_project_id) # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] multi_sr_status_id(%s)\n' \ - # % (__file__, multi_sr_status_id) for each_sr_status_id in multi_sr_status_id: - print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) + print 'each_sr_status_id(%s)\n' % (each_sr_status_id) if each_sr_status_id == 0: print 'each_sr_status_id is zero!! skip updating the sr_stage\n' @@ -1365,8 +1313,8 @@ def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name, ### [POST_IMAGE] stage end : update 'S' or 'R' status if 'base' in bm_snapshot_name.lower(): sr_stage_status = 'S' - print '[%s] This is [Base] project!! sr_stage_status(%s)\n' \ - % (__file__, sr_stage_status) + print 'This is [Base] project!! sr_stage_status(%s)\n' \ + % (sr_stage_status) else: sr_stage_status = 'R' @@ -1380,7 +1328,7 @@ def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name, def end_create_snapshot_for_post_build_snapshot(bm_end_datetime, bm_snapshot_url, bm_snapshot_name): - print '[%s] enter end_create_snapshot_for_post_build_snapshot\n' % (__file__) + print 'enter end_create_snapshot_for_post_build_snapshot\n' # update the build_snapshot data query = "UPDATE build_snapshot SET snapshot_url = %s, " \ @@ -1443,21 +1391,21 @@ def update_base_build_id(bm_snapshot_name, bm_base_build_id): buildmonitor_db.do_query(query, query_data) def update_sr_submit_log(sr_submit_log_id, sr_tag, status, status_reason): - print "[%s] update_str_submit_log %s, %s, %s\n" % (__file__, sr_submit_log_id, sr_tag, status_reason) + print "update_str_submit_log %s, %s, %s\n" % (sr_submit_log_id, sr_tag, status_reason) query = "UPDATE sr_submit_log SET status=%s,sr_tag=%s,reason=%s WHERE id=%s" query_data = (status, sr_tag, status_reason, sr_submit_log_id) buildmonitor_db.do_query(query, query_data) def update_sr_submit_log_completed(git_tag): - print "[%s] update_sr_submit_log_completed %s\n" % (__file__, git_tag) + print "update_sr_submit_log_completed %s\n" % (git_tag) query = "UPDATE sr_submit_log SET status='Completed' WHERE sr_tag=%s ORDER BY id DESC LIMIT 1" query_data = (git_tag,) buildmonitor_db.do_query(query, query_data) def update_repa(sr_tag, profile, status, status_reason): - print "[%s] update_repa %s, %s, %s, %s\n", (__file__, sr_tag, profile, status, status_reason) + print "update_repa %s, %s, %s, %s\n", (sr_tag, profile, status, status_reason) query = "UPDATE sr_accept_log SET status=%s,status_reason=%s WHERE sr=%s AND profile=%s ORDER BY id DESC LIMIT 1" query_data = (status, status_reason, sr_tag, profile) @@ -1469,7 +1417,7 @@ def update_build_log(content): base_url = content.get('base_url') pkgs = content.get('pkgs') - print "[%s] update build log %s %s %s\n" % (__file__, project, repo, base_url) + print "update build log %s %s %s\n" % (project, repo, base_url) query = "SELECT bt.id, ipa.id, bt.arch, ipa.package_name "+ \ "FROM info_project ip, build_project bp, build_target bt, info_package ipa "+\ "WHERE bp.info_project_id = ip.id "+ \ @@ -1499,7 +1447,7 @@ def update_build_log(content): for arch in pkgs.keys(): for pkg in pkgs[arch].keys(): build_log_url = os.path.join(base_url, pkgs[arch][pkg]) - print '[%s] build_log %s %s %s\n' % (__file__, arch, pkg, build_log_url) + print 'build_log %s %s %s\n' % (arch, pkg, build_log_url) query = "UPDATE build_package SET build_log_url=%s WHERE build_target_id=%s AND info_package_id=%s" build_target_id = id_data[arch][pkg]['bt_id'] info_package_id = id_data[arch][pkg]['ipa_id'] @@ -1749,7 +1697,7 @@ def update_unresolvable_broken_packages(project, unresolvable_broken_packages): def update_snapshot_manifest(snapshot_name, manifestdata, datetime): - print '[%s] enter update_snapshot_manifest\n' % (__file__) + print 'enter update_snapshot_manifest\n' if snapshot_name and manifestdata: bm_ext = BuildMonitorExtention() #INSERT MANIFEST DATA TO BUILDMONITOR @@ -1760,13 +1708,12 @@ def update_snapshot_manifest(snapshot_name, manifestdata, datetime): def TRBS_start_pre_build_for_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, trbs_build_project_id): - print '[%s] enter TRBS_start_pre_build_for_sr_stage\n' % (__file__) + print 'enter TRBS_start_pre_build_for_sr_stage\n' # get current_sr_status_id (should be here after sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) ### [SR_SUBMIT] end stage : SR submit info_stage_id = SR_SUBMIT @@ -1785,7 +1732,7 @@ def TRBS_start_pre_build_for_sr_stage(git_tag, bm_start_datetime, def TRBS_sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime, bm_end_datetime, trbs_build_project_id): - print '[%s] enter TRBS_sr_submit_for_sr_stage\n' % (__file__) + print 'enter TRBS_sr_submit_for_sr_stage\n' ### [SR_SUBMIT] SR submit info_stage_id = SR_SUBMIT @@ -1797,24 +1744,19 @@ def TRBS_sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime, def TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, bm_src_project_lst): - print '[%s] enter TRBS_package_build_for_sr_detail_sr_stage\n' % (__file__) + print 'enter TRBS_package_build_for_sr_detail_sr_stage\n' # get current_sr_status_id (should be here after sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) # Wait 60 seconds to find the info_project_id - #print '[%s] wait 60 sec\n' % (__file__) - #sleep(60) ### for sr_status_detail & sr_stage # bm_src_project_lst is needed for multi profile - print '[%s] bm_src_project_lst(%s)\n' % (__file__, bm_src_project_lst) + print 'bm_src_project_lst(%s)\n' % (bm_src_project_lst) for bm_src_project in bm_src_project_lst: - #print '[%s] bm_src_project(%s)\n' % (__file__, bm_src_project) - # get info_project_id -> get trbs_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" query_data = (bm_src_project,) @@ -1822,27 +1764,26 @@ def TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (info_project_id,) trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] info_project_id(%s), trbs_build_project_id(%s)\n' \ - % (__file__, info_project_id, trbs_build_project_id) + print 'info_project_id(%s), trbs_build_project_id(%s)\n' \ + % (info_project_id, trbs_build_project_id) # defensive code for the duplicated build_project_id if trbs_build_project_id == INVALID_ID: - print '[%s] cannot find build_project_id!! Adding NOW!!\n' % (__file__) + print 'cannot find build_project_id!! Adding NOW!!\n' query = "INSERT INTO build_project (info_project_id, status) VALUES(%s, %s)" query_data = (info_project_id, 'C') buildmonitor_db.do_query(query, query_data) query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (info_project_id,) trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s][After] info_project_id(%s), trbs_build_project_id(%s)\n' \ - % (__file__, info_project_id, trbs_build_project_id) + print '[After] info_project_id(%s), trbs_build_project_id(%s)\n' \ + % (info_project_id, trbs_build_project_id) # get sr_status_detail_id for checking group submit query = "SELECT id FROM sr_status_detail WHERE sr_status_id = %s " \ "AND trbs_build_project_id = %s" query_data = (curr_sr_status_id, trbs_build_project_id) sr_status_detail_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] sr_status_detail_id(%s)\n' % (__file__, sr_status_detail_id) if sr_status_detail_id == INVALID_ID: # get trbs_build_project_id @@ -1865,8 +1806,8 @@ def TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, trbs_build_project_id) else: # clear the existing tables (sr_stage & build_snapshot) - print '[%s] Already existing sr_status_id(%s)!! clear the related tables\n' \ - % (__file__, sr_status_detail_id) + print 'Already existing sr_status_id(%s)!! clear the related tables\n' \ + % (sr_status_detail_id) query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND build_project_id = %s" query_data = (curr_sr_status_id, trbs_build_project_id) buildmonitor_db.do_query(query, query_data) @@ -1899,13 +1840,12 @@ def TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, # [TRBS][job_pre_release_obs.py] def TRBS_update_fail_status_for_sr_stage(project, bm_git_tag): - print '[%s] enter TRBS_update_fail_status_for_sr_stage\n' % (__file__) + print 'enter TRBS_update_fail_status_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id (%s)\n' % (__file__, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -1923,7 +1863,7 @@ def TRBS_update_fail_status_for_sr_stage(project, bm_git_tag): buildmonitor_db.do_query(query, query_data) def TRBS_start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bBuildFail): - print '[%s] enter TRBS_start_pre_create_snapshot_for_sr_stage\n' % (__file__) + print 'enter TRBS_start_pre_create_snapshot_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" @@ -1938,7 +1878,7 @@ def TRBS_start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_da query_data = (curr_info_project_id,) curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] bBuildFail(%s)\n' % (__file__, bBuildFail) + print 'bBuildFail(%s)\n' % (bBuildFail) if bBuildFail == True: info_stage_status = 'F' else: @@ -1962,11 +1902,10 @@ def TRBS_start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_da bm_start_datetime, 'R', curr_build_project_id) buildmonitor_db.do_query(query, query_data) else: - print '[%s] Build failed!! skip [TRBS_SNAP] stage start\n' \ - % (__file__) + print 'Build failed!! skip [TRBS_SNAP] stage start\n' def TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime): - print '[%s] enter TRBS_start_pre_create_snapshot_for_build_snapshot\n' % (__file__) + print 'enter TRBS_start_pre_create_snapshot_for_build_snapshot\n' # get pre_info_project_id -> get trbs_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -1975,8 +1914,6 @@ def TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_st query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (pre_info_project_id,) trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] pre_info_project_id(%s), trbs_build_project_id(%s)\n' \ - # % (__file__, pre_info_project_id, trbs_build_project_id) ### to check duplicate build_snapshot_id query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" @@ -1990,8 +1927,7 @@ def TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_st query_data = (trbs_build_project_id, bm_start_datetime, 'R') buildmonitor_db.do_query(query, query_data) else: - print '[%s] duplicated build_snapshot_id!! skip insert & clear tables\n' \ - % (__file__) + print 'duplicated build_snapshot_id!! skip insert & clear tables\n' ### clear build_snapshot_package & build_image tables query = "DELETE FROM build_snapshot_package WHERE build_snapshot_id = %s" @@ -2033,7 +1969,7 @@ def TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, b bm_trg_count, bm_pkg_count, BM_PKG_LIMIT): - print '[%s] enter TRBS_create_snapshot_packages_for_build_snapshot_package\n' % (__file__) + print 'enter TRBS_create_snapshot_packages_for_build_snapshot_package\n' # get trbs_info_project_id -> get trbs_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -2042,14 +1978,11 @@ def TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, b query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (trbs_info_project_id,) trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] trbs_info_project_id(%s), trbs_build_project_id(%s)\n' \ - # % (__file__, trbs_info_project_id, trbs_build_project_id) # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" query_data = (trbs_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) # bulk insert query = "INSERT INTO build_snapshot_package (build_snapshot_id, repository, " \ @@ -2059,8 +1992,6 @@ def TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, b query_list = [] for each_pkg_name, each_pkg_mdate, each_pkg_size in zip(bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst): timestamp = datetime.fromtimestamp(each_pkg_mdate) - #print '[%s] each_pkg_name(%s), timestamp(%s), each_pkg_size(%s)' \ - # % (__file__, each_pkg_name, timestamp, each_pkg_size) query_list.append((curr_build_snapshot_id, bm_repo, bm_arch, each_pkg_name, timestamp, each_pkg_size, bm_pkg_url)) @@ -2068,7 +1999,7 @@ def TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, b def TRBS_end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bm_end_datetime): - print '[%s] enter TRBS_end_pre_create_snapshot_for_sr_stage\n' % (__file__) + print 'enter TRBS_end_pre_create_snapshot_for_sr_stage\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" @@ -2102,7 +2033,7 @@ def TRBS_end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, def TRBS_end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, bm_snapshot_url, bm_snapshot_num, bm_end_datetime): - print '[%s] enter TRBS_end_pre_create_snapshot_for_build_snapshot\n' % (__file__) + print 'enter TRBS_end_pre_create_snapshot_for_build_snapshot\n' # get trbs_info_project_id -> get trbs_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" @@ -2111,8 +2042,6 @@ def TRBS_end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (trbs_info_project_id,) trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] trbs_info_project_id(%s), trbs_build_project_id(%s)\n' \ - # % (__file__, trbs_info_project_id, trbs_build_project_id) ### for build_snapshot query = "UPDATE build_snapshot SET snapshot_name = %s, snapshot_url = %s, " \ @@ -2125,7 +2054,7 @@ def TRBS_end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, # [TRBS][job_imager.py] def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime): - print '[%s] enter TRBS_update_fail_create_image_for_sr_stage\n' % (__file__) + print 'enter TRBS_update_fail_create_image_for_sr_stage\n' bm_prj_name = fields["project"] bm_split_data = fields["project"].split(':')[-1] @@ -2133,8 +2062,6 @@ def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime): bm_git_tag = 'submit/' + bm_prj_name.split(":submit:")[-1].replace(':', '/') bm_url = os.path.join(fields.get('url_pub_base', ''), fields['repo_path'], fields['images_path']) - #print '[%s] bm_prj_name(%s), bm_split_data(%s), bm_git_tag(%s), bm_url(%s)\n' \ - # % (__file__, bm_prj_name, bm_split_data, bm_git_tag, bm_url) bm_end_datetime = datetime.now() bm_repo = fields["repo"] @@ -2145,8 +2072,6 @@ def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime): query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s][trbs_build] info_stage_id(%s), query_data(%s), curr_sr_status_id(%s)\n' \ - # % (__file__, info_stage_id, query_data, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -2177,26 +2102,22 @@ def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime): curr_build_snapshot_id, bm_repo, bm_device_name) buildmonitor_db.do_query(query, query_data) else: - print '[%s] There is no postrelease stage in TRBS system\n' \ - % (__file__) + print 'There is no postrelease stage in TRBS system\n' #=============================================================================== # [TRBS][job_post_image.py] def TRBS_end_create_image_for_sr_stage(bm_start_datetime, project): - print '[%s] enter TRBS_end_create_image_for_sr_stage project(%s)\n' % (__file__, project) + print 'enter TRBS_end_create_image_for_sr_stage project(%s)\n' % (project) if project.startswith("home:prerelease:") or project.startswith("home:trbs:"): bm_end_datetime = datetime.now() bm_git_tag = 'submit/' + project.split(":submit:")[-1].replace(':', '/') - #print '[%s] bm_git_tag(%s)\n' % (__file__, bm_git_tag) # [trbs_build] get current_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s][trbs_build] query_data(%s), curr_sr_status_id(%s)\n' \ - # % (__file__, query_data, curr_sr_status_id) # get curr_info_project_id -> get curr_build_project_id for multi profile query = "SELECT id FROM info_project WHERE project_name = %s" @@ -2214,14 +2135,13 @@ def TRBS_end_create_image_for_sr_stage(bm_start_datetime, project): query = "SELECT status FROM build_image WHERE build_snapshot_id = %s" query_data = (curr_build_snapshot_id,) multi_build_image_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - print '[%s] multi_build_image_status(%s)\n' % (__file__, multi_build_image_status) + print 'multi_build_image_status(%s)\n' % (multi_build_image_status) isFailed = 0 for each_build_image_status in multi_build_image_status: - #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status) if each_build_image_status and each_build_image_status[0] == 'F': isFailed = 1 - print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed) + print 'isFailed(%s)!! skip updating the sr_stage\n' % (isFailed) if isFailed == 0: ### [TRBS_IMAGE] stage : [trbs] image creation @@ -2232,25 +2152,22 @@ def TRBS_end_create_image_for_sr_stage(bm_start_datetime, project): curr_sr_status_id, info_stage_id, curr_build_project_id) buildmonitor_db.do_query(query, query_data) else: - print '[%s] There is no postrelease stage in TRBS system\n' \ - % (__file__) + print 'There is no postrelease stage in TRBS system\n' #================================================================================== # Sync_SR def sync_sr_submit_for_sync_sr_map(bm_sync_git_tag, bm_member_git_tag_list, source_snapshot_name=None): - print '[%s] enter sync_sr_submit_for_sync_sr_map\n' % (__file__) + print 'enter sync_sr_submit_for_sync_sr_map\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_sync_git_tag,) sync_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] sync_sr_status_id(%s)\n' % (__file__, sync_sr_status_id) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_member_git_tag_list,) member_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] member_sr_status_id(%s)\n' % (__file__, member_sr_status_id) #Fake snapshot name query = "SELECT id FROM build_snapshot WHERE build_project_id = %s AND snapshot_name = %s" @@ -2270,53 +2187,51 @@ def sync_sr_submit_for_sync_sr_map(bm_sync_git_tag, bm_member_git_tag_list, sour buildmonitor_db.do_query(query, query_data) def sync_sr_submit_for_sr_status(bm_git_tag): - print '[%s] enter sync_sr_submit_for_sr_status\n' % (__file__) + print 'enter sync_sr_submit_for_sr_status\n' # get curr_sr_status_id query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (bm_git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) if curr_sr_status_id == INVALID_ID: query = "INSERT INTO sr_status (sr, status, submit_time) VALUES(%s, %s, %s)" query_data = (bm_git_tag, 'C', datetime.strptime(bm_git_tag[-15:], '%Y%m%d.%H%M%S')) buildmonitor_db.do_query(query, query_data) else: - print '[%s] Already existing sr_status_id(%s) skip INSERT sr_stage\n' \ - % (__file__, curr_sr_status_id) + print 'Already existing sr_status_id(%s) skip INSERT sr_stage\n' \ + % (curr_sr_status_id) def sync_sr_submit_for_sr_commit(commit_date, commit_msg, submit_date, submit_msg, submitter, git_tag, gerrit_project, gerrit_newrev, gerrit_account_name): - print '[%s] enter sync_sr_submit_for_sr_commit\n' % (__file__) + print 'enter sync_sr_submit_for_sr_commit\n' # get current_sr_status_id (should be here, after sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) - print '[%s] gerrit_project(%s)\n' % (__file__, gerrit_project) + print 'gerrit_project(%s)\n' % (gerrit_project) if gerrit_project[0] == '-': - print '[%s] mixed git(%s)\n' % (__file__, gerrit_project) + print 'mixed git(%s)\n' % (gerrit_project) gerrit_project = gerrit_project[1:] obs_pkg_name = os.path.basename(gerrit_project) + '(mixed)' elif gerrit_project[0] == '+': - print '[%s] pure git(%s)\n' % (__file__, gerrit_project) + print 'pure git(%s)\n' % (gerrit_project) gerrit_project = gerrit_project[1:] obs_pkg_name = os.path.basename(gerrit_project[1:]) elif gerrit_project == "N/A": - print '[%s] Sync SR(%s)\n' % (__file__, gerrit_project) + print 'Sync SR(%s)\n' % (gerrit_project) obs_pkg_name = "N/A" else: - print '[%s] no mixed marker "+" or "-", will be set as default(%s)\n' \ - % (__file__, gerrit_project) + print 'no mixed marker "+" or "-", will be set as default(%s)\n' \ + % (gerrit_project) obs_pkg_name = os.path.basename(gerrit_project) bm_submitter = submitter.replace('<', '').replace('>', '') - print '[%s] bm_submitter(%s) obs_pkg_name(%s)' \ - % (__file__, bm_submitter, obs_pkg_name) + print 'bm_submitter(%s) obs_pkg_name(%s)' \ + % (bm_submitter, obs_pkg_name) query = "INSERT INTO sr_commit (sr_status_id, git_repository," \ "obs_package_name, git_commit_id, git_commit_date, " \ @@ -2331,24 +2246,19 @@ def sync_sr_submit_for_sr_commit(commit_date, commit_msg, submit_date, submit_ms def sync_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, bm_src_project_lst): - print '[%s] enter sync_package_build_for_sr_detail_sr_stage\n' % (__file__) + print 'enter sync_package_build_for_sr_detail_sr_stage\n' # get current_sr_status_id (should be here after sync_sr_submit_for_sr_status) query = "SELECT id FROM sr_status WHERE sr = %s" query_data = (git_tag,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id) # Wait 60 seconds to find the info_project_id - #print '[%s] wait 60 sec\n' % (__file__) - #sleep(60) ### for sr_status_detail & sr_stage # bm_src_project_lst is needed for multi profile - print '[%s] bm_src_project_lst(%s)\n' % (__file__, bm_src_project_lst) + print 'bm_src_project_lst(%s)\n' % (bm_src_project_lst) for bm_src_project in bm_src_project_lst: - #print '[%s] bm_src_project(%s)\n' % (__file__, bm_src_project) - # get info_project_id -> get pre_build_project_id query = "SELECT id FROM info_project WHERE project_name = %s" query_data = (bm_src_project,) @@ -2356,27 +2266,26 @@ def sync_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s] info_project_id(%s), pre_build_project_id(%s)\n' \ - % (__file__, info_project_id, pre_build_project_id) + print 'info_project_id(%s), pre_build_project_id(%s)\n' \ + % (info_project_id, pre_build_project_id) # defensive code for the duplicated build_project_id if pre_build_project_id == INVALID_ID: - print '[%s] cannot find build_project_id!! Adding NOW!!\n' % (__file__) + print 'cannot find build_project_id!! Adding NOW!!\n' query = "INSERT INTO build_project (info_project_id, status) VALUES(%s, %s)" query_data = (info_project_id, 'C') buildmonitor_db.do_query(query, query_data) query = "SELECT id FROM build_project WHERE info_project_id = %s" query_data = (info_project_id,) pre_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - print '[%s][After] info_project_id(%s), pre_build_project_id(%s)\n' \ - % (__file__, info_project_id, pre_build_project_id) + print '[After] info_project_id(%s), pre_build_project_id(%s)\n' \ + % (info_project_id, pre_build_project_id) # get sr_status_detail_id for checking group submit query = "SELECT id FROM sr_status_detail WHERE sr_status_id = %s " \ "AND pre_build_project_id = %s" query_data = (curr_sr_status_id, pre_build_project_id) sr_status_detail_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] sr_status_detail_id(%s)\n' % (__file__, sr_status_detail_id) if sr_status_detail_id == INVALID_ID: # get pre_build_project_id @@ -2399,8 +2308,8 @@ def sync_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, pre_build_project_id) else: # clear the existing tables (sr_stage & build_snapshot) - print '[%s] Already existing sr_status_id(%s)!! clear the related tables\n' \ - % (__file__, sr_status_detail_id) + print 'Already existing sr_status_id(%s)!! clear the related tables\n' \ + % (sr_status_detail_id) query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND build_project_id = %s" query_data = (curr_sr_status_id, pre_build_project_id) buildmonitor_db.do_query(query, query_data) @@ -2487,8 +2396,8 @@ def main(): if trigger_info_data: content = trigger_info(trigger_info_data) else: - print '[%s] trigger_info_data is empty!!(%s)\n' \ - % (__file__, trigger_info_data) + print 'trigger_info_data is empty!!(%s)\n' \ + % (trigger_info_data) return 1 bm_stage = content.get("bm_stage") @@ -2496,7 +2405,7 @@ def main(): #======================================================= # Add_Tag if bm_stage == "Add_Tag": - print '[%s][Add_Tag]\n' % (__file__) + print '[Add_Tag]\n' sr_submit_log_id = content.get("sr_submit_log_id") sr_tag = content.get("sr_tag") status = content.get("status") @@ -2507,7 +2416,7 @@ def main(): #======================================================= # Submit elif bm_stage == 'Submit' or bm_stage == '[TRBS]_Submit': - print '[%s][Submit]\n' % (__file__) + print '[Submit]\n' # get vars commit_date = transform_date(content.get("commit_date")) @@ -2526,14 +2435,6 @@ def main(): #bm_src_project_lst = get_src_proj_lst(content.get("bm_src_project_lst")) bm_src_project_lst = content.get("bm_src_project_lst") - ''' - # empty check - if not bm_src_project_lst: - print '[%s] bm_src_project_lst is empty, skip Submit stage!!\n' \ - % (__file__) - return - ''' - # func call ### sr_status -> sr_commit -> sr_stage & sr_status_detail sr_submit_for_sr_status(git_tag) @@ -2542,13 +2443,13 @@ def main(): gerrit_newrev, gerrit_account_name, obs_package_name, status) if bm_stage == 'Submit': - print '[%s][Submit]\n' % (__file__) + print '[Submit]\n' package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, bm_src_project_lst) # [17_0110] TRBS if bm_stage == '[TRBS]_Submit': - print '[%s][[TRBS]_Submit]\n' % (__file__) + print '[[TRBS]_Submit]\n' TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime, bm_end_datetime, bm_src_project_lst) @@ -2565,7 +2466,7 @@ def main(): #======================================================= # Sync_SR_Submit elif bm_stage == 'Sync_SR_Submit': - print '[%s][Sync_SR_Submit]\n' % (__file__) + print '[Sync_SR_Submit]\n' # get vars commit_date = transform_date(content.get("commit_date")) @@ -2638,7 +2539,7 @@ def main(): #======================================================= # [PRE] Snap elif bm_stage == 'Pre_Snap_Start' or bm_stage == '[TRBS]_Pre_Snap_Start': - print '[%s][Pre_Snap_Start]\n' % (__file__) + print '[Pre_Snap_Start]\n' # get vars project = content.get("project") @@ -2650,12 +2551,12 @@ def main(): # func call if bm_stage == 'Pre_Snap_Start': - print '[%s][Pre_Snap_Start]\n' % (__file__) + print '[Pre_Snap_Start]\n' start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bBuildFail, BuildFailReason) # [17_0110] TRBS if bm_stage == '[TRBS]_Pre_Snap_Start': - print '[%s][[TRBS]_Pre_Snap_Start]\n' % (__file__) + print '[[TRBS]_Pre_Snap_Start]\n' TRBS_start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bBuildFail) # if bBuildFail is True then skip Creating images @@ -2667,8 +2568,7 @@ def main(): if bm_stage == '[TRBS]_Pre_Snap_Start': TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime) else: - print '[%s] Build failed!! skip insert build_snapshot_id\n' \ - % (__file__) + print 'Build failed!! skip insert build_snapshot_id\n' update_unresolvable_broken_packages(project, unresolvable_broken_packages) @@ -2680,7 +2580,7 @@ def main(): bm_remote_jenkins_build_job(remote_data) elif bm_stage == 'Pre_Snap_End' or bm_stage == '[TRBS]_Pre_Snap_End': - print '[%s][Pre_Snap_End]\n' % (__file__) + print '[Pre_Snap_End]\n' # get vars project = content.get("project") @@ -2694,7 +2594,7 @@ def main(): # func call if bm_stage == 'Pre_Snap_End': - print '[%s][Pre_Snap_End]\n' % (__file__) + print '[Pre_Snap_End]\n' end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bm_end_datetime) @@ -2706,7 +2606,7 @@ def main(): # [17_0110] TRBS if bm_stage == '[TRBS]_Pre_Snap_End': - print '[%s][[TRBS]_Pre_Snap_End]\n' % (__file__) + print '[[TRBS]_Pre_Snap_End]\n' TRBS_end_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime, bm_end_datetime) @@ -2725,12 +2625,12 @@ def main(): if bm_spl_data in bm_snapshot_url: remote_data['bm_snapshot_url'] = bm_snapshot_url.split(bm_spl_data)[1] else: - print '[%s] check the bm_spl_data(%s)!!\n' \ - % (__file__, bm_spl_data) + print 'check the bm_spl_data(%s)!!\n' \ + % (bm_spl_data) bm_remote_jenkins_build_job(remote_data) elif bm_stage == 'Pre_Snap_packages' or bm_stage == '[TRBS]_Pre_Snap_packages': - print '[%s][Pre_Snap_packages]\n' % (__file__) + print '[Pre_Snap_packages]\n' # get vars project = content.get("project") @@ -2746,7 +2646,7 @@ def main(): # func call if bm_stage == 'Pre_Snap_packages': - print '[%s][Pre_Snap_packages]\n' % (__file__) + print '[Pre_Snap_packages]\n' create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arch, bm_pkg_url, bm_pkg_name_lst, @@ -2757,7 +2657,7 @@ def main(): BM_PKG_LIMIT) # [17_0110] TRBS if bm_stage == '[TRBS]_Pre_Snap_packages': - print '[%s][[TRBS]_Pre_Snap_packages]\n' % (__file__) + print '[[TRBS]_Pre_Snap_packages]\n' TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arch, bm_pkg_url, bm_pkg_name_lst, @@ -2776,12 +2676,12 @@ def main(): if bm_spl_data in bm_pkg_url: remote_data['bm_pkg_url'] = bm_pkg_url.split(bm_spl_data)[1] else: - print '[%s] check the bm_spl_data(%s)!!\n' \ - % (__file__, bm_spl_data) + print 'check the bm_spl_data(%s)!!\n' \ + % (bm_spl_data) bm_remote_jenkins_build_job(remote_data) elif bm_stage == 'Pre_Snap_Fail' or bm_stage == '[TRBS]_Pre_Snap_Fail': - print '[%s][Pre_Snap_Fail]\n' % (__file__) + print '[Pre_Snap_Fail]\n' # get vars project = content.get("project") @@ -2789,12 +2689,12 @@ def main(): # func call if bm_stage == 'Pre_Snap_Fail': - print '[%s][Pre_Snap_Fail]\n' % (__file__) + print '[Pre_Snap_Fail]\n' update_fail_status_for_sr_stage(project, bm_git_tag) # [17_0110] TRBS if bm_stage == '[TRBS]_Pre_Snap_Fail': - print '[%s][[TRBS]_Pre_Snap_Fail]\n' % (__file__) + print '[TRBS]_Pre_Snap_Fail]\n' TRBS_update_fail_status_for_sr_stage(project, bm_git_tag) # TRBS Sender mode @@ -2807,7 +2707,7 @@ def main(): #======================================================= # [PRE]/[POST] Image elif bm_stage == 'Image' or bm_stage == '[TRBS]_Image': - print '[%s][Image]\n' % (__file__) + print '[Image]\n' # get vars image_status = content.get("status") @@ -2816,20 +2716,18 @@ def main(): bm_end_datetime = content.get("bm_end_datetime") bm_snapshot_name = content.get("build_id") bm_img_size = content.get("bm_img_size") - #print '[%s] fields(%s), bm_start_datetime(%s), bm_snapshot_name(%s)\n' \ - # % (__file__, fields, bm_start_datetime, bm_snapshot_name) create_image_for_build_image(fields, bm_start_datetime, bm_end_datetime, bm_snapshot_name, bm_img_size) if image_status == 'failed': if bm_stage == 'Image': - print '[%s][Image]\n' % (__file__) + print '[Image]\n' update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot_name) # [17_0110] TRBS] if bm_stage == '[TRBS]_Image': - print '[%s][[TRBS]_Image]\n' % (__file__) + print '[[TRBS]_Image]\n' TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime) # TRBS Sender mode @@ -2846,7 +2744,7 @@ def main(): #======================================================= # [PRE]/[POST] Post_Image elif bm_stage == 'Post_Image' or bm_stage == '[TRBS]_Post_Image': - print '[%s][Post_Image]\n' % (__file__) + print '[Post_Image]\n' # get vars bm_start_datetime = content.get("bm_start_datetime") @@ -2854,13 +2752,13 @@ def main(): # func call if bm_stage == 'Post_Image': - print '[%s][Post_Image]\n' % (__file__) + print '[Post_Image]\n' bm_snapshot_name = content.get("bm_snapshot_name") end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name) # [17_0110] TRBS if bm_stage == '[TRBS]_Post_Image': - print '[%s][[TRBS]_Post_Image]\n' % (__file__) + print '[[TRBS]_Post_Image]\n' TRBS_end_create_image_for_sr_stage(bm_start_datetime, project) # TRBS Sender mode @@ -2873,7 +2771,7 @@ def main(): #======================================================= # SR Accept or Reject elif bm_stage == 'SR_Accept': - print '[%s][SR_Accept]\n' % (__file__) + print '[SR_Accept]\n' # get vars event_fields = content.get("event_fields") @@ -2889,7 +2787,7 @@ def main(): #======================================================= # [POST] Snap elif bm_stage == 'Post_Snap_Start': - print '[%s][Post_Snap_Start]\n' % (__file__) + print '[Post_Snap_Start]\n' # get vars project = content.get("project") @@ -2902,7 +2800,7 @@ def main(): update_unresolvable_broken_packages(project, unresolvable_broken_packages) elif bm_stage == 'Post_Snap_snapshot': - print '[%s][Post_Snap_snapshot]\n' % (__file__) + print '[Post_Snap_snapshot]\n' project = content.get("project") bm_snapshot_name = content.get("bm_snapshot_name") bm_start_datetime = content.get("bm_start_datetime") @@ -2910,7 +2808,7 @@ def main(): bm_snapshot_name, bm_start_datetime) elif bm_stage == 'Post_Snap_packages': - print '[%s][Post_Snap_packages]\n' % (__file__) + print '[Post_Snap_packages]\n' # get vars bm_snapshot_name = content.get("bm_snapshot_name") @@ -2930,7 +2828,7 @@ def main(): bm_pkg_mdate_lst, bm_pkg_size_lst) elif bm_stage == 'Post_Snap_End': - print '[%s][Post_Snap_End]\n' % (__file__) + print '[Post_Snap_End]\n' # get vars bm_start_datetime = content.get("bm_start_datetime") @@ -2955,12 +2853,12 @@ def main(): update_base_build_id(bm_snapshot_name, bm_base_build_id) elif bm_stage == 'Post_Snap_Fail': - print '[%s][Post_Snap_Fail]\n' % (__file__) + print '[Post_Snap_Fail]\n' bm_snapshot_name = content.get("bm_snapshot_name") update_fail_create_snapshot_for_sr_stage(bm_snapshot_name) elif bm_stage == 'Update_Manifest': - print '[%s][Update_Manifest]\n' % (__file__) + print '[Update_Manifest]\n' bm_snapshot_name = content.get("bm_snapshot_name") bm_start_datetime = content.get("bm_start_datetime") bm_snapshot_name = content.get("bm_snapshot_name") @@ -2969,7 +2867,7 @@ def main(): update_snapshot_manifest(bm_snapshot_name, bm_manifestdata, bm_start_datetime) elif bm_stage == 'REPA': - print '[%s][REPA]\n' % (__file__) + print '[REPA]\n' sr_tag = content.get("sr_tag") profile = content.get("profile") status = content.get("status") @@ -2978,7 +2876,7 @@ def main(): update_repa(sr_tag, profile, status, status_str) elif bm_stage == "UPDATE_BUILD_LOG": - print "[%s][UPDATE_BUILD_LOG]\n" % (__file__) + print "[UPDATE_BUILD_LOG]\n" update_build_log(content) # TRBS Sender mode -- 2.7.4