Ejemplo n.º 1
0
def today_calendar():
    fullimg = Image.new('1', (640, 384), color=255)
    fullimg2 = Image.new('1', (640, 384), color=255)
    weather = WeatherWidget(owm_api_key)
    fullimg.paste(weather.get_weather(owm_location), box=(0, 0))
    timewidget = TimeWidget()
    fullimg.paste(timewidget.get_time(), box=(128, 0))
    calendar = CalendarWidget(family_names)
    event_getter = CalDavProvider(calendar_username, calendar_password)
    test_event_list = []

    today_start = datetime.now().replace(hour=8, minute=0, second=0, microsecond=0)
    today_end = today_start.replace(hour=21, minute=0, second=0, microsecond=0)

    for url in calendar_list:
        test_event_list.append(event_getter.get_calendar(url, today_start, today_end))
    img1, img2 = calendar.get_calendar(test_event_list)
    fullimg.paste(img1, box=(0, 80))
    fullimg2.paste(img2, box=(0, 80))
    return fullimg, fullimg2
Ejemplo n.º 2
0
def week_calendar(calid, name):
    fullimg = Image.new('1', (640, 384), color=255)
    fullimg2 = Image.new('1', (640, 384), color=255)
    weather = WeatherWidget(owm_api_key)
    fullimg.paste(weather.get_weather(owm_location), box=(0, 0))
    timewidget = TimeWidget()
    fullimg.paste(timewidget.get_time(), box=(128, 0))
    event_getter = CalDavProvider(calendar_username, calendar_password)
    test_event_list = []

    today = datetime.today()
    curdate = today + timedelta(days=-today.weekday(), weeks=0)
    curdate = curdate.replace(hour=8, minute=0, second=0, microsecond=0)

    for day in range(7, 12):
        test_event_list.append(event_getter.get_calendar(calendar_list[calid], curdate, curdate.replace(hour=21)))
        curdate = curdate + timedelta(days=1)

    calendar = CalendarWidget(['L', 'M', 'X', 'J', 'V'])
   
    img1, img2 = calendar.get_calendar(test_event_list, title=name)
    fullimg.paste(img1, box=(0, 80))
    fullimg2.paste(img2, box=(0, 80))
    return fullimg, fullimg2