I think I just need a second set of eyes on this. I'm just using Python to capture some user inputs to pass down to GME command. I'm only using the export to CSV to hammer out the behavior, but the final outcome will be an ArcPY tool for creating sample points. Fun stuff. (Please ignore my imported modules).
import arcpy, os, sys, subprocess inFeatures = r"D:\TEMP\junk.shp" OutputLocation = r"D:\TEMP" OutputBasename = os.path.splitext(inFeatures) OutputCSV = OutputBasename + ".csv" GME = r'C:\Program Files (x86)\SpatialEcology\GME\SEGME.exe' ARG = ' export.csv(in=\"' + inFeatures + '", out=\"' + OutputCSV + '");' CMD = GME + ARG print CMD subprocess.call(CMD)
The printed command is as follows:
C:\Program Files (x86)\SpatialEcology\GME\SEGME.exe export.csv(in="D:\TEMP\junk.shp", out="D:\TEMP\junk.csv");
And that looks to be correct
I have excluded the '-c' switch for the sake of debugging.
When GME is launched, the following output is provided.
Found R here: C:\Program Files\R\R-3.0.1\bin To switch to a different version of R use the 'Set R executable folder' item in the File menu, or use the r.setpath() command. export.csv(in=D:\TEMP\junk.shp, out=D:\TEMP\junk.csv); Error: Variable name could not be resolved (D:\TEMP\junk.shp) or quotes were omitted when providing a text parameter; command cannot be interpreted
The actual command within GME should look like this:
So, for some reason my quotes are not getting passed to GME?
The only clue I have related to this in the documentation is as follows:
Please note that you need to add a backslash before all quote marks in the commands text, otherwise it is the same syntax as GME. For instance, here is a Python call to GME that tells it to run the GME script called "E:ndatangmescript.txt": subp.call(r'C:nProgram FilesnSpatialEcologynGMEnSEGME.exe -c run(in=n"E:ndatangmescript.txtn");');
Also, please note I'm still learning the ins & outs of subprocess.
Aside from 'is my syntax correct?', I'm not sure how to roll this into a more direct question.
EDIT: I'm adding the only Python reference in the help document:
You must rst load the subprocess Python library (using: import subprocess as subp) at the beginning of your Python session. To call GME from the command line you use the following generic syntax: os.system(r'pathnSEGME.exe commands') where path is the full directory path to the SEGME command, usually: subp.call(r'C:nProgram FilesnSpatialEcologynGMEnSEGME.exe commands') and commands is the list of commands you wish to execute. Note that the r at the beginning of that path name is not a mistake: it tells Python to interpret the following text literally. Please note that you need to add a backslash before all quote marks in the commands text, otherwise it is the same syntax as GME. For instance, here is a Python call to GME that 17 tells it to run the GME script called "E:\data\gmescript.txt": subp.call(r'C:\Program Files\SpatialEcology\GME\SEGME.exe -c run(in=\"E:\datangmescript.txt\");'); (This command has been displayed on two lines here because it is too long for a single line, though in Python it would be a single line). Note that by including -c directly after SEGME.exe, this will force the GME interface to close when it has nished running the specied commands.