|
8 | 8 | import json |
9 | 9 | import os |
10 | 10 | import uuid |
11 | | -import traceback |
12 | 11 | from datetime import datetime |
13 | 12 | from pprint import pprint |
14 | 13 | from typing import Optional, List |
@@ -320,34 +319,23 @@ def handle_installation_event(action: str, body: dict): |
320 | 319 | return {'status': f'GitHub installation {action} event malformed.'} |
321 | 320 |
|
322 | 321 | cla.log.debug(f'Locating organization using name: {org_name}') |
323 | | - try: |
324 | | - existing = get_organization(org_name) |
325 | | - cla.log.debug( |
326 | | - f"{func_name} - post-get_organization type={type(existing)} " |
327 | | - f"keys={list(existing.keys()) if isinstance(existing, dict) else '(n/a)'} " |
328 | | - f"values={list(existing.values()) if isinstance(existing, dict) else '(n/a)'}" |
329 | | - ) |
330 | | - if 'errors' in existing: |
331 | | - cla.log.warning(f'{func_name} - Received github installation created event for organization: {org_name}, ' |
332 | | - 'but the organization is not configured in EasyCLA') |
333 | | - # TODO: Need a way of keeping track of new organizations that don't have projects yet. |
334 | | - return {'status': 'Github Organization must be created through the Project Management Console.'} |
335 | | - elif not existing.get('organization_installation_id'): |
336 | | - cla.log.info(f'{func_name} - Setting installation ID for github organization: {existing.get("organization_name")} to {installation_id}') |
337 | | - update_organization(existing.get('organization_name'), existing.get('organization_sfid'), installation_id) |
338 | | - cla.log.info(f'{func_name} - Organization enrollment completed: {existing.get("organization_name")}') |
339 | | - return {'status': 'Organization Enrollment Completed. CLA System is operational'} |
340 | | - else: |
341 | | - cla.log.info(f'{func_name} - Organization already enrolled: {existing.get("organization_name")}') |
342 | | - cla.log.info(f'{func_name} - installation ID: {existing.get("organization_installation_id")}') |
343 | | - cla.log.info(f'{func_name} - Updating installation ID for github organization: {existing.get("organization_name")} to {installation_id}') |
344 | | - update_organization(existing.get('organization_name'), existing.get('organization_sfid'), installation_id) |
345 | | - return {'status': 'Already Enrolled Organization Updated. CLA System is operational'} |
346 | | - except Exception as e: |
347 | | - cla.log.error(f"{func_name} - exception entering/enforcing enrollment branches: {type(e).__name__}: {e}\n" |
348 | | - f"{traceback.format_exc()}" |
349 | | - ) |
350 | | - raise |
| 322 | + existing = get_organization(org_name) |
| 323 | + if 'errors' in existing: |
| 324 | + cla.log.warning(f'{func_name} - Received github installation created event for organization: {org_name}, ' |
| 325 | + 'but the organization is not configured in EasyCLA') |
| 326 | + # TODO: Need a way of keeping track of new organizations that don't have projects yet. |
| 327 | + return {'status': 'Github Organization must be created through the Project Management Console.'} |
| 328 | + elif not existing.get('organization_installation_id'): |
| 329 | + cla.log.info(f'{func_name} - Setting installation ID for github organization: {existing.get("organization_name")} to {installation_id}') |
| 330 | + update_organization(existing.get('organization_name'), existing.get('organization_sfid'), installation_id) |
| 331 | + cla.log.info(f'{func_name} - Organization enrollment completed: {existing.get("organization_name")}') |
| 332 | + return {'status': 'Organization Enrollment Completed. CLA System is operational'} |
| 333 | + else: |
| 334 | + cla.log.info(f'{func_name} - Organization already enrolled: {existing.get("organization_name")}') |
| 335 | + cla.log.info(f'{func_name} - installation ID: {existing.get("organization_installation_id")}') |
| 336 | + cla.log.info(f'{func_name} - Updating installation ID for github organization: {existing.get("organization_name")} to {installation_id}') |
| 337 | + update_organization(existing.get('organization_name'), existing.get('organization_sfid'), installation_id) |
| 338 | + return {'status': 'Already Enrolled Organization Updated. CLA System is operational'} |
351 | 339 |
|
352 | 340 | elif action == 'deleted': |
353 | 341 | cla.log.debug(f'{func_name} - processing github installation activity for action: {action}') |
|
0 commit comments