link calendarId to config.py to ease user setup

This commit is contained in:
Marius Cramer 2020-05-18 20:42:34 +02:00
parent 0c9e76e23d
commit 79849610ab
2 changed files with 12 additions and 4 deletions

View file

@ -4,6 +4,13 @@ from pathlib import Path
def get_week(d=datetime.today()):
return (int(d.strftime("%W")) + 52 - 5) % 52
# default is 'primary', if you are using a separate calendar for your course schedule,
# your calendarId (which you can find by going to your Google Calendar settings, selecting
# the relevant calendar and scrolling down to Calendar ID) probably looks like
# xxxxxxxxxxxxxxxxxxxxxxxxxg@group.calendar.google.com
# example:
# USERCALENDARID = 'xxxxxxxxxxxxxxxxxxxxxxxxxg@group.calendar.google.com'
USERCALENDARID = 'primary'
CURRENT_COURSE_SYMLINK = Path('~/current_course').expanduser()
CURRENT_COURSE_ROOT = CURRENT_COURSE_SYMLINK.resolve()
CURRENT_COURSE_WATCH_FILE = Path('/tmp/current_course').resolve()

View file

@ -21,6 +21,7 @@ from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from courses import Courses
from config import USERCALENDARID
courses = Courses()
@ -58,7 +59,7 @@ def join(*args):
def truncate(string, length):
ellipsis = ' ...'
if len(string) < length:
return string
return string
return string[:length - len(ellipsis)] + ellipsis
def summary(text):
@ -186,7 +187,7 @@ def main():
if 'dateTime' in event['start']
]
events = get_events('primary')
events = get_events(userCalendarId)
# events = get_events('primary') + get_events('school-calendar@import.calendar.google.com')
print('Done')
@ -197,7 +198,7 @@ def main():
print(text(events, now))
if now < evening:
scheduler.enter(DELAY, 1, print_message)
for event in events:
# absolute entry, priority 1
scheduler.enterabs(event['start'].timestamp(), 1, activate_course, argument=(event, ))
@ -205,7 +206,7 @@ def main():
# Immediate, priority 1
scheduler.enter(0, 1, print_message)
scheduler.run()
def wait_for_internet_connection(url, timeout=1):
while True: