Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix improper method call mktemp #2195

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/spikeinterface/extractors/mdaextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down