From 8968e9be568240ab2ac3ce2e36ea7114cb750ba7 Mon Sep 17 00:00:00 2001 From: xwjiang-ms <96218837+xwjiang-ms@users.noreply.github.com> Date: Sun, 4 Feb 2024 09:53:09 +0800 Subject: [PATCH] Fix invalid syntax in log analyzer (#11558) What is the motivation for this PR? when running testcase with log analyzer, would get error: E File "/data/sonic-mgmt-int/tests/common/plugins/loganalyzer/loganalyzer.py", line 167 E file_path = os.path.join(tmp_folder, f"log_error_{self.marker_prefix}_{cur_time}.json") E ^ E SyntaxError: invalid syntax How did you do it? use .format() instead of f"" --- tests/common/plugins/loganalyzer/loganalyzer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common/plugins/loganalyzer/loganalyzer.py b/tests/common/plugins/loganalyzer/loganalyzer.py index a44e397fa97..8632fe7b182 100644 --- a/tests/common/plugins/loganalyzer/loganalyzer.py +++ b/tests/common/plugins/loganalyzer/loganalyzer.py @@ -164,7 +164,7 @@ def save_matching_errors(self, result_log_errors): tmp_folder = "/tmp/loganalyzer/{}".format(self.ansible_host.hostname) os.makedirs(tmp_folder, exist_ok=True) cur_time = time.strftime("%d_%m_%Y_%H_%M_%S", time.gmtime()) - file_path = os.path.join(tmp_folder, f"log_error_{self.marker_prefix}_{cur_time}.json") + file_path = os.path.join(tmp_folder, "log_error_{}_{}.json".format(self.marker_prefix, cur_time)) logging.info("Log errors will be saved in file: {}".format(file_path)) data = {'log_errors': log_errors} with open(file_path, "w+") as file: