Skip to main content

I was wondering if it is possible to access the content of a workbenchs log file in a Shutdown Python script on FME Server and email the content.

I have a central workbench calling several other workbenches to perform analysis. I want to parse the finished log-file to get warnings, errors and information about features identified and written. The final statement if the run was successful is unfortunately not enough.

 

The parsed data should be send as text in an email.

Until now I was testing locally with success, but the same workbench at a 2018 server fails with FME_END_PYTHON failure.

import fme

 

import smtplib

 

from email.mime.text import MIMEText

 

from email.mime.multipart import MIMEMultipart

 

from email.utils import COMMASPACE, formatdate

 

 

def send_email(send_from, send_to, subject, text, server='*****'):

 

'''send email with analysis results'''

 

assert isinstance(send_to, list)

 

outer = MIMEMultipart()

 

outer<'From'] = send_from

 

outer 'To'] = COMMASPACE.join(send_to)

 

outerÂ'Date'] = formatdate(localtime=True)

 

outer>'Subject'] = subject

 

outer.attach(MIMEText(text))

 

smtp = smtplib.SMTP(server)

 

smtp.sendmail(send_from, send_to, outer.as_string())

 

smtp.close()

 

 

m_text = fme.logFileName

 

send_email('*****', a'*****'], 'Log file from server', m_text)

Would it be an idea to use a Notification (email after successful run) instead of a shutdown script?

I have been using that a lot and it works fine and is easy to implement.


It should definitely be possible. But have you checked that all the necessary modules are available in the Python interpreter that's used on FME Server.

Also, can please you post the complete error message on FME Server.


An alternative is to "wrap up" the workspace in a master workspace that uses the FMEServerJobSubmitter followed by the FMEServerLogRetriever and an Email transformer.


Would it be an idea to use a Notification (email after successful run) instead of a shutdown script?

I have been using that a lot and it works fine and is easy to implement.

I second using a notification email. You can customise it in the "central workbench".

 

 


It should definitely be possible. But have you checked that all the necessary modules are available in the Python interpreter that's used on FME Server.

Also, can please you post the complete error message on FME Server.

As far as I can see is there not much of an error message. I attach a screenshot of the result data section

 

 

 


Would it be an idea to use a Notification (email after successful run) instead of a shutdown script?

I have been using that a lot and it works fine and is easy to implement.

I do not have huge experience in using the notification email, but if its possible to get the parsed data into the notification email then I will do this.

 

 


An alternative is to "wrap up" the workspace in a master workspace that uses the FMEServerJobSubmitter followed by the FMEServerLogRetriever and an Email transformer.

Interesting!

 

 


Reply