From d919a4803c4bea870fd4f34f7cabe337edf6c3a3 Mon Sep 17 00:00:00 2001 From: SungHun Hwang Date: Mon, 27 Feb 2017 16:59:03 +0900 Subject: [PATCH] [BuildMonitor] fix to get the right bm_img_path when there are various img file formats fix to get the right bm_img_path from 'manifest.json' file when there are various img file formats mic support various image file formats (*.tar.gz, *.bz2, etc) some images in common profile are created by *.bz2 Change-Id: Id9506867062b418a61591e6b0556b361821fd2ac Signed-off-by: SungHun Hwang --- job_imager.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/job_imager.py b/job_imager.py index 63570a7..c1481cb 100755 --- a/job_imager.py +++ b/job_imager.py @@ -340,10 +340,27 @@ def main(): if buildmonitor_enabled: bm_img_url = os.path.join(sync_src, fields['images_path']) - bm_img_path = bm_img_url + '/' + build_id + '_' + fields['name'] + '.tar.gz' - bm_img_size = os.path.getsize(bm_img_path) - #print '[%s] bm_img_path(%s), bm_img_size(%s)\n' \ - # % (__file__, bm_img_path, bm_img_size) + + # get bm_img_name from 'manifest.json' file + search_name = 'image_files' + manifest_name = 'manifest.json' + bm_manifest_path = os.path.join(bm_img_url, manifest_name) + with open(bm_manifest_path,'r') as f: + bm_dict = eval(f.read()) + for key, val in bm_dict.iteritems(): + if isinstance(val, dict) and val.has_key(search_name): + bm_img_name = val.get(search_name)[0] + + bm_img_path = os.path.join(bm_img_url, bm_img_name) + print '[%s] bm_img_path(%s))\n' % (__file__, bm_img_path) + + if os.path.isfile(bm_img_path): + bm_img_size = os.path.getsize(bm_img_path) + #print '[%s] bm_img_path(%s), bm_img_size(%s)\n' \ + # % (__file__, bm_img_path, bm_img_size) + else: + print '[%s] %s does not exist!!\n' % (__file__, bm_img_path) + bm_img_size = 0 bm_end_datetime = datetime.datetime.now() bm_stage = 'Image' -- 2.7.4