From: SungHun Hwang Date: Tue, 1 Aug 2017 23:53:44 +0000 (+0900) Subject: [BuildMonitor] Add submit_time data at [sr_status] table X-Git-Tag: submit/trunk/20190927.012743~358^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba15466642dfc60dc7caf39cf1e3f7f4c4abb8fb;p=services%2Fjenkins-scripts.git [BuildMonitor] Add submit_time data at [sr_status] table - Add submit_time data at [sr_status] table - import method changed (datetime.datetime -> datetime) Change-Id: Ia35351819841378f3cf66c56683bae8787a4c0a5 Signed-off-by: SungHun Hwang --- diff --git a/job_buildmonitor.py b/job_buildmonitor.py index 4072c03..62eaac8 100644 --- a/job_buildmonitor.py +++ b/job_buildmonitor.py @@ -42,11 +42,11 @@ TABLE : sr_status import os import sys -import datetime import json import base64 import re +from datetime import datetime from time import sleep from common import buildmonitor_db from common.buildtrigger import trigger_info, trigger_next, remote_jenkins_build_job @@ -163,8 +163,8 @@ def sr_submit_for_sr_status(bm_git_tag): #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) VALUES(%s, %s)" - query_data = (bm_git_tag, 'C') + 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' \ @@ -519,7 +519,7 @@ 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.datetime.fromtimestamp(each_pkg_mdate) + 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, @@ -607,7 +607,7 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot #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.datetime.now() + bm_end_datetime = datetime.now() bm_repo = fields["repo"] bm_device_name = fields["name"] @@ -708,7 +708,7 @@ def create_image_for_build_image(fields, bm_start_datetime, 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) - bm_end_datetime = datetime.datetime.now() + bm_end_datetime = datetime.now() if project.startswith("home:prerelease:") or project.startswith("home:trbs:"): bm_git_tag = project.split(":")[-3] + '/' + project.split(":")[-2] + '/' + project.split(":")[-1] @@ -1106,7 +1106,7 @@ def start_create_snapshot_for_sr_stage(project, bm_start_datetime): for each_sr_status_id in multi_sr_status_id: print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) info_stage_id = POST_BUILD - bm_end_datetime = datetime.datetime.now() + bm_end_datetime = datetime.now() query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \ "WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s" query_data = (bm_end_datetime, 'S', @@ -1195,7 +1195,7 @@ def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, 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.datetime.fromtimestamp(each_pkg_mdate) + 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) @@ -1698,7 +1698,7 @@ 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.datetime.fromtimestamp(each_pkg_mdate) + 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, @@ -1776,7 +1776,7 @@ def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime): #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.datetime.now() + bm_end_datetime = datetime.now() bm_repo = fields["repo"] bm_device_name = fields["name"] @@ -1827,7 +1827,7 @@ 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) if project.startswith("home:prerelease:") or project.startswith("home:trbs:"): - bm_end_datetime = datetime.datetime.now() + bm_end_datetime = datetime.now() bm_git_tag = project.split(":")[-3] + '/' + project.split(":")[-2] + '/' + project.split(":")[-1] #print '[%s] bm_git_tag(%s)\n' % (__file__, bm_git_tag)