Skip to main content
Question

Run a workbench with Python from a Shutdown script

  • January 24, 2020
  • 2 replies
  • 47 views

salvaleonrp
Enthusiast
Forum|alt.badge.img+20

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
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • 8392 replies
  • January 27, 2020

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.


paalped
Contributor
Forum|alt.badge.img+5
  • Contributor
  • 130 replies
  • January 27, 2020

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()[0]
  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.