diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index f16992d31ef71784fb8d5ddc5166e45436f79df1..3f6022af9b2aef73530d183b9580ceeebc396efe 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -18,6 +18,7 @@ import sys import subprocess import time import types +import psutil from io import StringIO from typing import Union, Any @@ -505,6 +506,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 @@ -519,7 +523,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: @@ -531,7 +536,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: