diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index a19d62a524573455ae999372aaa806c3a15b5131..f7e4532b73130630798e868a4e0f5643901c1c7f 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -19,7 +19,7 @@ import subprocess import time import types import resource - +import psutil from io import StringIO from typing import Union, Any @@ -537,6 +537,9 @@ def remove_file(file: str, verbosity: int = 0) -> None: ) +def get_username(): + return psutil.Process().username() + def temp_dir(*args: str) -> str: """ Function to create directory within the TMP directory of the file system @@ -551,7 +554,8 @@ def temp_dir(*args: str) -> str: """ tmp_dir = tempfile.gettempdir() - path = os.path.join(tmp_dir, "binary_c_python") + username = get_username() + path = os.path.join(tmp_dir, "binary_c_python-{}".format(username)) # loop over the other paths if there are any: if args: @@ -563,7 +567,6 @@ def temp_dir(*args: str) -> str: return path - def create_hdf5(data_dir: str, name: str) -> None: """ Function to create an hdf5 file from the contents of a directory: