示例#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_get(request, device):
    '''
    返回用户信息或者设备信息
    '''
    if request.REQUEST.has_key('PIN') or request.REQUEST.has_key('Card'):
        '''异地考勤入口'''
        return cdata_get_pin(request, device)
    else:
        '''服务器下发机器信息(如设备上传标识位)'''
        if SYNC_MODEL:
            alg_ver = "1.0"
            if request.REQUEST.has_key('pushver'):
                alg_ver = request.REQUEST.get('pushver')
            device.alg_ver = alg_ver
            device.set("alg_ver")  ########更新设备版本
            resp = device.get_option()
        else:
            deal_pushver(request, device)
            resp = cdata_get_options(device)
        return device_response_write(resp)
示例#4
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: