@csrf_exempt
@never_cache
def endpoint_logs(request):
    """Saves an endpoint server Apache logs."""
    response, group, ip = endpoint_common(request)
    if response is not None:
        return response

    # Take a lock on the file
    while True:
        logfile = file(os.path.join(CONFIG['config']['logdir'], "access-%s-%s.log" % (group, ip)), 'a')
        try:
            fcntl.lockf(logfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
        except __HOLE__:
            time.sleep(1)
        else:
            break

    # Write out the log lines
    logfile.write(request.POST['data'])
    logfile.flush()

    # Unlock the file
    fcntl.lockf(logfile, fcntl.LOCK_UN)

    # Close the file
    logfile.close()

    # Write out that everything went okay
    response = http.HttpResponse(content_type='text/plain')
    response.write('OK\n')
    return response


# Save some data about flumotion
dataset/ETHPy150Open timvideos/streaming-system/website/tracker/views.py/endpoint_logs