示例#1
0
def cdata_get(request,device):
    '''
    返回用户信息或者设备信息
    '''
    if request.REQUEST.has_key('PIN'):
        return cdata_get_pin(request, device)
    else:
        deal_pushver(request,device)
        resp =cdata_get_options(device)
        return device_response_write(resp)
示例#2
0
def cdata(request):
    '''
    设备向服务器的http:://xxx/cdata请求
    '''
    from device_http.network import network_monitor
    network_monitor(request)

    encrypt = 1
    response = device_response()
    try:
        resp = ""
        from mysite import authorize_fun
        language = request.REQUEST.get('language', None)  #---获得语言参数
        authorize_fun.check_push_device(language)  #---连接设备数量控制
        device = check_device(request, True)  #---检测、验证当前发出请求的设备
        if device is None:
            response.write("UNKNOWN DEVICE")
            return response
        else:
            if request.REQUEST.has_key('action'):
                resp += "OK\n"
            elif request.method == 'GET':  #---设备GET请求
                if request.REQUEST.has_key('PIN'):  #---带人员PIN参数
                    resp += cdata_get_pin(request, device)
                else:  #--- 设备push的版本及其他一些信息的返回
                    alg_ver = "1.0"  #--- push 默认版本
                    if request.REQUEST.has_key(
                            'pushver'):  #---没有"PIN"但有"pushver" push版本参数
                        alg_ver = request.REQUEST.get(
                            'pushver'
                        )  #2010-8-25  device字段alg_ver用来区分新老固件  >=2.0为新固件,默认为旧固件
                    device.alg_ver = alg_ver
                    device.save()
                    resp += cdata_get_options(device)
                    encrypt = 0
            elif request.method == 'POST':  #---设备POST请求
                try:
                    resp += cdata_post(request, device)
                except Exception, e:
                    resp = u"ERROR: %s" % e
                    errorLog(request)
            else:
示例#3
0
def cdata(request):
    '''
    设备向服务器的http:://xxx/cdata请求
    '''
    from device_http.network import network_monitor
    network_monitor(request)
    
    encrypt = 1
    response = device_response()
    try:
        resp = ""
        from mysite import authorize_fun
        language=request.REQUEST.get('language',None)   #---获得语言参数
        authorize_fun.check_push_device(language)   #---连接设备数量控制
        device = check_device(request, True)    #---检测、验证当前发出请求的设备
        if device is None: 
            response.write("UNKNOWN DEVICE")
            return response
        else:        
            if request.REQUEST.has_key('action'):
                resp += "OK\n"
            elif request.method == 'GET':   #---设备GET请求
                if request.REQUEST.has_key('PIN'):  #---带人员PIN参数
                    resp+=cdata_get_pin(request, device)
                else:   #--- 设备push的版本及其他一些信息的返回
                    alg_ver="1.0" #--- push 默认版本
                    if request.REQUEST.has_key('pushver'):  #---没有"PIN"但有"pushver" push版本参数
                        alg_ver=request.REQUEST.get('pushver')    #2010-8-25  device字段alg_ver用来区分新老固件  >=2.0为新固件,默认为旧固件
                    device.alg_ver=alg_ver
                    device.save()
                    resp+=cdata_get_options(device)
                    encrypt = 0
            elif request.method == 'POST':  #---设备POST请求
                try:
                    resp+=cdata_post(request, device)
                except Exception, e:
                    resp = u"ERROR: %s" % e
                    errorLog(request)
            else: