Skip to main content

I would like to run a workspace using python and the code I have is simple, but it's not working. Is there something wrong with my python code or could it be something else?

import subprocess
args = dr"C:\Program Files\FME\fme.exe", "C:\ProgramData\Geocortex\Workflow\FMEScripts\testEmailer.fmw"]
subprocess.Popen(args)

 

You are missing a couple of arguments, like the path to the workspace to be run and optionally any published parameters.

 

 


You are missing a couple of arguments, like the path to the workspace to be run and optionally any published parameters.

 

 

oops. I posted the wrong code. I edited the question to show my py script


I've never used subprocess to run an fme workspace. There is an article on using fmeobjects and the FMEWorkspaceRunner.

 

 

https://knowledge.safe.com/articles/1158/run-an-fme-workspace-from-python-using-fmeworkspac.html

I found the problem. It was the syntax. So this thread has a similar line of code, but I noticed that the second argument has double backslashes and no r. 

https://knowledge.safe.com/articles/1158/run-an-fme-workspace-from-python-using-fmeworkspac.html

So I tested and found that either I need to put 'r' before the literal string for the path, or escape the '\' with '\\'. And that worked. so here is my new code and this is working.

import subprocess,os,getpass
args = sr"C:\Program Files\FME\fme.exe", r"C:\ProgramData\Geocortex\Workflow\FMEScripts\testEmailer.fmw"]
subprocess.Popen(args)

Reply