Skip to main content

I was using this question to help with launching workbench from shutdown script but I kept failing.

https://knowledge.safe.com/questions/93753/how-to-execute-a-workbench-from-python.html

The error message I get is.

BADNEWS: FME_END_PYTHON failure class StatusInfo *__cdecl FMETranslator::translate(class FMETValOrderedVector<class ObsoleteString>,bool &,void (__cdecl *)(FME_MsgLevel,const char *),void (__cdecl *)(const char *),bool,bool (__cdecl *)(void *,class ObsoleteString &),void *,bool)(c:\code\fme\foundation\kernel\fmetran.cpp:1369) - class StatusInfo *__cdecl FMETranslator::translate(class FMETValOrderedVector<class ObsoleteString>,bool &,void (__cdecl *)(FME_MsgLevel,const char *),void (__cdecl *)(const char *),bool,bool (__cdecl *)(void *,class ObsoleteString &),void *,bool)(c:\code\fme\foundation\kernel\fmetran.cpp:1369)

Here's my code:

import sys, os, fmeobjects

sys.path.append(r"C:\Program Files\FME\fmeobjects\python37")
os.chdir(r"C:\Program Files\FME")

runner = fmeobjects.FMEWorkspaceRunner()

# initiate FMEWorkspaceRunner Class

# Full path to Workspace, example comes from the FME 2014 Training Full Dataset
workspace = '"C:\Program Files\FME\fme.exe" "C:\Users\myname\My Documents\workspace\retrieveLogInfo.fmw"'
# Use Try so we can get FME Exception
try:
# Run Workspace with parameters set in above directory
   runner.run(workspace)
# or use promptRun to prompt for published parameters
#runner.promptRun(workspace)
except fmeobjects.FMEException as ex:
# Print out FME Exception if workspace failed
   print ex.message
else:
#Tell user the workspace ran
   print('The Workspace %s ran successfully'.format(workspace))
# get rid of FMEWorkspace runner so we don't leave an FME process running
runner = none

BADNEWS messages aren't errors, they're internal debug messages used by the developers at Safe. I recommend disabling them unless you need them for a very specific reason, e.g. debugging something for Safe. In this case, there is unfortunately not much help in them.

I suspect that the principal error in your script is that you cannot use the "fmeobjects" module in the startup or shutdown scripts.


If you are able to replace writers With FeatureWriter its much cleaner to use a WorkspaceRunner transformer. But if you have to have it in a shutdownscript, and can not use fmeobjects. you can try With subprocess.

  1. import os
  2. import sys
  3. from subprocess import Popen, PIPE
  4.  

  5. # Full path to Workspace, example comes from the FME 2014 Training Full Dataset
  6.  

  7. command = '"C:\\Program Files\\FME\\fme.exe" "C:\\Users\\myname\\My Documents\\workspace\\retrieveLogInfo.fmw"'.split()

 

  1. # Use Try so we can get FME Exception
  2. try:
  3. # Run Workspace with parameters set in above directory
  4. result = Popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()e0]
  5.  

  6. except Exception as ex:
  7. # Print out Exception if command failed
  8. print(ex.message)
  9. print(result)
  10. else:
  11. #Tell user the workspace ran
  12. print('The Workspace %s ran successfully'.format(workspace))
  13.  

I did not try this my self, but I believe it should work. did not run code so there might be typos and syntax errors beware.


Reply