-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOlympia.py
More file actions
64 lines (52 loc) · 1.81 KB
/
Olympia.py
File metadata and controls
64 lines (52 loc) · 1.81 KB
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
57
58
59
60
61
62
63
64
import os.path
import client
import json
import logging
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
creds = "./credentials/credentials.json"
fpath = "./credentials/token.json"
def main():
outFile = logging.FileHandler(filename="log.txt", encoding="utf-8", mode='w')
tokens = {}
oClient = client.olympiaClient(fpath)
print(oClient.tokens)
oClient.run(oClient.tokens["TOKEN"], log_handler=outFile, log_level=logging.WARNING)
if __name__ == "__main__":
main()
"""
def main():
creds = None
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials/credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
with open('token.json', 'w') as token:
token.write(creds.to_json())
try:
service = build('sheets', 'v4', credentials=creds)
# Call the Sheets API
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId=,
range="Master!").execute()
values = result.get('values', [])
if not values:
print('No data found.')
return
print('Name, Major:')
for row in values:
if (len(row) > 0):
print('%s, %s' % (row[1], row[4]))
except HttpError as err:
print(err)
if __name__ == '__main__':
main()
"""