From 8f19e4bf87f87c6c84d6e0310f9985d65a428b65 Mon Sep 17 00:00:00 2001 From: Brett Snipes Date: Sat, 17 Aug 2019 22:26:38 -0400 Subject: [PATCH 1/3] Add venv/ to .gitignore to ignore virtual environment --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ce8552a..6a102da 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ config.ini !.elasticbeanstalk/*.cfg.yml !.elasticbeanstalk/*.global.yml /all_meetings.json + +# Virtual Environment +/venv From 1fdd4fcb5bc0af8c769619bd4d9049e9012c19cb Mon Sep 17 00:00:00 2001 From: Brett Snipes Date: Sun, 18 Aug 2019 13:35:54 -0400 Subject: [PATCH 2/3] Comment out Miniconda environment, to allow other venv setups --- update_cal_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_cal_data.py b/update_cal_data.py index b3101d8..ad2cbd3 100644 --- a/update_cal_data.py +++ b/update_cal_data.py @@ -1,4 +1,4 @@ -#!/home/ubuntu/miniconda2/envs/cal_service/bin/python +##!/home/ubuntu/miniconda2/envs/cal_service/bin/python # encoding: utf-8 import app import simplejson as json From abf2bdba66bcbdc6bf6c031e3ce2b9b322d21f04 Mon Sep 17 00:00:00 2001 From: Brett Snipes Date: Sun, 18 Aug 2019 13:47:39 -0400 Subject: [PATCH 3/3] Catch exceptions if venue id not properly supplied --- app.py | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/app.py b/app.py index f16fba5..61dec83 100644 --- a/app.py +++ b/app.py @@ -123,12 +123,13 @@ def get_eventbrite_venues(events_list): venue_ids = list(set(venue_ids)) venues = [] for venue_id in venue_ids: - url = 'https://www.eventbriteapi.com/v3/venues/{}/'.format(venue_id) - r = requests.get(url, headers={"Authorization": "Bearer {}".format(token)}, verify=True) - if r.status_code != 200: - raise Exception('Could not connect to Eventbrite API at {}. Status Code: {}'.format(url, r.status_code)) - data = json.loads(r.text) - venues.append(data) + if venue_id != None: # Catch exception if venue id not properly supplied + url = 'https://www.eventbriteapi.com/v3/venues/{}/'.format(venue_id) + r = requests.get(url, headers={"Authorization": "Bearer {}".format(token)}, verify=True) + if r.status_code != 200: + raise Exception('Could not connect to Eventbrite API at {}. Status Code: {}'.format(url, r.status_code)) + data = json.loads(r.text) + venues.append(data) return venues @@ -154,26 +155,27 @@ def format_eventbrite_events(events_list, venues_list, group_list): venues[venue_id] = venue_dict for event in events_list: - group_item = [i for i in group_list if i['field_events_api_key'] == event.get('organizer_id')][0] - group_name = group_item.get('title') - tags = group_item.get('field_org_tags') - uuid = group_item.get('uuid') - nid = group_item.get('nid') - event_dict = { - 'event_name': event.get('name').get('text'), - 'group_name': group_name, - 'venue': venues[event.get('venue_id')], - 'url': event.get('url'), - 'time': event.get('start').get("utc"), - 'tags': tags, - 'rsvp_count': None, - 'created_at': event.get('created'), - 'description': event.get('description').get('text'), - 'uuid': uuid, - 'nid': nid, - 'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') - } - events.append(event_dict) + if type(event.get('venue_id')) == str: # If venue id error + group_item = [i for i in group_list if i['field_events_api_key'] == event.get('organizer_id')][0] + group_name = group_item.get('title') + tags = group_item.get('field_org_tags') + uuid = group_item.get('uuid') + nid = group_item.get('nid') + event_dict = { + 'event_name': event.get('name').get('text'), + 'group_name': group_name, + 'venue': venues[event.get('venue_id')], + 'url': event.get('url'), + 'time': event.get('start').get("utc"), + 'tags': tags, + 'rsvp_count': None, + 'created_at': event.get('created'), + 'description': event.get('description').get('text'), + 'uuid': uuid, + 'nid': nid, + 'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') + } + events.append(event_dict) return events