forked from lkbnch/EZCal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestrun.py
56 lines (45 loc) · 1.55 KB
/
testrun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from googleapiclient import discovery
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
import pickle
from datetime import datetime, timedelta
def create_calendar(name):
scopes = ['https://www.googleapis.com/auth/calendar']
flow = InstalledAppFlow.from_client_secrets_file("client_secret.json", scopes=scopes)
credentials = flow.run_console()
pickle.dump(credentials, open("token.pkl", "wb"))
credentials = pickle.load(open("token.pkl", "rb"))
service = build("calendar", "v3", credentials=credentials)
result = service.calendarList().list().execute()
start_time = datetime(2022, 8, 7, 21, 0, 0)
end_time = start_time + timedelta(hours=2)
<<<<<<< HEAD
event = {
'summary': 'Google I/O 2015',
'location': '335 Madison Ave, New York, NY 03827',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': start_time.strftime("%Y-%m-%dT%H:%M:%S"),
'timeZone': timezone,
},
'end': {
'dateTime': end_time.strftime("%Y-%m-%dT%H:%M:%S"),
'timeZone': timezone,
},
}
=======
timezone = 'America/New_York'
>>>>>>> e4ec554b46cb7074b8fd1001b4360e54fb0b2710
name = name
event = {
'summary': name,
'start': {
'dateTime': start_time.strftime("%Y-%m-%dT%H:%M:%S"),
'timeZone': timezone,
},
'end': {
'dateTime': end_time.strftime("%Y-%m-%dT%H:%M:%S"),
'timeZone': timezone,
},
}
event = service.events().insert(calendarId='primary', body=event).execute()