def chooseBatchDef(fromPhpCmd, rev, type='batch'): ''' 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__('ctrlpy.lib.BatchDo.osa_' + b, globals(), locals(), ['index'], -1) except Exception as e: save_log('ERROR', 'Import Error:' + str(e)) break if not f: save_log('ERROR', 'Import file Error!') return False NewIpSubThreed(rev, f, type) #ipSubThreed(rev,f,type) except Exception as e: save_log('ERROR', 'BATCH func error:' + str(e)) return False return True
def chooseBatchDef(fromPhpCmd,rev,type='batch'): ''' 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__('ctrlpy.lib.BatchDo.osa_'+b, globals(), locals(), ['index'], -1) except Exception as e: save_log('ERROR','Import Error:'+str(e)) break if not f: save_log('ERROR','Import file Error!') return False NewIpSubThreed(rev,f,type) #ipSubThreed(rev,f,type) except Exception as e: save_log('ERROR','BATCH func error:'+str(e)) return False return True
def isBatchCmd(fromPhpCmd): ''' @fromPhpCmd 来自php端的批量操作指令 @例如:BATCH_DOCUMENT_DISTRIBUTION ''' batchlist = BATCHLIST.keys() if fromPhpCmd in batchlist: return True return False
def ayCmdToConsole(fromPhpCmd): ''' @fromPhpCmd: 来自php端的指令 解析来自Php端的指令传递给unctrlpy ''' try: num = len(fromPhpCmd.split('!')) return re.search('.*!',fromPhpCmd).group()[0:-1], fromPhpCmd.split('!')[num-1] except AttributeError: try: batchlist = BATCHLIST.keys() if re.search('BATCH_',fromPhpCmd): phpdict = eval(fromPhpCmd) if phpdict['command'] in batchlist: return phpdict['command'],1 return 0,0 except Exception as allargs: errlog = 'ayCmdToConsole Error : %s ' % allargs save_log('ERROR', errlog) return 0,0