1

I'm running a FME Workbench from my Python script and I struggle to print the log in the cmd.

When I run the FME Workbench (from FME without Python), I got this error in the FME translation log :

2022年04月20日 10:15:57| 4.7| 0.2|ERROR |Bulk copy failed on table 'test_fme.SIG.ESP_NET_ApportVolontaire' using delimiter ':'. Error was 'ERROR: null value in column "objectid_sde" violates not-null constraint
DETAIL: Failing row contains (83858, null, 29019, 26/01/2022, GV, La poste st jacques_GV (ER), provisoire, GV142A1, null, null...'

I'd like this log to be printed in the cmd when I run the FME Workbench with Python. I got a loop for that :

for couche in ListeCouches :
 try :
 parameters = {}
 parameters['FEATURE_TYPES'] = couche 
 workspace.runWithParameters(workspace_path,parameters)
 print(couche)
 except Exception as ex:
 print(ex)
 continue

I've read stuffs with

logger = fmeobjects.FMELogFile()
logger.logMessageString("{}".format('Error'), fmeobjects.FME_ERROR)

but I don't understand what to do with.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Apr 20, 2022 at 9:17

1 Answer 1

0

I think the logger snippet you added at the end is for writing to the FME log file when you have python embedded in your FME Workspace. Whether that's part of a python startup or shutdown script, or a PythonCaller, etc. See the documentation.

If I understand correctly, you want to print the FME log file to the python console when you run your code to launch FME.

One way to do this is to read the log file after it has been written and print to the console.

Something like the following:

FMELog= open(theFMELogFilePath, 'r')
for line in FMELog.readlines():
 print line

Of course, this won't display the log immediately, it will print only when the workspace has completed.

answered Apr 21, 2022 at 23:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.