Norman Khine norman at khine.net
Wed Oct 6 15:26:28 CEST 2010


On Tue, Oct 5, 2010 at 5:57 PM, Susana Iraiis Delgado Rodriguez
<susana.delgado_s at utzmg.edu.mx> wrote:
> Hello, I already solved the problem, I change all the code, instead of using
> os.system I changed to subprocess.Popen() and it worked fine:
> import shlex, subprocess
> def process():
>      print "Ingresa en el siguiente orden:"
>      print "Nombre del nuevo mapa.shp Nombre de la capa Nombre del mapa
> original"
>      command_line = raw_input()
>      args = shlex.split(command_line)
>      p = subprocess.Popen(['C:/Archivos de
> programa/FWTools2.4.7/bin/ogr2ogr', args[0], '-where', args[1], args[2]])
>  if p:
>   print "Mapa generado"
> process()
> Now the user has to enter 3 arguments an finally it worked. I have a
> question, how can I tell the user if p execute ok? because even thouhg I
> entered wrong parameters, it prints "Mapa generado". This line should only
> appears if the arguments are acceptable.

it is better to validate the user input arguments before you execute
the subprocess

> 2010/10/5 Susana Iraiis Delgado Rodriguez <susana.delgado_s at utzmg.edu.mx>
>> Hello Norman:
>> Thank you for taking the time to answer. I already changed my os.system()
>> for your code. I got an error, when I executed this:
>> os.system(" 'C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr.exe ' "+arg1
>> +" -where "+arg2 +" " +arg3)
>> it throws me that "C:/Archivos"  is not recognized as an executable
>> external or internal command, programm or file.
>> If you really have other opton to fix my problem I'll be thankful because
>> I don't have any idea to make this code useful.
>> Thank you
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )

More information about the Tutor mailing list