BRGVersion:5 revision:$Revision$ baselib:core baselib:lal1 begin:graphprops propdef:AutomationHost|string|1||None propdef:AutomationPort|string|1||None propdef:AutomationUsername|string|1||None propdef:AutomationPassword|password|1||None propdef:Recipients|string|1||None propdef:SMTP_UserName|string|1||None propdef:SMTP_Password|password|1||None propdef:SMTP_Server|string|1||None propdef:SMTP_Port|string|1||None prop:AutomationHost={{%ls.brain.machinename%}} prop:AutomationPort=8080 prop:AutomationUsername=brain encrypted:simple=nFZhmIpdcU/tLMZFEdRHethHrEDx+VB7UhbucJjT prop:Recipients=ssmith@lavastorm.com prop:SMTP_UserName=none encrypted:simple=nFZhmIpPSW/SHvdQC8heRctQ4lnx5VFM prop:SMTP_Server=mailrelay.comcast.com prop:SMTP_Port=25 end:graphprops libnode:LAE_Properties bretype:core::Python editor:Label=LAE Properties editor:handle=559c0f4746af704a editor:sortkey=498746972bcb2901 output:498746a6305a42e2/out1= prop:Python2Implementation=<"": vv=self.properties.getString(p,"*undefined*") outRec["Zone"] = "Brain" outRec["Property"] = p outRec["Value"] = vv outRec["Type"] = "String" self.outputs[0].write(outRec) else: for v in self.properties.getPropertyNames(): outRec["Zone"] = "Brain" outRec["Property"] = v if self.properties.isArray(v) == True: a = self.properties.getArray(v) if len(a)>0: #outRec["Value"] = a[0] for i in range(len(a)): vv = a[i] outRec["Value"] = vv outRec["Type"] = "Array:"+"%03d" % i self.outputs[0].write(outRec) else: outRec["Value"] = self.properties.getString(v) outRec["Type"] = "String" self.outputs[0].write(outRec) for v in os.environ.keys(): outRec = self.outputs[0].newRecord() outRec["Zone"] = "OS" outRec["Property"] = v outRec["Type"] = "String" outRec["Value"] = os.environ[v] self.outputs[0].write(outRec) otherMiscProperties(self) def finalize(self, val): super(BrainNode, self).finalize(val) def pump(self, quant): while quant.permitsRunning(self): # your code here # when complete return False # finished your quantum, you want pump called again return True return BrainNode EOX prop:ToolCode=<\r\n" message = message + "\r\n" if self.bodymessage != '': message = message + self.bodymessage if self.bodytext != '': message = message + "\r\n\r\n"+ self.bodytext message = message + "\r\n" message = message + "\r\n" msg = MIMEMultipart() msg['From'] = Sender msg['To'] = Recipients msg['Subject'] = self.Subject msg.attach(MIMEText(message,'html')) files=[] if self.properties.getString('ls.brain.smtpmail.filestoattach',"") <> '': t = self.properties.getString('ls.brain.smtpmail.filestoattach',"").split(",") files.extend(t) if self.attachFiles <> '': t = self.attachFiles.split(",") files.extend(t) #self.logInfo("C="+str(t)) for file in files: bad=False try: f = open(file,"rb") except IOError: bad = True if not bad: part = MIMEBase('application', "octet-stream") part.set_payload( f.read() ) Encoders.encode_base64(part) part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(file)) msg.attach(part) server = smtplib.SMTP(smtpServer, smtpPort) #server.set_debuglevel(1) server.ehlo() if SSLREQUIRED: server.starttls() server.ehlo() if AUTHREQUIRED: server.login(smtpUser,smtpPass) if Recipients != '': server.sendmail('', Recipients.split(','), msg.as_string() ) self.logInfo(message) server.rset() server.quit() server.close() def setemailheader(self): self.header = '' for idx,field in enumerate(self.columnOrder): self.header = self.header + '' + field.strip() def setemailrcp2(self,rec): if len(self.inputs) > 0 and self.rcp2f != '': self.Recipients2 = rec[self.rcp2f] else: self.Recipients2 = '' def setemailbody(self): if self.columnOrder > '': self.bodytext = '\n' else: self.bodytext = '' if self.sendHeaders or true: self.bodytext = self.bodytext + self.header + '\n' def closeemailbody(self): if self.bodytext != '' and self.columnOrder > '': self.bodytext = self.bodytext + '
\n' def closeandsendemail(self): if self.bodytext != '' or self.sendZeroInput: sendmail(self) setemailbody(self) else: self.logInfo('Zero Input - email not sent') def setup(brainNodeControlObj, BrainNodeClass): class BrainNode(BrainNodeClass): def initialize(self): super(BrainNode, self).initialize() self.sendZeroInput = self.properties.getBool('ls.brain.smtpmail.sendZeroInput') self.sendHeaders = self.properties.getBool('ls.brain.smtpmail.sendHeaders',True) self.columnOrder = self.properties.getString('ls.brain.smtpmail.columnOrder','').split(',') self.Recipients = self.properties.getString('ls.brain.smtpmail.Recipients','') self.rcp2f = self.properties.getString('ls.brain.smtpmail.RecipientsField','') self.attachFileNameField = self.properties.getString('ls.brain.smtpmail.attachFileNameField',"") #self.logInfo("A="+self.attachFileNameField) if self.Recipients=='' and self.rcp2f=='': raise Exception, 'No recipients specified' return False self.message = '' self.header = '' self.attachFiles = '' fn = self.properties.getString('ls.brain.smtpmail.Message','') if fn != '': f=open(fn,"r") self.message = f.read() self.bodymessage=self.message self.reccount=0 if len(self.inputs) > 0: setemailheader(self) self.thisrec = self.inputs[0].read() if self.thisrec: self.reccount=1 if self.attachFileNameField <> "": self.attachFiles=self.thisrec[self.attachFileNameField] else: self.thisrec = [] self.Subject = self.properties.getString('ls.brain.smtpmail.Subject','Message from LAE') self.Subject = substituteMessageVars(self,self.Subject) setemailrcp2(self,self.thisrec) if len(self.inputs) > 0: setemailbody(self) gbv='_all_' gb = self.properties.getString('ls.brain.smtpmail.GroupBy','') if gb != '': gbv=self.thisrec[gb] if self.thisrec: self.bodymessage=substituteMessageVars(self,self.bodymessage) setemailrcp2(self,self.thisrec) while self.thisrec: if self.attachFileNameField <> "": #self.logInfo("D1="+str(rec["FileName"])) #self.logInfo("D2="+str(self.attachFileNameField)) self.attachFiles = str(self.thisrec[str(self.attachFileNameField)]) #self.logInfo("D3="+str(self.attachFiles)) self.bodytext = self.bodytext + '\n' for idx,field in enumerate(self.columnOrder): if field.strip() <> '': self.bodytext = self.bodytext+ '' + str(rec[field.strip()]) + '\n' self.thisrec = self.inputs[0].read() self.reccount=self.reccount+1 if gb <> '': if rec and rec[gb]<>gbv: closeemailbody(self) closeandsendemail(self) self.bodymessage=substituteMessageVars(self,self.thisrec) setemailrcp2(self,self.thisrec) gbv=self.thisrec[gb] time.sleep(1) if len(self.inputs) > 0: if self.reccount > 0: closeemailbody(self) closeandsendemail(self) else: self.logInfo("No records to send") else: closeandsendemail(self) def finalize(self, val): super(BrainNode, self).finalize(val) def pump(self, quant): while quant.permitsRunning(self): return False return True return BrainNode EOX prop:PythonCodeOnServer=true prop:RecipientsField={{^^}} prop:SSLREQUIRED=false prop:SendWithZeroInput=true prop:Sender=none@cable.comcast.com prop:Subject=Test Email prop:ToolCode=< -1 then s=str(field(str(i+1))) else s="" emit * override emit str(s) as renderedMessage where s > "" EOX editor:XY=660,230 end:Ensure_Message_Exists node:JSON_Data bretype:lal1::JSON Data editor:handle=559bde8d653441f7 editor:sortkey=557b196a2fbc0f20 input:5577c39b625f4a37/response=HTTP.506b1e775ec369f0 output:@51781d234c465db7/= output:@522743291aa237ba/= output:@522743281dab2bc6/= prop:CoerceData=Always prop:JsonData=RESPONSE prop:JsonDataParamType=Data Field prop:NoRecordForOutputBehavior=Ignore editor:XY=560,240 end:JSON_Data node:Throw_Error_on_Failure bretype:core::Filter editor:Label=Throw Error on Failure editor:handle=559bde8d787c4874 editor:sortkey=557b196a5886038f input:@40fd2c74167f1ca2/=Ensure_Message_Exists.40fd2c7420761db6 output:@40fd2c7420761db6/= prop:Script=< 0 then abort(str(renderedMessage)) EOX editor:XY=760,230 end:Throw_Error_on_Failure box: label:Parse out Error Message rect:490,180,310,110 backgroundcolor:13434879 end: end:Automation_Query_2 node:Query_API bretype:lal1::HTTP editor:Label=Query API editor:handle=559be08d3ccd7585 editor:sortkey=53a475367af14483 input:53a4766d580a597e/out1=Build_Query_URL_and_Get_Select_Field_List.40fd2c7420761db6 output:@506b1e775ec369f0/= prop:ContentType=text/plain prop:ContentTypeOutputField=CONTENT_TYPE prop:ContentTypeParamType=Literal prop:DataOutputField=RESPONSE prop:DataOutputFieldEncoding=None prop:DataOutputFieldType=Unicode prop:HeaderOutputField=HEADER prop:Method=GET prop:MethodParamType=Literal prop:PassThroughFields=Unused prop:StatusCodeOutputField=STATUS_CODE prop:StatusMessageOutputField=STATUS_MESSAGE prop:Url=QUERY_URL prop:UrlParamType=Field editor:XY=460,140 end:Query_API node:Query_API_2 bretype:lal1::HTTP editor:Label=Query API editor:handle=559bf90d77252175 editor:sortkey=53a475367af14483_2 input:53a4766d580a597e/out1=Build_Query_URL_and_Get_Select_Field_List_2.40fd2c7420761db6 output:@506b1e775ec369f0/= prop:ContentType=text/plain prop:ContentTypeOutputField=CONTENT_TYPE prop:ContentTypeParamType=Literal prop:DataOutputField=RESPONSE prop:DataOutputFieldEncoding=None prop:DataOutputFieldType=Unicode prop:HeaderOutputField=HEADER prop:Method=GET prop:MethodParamType=Literal prop:PassThroughFields=Unused prop:StatusCodeOutputField=STATUS_CODE prop:StatusMessageOutputField=STATUS_MESSAGE prop:Url=QUERY_URL prop:UrlParamType=Field editor:XY=800,110 end:Query_API_2 node:Build_Query_URL_and_Get_Select_Field_List bretype:core::Filter editor:Label=Build Query URL and Get Select Field List editor:handle=559be08d2bb20e5f editor:sortkey=53a8860e7bbf1c33 input:@40fd2c74167f1ca2/=Add_Login_Token.40fd2c7445835585 output:@40fd2c7420761db6/= prop:Script=< "": self.outputs[1].write(self.outrec1) self.inrec=self.inputs[0].read() return True return BrainNode EOX editor:XY=880,110 editor:propdef=FileName|string|1||None end:Parse_API_Response_2 node:Parse_API_Response bretype:core::Python editor:Label=Parse API Response editor:handle=559be34b55961eda editor:sortkey=54e660df21f446bc_3 input:54ee478104e13ce2/=Query_API.506b1e775ec369f0 output:54e665c100001bcc/Output= output:559be4dc6af64d1b/Message= prop:FileName=/cspp_commissions/Data/sfdc_temp.json prop:LogLevel=1 prop:Python2Implementation=< "": self.outputs[1].write(self.outrec1) self.inrec=self.inputs[0].read() return True return BrainNode EOX editor:XY=540,140 editor:propdef=FileName|string|1||None end:Parse_API_Response node:Throw_Error_on_Failure bretype:core::Filter editor:Label=Throw Error on Failure editor:handle=559be08d3b3639e4 editor:sortkey=557b196a5886038f input:@40fd2c74167f1ca2/=Parse_API_Response.559be4dc6af64d1b output:@40fd2c7420761db6/= prop:Script=< 0 then abort(str(renderedMessage)) EOX editor:XY=600,220 end:Throw_Error_on_Failure node:Throw_Error_on_Failure_2 bretype:core::Filter editor:Label=Throw Error on Failure editor:handle=559c0f2f47407169 editor:sortkey=557b196a5886038f_2 input:@40fd2c74167f1ca2/=Parse_API_Response_2.559be4dc6af64d1b output:@40fd2c7420761db6/= prop:Script=< 0 then abort(str(renderedMessage)) EOX editor:XY=940,220 end:Throw_Error_on_Failure_2 node:add_WHERE_conditions bretype:core::Filter editor:Label=add WHERE conditions editor:handle=559be2254301657c editor:sortkey=559be2254301657c input:@40fd2c74167f1ca2/=Remove_n_and_t.40fd2c7420761db6 output:@40fd2c7420761db6/= prop:Script=< property("graph.graphname") EOX editor:XY=990,110 end:Omit_Self node:Build_Message_Body bretype:core::Composite editor:Label=Build Message Body editor:handle=559c3a2516ce35f1 editor:sortkey=559c3a2516ce35f1 input:559c3a25663f35e0/FileNames=Build_FileNames.40fd2c7420761db6 inputxy:0=50,90 inputrotation:0=0 output:559c3a25484a645a/Agg - out1= outlink:0=/=Lookup.40fd2c7445835585 outputxy:0=770,90 outputrotation:0=0 inclockxy:Inclock=20,30 outclockxy:Outclock=400,30 editor:XY=1150,110 node:Email_Results bretype:core::Composite editor:Label=Email Results editor:handle=55c934c5088d5233 editor:sortkey=5580a22878315703 input:5580a2284d091674/BRD Log=^.559c3a25663f35e0 inputxy:0=40,120 inputrotation:0=0 output:559d77802bc12687/= outlink:0=/=Create_Message.40fd2c744c862db0 outputxy:0=970,120 outputrotation:0=0 inclockxy:Inclock=20,30 outclockxy:Outclock=400,30 editor:XY=200,320 node:Error_Records bretype:core::Filter editor:Label=Error Records? editor:handle=55c934c55ecf3ec1 editor:sortkey=55806f943f986f9e input:@40fd2c74167f1ca2/=Read_LOGBRD.40fd2c74028104af output:@40fd2c7420761db6/= output:55c93a3b6cb00e6a/out2= output:55c93a3c248a61b1/out3= prop:Script=<= 0 then fieldName = "logEvent.message.message.arg" if inputFields(1).find("logEvent.message.message") >= 0 then fieldName = "logEvent.message.message" lastValue = str(null) } if firstInGroup and fieldName.isNotNull() then { lastValue = trim(field(fieldName)) combinedLines = 'Id'.str() + ": " + lastValue } else if fieldName.isNotNull() then { if lastValue == trim(field(fieldName)) then { 1 == 1 } else { lastValue = trim(field(fieldName)) combinedLines = combinedLines.joinStrings('Id'.str() + ": " + lastValue,"\n") } } else { combinedLines = 'Id' } emit lastValue emit * emit combinedLines as Message where lastInGroup EOX prop:VerifyInputsGrouped=false prop:VerifyInputsSorted=false editor:XY=600,200 end:Combine_Error_Messages node:Create_Message bretype:core::Agg editor:Label=Create Message editor:handle=55c934c550e72da8 editor:sortkey=55808dcd4df33c55 input:@40fd2c7427456e5b/=Cat.40fd2c74676e03c3 output:@40fd2c744c862db0/= prop:GroupBy=<") as Message where lastInGroup EOX editor:XY=830,120 end:Create_Message node:Read_LOGBRD bretype:core::Multiple BRD Files editor:Label=Read LOG.>BRD editor:handle=55c93f3f0cb14778 editor:sortkey=559c278757030612 input:@40fd2c7405e716f4/=^.5580a2284d091674 output:@40fd2c74028104af/= prop:Filename=< -1 or Text.strFindI("Node Processing.") > -1 or Text.strFindI("Node Initializing.") > -1 or Text.strFindI("Node Completed.") > -1 ) ) EOX editor:XY=290,130 end:Look_for_Error_Messages node:Read_LOGBRD bretype:core::Multiple BRD Files editor:Label=Read LOG.>BRD editor:handle=559c278757030612 editor:sortkey=559c278757030612 input:@40fd2c7405e716f4/=^.559c3a25663f35e0 output:@40fd2c74028104af/= prop:Enabled=false prop:Filename=<