def device_cmd_check(device, id): try: cmd = devcmds.objects.get(id=id) except ObjectDoesNotExist: return getJSResponse('_ERROR_ID_') else: if cmd.CmdReturn == None and cmd.CmdTransTime: return getJSResponse('_PROCESSING_') return getJSResponse('_WAITTING_') else: try: if cmd.CmdContent.find('Shell ls -l ') == 0: data = file( getUploadFileName(device.SN, id, 'shellout.txt')).read() data = showFList(data, cmd.CmdContent[12:]) else: fname = cmd.CmdContent[8:] fname = getUploadFileURL(device.SN, id, fname) data = 'URL:' + fname except: data = '_NONE_' errorLog() return getJSResponse(data) return
def getMiniData(request, ModelName): miniData = request.GET.get('key', '') toResponse = "'" pk, pk_note, pk_note2, objs = (None, None, None, None) if miniData == 'UserID': pk, pk_note, pk_note2 = ('id', 'PIN', 'EName') objs = employee.objects.all() objs = objs.order_by('PIN').values('id', 'PIN', 'EName') if miniData in ('SN', 'Device'): pk, pk_note = ('SN', 'Alias') objs = iclock.objects.filter(Q(DelTag__isnull=True) | Q(DelTag=0)) objs = objs.order_by('Alias').values('SN', 'Alias') else: if miniData in ('DeptID', 'depart'): pk, pk_note = ('DeptID', 'DeptName') objs = department.objects.all().values('DeptID', 'DeptName') else: if miniData in ('User', 'Administrator'): pk, pk_note = ('id', 'username') objs = User.objects.all().values('id', 'username') res = {} if objs.count(): for row in objs: res[row[pk]] = '%s' % row[pk_note] + ( pk_note2 and ' %s' % row[pk_note2] or '') toResponse = smart_str(simplejson.dumps(res)) return getJSResponse(toResponse)
def getMiniData(request, ModelName): # dialog 获取数据 miniData=request.GET.get("key", "") toResponse = "'" pk, pk_note, pk_note2, objs = (None, None, None, None) if miniData == "UserID": pk, pk_note, pk_note2 = ("id", "PIN", "EName") objs = employee.objects.all() objs=objs.order_by("PIN").values("id", "PIN", "EName") if miniData in ["SN","Device"]: pk, pk_note = ("SN", "Alias") objs = iclock.objects.filter(Q(DelTag__isnull=True)|Q(DelTag=0)) objs=objs.order_by("Alias").values("SN", "Alias") elif miniData in ["DeptID", "depart"]: pk, pk_note = ("DeptID", "DeptName") objs = department.objects.all().values("DeptID", "DeptName") elif miniData in ["User", "Administrator"]: pk, pk_note = ("id", "username") objs = User.objects.all().values("id", "username") res={} if objs.count(): for row in objs: res[row[pk]]=("%s"%row[pk_note])+(pk_note2 and (" %s"%row[pk_note2]) or "") toResponse = smart_str(simplejson.dumps(res)) return getJSResponse(toResponse)
def device_cmd_check(device, id): try: cmd=devcmds.objects.get(id=id) except ObjectDoesNotExist: return getJSResponse("_ERROR_ID_") if cmd.CmdReturn==None: if cmd.CmdTransTime: return getJSResponse("_PROCESSING_") else: return getJSResponse("_WAITTING_") else: try: if cmd.CmdContent.find("Shell ls -l ")==0: data=file(getUploadFileName(device.SN, id, "shellout.txt")).read() data=showFList(data, cmd.CmdContent[12:]) else: fname=cmd.CmdContent[8:] fname=getUploadFileURL(device.SN, id, fname) data="URL:"+fname #file(fname).read() except: data="_NONE_" errorLog() return getJSResponse(data)
def device_file_get(device, fileName): id=appendDevCmdOld(device, "GetFile "+fileName) return getJSResponse("%s"%id)
def device_file_ls(device, dir): id=appendDevCmdOld(device, "Shell ls -l "+dir) return getJSResponse("%s"%id)
def device_file_get(device, fileName): id = appendDevCmdOld(device, 'GetFile ' + fileName) return getJSResponse('%s' % id)
def device_file_ls(device, dir): id = appendDevCmdOld(device, 'Shell ls -l ' + dir) return getJSResponse('%s' % id)