Skip to content
Snippets Groups Projects
Commit d411a33b authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Use NamedTemporaryFile instead of mkstemp.

parent eb34a9c3
Branches
Tags
1 merge request!1Rewrite devkit service in python.
......@@ -62,15 +62,11 @@ def write_file(data: bytes) -> str:
Return the empty string if unable to open temp file for some reason
"""
# Get 1 from the resulting tuple, since that's the filename
filename = tempfile.mkstemp(prefix="devkit-", dir="/tmp/", text=True)[1]
# Then open ourselves
with open(filename, "w", encoding='utf-8') as file:
with tempfile.NamedTemporaryFile(mode='w', prefix='devkit-1', encoding='utf-8',
delete=False) as file:
file.write(data.decode())
file.close()
return filename
return file.name
return ''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment