'Check that all users are properly routed on the proxy.'

@gen.coroutine
def check_routes(self, user_dict, service_dict, routes=None):

    if (not routes):
        routes = (yield self.get_all_routes())
    user_routes = {path for (path, r) in routes.items() if ('user' in r['data'])}
    futures = []
    db = self.db
    good_routes = {'/'}
    hub = self.app.hub
    if ('/' not in routes):
        self.log.warning('Adding    missing    default    route')
        futures.append(self.add_hub_route(hub))
    else:
        route = routes['/']
        if (route['target'] != hub.host):
            self.log.warning('Updating    default    route    %s    \xe2\x86\x92    %s', route['target'], hub.host)
            futures.append(self.add_hub_route(hub))
    for orm_user in db.query(User):
        user = user_dict[orm_user]
        for (name, spawner) in user.spawners.items():
            if spawner.ready:
                spec = spawner.proxy_spec
                good_routes.add(spec)
                if (spec not in user_routes):
                    self.log.warning('Adding    missing    route    for    %s    (%s)', spec, spawner.server)
                    futures.append(self.add_user(user, name))
                else:
                    route = routes[spec]
                    if (route['target'] != spawner.server.host):
                        self.log.warning('Updating    route    for    %s    (%s    \xe2\x86\x92    %s)', spec, route['target'], spawner.server)
                        futures.append(self.add_user(user, name))
            elif spawner._proxy_pending:
                good_routes.add(spawner.proxy_spec)
    service_routes = {r['data']['service']: r for r in routes.values() if ('service' in r['data'])}
    for orm_service in db.query(Service).filter((Service.server != None)):
        service = service_dict[orm_service.name]
        if (service.server is None):
            self.log.error("Service    %s    has    no    server,    but    wasn't    filtered    out.", service)
            continue
        good_routes.add(service.proxy_spec)
        if (service.name not in service_routes):
            self.log.warning('Adding    missing    route    for    %s    (%s)', service.name, service.server)
            futures.append(self.add_service(service))
        else:
            route = service_routes[service.name]
            if (route['target'] != service.server.host):
                self.log.warning('Updating    route    for    %s    (%s    \xe2\x86\x92    %s)', route['routespec'], route['target'], spawner.server.host)
                futures.append(self.add_service(service))
    for routespec in routes:
        if (routespec not in good_routes):
            self.log.warning('Deleting    stale    route    %s', routespec)
            futures.append(self.delete_route(routespec))
    for f in futures:
        (yield f)
