Google-GonG script is almost done! Added some todos.
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import datetime
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
import reference
|
||||
|
||||
from google.auth.transport.requests import Request
|
||||
from google.oauth2.credentials import Credentials
|
||||
@ -10,6 +12,7 @@ from googleapiclient.errors import HttpError
|
||||
|
||||
# If modifying these scopes, delete the file token.json.
|
||||
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]
|
||||
IGNORE_TYPES = ["workingLocation", "outOfOffice", "focusTime"]
|
||||
|
||||
|
||||
def main():
|
||||
@ -55,29 +58,50 @@ def main():
|
||||
print("No upcoming events found.")
|
||||
return
|
||||
|
||||
# curr_client = "Artera"
|
||||
# if curr_client in reference.GONG_URLS.keys():
|
||||
# cmd=f'''osascript -e 'display notification "Meeting with {curr_client} soon. Opening GonG URL"' '''
|
||||
# os.system(cmd)
|
||||
# time.sleep(5)
|
||||
# os.system(f"open {reference.BASE_URL}{reference.GONG_URLS[curr_client]}")
|
||||
# else:
|
||||
# print("Not found")
|
||||
# Prints the start and name of the next 10 events
|
||||
for event in events:
|
||||
# Parse the datetime first
|
||||
start = event["start"].get("dateTime", event["start"].get("date"))[:-6]
|
||||
# start = start[:-6]
|
||||
start_time = datetime.datetime.strptime(start, "%Y-%m-%dT%H:%M:%S")
|
||||
now = datetime.datetime.now()
|
||||
if len(start) > 4:
|
||||
if event["eventType"] not in IGNORE_TYPES:
|
||||
# start = start[:-6]
|
||||
start_time = datetime.datetime.strptime(start, "%Y-%m-%dT%H:%M:%S")
|
||||
now = datetime.datetime.now()
|
||||
difference = start_time - now
|
||||
seconds_in_day = 24 * 60 * 60
|
||||
time_left_in_min_sec = divmod(difference.days * seconds_in_day + difference.seconds, 60)
|
||||
# print(time_left_in_min_sec)
|
||||
|
||||
difference = start_time - now
|
||||
seconds_in_day = 24 * 60 * 60
|
||||
time_left_in_min_sec = divmod(difference.days * seconds_in_day + difference.seconds, 60)
|
||||
|
||||
# Then parse the name to attribute it to a client.
|
||||
client_name = event["summary"]
|
||||
# if time_left_in_min_sec[0] < 1:
|
||||
# print("Upcoming Meeting")
|
||||
# else:
|
||||
# print("Nothing new")
|
||||
# print(start, event["organizer"]["email"])
|
||||
if event["eventType"] != "outOfOffice":
|
||||
# print(event["organizer"]["email"])
|
||||
for items in event["attendees"]:
|
||||
print(items["email"])
|
||||
# Then parse the name to attribute it to a client.
|
||||
client_name = event["summary"]
|
||||
print(client_name)
|
||||
if time_left_in_min_sec[0] < 10 and time_left_in_min_sec > 0:
|
||||
if client_name in reference.GONG_URLS.keys():
|
||||
cmd=f'''osascript -e 'display notification "Meeting with {curr_client} soon. Opening GonG URL"' '''
|
||||
os.system(cmd)
|
||||
time.sleep(5)
|
||||
os.system(f"open {reference.BASE_URL}{reference.GONG_URLS[curr_client]}")
|
||||
else:
|
||||
# print("Not found")
|
||||
pass
|
||||
# print("Upcoming Meeting")
|
||||
# if client_name in reference.GONG_URLS.keys()
|
||||
else:
|
||||
pass
|
||||
# print("Nothing new")
|
||||
# print(start, event["organizer"]["email"])
|
||||
# if event["eventType"] != "outOfOffice":
|
||||
# print(event["organizer"]["email"])
|
||||
# for items in event["attendees"]:
|
||||
# print(items["email"])
|
||||
|
||||
except HttpError as error:
|
||||
print(f"An error occurred: {error}")
|
||||
|
||||
Reference in New Issue
Block a user