示例#1
0
def chooseBatchDef(fromPhpCmd,rev):
	'''	
	Description: 接收来自PHP端的批量操作指令,执行指定函数
				 前缀:osa_ 加上 PHP端指令名称作函数名称.
				 批量操作的参数统一为:接到到的指令详情
	@fromPhpCmd 来自php端的批量操作指令
	@rev 接收到的指令内容
	return 返回执行结果
	'''
	try:
		
		batchlist = BATCHLIST.keys()
		
                for b in batchlist:
                        path = DIRS['PY_OSA_LIB']+'BatchDo/osa_'+ b +'.py'
                        if os.path.exists(path) and b == fromPhpCmd:
                                try:
                                        f = __import__('unctrlpy.lib.BatchDo.osa_'+b, globals(), locals(), ['index'], -1)
                                except Exception as e:
                                        save_log('ERROR','Import Error:'+str(e))
				break
		if not f:
			return "{'status': 'ERROR', 'result': 'Import batch file Error!'}"
		return f.index(rev)
	except Exception as e:
	
		save_log('ERROR','chooseBatchDef error:'+str(e))
		return "{'status': 'ERROR', 'result': 'chooseBatchDef error:'"+str(e)+"}"
示例#2
0
def isBatchCmd(fromPhpCmd):
	'''
	@fromPhpCmd 来自php端的批量操作指令
	@例如:BATCH_DOCUMENT_DISTRIBUTION
	'''
	batchlist = BATCHLIST.keys()
	
	if fromPhpCmd in batchlist:
		return True
	return False
示例#3
0
def ayCmd(fromAngentCmd):
	'''
	@fromPhpCmd: 来自agent端的指令	
	'''
	try:
		phpdict = {}
		batchlist = BATCHLIST.keys()
		if re.search('BATCH_',fromAngentCmd):
			phpdict = eval(fromAngentCmd)
		if not phpdict or not phpdict['command']:
			return False
		if phpdict['command'] in batchlist:
			return phpdict['command']
		return False		
	except Exception as allargs:				
		errlog = 'ayCmdToConsole Error : %s ' % allargs
		save_log('WARNING', errlog)	
		return False