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
def get_user():
user = ''
if user == '':
try:
user = os.getlogin()
return os.getlogin()
except Exception:
pass
if user == '':
if 'USER' in os.environ:
return os.environ['USER']
if 'USERNAME' in os.environ:
return os.environ['USERNAME']
if sys.platform != 'win32':
try:
import pwd
user = pwd.getpwuid(os.getuid())[0]
return pwd.getpwuid(os.getuid())[0]
except Exception:
pass
return user
return ''
def get_gpu():