

def status_img_url(request, agg_id):
    'Get the url for the status image of the aggregate'
    aggregate = get_object_or_404(Aggregate, pk=agg_id)
    success = HttpResponse(reverse('img_media', args=['active.png']))
    fail = HttpResponse(reverse('img_media', args=['inactive.png']))
    try:
        agg_status = aggregate.as_leaf_class().check_status()
        if (agg_status != aggregate.available):
            aggregate.available = agg_status
            aggregate.save()
        if agg_status:
            return success
        else:
            return fail
    except:
        logger.error(traceback.format_exc())
        return fail

dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/aggregate/views.py status_img_url/original