| 12345678910111213141516171819202122232425262728293031 |
- import threading
- import email_mailgun
- import todo_wunderlist
- import input_sources
- import output
- def _get_services():
- return {
- 'email': email_mailgun.Email(),
- 'food': todo_wunderlist.Wunderlist(True, 'food'),
- 'todo': todo_wunderlist.Wunderlist(False),
- #'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(5)
- if t is not None and t in services and services[t].initialized:
- output.debug('Entering %s' % t)
- services[t].call()
- elif t is not None:
- output.failure('"%s" is not a valid service.' % t)
|