I have developed some python scripts to be run when translations are completed. I developed these in PythonWin. I've been pasting the text of these scripts into the "Shutdown Python Script" area under Workspace parameters. Can I call the scripts instead?
Instead of adding a shutdown python script, is it possible to call a python script when the translation has completed?
Best answer by takashi
Hi @angela, if you are looking for a way to run a script defined in an external Python script file when the translation has completed, an easy way is to save your script file (*.py) into the same directory in which you have saved the workspace file (*.fmw), and import it as an module in the shutdown script.
For example, if you have "my_script.py" that contains a function called "my_func()", you can call the function in the shutdown script like this.
import my_script
my_script.my_func()See here to learn more: Python Documentation > The Python Tutorial > 6. Modules
You can also use a function or class defined in an external file with a PythonCaller.
However, note that the function/class definition has to be conformed to the templates described in the transformer parameter "Python Script". For example, a function that you want to call with a PythonCaller should take a single argument which stores an fmeobject.FMEFeature object.
# my_script.py
def my_func(feature):
# do something
pass
PythonCaller parameters:
- Python Script: import my_script
- Class or Function to Process Features: my_script.my_func
Hope this helps.
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.
Login to the community
No account yet? Create an account
An FME Account is required to contribute
LoginEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.


