mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
temp json fole wrapper is safe
This commit is contained in:
parent
5a43242bda
commit
1568d40c98
1 changed files with 8 additions and 11 deletions
|
|
@ -87,28 +87,25 @@ def deprecated(new_destination):
|
|||
def _make_temp_json_file():
|
||||
"""Wrapping function for json temp file
|
||||
"""
|
||||
temporary_json_file = None
|
||||
try:
|
||||
# Store dumped json to temporary file
|
||||
temporary_json_file = tempfile.NamedTemporaryFile(
|
||||
with tempfile.NamedTemporaryFile(
|
||||
mode="w", suffix=".json", delete=False
|
||||
)
|
||||
temporary_json_file.close()
|
||||
temporary_json_filepath = temporary_json_file.name.replace(
|
||||
"\\", "/"
|
||||
)
|
||||
) as tmpfile:
|
||||
temporary_json_filepath = tmpfile.name.replace("\\", "/")
|
||||
|
||||
yield temporary_json_filepath
|
||||
|
||||
except IOError as _error:
|
||||
except IOError as exc:
|
||||
raise IOError(
|
||||
"Unable to create temp json file: {}".format(
|
||||
_error
|
||||
)
|
||||
"Unable to create temp json file: {}".format(exc)
|
||||
)
|
||||
|
||||
finally:
|
||||
# Remove the temporary json
|
||||
os.remove(temporary_json_filepath)
|
||||
if temporary_json_file is not None:
|
||||
os.remove(temporary_json_filepath)
|
||||
|
||||
|
||||
def get_ocio_config_script_path():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue