Skip to main content
Solved

How to know if a translation was successfully or not

  • September 7, 2018
  • 5 replies
  • 47 views

I have a c# application that runs fme translation but how can I know if the translation was successfully or not?

Best answer by david_r

You can also use the workspace shutdown script to write out the translation status.

Sample Python shutdown script that will write either "SUCCESS" or "FAILURE" to the text file named <workspace filename>_status.log

import fme

message = 'SUCCESS' if fme.status else 'FAILURE'

log_filename = fme.macroValues['FME_MF_DIR'] + '/' + 
               fme.macroValues['WORKSPACE_NAME'] + '_status.log'

with open(log_filename, 'w') as statuslog:
    statuslog.write(message)

There's a lot if interesting stuff in the 'fme' module that you may want to in include in this file:

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

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.

5 replies

david_r
Celebrity
  • September 7, 2018

How does your code run the FME translation? Using the .NET IFMEOWorkspaceRunner interface, or by any other method?


How does your code run the FME translation? Using the .NET IFMEOWorkspaceRunner interface, or by any other method?

No I don't use IFMEOWorkspaceRunner, the simplest way I found was to open a process and run it with arguments; but I need to know if the translation was successfully or not in order to save the result in a table.

 

In case is needed this is the code I use for open a process, pass the arguments and run fme.

 

 

ProcessStartInfo info = new ProcessStartInfo;

 

info.Arguments = "/C fme.exe " + workspace + " --BName " + BNameFix + " --BType " + BType + " --DB " + DB + " --Schema " + Schema + " --DName " + DName + " --DestDataset_ACAD " + "\\"";

 

info.FileName = "fme.exe";

 

Process.Start (info);

 

 


david_r
Celebrity
  • September 10, 2018

The simplest solution is probably to use the Process.ExitCode property:

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.exitcode?redirectedfrom=MSDN&view;=netframework-4.7.2#System_Diagnostics_Process_ExitCode

There may be some cases where this won't work, however, and if so you'll probably have to scan the FME log file and look for either string (I recommend case sensitive):

Translation was SUCCESSFUL

or

Translation FAILED

The simplest solution is probably to use the Process.ExitCode property:

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.exitcode?redirectedfrom=MSDN&view;=netframework-4.7.2#System_Diagnostics_Process_ExitCode

There may be some cases where this won't work, however, and if so you'll probably have to scan the FME log file and look for either string (I recommend case sensitive):

Translation was SUCCESSFUL

or

Translation FAILED
Thank you @david_r; but as you said this won't wok in some cases and I was thinking what if I can use python? there's any way that I can use python to know or to log into a file if the translation was successful or not? thanks

 


david_r
Celebrity
  • Best Answer
  • September 10, 2018

You can also use the workspace shutdown script to write out the translation status.

Sample Python shutdown script that will write either "SUCCESS" or "FAILURE" to the text file named <workspace filename>_status.log

import fme

message = 'SUCCESS' if fme.status else 'FAILURE'

log_filename = fme.macroValues['FME_MF_DIR'] + '/' + 
               fme.macroValues['WORKSPACE_NAME'] + '_status.log'

with open(log_filename, 'w') as statuslog:
    statuslog.write(message)

There's a lot if interesting stuff in the 'fme' module that you may want to in include in this file:

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