Skip to main content
Question

Capture fmeobjects.FMELogFile() output in real time using Python?


blueinc
Contributor
Forum|alt.badge.img+6

Hi there,

Here's a conundrum for all you wonderful conundrumers...!

Background: I have a BASE.FMW that reads a list of names and runs a Workspace Runner for each name. Before it does, it writes out a quick message using the MessageLogger and the 'WARN' flag to the logfile I have set up. Each call to the WSR takes some time to run. The log line in the translation line and the log file looks like this:

2021-08-20 14:37:30|  4.3| 0.0|WARN |Processing 3 Named: Town of Comox...

 

Back to the Present: I am building a PYTHON standalone script using fmeobjects.FMEWorkspaceRunner().runWithParameters(BASE.FMW, myparams) to run the BASE.FMW and it runs fine and produces the correct results, including the log file.

 

My conundrum: the LIVE feedback in python from fmeobjects is non-existent. I would like to get those 'WARN' log lines from the logger AS IT IS WRITING THEM so I can give my python user some indication that something, anything, is happening. Right now, the .runWithParameters() is a black box and the user just has to sit there hoping that something is happening while watching their thumbs twiddle.

 

I have a snippet of python code that grabs lines from a file and prints them but it only runs either after the .runWithParameters() completes or hangs in a While loop because I can't figure out how to stop it. :-)

 

Can the FMELogfile give me what it's writing LIVE using STANDARDOUT or something?

 

Your thoughts?

TIA,

Brian

2 replies

david_r
Celebrity
  • August 23, 2021

It is possible to provide FMELogFile with a custom function is called every time a new line is sent to the log.

Take a look at my reply with sample code here: https://community.safe.com/s/question/0D54Q000080hECASA2/can-i-force-a-translation-to-fail-if-violation-of-a-primary-key-occurs-when-writing-to-sql-server


blueinc
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • August 27, 2021

Hi David_r

Thanks for getting back to me.

That solution looks promising. I was having a compatibility issue with Startup Scripts and arcpy but that shouldn't be a factor here.

I'll give it a try. Thanks again,

Brian


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings