import threading import email_mailgun import todo_wunderlist import input_sources import output import current_time import help import echo def _get_services(): services = { 'email': email_mailgun.Email(), 'food': todo_wunderlist.Wunderlist(True, 'food'), 'todo': todo_wunderlist.Wunderlist(False), 'time': current_time.CurrentTime('Europe/Dublin'), 'echo': echo.Echo(), #'play': music.Music(), } services['help'] = help.Help(services) return services 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.tts('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)