From 6004b6e8320d7876af7818dd4c59bbd4cb3dff9d Mon Sep 17 00:00:00 2001 From: fazledyn-or Date: Mon, 13 Nov 2023 15:52:03 +0600 Subject: [PATCH 1/2] Replaced `mktemp` with `mkstemp` Signed-off-by: fazledyn-or --- .../preprocessing/deepinterpolation/generators.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/spikeinterface/preprocessing/deepinterpolation/generators.py b/src/spikeinterface/preprocessing/deepinterpolation/generators.py index 8200340ac1..d63080be41 100644 --- a/src/spikeinterface/preprocessing/deepinterpolation/generators.py +++ b/src/spikeinterface/preprocessing/deepinterpolation/generators.py @@ -3,6 +3,7 @@ import json from typing import Optional import numpy as np +import os from ...core import load_extractor, concatenate_recordings, BaseRecording, BaseRecordingSegment @@ -85,7 +86,8 @@ def __init__( sequential_generator_params["total_samples"] = self.total_samples sequential_generator_params["pre_post_omission"] = pre_post_omission - json_path = tempfile.mktemp(suffix=".json") + json_fd, json_path = tempfile.mkstemp(suffix=".json") + os.close(json_fd) with open(json_path, "w") as f: json.dump(sequential_generator_params, f) super().__init__(json_path) @@ -243,7 +245,8 @@ def __init__( sequential_generator_params["total_samples"] = self.total_samples sequential_generator_params["pre_post_omission"] = pre_post_omission - json_path = tempfile.mktemp(suffix=".json") + json_fd, json_path = tempfile.mkstemp(suffix=".json") + os.close(json_fd) with open(json_path, "w") as f: json.dump(sequential_generator_params, f) super().__init__(json_path) From 398581d758d0d177d4389810927288039dca8cab Mon Sep 17 00:00:00 2001 From: fazledyn-or Date: Mon, 13 Nov 2023 15:52:14 +0600 Subject: [PATCH 2/2] Closed file-descriptor from `mkstemp` Signed-off-by: fazledyn-or --- src/spikeinterface/extractors/mdaextractors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/spikeinterface/extractors/mdaextractors.py b/src/spikeinterface/extractors/mdaextractors.py index 229e3ef0d0..fb1ee60a99 100644 --- a/src/spikeinterface/extractors/mdaextractors.py +++ b/src/spikeinterface/extractors/mdaextractors.py @@ -449,6 +449,7 @@ def _download_bytes_to_tmpfile(url, start, end): headers = {"Range": "bytes={}-{}".format(start, end - 1)} r = requests.get(url, headers=headers, stream=True) fd, tmp_fname = tempfile.mkstemp() + os.close(fd) with open(tmp_fname, "wb") as f: for chunk in r.iter_content(chunk_size=1024): if chunk: