Ejemplo n.º 1
0
def api_submit_datavalue(request, datestamp, sn, val):
    msg = "[SUBMITTED] datestamp: %s, sn: %s, val: %s" % (datestamp, sn, val)
    logger.info(msg)
    try:
        results = data_value_submission(datestamp, sn, val, request.META.get("REMOTE_ADDR"))
    except Exception as E:
        results = " Exception: " + E.message
    return HttpResponse(msg + results)
Ejemplo n.º 2
0
def api_submit_datavalue(request, sn, val, mode, datestamp="now"):
    msg = "[SUBMITTED] datestamp: %s, sn: %s, val: %s, mode=%s" % (datestamp, sn, val, mode)
    print(msg)
    logger.info(msg)

    try:
    	if "obj" in mode:
        	is_obj = True
    	else:
        	is_obj = False
        results = data_value_submission(datestamp, sn, val, request.META.get('REMOTE_ADDR'),is_obj)
    except Exception as E:                
        results = 'Exception:' + E.message
    return HttpResponse(results)
Ejemplo n.º 3
0
def api_control(request):
    logger.debug("api_control()")
    cmd = request.GET.get("cmd")
    val = request.GET.get("val")

    logger.debug("api_control(cmd = %s, val = %s)" % (cmd, str(val)))
    if "ping" in cmd:
        logger.debug("\trespondng to ping")
        response = '"pong"'
    elif "data_entry" in cmd:
        logger.debug("\trespondng to data_entry : val= %s" % val)
        submitted_data = simplejson.loads(val)
        response = data_value_submission("now", submitted_data[0], submitted_data[1], request.META.get("REMOTE_ADDR"))
    else:
        response = '"none"'

    # response = '"main_io cmd=%s, val=%s time=%s"' %  (cmd,val,datetime.datetime.now())
    logger.debug("response = %s" % response)
    return HttpResponse(response, content_type="text/json")