Skip to main content
Solved

How to know if a translation was successfully or not

  • September 7, 2018
  • 5 replies
  • 36 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

1import fme
2
3message = 'SUCCESS' if fme.status else 'FAILURE'
4
5log_filename = fme.macroValues['FME_MF_DIR'] + '/' + 
6               fme.macroValues['WORKSPACE_NAME'] + '_status.log'
7
8with open(log_filename, 'w') as statuslog:
9    statuslog.write(message)
10

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

View original
Did this help you find an answer to your question?
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?


david_r wrote:

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):

1Translation was SUCCESSFUL

or

1Translation FAILED

david_r wrote:

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):

1Translation was SUCCESSFUL

or

1Translation 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

1import fme
2
3message = 'SUCCESS' if fme.status else 'FAILURE'
4
5log_filename = fme.macroValues['FME_MF_DIR'] + '/' + 
6               fme.macroValues['WORKSPACE_NAME'] + '_status.log'
7
8with open(log_filename, 'w') as statuslog:
9    statuslog.write(message)
10

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


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