473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with os.spawnv

I've had to migrate back to Python 2.1 and am now trying to use
os.spawnv to get around a memory leak (either in Python or ArcGIS or
both) in a geoprocessing script.

This script (Second Script) gets each Ascii file in the workspace,
converts it to a raster, sets the spatial reference, and hillshades it.
The script works on its own. In the Main Script I can successfully pass
parameters in a list, but no geoprocessing is ever initiated when using
os.spawnv. No errors are being thrown so I don't have a traceback to
post. Help getting this straightened out would be EXTREMELY
appreciated!
Main Script

# Import subprocess module
import os, sys

# Define arguments for subprocess
pyPath = "E:\\Python242\\python.exe"
pyScript = "E:\\Documents and
Settings\\Administrator\\Desktop\\Ian\\GIS\\Python \\subProcess2.py"
workspace = "E:\\GISTest"

# Get a list of ASCII files in the workspace for ASCII To Raster
conversion
filenames = os.listdir(workspace)
filenames = [filename.lower()
for filename in filenames
if (filename[-4:].lower() == ".asc" and filename[0] != "-" )]
for filename in filenames:
# Define Img filename, truncating .asc from inAscii filename
inAscii = workspace + "\\" + filename
outImg = workspace + "\\" + filename[:-4] + ".img"

# Create parameter list
parameterList = []
# First parameter is the name of the Python executable
parameterList.append('python.exe')
# Second parameter is the full path of the Python script
parameterList.append(pyScript)
# The following parameters are the arguments for the Batch script
parameterList.append(filename)
parameterList.append(inAscii)
parameterList.append(outImg)
parameterList.append(outHill)
print parameterList
# Run subprocess
os.spawnv(os.P_WAIT, pyPath, parameterList)
print parameterList

Second Script

I can't post this verbatim for work reasons, but basically it goes:

import sys, os, win32com.client, string
gp = win32com.client.Dispatch("esriGeoprocessing.GpDisp atch.1")
gp.SetProduct("ArcInfo")
gp.CheckOutExtension("Spatial")

# For each ASCII file, convert into IMG format
filename = sys.argv[1]
inAscii = sys.argv[2]
outImg = sys.argv[3]
outHill = sys.argv[4]

Do Ascii to raster conversion using inAscii, creating outImg

Set spatial reference

Hillshade using outImg, creating outHill

Convert each hillshade to IMG format, using outHill

Feb 10 '06 #1
0 6441

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: nushin | last post by:
Greetings, I am running RedHat 7.3 and trying to spawn a hello.py program from hello_driver.py by using spawn*( ) API, as a P_NOWAIT : os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python hello.py...
3
by: nushin | last post by:
Try to launch a test program that prints hello world for a minute or so using, spawnv( ) or spawnl( ). Check to see the process state code that the program is running. I am using RedHat Linux 7.3...
1
by: nushin | last post by:
If you do not null out the output of your parent process that launches a child process by os.spawnv( ) in P_NOWAIT mode, you will see that your child process is launched *synchronously* instead of...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
3
by: IamIan | last post by:
I am using os.spawnv in Python 2.1 to do some geoprocessing in a subroutine/process. Everything works great, except when the processing is done the subroutine just waits for a couple minutes before...
0
by: Damon Pettitt | last post by:
I'm not sure if this is how I'm supposed to post, but I saw a thread entitled, "Help with os.spawnv", that I wanted to respond to. I believe if you change the variable pyScript from:...
0
by: Chris Reuter | last post by:
I've been trying to start a particular external program from Python using os.spawnv(). This works perfectly under Linux but under Windows, it first runs the program, then throws an OSError...
2
by: Fabio Chelly | last post by:
Hi, I have a command line that works fine when I execute it directly: c:\\curl.exe -T c:\\upload.txt -u login:pwd ftp://ftp-myurl --ftp-ssl But when I try to use os.spawnv to excute it from...
8
by: Henrik Lied | last post by:
Hi there! I'm trying to convert a video in a background process. The scenario I'm after: 1. The user uploads a video 2. The video is saved in my media directory, and the database is populated...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.