def test_getInfo(self): gcal = GCalendar('.\gcaltest.xml') assert_equal( u'◎ねころびお休み◎', gcal.getDateInfo(datetime.date(2010, 12, 31))) assert_equal( u'通常営業時間 11時から21時', gcal.getDateInfo(datetime.date(2011, 1, 21))) assert_equal( u'19時よりモンハンオフ予定', gcal.getDateInfo(datetime.date(2011, 2, 27)))
def start(self): clock = ClockThread.ClockThread() clock.setDaemon(True) clock.start() musicPlayer = MusicPlayer.MusicPlayer() textToSpeech = TextToSpeech.TextToSpeech() weather = Weather.Weather() segmentDimmer = SegmentDimmerThread.SegmentDimmerThread(clock, weather) segmentDimmer.setDaemon(True) segmentDimmer.start() gCalendar = GCalendar.GCalendar() volumeController = VolumeControllerThread.VolumeControllerThread() volumeController.setDaemon(True) volumeController.start() sleep(1) # Wait one second so clock's hour and minute values get filled ready for when alarm needs them alarm = AlarmThread.AlarmThread(musicPlayer, textToSpeech, weather, clock, gCalendar) alarm.setDaemon(True) # DEFAULT WAKEUP TIME - 6:00AM alarm.setAlarm(6,0) alarm.start() internalCommServer = InternalCommServer.InternalCommServer(alarm, musicPlayer, textToSpeech) internalCommServer.setDaemon(True) internalCommServer.start() try: while (self.ended == False): sleep(1) except (KeyboardInterrupt, SystemExit): logger.warn("Interrupted") logger.warn("Main powering off process beginning") clock.end() alarm.end() segmentDimmer.end() volumeController.end() internalCommServer.end() sleep(2) logger.info("Main powering off process finished")
def test_NoSchedule(self): gcal = GCalendar('.\gcaltest.xml') assert_equal( u'', gcal.getDateInfo(datetime.date(2011, 1, 5)))
def test_doubleSchedule(self): gcal = GCalendar('.\gcaltest.xml') assert_equal( u'19時よりモンハンオフ予定 / 通常営業時間 13時から23時', gcal.getDateInfo(datetime.date(2011, 2, 1)))
y += 1 for event in calendar_data.events: screen.addstr(y, 0, ' ') # because we can overflow screen.addstr(y, 1, event.start.strftime('%a - %X')) screen.addstr(y, 19, event.summary.encode(code)) y += 1 return y def render_screen(): calendar_list = calendar.get_calendar_list() draw_with_calendar_list(stdscr, calendar_list) stdscr.refresh() if __name__ == '__main__': # we're going to want to delay starting curses until after we auth! # move to after teh ctor for GCalendar start_curses() calendar = GCalendar('client_secrets.json', sys.argv) stdscr.nodelay(1) while 1: try: render_screen() time.sleep(sleepTime * 60) except httplib.BadStatusLine: continue end_curses()
#!/usr/bin/python import sys from GCalendar import * def draw_with_calendar_list(screen, calendar_list): y = 0 for calendar_data in calendar_list: screen.addstr(y, 0, calendar_data.summary) y += 1 for event in calendar_data.events: screen.addstr(y, 1, event.summary) screen.refresh() # @brief run with --noauth_local_webserver on a remote machine! if __name__ == '__main__': calendar = GCalendar('client_secrets.json', sys.argv) calendar_list = calendar.get_calendar_list() for calendar_data in calendar_list: print calendar_data.id, ',', calendar_data.summary for event in calendar_data.events: print '\tsummary:', event.summary, '; start:', event.start