(celery_workers)
return expect_running, expect_stopped
Parses the response from the flower get workers api into a list of hosts
    we expect to be running and a list of hosts we expect to be stopped
Parses the response from the flower get workers api into a list of hosts
    we expect to be running and a list of hosts we expect to be stopped
Parses the response from the flower get workers api into a list of hosts we expect to be running and a list of hosts we expect to be stopped
def parse_celery_workers(celery_workers):
    """
    Parses the response from the flower get workers api into a list of hosts
    we expect to be running and a list of hosts we expect to be stopped
    """
    expect_stopped = []
    expect_running = list(filter(
        lambda hostname: not hostname.endswith('_timestamp'),
        celery_workers,
    ))

    timestamped_workers = list(filter(
        lambda hostname: hostname.endswith('_timestamp'),
        celery_workers,
    ))

    def _strip_timestamp(hostname):
        return '.'.join(hostname.split('.')[:-1])

    timestamped_workers = sorted(timestamped_workers, key=_strip_timestamp)

    for hostname, group in groupby(timestamped_workers, _strip_timestamp):

        sorted_workers = sorted(list(group), reverse=True)
        expect_running.append(sorted_workers.pop(0))
        expect_stopped.extend(sorted_workers)
    return expect_running, expect_stopped
def parse_celery_workers ( celery_workers ) : expect_stopped = [ ] expect_running = list ( filter ( lambda hostname : not hostname . endswith ( '_timestamp' ) , celery_workers , ) ) timestamped_workers = list ( filter ( lambda hostname : hostname . endswith ( '_timestamp' ) , celery_workers , ) ) def _strip_timestamp ( hostname ) : return '.' . join ( hostname . split ( '.' ) [ : - 1 ] ) timestamped_workers = sorted ( timestamped_workers , key = _strip_timestamp ) for hostname , group in groupby ( timestamped_workers , _strip_timestamp ) : sorted_workers = sorted ( list ( group ) , reverse = True ) expect_running . append ( sorted_workers . pop ( 0 ) ) expect_stopped . extend ( sorted_workers ) return expect_running , expect_stopped