Skip to main content
Question

FME command line: return count of features

  • June 20, 2018
  • 1 reply
  • 14 views

Currently I use python to launch FME workspaces and return error with subprocess (below). Is it possible to also return count of the features written?

CommandLine = 'FME ' +ScriptName +' -LOG_FILENAME ' +FME_LOG

 

try:

 

retcode = subprocess.call(CommandLine)

 

if retcode == 0:

 

logger.info(' Complete on SABOGISP01 @@@ ')

1 reply

david_r
Celebrity
  • June 21, 2018

Unfortunately, no, not directly.

But you can leverage the Python shutdown script to write the feature counts in a small json (or other) file which you can easily re-read in your external Python script. Example shutdown script that outputs "workspace_results.json" in the same folder as your workspace:

import fme
import os.path
import json

if fme.status:
    content = json.dumps(fme.featuresWritten)
else:
    content = json.dumps({'failure': fme.failureMessage})

log_filename = os.path.join(fme.macroValues['FME_MF_DIR'], 'workspace_results.json')
with open(log_filename, 'w'as logfile:
    logfile.write(content)

Be aware that FeatureWriters will not be listed, however (see here).

For more information about the objects available in the Python shutdown script, see:

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Workbench/Configuration/FME_END_PYTHON.htm


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