From 494b7bae12a12e461b0f22380feef96b41401bbb Mon Sep 17 00:00:00 2001 From: fazledyn-or Date: Wed, 8 Nov 2023 18:19:48 +0600 Subject: [PATCH 1/2] Replaced `mktemp` with `mkstemp` Signed-off-by: fazledyn-or --- report_py3o/models/py3o_report.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index 3aa2d3480..5dc5bd8c0 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -309,7 +309,8 @@ class Py3oReport(models.TransientModel): attachment = existing_reports_attachment.get(model_instance.id) if attachment and self.ir_actions_report_id.attachment_use: content = base64.b64decode(attachment.datas) - report_file = tempfile.mktemp("." + self.ir_actions_report_id.py3o_filetype) + fd, report_file = tempfile.mkstemp("." + self.ir_actions_report_id.py3o_filetype) + os.close(fd) with open(report_file, "wb") as f: f.write(content) return report_file @@ -318,7 +319,8 @@ class Py3oReport(models.TransientModel): def _zip_results(self, reports_path): self.ensure_one() zfname_prefix = self.ir_actions_report_id.name - result_path = tempfile.mktemp(suffix="zip", prefix="py3o-zip-result") + fd, result_path = tempfile.mkstemp(suffix="zip", prefix="py3o-zip-result") + os.close(fd) with ZipFile(result_path, "w", ZIP_DEFLATED) as zf: cpt = 0 for report in reports_path: From 1e86acae8b7727d469981b3e872c9aefc95f1fc9 Mon Sep 17 00:00:00 2001 From: fazledyn-or Date: Thu, 9 Nov 2023 10:48:54 +0600 Subject: [PATCH 2/2] Reformatted using pre-commit Signed-off-by: fazledyn-or --- report_py3o/models/py3o_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/report_py3o/models/py3o_report.py b/report_py3o/models/py3o_report.py index 5dc5bd8c0..6879fe681 100644 --- a/report_py3o/models/py3o_report.py +++ b/report_py3o/models/py3o_report.py @@ -309,7 +309,9 @@ class Py3oReport(models.TransientModel): attachment = existing_reports_attachment.get(model_instance.id) if attachment and self.ir_actions_report_id.attachment_use: content = base64.b64decode(attachment.datas) - fd, report_file = tempfile.mkstemp("." + self.ir_actions_report_id.py3o_filetype) + fd, report_file = tempfile.mkstemp( + "." + self.ir_actions_report_id.py3o_filetype + ) os.close(fd) with open(report_file, "wb") as f: f.write(content)