Re: [Tutor] Runnig a windows.exe from python

2010-09-30 Thread Susana Iraiis Delgado Rodriguez
Hello !

I apoligize for the format of my last message, I didn't realize that putting
my text in bold format will show those asterisks.
By the way you're Alan, for the pythom module I first had to read my
arguments and passed them to the os.system(), it worked. Now when I execute
this command, in my normal DOS Windows, I must change to another path before
I run the .exe, I don't know how to tell this to my python module. This is
my code:

from dbf import *
from osgeo import ogr
import os
import sys
def call():
  os.chdir('C:\Python26')
  arg1 = R1G-GEODESIA2.shp
  arg2 = LAYER = 'R1G-GEODESIA'
  arg4 = tapalpa_05_plani_point.shp
  os.system('C:/Archivos de programa/FWTools2.4.7/setfw')
  os.system('C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr.exe'+ 
+arg1 + + -where + + arg3 +  +arg4)
call()

If I run it, it shows me the following error:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
on
win32
Type help, copyright, credits or license for more information.
 import fw
Ingresa el nombre para el nuevo mapa
R1G-GEODESIA2.shp
Ingresa la condicion
LAYER = 'R1G-GEODESIA'
Ingresa el nombre del mapa original
tapalpa_05_plani_point.shp
FAILURE:
Unable to open datasource `arg3' with the following drivers.
  - ESRI Shapefile
  - MapInfo File
  - UK .NTF
  - SDTS
  - TIGER
  - S57
  - DGN
  - VRT
  - REC
  - Memory
  - BNA
  - CSV
  - NAS
  - GML
  - GPX
  - KML
  - GeoJSON
  - Interlis 1
  - Interlis 2
  - GMT
  - SQLite
  - ODBC
  - PGeo
  - OGDI
  - PostgreSQL
  - MySQL
  - XPlane
  - AVCBin
  - AVCE00
  - DXF
  - Geoconcept
  - GeoRSS
  - GPSTrackMaker
  - VFK

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Runnig a windows.exe from python

2010-09-30 Thread Steven D'Aprano
On Fri, 1 Oct 2010 04:05:08 am Susana Iraiis Delgado Rodriguez wrote:
 Hello !

 I apoligize for the format of my last message, I didn't realize that
 putting my text in bold format will show those asterisks.
 By the way you're Alan, for the pythom module I first had to read my
 arguments and passed them to the os.system(), it worked. Now when I
 execute this command, in my normal DOS Windows, I must change to
 another path before I run the .exe, I don't know how to tell this to
 my python module. 

os.chrdir(path)

changes to a new path.



-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Runnig a windows.exe from python

2010-09-29 Thread Susana Iraiis Delgado Rodriguez
Hello everyone:

I'm working in a simple python module to run a external command, this
command is named ogr2ogr.exe . When I execute my python script :

*import os
def call():
 os.system(' C:\\Archivos de programa\\FWTools2.4.7\\bin\\ogr2ogr.exe
')*
* raw_input()*
*call()*
It runs, but if I want to enter arguments: *ogr2ogr*  to test my .exe, it
shows me an error *ogr2ogr is not define, *any suggestion?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Runnig a windows.exe from python

2010-09-29 Thread Steven D'Aprano
On Thu, 30 Sep 2010 05:49:53 am Susana Iraiis Delgado Rodriguez wrote:
 Hello everyone:

 I'm working in a simple python module to run a external command, this
 command is named ogr2ogr.exe . When I execute my python script :

 *import os
 def call():
  os.system(' C:\\Archivos de
 programa\\FWTools2.4.7\\bin\\ogr2ogr.exe ')*
 * raw_input()*
 *call()*
 It runs, but if I want to enter arguments: *ogr2ogr*  to test my
 .exe, it shows me an error *ogr2ogr is not define, *any suggestion?

Please don't add extra bits around the code you use -- there's no need 
to add asterisks * around the code. Just copy and paste it it into the 
email.

Can you please copy and paste the exact error message you get? Include 
the full traceback, not just the last line.

Also, it is a little-known thing that Windows accepts forward slashes as 
well as back-slashes in pathnames. So it is easier to write:

C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr.exe 

than:

C:\\Archivos de programa\\FWTools2.4.7\\bin\\ogr2ogr.exe 



-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Runnig a windows.exe from python

2010-09-29 Thread Alan Gauld
Susana Iraiis Delgado Rodriguez susana.delgad...@utzmg.edu.mx 
wrote


I'm working in a simple python module to run a external command, 
this

command is named ogr2ogr.exe . When I execute my python script :

*import os
def call():
os.system(' C:\\Archivos de 
programa\\FWTools2.4.7\\bin\\ogr2ogr.exe

')*
* raw_input()*
*call()*
It runs, but if I want to enter arguments: *ogr2ogr*  to test my 
.exe, it

shows me an error *ogr2ogr is not define, *any suggestion?


You need to read the arfguments before calling the exe. Then create 
the full

command string and pass that tro os.system.

However os.system is a blunt instrument, you will find you have much 
more

control using the subprocess module which supercedes os.system and
various others ways of executing external programs. It take a wee bit
more effort but the extra control is worth it.

The documentation  has numerous examples and the Using the OS
topic of my tutorial has some info too.

HTH

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor