Tuesday 26 January 2016

arcpy - ArcGIS Calling Wrong fme.exe When Python Script Converted To An ArcGIS Script Tool


I'm using this this bit of code to execute a FME Workbench file through a Python script ...


import os
os.system("fme.exe P:\\Mapping\\Scripts\\FME\\Easements_ROW_Extract_From_CAD.fmw")

However, when I try using it as an ArcGIS script tool, ArcGIS tries to execute it using the Data Interop's fme.exe. I only have the stand alone version of FME. I tried using the full path to the fme.exe i'm trying to use, but that's not working ( the script runs without error, but nothing is produced). Any ideas on how to get this script to work, using the stand alone version of FME, as an ArcGIS script tool?



Answer



This worked for me. Apparently the os.system module is being replaced by the subprocess module. Here is the documentation.


import subprocess
subprocess.Popen(['C:\\Program Files\\FME\\fme.exe', 'P:\\Mapping\\Scripts\\FME\\Easements_ROW_Extract_From_CAD.fmw'])


This now works within an ArcGIS script tool.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...