| 1234567891011121314151617181920212223242526272829303132333435 |
- import threading
- import email_mailgun
- import todo_wunderlist
- import input_sources
- import output
- import current_time
- def _get_services():
- return {
- 'email': email_mailgun.Email(),
- 'food': todo_wunderlist.Wunderlist(True, 'food'),
- 'todo': todo_wunderlist.Wunderlist(False),
- 'time': current_time.CurrentTime('Europe/Dublin'),
- #'play': music.Music(),
- }
- def launch_services(interrupted):
- services = _get_services()
- for s in services.values():
- if not s.initialized:
- t = threading.Thread(target=s.init)
- t.start()
- output.text('Ready.')
- while not interrupted():
- t = input_sources.get_token(1)
- if t is not None and t in services and services[t].initialized:
- output.debug('Entering %s' % t)
- services[t].call()
- elif t == 'quit':
- return
- elif t is not None:
- output.failure('"%s" is not a valid service.' % t)
|