Commit d158c8ad authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Windows: Fix 'pwd' import.

No related merge requests found
Pipeline #54428 passed with stages
in 7 minutes and 46 seconds
Showing with 8 additions and 2 deletions
+8 -2
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import pwd
import time import time
import logging import logging
import traceback import traceback
...@@ -33,6 +32,13 @@ from functools import ( ...@@ -33,6 +32,13 @@ from functools import (
reduce, partial, wraps reduce, partial, wraps
) )
try:
import pwd
with_pwd = True
except Exception as e:
print("Module 'pwd' is not available")
with_pwd = False
########### ###########
# LOGGING # # LOGGING #
########### ###########
...@@ -273,7 +279,7 @@ def timestamp_to_old_pamhyr_date(time: int): ...@@ -273,7 +279,7 @@ def timestamp_to_old_pamhyr_date(time: int):
def get_user_name(): def get_user_name():
if posix: if with_pwd:
return pwd.getpwuid(os.getuid()).pw_gecos return pwd.getpwuid(os.getuid()).pw_gecos
else: else:
return "Me" return "Me"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment