Skip to content
Snippets Groups Projects
Commit fb62f19a authored by Robert Latta's avatar Robert Latta
Browse files

added logging of duplicate email in OTRS customer-user export

parent 52eefd0f
No related branches found
No related tags found
No related merge requests found
import logging
import re import re
from collections import OrderedDict from collections import OrderedDict
from inventory_provider import environment
from inventory_provider.db import ims from inventory_provider.db import ims
from inventory_provider.db.ims import InventoryStatus from inventory_provider.db.ims import InventoryStatus
environment.setup_logging()
logger = logging.getLogger(__name__)
INTERNAL_POP_NAMES = { INTERNAL_POP_NAMES = {
'Cambridge OC', 'Cambridge OC',
'DANTE Lab', 'DANTE Lab',
...@@ -228,5 +233,17 @@ def otrs_get_customer_users_rows(ds): ...@@ -228,5 +233,17 @@ def otrs_get_customer_users_rows(ds):
yield c yield c
sorted_cus = sorted(get_all_cus_user_rows(), key=lambda x: x['email']) 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: for cu in sorted_cus:
yield list(cu.values()) yield list(cu.values())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment