def status(gandi, service):
    """Display current status from status.gandi.net."""

    if not service:
        global_status = gandi.status.status()
        if global_status['status'] == 'FOGGY':
            # something is going on but not affecting services
            filters = {
                'category': 'Incident',
                'current': True,
            }
            events = gandi.status.events(filters)
            for event in events:
                if event['services']:
                    # do not process services
                    continue
                event_url = gandi.status.event_timeline(event)
                service_detail = '%s - %s' % (event['title'], event_url)
                gandi.echo(service_detail)

    # then check other services
    descs = gandi.status.descriptions()
    needed = services = gandi.status.services()
    if service:
        needed = [serv for serv in services
                  if serv['name'].lower() == service.lower()]

    for serv in needed:
        if serv['status'] != 'STORMY':
            output_service(gandi, serv['name'], descs[serv['status']])
            continue

        filters = {
            'category': 'Incident',
            'services': serv['name'],
            'current': True,
        }
        events = gandi.status.events(filters)
        for event in events:
            event_url = gandi.status.event_timeline(event)
            service_detail = '%s - %s' % (event['title'], event_url)
            output_service(gandi, serv['name'], service_detail)

    return services
def status ( gandi , service ) : if not service : global_status = gandi . status . status ( ) if global_status [ 'status' ] == 'FOGGY' : filters = { 'category' : 'Incident' , 'current' : True , } events = gandi . status . events ( filters ) for event in events : if event [ 'services' ] : continue event_url = gandi . status . event_timeline ( event ) service_detail = '%s - %s' % ( event [ 'title' ] , event_url ) gandi . echo ( service_detail ) descs = gandi . status . descriptions ( ) needed = services = gandi . status . services ( ) if service : needed = [ serv for serv in services if serv [ 'name' ] . lower ( ) == service . lower ( ) ] for serv in needed : if serv [ 'status' ] != 'STORMY' : output_service ( gandi , serv [ 'name' ] , descs [ serv [ 'status' ] ] ) continue filters = { 'category' : 'Incident' , 'services' : serv [ 'name' ] , 'current' : True , } events = gandi . status . events ( filters ) for event in events : event_url = gandi . status . event_timeline ( event ) service_detail = '%s - %s' % ( event [ 'title' ] , event_url ) output_service ( gandi , serv [ 'name' ] , service_detail ) return services
Display current status from status.gandi.net.