use log.info instead of print. 18/319118/1
authorxuhy <huayong.xu@samsung.com>
Tue, 15 Oct 2024 10:54:52 +0000 (18:54 +0800)
committerxuhy <huayong.xu@samsung.com>
Tue, 15 Oct 2024 10:54:52 +0000 (18:54 +0800)
Change-Id: I7036b1bc5afc4e8191c20f3e3fe60c7ac9887648

gitbuildsys/cmd_qbbuild.py

index e06f97a198264b1049f36ff8d253fbf26c558745..8727546f10a9544aefb720afa3b6c08dc904b82c 100644 (file)
@@ -4,6 +4,7 @@
 
 from gitbuildsys import utils
 from gitbuildsys.conf import configmgr
+from gitbuildsys.log import LOGGER as log
 
 import os
 import re
@@ -43,12 +44,12 @@ BUILD_REQUEST_XML_TEMPLATE = '''<?xml version='1.0' encoding='UTF-8'?>
 def trigger_qb(session, url, file_path):
     """request qb to build"""
     req_url = "%s/rest/build_requests" % (url)
-    print("url: %s." % req_url)
+    log.info("url: %s." % req_url)
     with open(file_path, 'rb') as fobj:
         resp = session.post(req_url, data=fobj)
 
     conv_text = resp.text
-    print("build info: ", conv_text.strip())
+    log.info("build info: ", conv_text.strip())
 
 
 def request_build(session, url, conf_path, txt_file):
@@ -56,11 +57,11 @@ def request_build(session, url, conf_path, txt_file):
     # query configuration id from qb server.
     full_url = "%s/rest/ids?configuration_path=%s" % (url, conf_path)
     resp = session.get(full_url, verify=False)
-    print("response: ", resp.text)
+    log.info("response: ", resp.text)
 
     # replace configuration id in template.
     replaced = re.sub("{{configurationId}}", resp.text.strip(), BUILD_REQUEST_XML_TEMPLATE)
-    print("replaced: ", replaced)
+    log.info("replaced: ", replaced)
 
     # read commit id list.
     commit_id_list = ""
@@ -72,11 +73,11 @@ def request_build(session, url, conf_path, txt_file):
 
     # replace commit id list in template.
     replaced = re.sub("{{commitIdList}}", commit_id_list, replaced)
-    print("replaced: ", replaced)
+    log.info("replaced: ", replaced)
 
     # create a tmp dir.
     tmp = utils.Temp(prefix='gbs_', dirn=configmgr.get('tmpdir', 'general'), directory=True)
-    print("temp dir: ", tmp.path)
+    log.info("temp dir: ", tmp.path)
 
     # write build request into an xml.
     xml_file = tmp.path + '/gbs_buldrequest.xml'
@@ -89,14 +90,14 @@ def request_build(session, url, conf_path, txt_file):
 
 def main(args):
     """The main body"""
-    print(args.qb_account_conf)
-    print(args.qb_conf_path)
-    print(args.commit_id_file)
+    log.info(args.qb_account_conf)
+    log.info(args.qb_conf_path)
+    log.info(args.commit_id_file)
 
     conf_path = args.qb_account_conf
     if (not os.path.isabs(conf_path)):
         conf_path = os.path.abspath(os.path.expanduser(conf_path))
-    print(conf_path)
+    log.info(conf_path)
     with open(conf_path, 'r') as file:
         lines = file.readlines()
 
@@ -108,7 +109,7 @@ def main(args):
         key, value = line.split('=', 1)
         value = value.strip().strip('\'"')
         config[key] = value
-    print(config)
+    log.info(config)
 
     session = requests.Session()
     session.auth = (config['user'], config['passwd'])
@@ -116,6 +117,6 @@ def main(args):
     txt_path = args.commit_id_file
     if (not os.path.isabs(txt_path)):
         txt_path = os.path.abspath(os.path.expanduser(txt_path))
-    print(txt_path)
+    log.info(txt_path)
 
     request_build(session, config['url'], args.qb_conf_path, txt_path)