From d6894a0d1a922487c88028cc8291e7e090cf3472 Mon Sep 17 00:00:00 2001
From: Patrick Cernko <pcernko@mpi-klsb.mpg.de>
Date: Tue, 30 Jan 2024 11:20:19 +0100
Subject: [PATCH] do not fail but warn if mpildap module is not installed

---
 gen_config.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gen_config.py b/gen_config.py
index c3ff0a2..70586e0 100755
--- a/gen_config.py
+++ b/gen_config.py
@@ -6,7 +6,6 @@ import sys
 import argparse
 import xml.etree.ElementTree as ET
 import json
-import mpildap
 
 def err(msg):
     print('ERROR: '+msg, file=sys.stderr)
@@ -15,7 +14,17 @@ def warn(msg):
 def info(msg):
     print(msg)
 
+try:
+    import mpildap
+    mpildap_available = True
+except ModuleNotFoundError:
+    warn('mpildap module not available, email normalization will be skipped')
+    mpildap_available = False
+    pass
+
 def normalize_email(email):
+    if not mpildap_available:
+        return email
     lp, domain = email.split('@')
     ldap_mail = mpildap.ldaps(f'&(istEmailName={lp})(istMailDomainReceive={domain})', 'mail', unique=True)
     if ldap_mail:
-- 
GitLab