Skip to main content
Solved

running a workbench using python


tnarladni
Enthusiast
Forum|alt.badge.img+16

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 = [r"C:\Program Files\FME\fme.exe""C:\ProgramData\Geocortex\Workflow\FMEScripts\testEmailer.fmw"]
subprocess.Popen(args)

 

Best answer by tnarladni

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 = [r"C:\Program Files\FME\fme.exe"r"C:\ProgramData\Geocortex\Workflow\FMEScripts\testEmailer.fmw"]
subprocess.Popen(args)
View original
Did this help you find an answer to your question?

4 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • October 22, 2019

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

 

 


tnarladni
Enthusiast
Forum|alt.badge.img+16
  • Author
  • Enthusiast
  • October 22, 2019
jdh wrote:

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


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • October 22, 2019

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

tnarladni
Enthusiast
Forum|alt.badge.img+16
  • Author
  • Enthusiast
  • Best Answer
  • October 22, 2019

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 = [r"C:\Program Files\FME\fme.exe"r"C:\ProgramData\Geocortex\Workflow\FMEScripts\testEmailer.fmw"]
subprocess.Popen(args)

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