Skip to content

Commit fd28f68

Browse files
committed
Test 7
1 parent 4933cea commit fd28f68

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/xtl/common/os.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ def get_os_name_and_version() -> str:
2424
return f'{platform.system()} {platform.version()}'
2525

2626

27+
def get_username() -> str:
28+
try:
29+
return os.getlogin()
30+
except OSError:
31+
# Fallback for CI/CD environments where `os.getlogin()` fails
32+
import getpass
33+
return getpass.getuser()
34+
35+
36+
2737
class FileType(StrEnum):
2838
"""
2939
POSIX file type representation.

src/xtl/diffraction/automate/autoproc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from xtl.automate.shells import Shell, BashShell
1717
from xtl.automate.sites import ComputeSite
1818
from xtl.automate.jobs import Job, limited_concurrency
19-
from xtl.common.os import get_os_name_and_version, chmod_recursively
19+
from xtl.common.os import get_os_name_and_version, chmod_recursively, get_username
2020
from xtl.diffraction.images.datasets import DiffractionDataset
2121
from xtl.diffraction.automate.autoproc_utils import AutoPROCConfig, AutoPROCJobResults
2222
from xtl.exceptions.utils import Catcher
@@ -259,7 +259,7 @@ def _get_macro_content(self) -> str:
259259
content = [
260260
f'# autoPROC macro file',
261261
f'# Generated by xtl v.{__version__} on {datetime.now().isoformat()}',
262-
f'# {os.getlogin()}@{platform.node()} [{get_os_name_and_version()}]',
262+
f'# {get_username()}@{platform.node()} [{get_os_name_and_version()}]',
263263
f''
264264
]
265265

@@ -664,7 +664,7 @@ def _get_macro_content(self) -> str:
664664
content = [
665665
f'# aP_wf_process macro file',
666666
f'# Generated by xtl v.{__version__} on {datetime.now().isoformat()}',
667-
f'# {os.getlogin()}@{platform.node()} [{get_os_name_and_version()}]',
667+
f'# {get_username()}@{platform.node()} [{get_os_name_and_version()}]',
668668
f''
669669
]
670670

0 commit comments

Comments
 (0)