From dd99371dc9c33c4a2e7393c2be81be99538e6e4b Mon Sep 17 00:00:00 2001 From: Mario Ostieri Date: Fri, 3 Oct 2025 09:57:22 +0100 Subject: [PATCH 1/3] replace offending os.getlogin call with getpass.getuser --- src/ansys/dynamicreporting/core/utils/filelock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ansys/dynamicreporting/core/utils/filelock.py b/src/ansys/dynamicreporting/core/utils/filelock.py index f5d54ed24..7fe8a17f4 100644 --- a/src/ansys/dynamicreporting/core/utils/filelock.py +++ b/src/ansys/dynamicreporting/core/utils/filelock.py @@ -30,6 +30,7 @@ # Modules # ------------------------------------------------ import functools +import getpass import logging import os import threading @@ -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 From c963a2350b20e000bca625c6fad5dcb4c232431c Mon Sep 17 00:00:00 2001 From: Mario Ostieri Date: Fri, 3 Oct 2025 10:47:29 +0100 Subject: [PATCH 2/3] attempt test filelock change --- tests/test_filelock.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_filelock.py b/tests/test_filelock.py index 8a6207e4c..5243ebe22 100755 --- a/tests/test_filelock.py +++ b/tests/test_filelock.py @@ -111,12 +111,12 @@ 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) + From 96b45fd05969ec589d1d7a29c497892548ca61f6 Mon Sep 17 00:00:00 2001 From: Mario Ostieri Date: Fri, 3 Oct 2025 10:57:26 +0100 Subject: [PATCH 3/3] code style fixes --- tests/test_filelock.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_filelock.py b/tests/test_filelock.py index 5243ebe22..e552081ed 100755 --- a/tests/test_filelock.py +++ b/tests/test_filelock.py @@ -111,7 +111,7 @@ 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") - + lock = fl.nexus_file_lock(filename=tmp_file) # Debug info @@ -119,4 +119,3 @@ def test_nexus_filelock(request) -> None: print("Expected FileLock type:", fl.FileLock) assert isinstance(lock, fl.FileLock) -