diff --git a/src/tools.py b/src/tools.py index ae8da822c460f15e3a009ec56ebe475b4bc87c9b..b8a4c0b3258ac08672318244108fdd8e90cf53d7 100644 --- a/src/tools.py +++ b/src/tools.py @@ -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"