cross-platform getuser

Signed-off-by: vladmandic <mandic00@live.com>
pull/59/head
vladmandic 2025-11-17 20:06:09 -05:00
parent 90abd719f5
commit 5c74458e2c
1 changed files with 11 additions and 9 deletions

View File

@ -56,19 +56,21 @@ bench_data = []
### system info module ### system info module
def get_user(): def get_user():
user = '' try:
if user == '': return os.getlogin()
try: except Exception:
user = os.getlogin() pass
except Exception: if 'USER' in os.environ:
pass return os.environ['USER']
if user == '': if 'USERNAME' in os.environ:
return os.environ['USERNAME']
if sys.platform != 'win32':
try: try:
import pwd import pwd
user = pwd.getpwuid(os.getuid())[0] return pwd.getpwuid(os.getuid())[0]
except Exception: except Exception:
pass pass
return user return ''
def get_gpu(): def get_gpu():