Skip to content
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
3 changes: 2 additions & 1 deletion src/ansys/dynamicreporting/core/utils/filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Modules
# ------------------------------------------------
import functools
import getpass
import logging
import os
import threading
Expand Down Expand Up @@ -473,7 +474,7 @@ def nexus_file_lock(filename: str) -> BaseFileLock:
# We will consider two pathnames:
# 1) the original pathname
# 2) replace the original filename directory with tempfile.gettempdir()
base_filename = os.path.basename(filename) + "." + os.getlogin()
base_filename = os.path.basename(filename) + "." + getpass.getuser()
lcl_filename = os.path.join(tempfile.gettempdir(), base_filename)

# if we are on Linux and the target filename is on an NFS drive
Expand Down
17 changes: 8 additions & 9 deletions tests/test_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ def test_soft(request) -> None:
def test_nexus_filelock(request) -> None:
test_path = join(request.fspath.dirname, "test_data")
tmp_file = join(test_path, "n_lock.txt")
try:
success = type(fl.nexus_file_lock(filename=tmp_file)) is fl.FileLock
except OSError: # Error due to not being able to get os.getlogin() on the machine
success = True
else:
success = False
if "win" in platform.system().lower():
success = True
assert success

lock = fl.nexus_file_lock(filename=tmp_file)

# Debug info
print("Resolved lock type:", type(lock))
print("Expected FileLock type:", fl.FileLock)

assert isinstance(lock, fl.FileLock)