From 8bdadcf92f0449f37cb229c149f63ff87a080597 Mon Sep 17 00:00:00 2001 From: huyunhui Date: Tue, 25 Jul 2023 12:00:14 +0800 Subject: [PATCH] fixup warnings Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I7NQ16 Signed-off-by: huyunhui --- test/scripts/auto_xts_test/get_resource/get_tool.py | 7 +++---- test/scripts/auto_xts_test/get_resource/spider.py | 5 ++--- test/scripts/auto_xts_test/get_result.py | 8 ++++---- test/scripts/performance_test/performance_build.py | 5 ++--- test/scripts/send_email.py | 6 +++--- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/test/scripts/auto_xts_test/get_resource/get_tool.py b/test/scripts/auto_xts_test/get_resource/get_tool.py index b1af7a061c..02c781bde7 100755 --- a/test/scripts/auto_xts_test/get_resource/get_tool.py +++ b/test/scripts/auto_xts_test/get_resource/get_tool.py @@ -47,7 +47,6 @@ def get_tool(url): if __name__ == "__main__": - yl = open(r".\get_resource\config.yaml", 'r') - data = yaml.safe_load(yl.read()) - get_tool(data['url_tools']) - yl.close() \ No newline at end of file + with open(r".\get_resource\config.yaml", 'r') as config_file: + data = yaml.safe_load(config_file.read()) + get_tool(data['url_tools']) \ No newline at end of file diff --git a/test/scripts/auto_xts_test/get_resource/spider.py b/test/scripts/auto_xts_test/get_resource/spider.py index 24f1882e49..2c06247719 100755 --- a/test/scripts/auto_xts_test/get_resource/spider.py +++ b/test/scripts/auto_xts_test/get_resource/spider.py @@ -70,10 +70,9 @@ def change_port(xml_path, xml_dw="./environment/device/port"): if __name__ == '__main__': - yl = open(r".\get_resource\config.yaml", 'r') - data = yaml.safe_load(yl.read()) + with open(r".\get_resource\config.yaml", 'r') as config_file: + data = yaml.safe_load(config_file.read()) dest_url = get_url(data['url_dailybuilds'], data['headers'], data['data'], data['url_dayu200']) get_images_and_testcases(dest_url, data['path_xts_pack'], data['path_xts_dir']) change_port(data['path_configfile']) - yl.close() \ No newline at end of file diff --git a/test/scripts/auto_xts_test/get_result.py b/test/scripts/auto_xts_test/get_result.py index 992731af24..4f3510ba24 100755 --- a/test/scripts/auto_xts_test/get_result.py +++ b/test/scripts/auto_xts_test/get_result.py @@ -21,12 +21,12 @@ import shutil import yaml if __name__ == "__main__": - yl = open(r".\get_resource\config.yaml", 'r') - data = yaml.safe_load(yl.read()) + with open(r".\get_resource\config.yaml", 'r') as f: + data = yaml.safe_load(f.read()) + path = data['path_xts_report'] - yl.close() file_list = os.listdir(path) - + summary_report = os.path.join(path, file_list[-1], "summary_report.html") if (os.path.exists(summary_report)): shutil.copy2(summary_report, "result\\") diff --git a/test/scripts/performance_test/performance_build.py b/test/scripts/performance_test/performance_build.py index a4d7572c56..94af3edf82 100644 --- a/test/scripts/performance_test/performance_build.py +++ b/test/scripts/performance_test/performance_build.py @@ -215,9 +215,8 @@ class PerformanceBuild(): if self.developing_test_mode: content = self.developing_test_data.split("\t") else: - src = open(self.config.temp_filename, "r", encoding='UTF-8') - content = src.read().split("\t") - src.close() + with open(self.config.temp_filename, "r", encoding='UTF-8') as src: + content = src.read().split("\t") clean_filter = False for task_build_time_str in content: if len(task_build_time_str) == 0: diff --git a/test/scripts/send_email.py b/test/scripts/send_email.py index 27243c19e4..07f7030f06 100755 --- a/test/scripts/send_email.py +++ b/test/scripts/send_email.py @@ -55,8 +55,9 @@ def add_image(msg, img_dic): def send_email(): - yl = open(r".\email_config.yaml", 'r') - data = yaml.safe_load(yl.read()) + with open(r".\email_config.yaml", 'r') as f: + data = yaml.safe_load(f.read()) + user_name = data["user_name"] sender = data["sender_email_address"] auth_code = data["auth_code"] @@ -68,7 +69,6 @@ def send_email(): perf_test = data["perf_report_file"] attachment_files = data["attatchment_files"] image_files = data["image_files"] - yl.close() msg = MIMEMultipart() msg['From'] = sender -- Gitee