Skip to main content
Best Answer

running a workbench using python

  • October 22, 2019
  • 4 replies
  • 87 views

tnarladni
Enthusiast
Forum|alt.badge.img+23

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

4 replies

jdh
Contributor
Forum|alt.badge.img+40
  • 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+23
  • Author
  • Enthusiast
  • October 22, 2019

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+40
  • 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+23
  • 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)