mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Windows: Fix 'pwd' import.
This commit is contained in:
1 parent
8c9eeb6160
commit
d158c8ad7a
1 file changed
+8
-2
+8
-2
@@ -17,7 +17,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import pwd
|
||||
import time
|
||||
import logging
|
||||
import traceback
|
||||
@@ -33,6 +32,13 @@ from functools import (
|
||||
reduce, partial, wraps
|
||||
)
|
||||
|
||||
try:
|
||||
import pwd
|
||||
with_pwd = True
|
||||
except Exception as e:
|
||||
print("Module 'pwd' is not available")
|
||||
with_pwd = False
|
||||
|
||||
###########
|
||||
# LOGGING #
|
||||
###########
|
||||
@@ -273,7 +279,7 @@ def timestamp_to_old_pamhyr_date(time: int):
|
||||
|
||||
|
||||
def get_user_name():
|
||||
if posix:
|
||||
if with_pwd:
|
||||
return pwd.getpwuid(os.getuid()).pw_gecos
|
||||
else:
|
||||
return "Me"
|
||||
|
||||
Reference in new issue
Block a user