예제 #1
0
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
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
def device_file_get(device, fileName):
	id=appendDevCmdOld(device, "GetFile "+fileName)
	return getJSResponse("%s"%id)
예제 #6
0
def device_file_ls(device, dir):
	id=appendDevCmdOld(device, "Shell ls -l "+dir)
	return getJSResponse("%s"%id)
예제 #7
0
def device_file_get(device, fileName):
    id = appendDevCmdOld(device, 'GetFile ' + fileName)
    return getJSResponse('%s' % id)
예제 #8
0
def device_file_ls(device, dir):
    id = appendDevCmdOld(device, 'Shell ls -l ' + dir)
    return getJSResponse('%s' % id)