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:\\Docume nts and
Settings\\Admin istrator\\Deskt op\\Ian\\GIS\\P ython\\subProce ss2.py"
workspace = "E:\\GISTes t"
# Get a list of ASCII files in the workspace for ASCII To Raster
conversion
filenames = os.listdir(work space)
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.a ppend('python.e xe')
# Second parameter is the full path of the Python script
parameterList.a ppend(pyScript)
# The following parameters are the arguments for the Batch script
parameterList.a ppend(filename)
parameterList.a ppend(inAscii)
parameterList.a ppend(outImg)
parameterList.a ppend(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("esri Geoprocessing.G pDispatch.1")
gp.SetProduct(" ArcInfo")
gp.CheckOutExte nsion("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 0 6472 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 >/dev/null
&'))
and when i check the process state code of hello.py by:
ps -aux
|
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 and Python
2.2.2 and i see that the program is either launched as Zombie state
using spawnv(), or running in State "S" sleep in spawnl( ).
Here's the sample code that launches my program:
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python...
|
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
asynchronously. This is a bug!
Here's a code sample:
In your parent.py file, call child.py as
os.spawnv(os.P_NOWAIT,'/usr/bin/python',('python', 'child.py'))
|
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 the microsoft HTML workshop utility, lets call it
c:\path\help.chm. My question is how do you launch it from the GUI?
What logic do I put behind the "help" button, in other words.
I thought it would be
os.spawnv(os.P_DETACH,...
|
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 closing
itself and returning to the main script. I have tried using sys.exit()
and exit() but these aren't doing anything.
What is the proper way to terminate this subroutine upon completion,
rather than waiting? Thank you.
| |
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:
"E:\\Documents and Settings\\Administrator\\Desktop\\Ian\\GIS\\Python\\subProcess2.py"
to
'"E:\Documents and Settings\Administrator\Desktop\Ian\GIS\Python\subProcess2.py"'
(this basically uses a single backslash and a single quote preceding the first...
|
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 exception
with the tuple (0, 'Error'):
>>> spawnv(P_WAIT, 'c:/mctools/bin/mc', )
Archelon Tool Driver 3.09 2005/02/16
No input file was given.
Traceback (most recent call last):
|
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 my python code, it
doesn't work at all. Here is my code:
exe = "c:\\curl.exe"
|
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 with the references
3. The video gets converted to FLV - but the user shouldn't have to
wait around for this to happen
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |