From d348da42fc35657e5673610284d691230e7de3e3 Mon Sep 17 00:00:00 2001 From: Simon Fonteneau Date: Tue, 3 Sep 2024 22:13:50 +0200 Subject: [PATCH] add create_directory_service in try --- gapslib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gapslib.py b/gapslib.py index 6dd5ca4..9a746e3 100644 --- a/gapslib.py +++ b/gapslib.py @@ -43,6 +43,9 @@ config = configparser.ConfigParser() config.read('/etc/gaps/gaps.conf') +logger.setLevel(logging.INFO) +logger.addHandler(logging.StreamHandler()) + logfile = config.get('common', 'logfile') fhandler = logging.FileHandler(logfile) logger.addHandler(fhandler) @@ -89,7 +92,11 @@ def create_directory_service(user_email): def update_password(mail, pwd, sha1hashnt): # Create a new service object - service = create_directory_service(config.get('google', 'admin_email')) + try: + service = create_directory_service(config.get('google', 'admin_email')) + except: + logger.error(json.dumps({'status':"error",'msg':str(e),'timestamp': str(datetime.datetime.utcnow())})) + return try: user = service.users().get(userKey = mail).execute()