updated all formatting.
This commit is contained in:
@@ -42,7 +42,6 @@ class CalGrab(object):
|
||||
orderBy='startTime'
|
||||
).execute()
|
||||
events = events_result.get('items', [])
|
||||
|
||||
if not events:
|
||||
print('No upcoming events found.')
|
||||
return
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from dateutil.parser import parse
|
||||
|
||||
|
||||
class Event(object):
|
||||
|
||||
def __init__(self, summary, start_time, end_time):
|
||||
@@ -10,8 +11,11 @@ class Event(object):
|
||||
def __str__(self):
|
||||
return f"summary : {self.summary}, end_time : {self.end_time}, start_time : {self.start_time}"
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_from_gcal_api_json(json):
|
||||
print(json['start'].get('dateTime'))
|
||||
return Event(json['summary'] if 'summary' in json else "No Title" , parse(json['start'].get('dateTime')), parse(json['end'].get('dateTime')))
|
||||
return Event(
|
||||
json['summary'] if 'summary' in json else "No Title",
|
||||
parse(json['start'].get('dateTime')),
|
||||
parse(json['end'].get('dateTime'))
|
||||
)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from calendar_grabber import CalGrab
|
||||
|
||||
|
||||
def process_events(events):
|
||||
print("PROCESSING EVENTS")
|
||||
for event in events:
|
||||
print(event)
|
||||
|
||||
|
||||
def main():
|
||||
cg = CalGrab("./.auth.json", "loskorep@productiveedge.com", [process_events])
|
||||
cg.update_at_interval(5, 15)
|
||||
|
||||
+7
-7
@@ -1,10 +1,8 @@
|
||||
|
||||
import board
|
||||
import busio
|
||||
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
|
||||
|
||||
from datetime import datetime, time
|
||||
|
||||
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
|
||||
import board
|
||||
import busio
|
||||
from pytz import timezone
|
||||
|
||||
from calendar_grabber import CalGrab
|
||||
@@ -25,20 +23,22 @@ i2c = busio.I2C(board.SCL, board.SDA)
|
||||
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)
|
||||
|
||||
|
||||
|
||||
def is_event_active(events, now):
|
||||
for event in events:
|
||||
if event.start_time < now and event.end_time > now:
|
||||
return True
|
||||
|
||||
|
||||
def is_work_time(now):
|
||||
return now < WORK_STOP and now > WORK_START
|
||||
|
||||
|
||||
def format_text(text):
|
||||
formatted = text[:16]
|
||||
formatted += f"\n" + text[16:]
|
||||
return formatted
|
||||
|
||||
|
||||
def update_display(color, text, cursor=False, blink=False):
|
||||
text = format_text(text)
|
||||
lcd.clear()
|
||||
@@ -55,7 +55,7 @@ def process_events(events):
|
||||
if is_working_time:
|
||||
update_display(color=COLOR_RED, text="Meeting in Progress")
|
||||
else:
|
||||
update_display(color=COLOR_RED, text="Fuck me -_-")
|
||||
update_display(color=COLOR_RED, text="Fuck this -_-")
|
||||
else:
|
||||
if is_working_time:
|
||||
update_display(color=COLOR_BLUE, text="Work time - No event")
|
||||
|
||||
Reference in New Issue
Block a user