Question

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

  • 21 August 2021
  • 2 replies
  • 4 views

Badge +5

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

Userlevel 4

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

Badge +5

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