def _get_service_class_safe(service_name, message="Choose the service for this command:"): if service_name is None: app.logger.info(message) service_classes = list(get_service_classes()) for i, c in enumerate(service_classes): if i == 0: app.logger.message(" - [%d] %s [default]" % (i+1, c.service_name)) else: app.logger.message(" - [%d] %s" % (i+1, c.service_name)) choice = _prompt_index('service', max_val=len(service_classes)+1) service_name = service_classes[choice-1].service_name try: return get_service_class(service_name) except: raise Exception("No such service: %s" % service_name)
def services(available=False): ''' Lists connected or available services. ''' account = _get_account() if available: app.logger.info("Available services:") for c in get_service_classes(): if c.service_name in account.services: app.logger.info("%s (connected)" % c.service_label) else: app.logger.info(c.service_label) else: app.logger.info("Connected services:") for s in account.services: app.logger.info("%s (logged in as %s)" % ( account.services[s].service_label, account.services[s].username))