jython2.7 读取文件做判断
读取文件内容,转换json,判断完成状态
做判断出口,通过走成功,不通过走失败
1 import os 2 import json 3 def readState(path): 4 path = path + r'/runstatus.txt' 5 fp = open(path, 'r') 6 return fp.read() 7 8 try: 9 flowFile = session.get() 10 filePath = flowFile.getAttribute('状态文件路径'.decode('utf8')) 11 shareFilePath = flowFile.getAttribute('共享目录'.decode('utf8')) 12 f11 = shareFilePath+filePath 13 res = readState(f11) 14 progresObj = json.loads(res) 15 typeName = progresObj["type"] 16 flowFile = session.putAttribute(flowFile, 'RUNSTATUS', 'RUN') 17 if typeName == "success": 18 session.transfer(flowFile, REL_SUCCESS) 19 else: 20 session.transfer(flowFile, REL_FAILURE) 21 except: 22 session.transfer(flowFile, REL_FAILURE)
正在运行继续跳转成功
1 var flowFile = session.get(); 2 if(flowFile != null) { 3 try { 4 var type = flowFile.getAttribute('RUNSTATUS') 5 if(type == 'RUN'){ 6 session.transfer(flowFile, REL_SUCCESS) 7 }else{ 8 session.transfer(flowFile, REL_FAILURE) 9 } 10 } catch(e) { 11 session.transfer(flowFile, REL_FAILURE) 12 } 13 }
通过了
1 var flowFile = session.get(); 2 if(flowFile != null) { 3 try { 4 flowFile = session.putAttribute(flowFile, 'RUNSTATUS', '') 5 session.transfer(flowFile, REL_SUCCESS) 6 } catch(e) { 7 session.transfer(flowFile, REL_FAILURE) 8 } 9 }
做你说过的 说你能做的;