Skip to content

Commit

Permalink
Fix invalid syntax in log analyzer (sonic-net#11558)
Browse files Browse the repository at this point in the history
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""
  • Loading branch information
xwjiang-ms authored Feb 4, 2024
1 parent 15cb803 commit 8968e9b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/common/plugins/loganalyzer/loganalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8968e9b

Please sign in to comment.