wsleavin

Error setting GP Properties in a Python Subprocess

Discussion created by wsleavin on Jul 1, 2011
So I am using the following code to call another python routine which does some geoprocessing.

def runcmd(cmd, format='s'):
  import subprocess
  proc = subprocess.Popen(cmd, shell=True,        stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  stdout,stderr=proc.communicate()
  exit_code=proc.wait()
  return exit_code,stdout,stderr


Everything works fine until I launch the primary script from the toolbox. It appears to me that if I try to set any environment variables (Workspace, Mask, Extent, etc) in the subroutine it throws an error. The sub looks basically like this...

# Import system modules
import arcgisscripting, time, sys, os

gp = arcgisscripting.create(9.3)
gp.OverwriteOutput = 1
gp.CheckOutExtension("spatial")
try:
#now do some gp stuff

suggestions?

/wJs

Outcomes