diff --git a/inventory_provider/db/ims_data.py b/inventory_provider/db/ims_data.py index 869241d03e023a6a8af5875867bb40638a5b1045..b648a9c78b18e06068c33e4d04e72f92a92de767 100644 --- a/inventory_provider/db/ims_data.py +++ b/inventory_provider/db/ims_data.py @@ -1,9 +1,14 @@ +import logging import re from collections import OrderedDict +from inventory_provider import environment from inventory_provider.db import ims from inventory_provider.db.ims import InventoryStatus +environment.setup_logging() +logger = logging.getLogger(__name__) + INTERNAL_POP_NAMES = { 'Cambridge OC', 'DANTE Lab', @@ -228,5 +233,17 @@ def otrs_get_customer_users_rows(ds): yield c sorted_cus = sorted(get_all_cus_user_rows(), key=lambda x: x['email']) + duplicate_emails = set() + previous_email = None + for cu in sorted_cus: + if cu['email'] == previous_email: + duplicate_emails.add(previous_email) + previous_email = cu['email'] + if duplicate_emails: + logger.error('Duplicate emails found in OTRS customer-user export: ' + f'{duplicate_emails}') + # raise KeyError('Duplicate emails found in OTRS customer-user export: ' # noqa + # f'{duplicate_emails}') + for cu in sorted_cus: yield list(cu.values())