From dbeecf19ce8eeb0e1c3e8979e991d98f87c22f6d Mon Sep 17 00:00:00 2001 From: lakshay162 Date: Sat, 25 Dec 2021 14:47:22 +0530 Subject: [PATCH 1/2] Update generate_token.py --- src/generate_token.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/generate_token.py b/src/generate_token.py index 85b41c8..29957b2 100644 --- a/src/generate_token.py +++ b/src/generate_token.py @@ -86,7 +86,10 @@ def chooseprofile(): for i in profiles: print(str(count)+'. '+i) count+=1 - profname=int(input('enter the number of the profile:')) + try: + profname=int(input('enter the number of the profile:')) + except ValueError: + raise Exception('You entered the wrong input. Enter option number of the profile.Not the profile name.\nBetter luck next time.') if profname-1 < len(profiles): file=open(os.path.join(os.getcwd(),'profiles',profiles[profname-1])) print(file.read()) @@ -227,19 +230,19 @@ def get_credentials(): calendar_ids = [] count = 1 while True: - calendar_list = service.calendarList().list(pageToken=page_token).execute() + calendar_list = service.calendarList().list(pageToken=page_token).execute()['items'][0:-2] print("\nThe following calendars are available in your google account. Please select one:\n\ (Note: The calendar name is your email, if you do not have multiple calendars)\n") - for calendar_list_entry in calendar_list['items']: + for calendar_list_entry in calendar_list: print(count, calendar_list_entry['id']) count+=1 print('\n') calendar_id = input("Please enter one of the above or enter 1,2,3 to select: ").strip() if len(calendar_id) == 1: - calendar_ids.append(calendar_list['items'][int(calendar_id)-1]['id']) + calendar_ids.append(calendar_list[int(calendar_id)-1]['id']) else: - for calendar_list_entry in calendar_list['items']: + for calendar_list_entry in calendar_list: if calendar_id in calendar_list_entry['id']: calendar_ids.append(calendar_list_entry['id']) From a7f8dd1fcc171a43747a9c5834f336b46e2b9583 Mon Sep 17 00:00:00 2001 From: lakshay162 Date: Sat, 25 Dec 2021 15:01:08 +0530 Subject: [PATCH 2/2] Update generate_token.py --- src/generate_token.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generate_token.py b/src/generate_token.py index 29957b2..d2010a2 100644 --- a/src/generate_token.py +++ b/src/generate_token.py @@ -230,7 +230,8 @@ def get_credentials(): calendar_ids = [] count = 1 while True: - calendar_list = service.calendarList().list(pageToken=page_token).execute()['items'][0:-2] + calendar_list1= service.calendarList().list(pageToken=page_token).execute() + calendar_list = calendar_list1['items'][0:-2] print("\nThe following calendars are available in your google account. Please select one:\n\ (Note: The calendar name is your email, if you do not have multiple calendars)\n") for calendar_list_entry in calendar_list: @@ -251,7 +252,7 @@ def get_credentials(): + NO SUCH CALENDAR FOUND. PLEASE SELECT ONE OF THE DISPLAYED IDS+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++''') else: - page_token = calendar_list.get('nextPageToken') + page_token = calendar_list1.get('nextPageToken') if not page_token: break