Bug in os.popen* and win32pipe.popen*? - pipetest.py [0/1]

Alan Miller ajm at enteract.com
Mon Apr 16 09:14:54 EDT 2001


Blast it, here's sample code not as an attachment:

import os, win32pipe

TESTFILE = r"c:\autoexec.bat"

#The following are for Info-Zip
#ZIPPROG = r"c:\utils\infozip\zip.exe"
#PASSWORD1 = '-P "password"'
#PASSWORD2 = '-P "pass word"'     #the space breaks things for popen* only, not system

#The following are for PKZip
ZIPPROG = r"PKZip"
PASSWORD1 = '-s"password"'
PASSWORD2 = '-s"pass word"'     #the space breaks things for popen* only, not system

logfile = open("c:\pipetest.log", "a")

print "System"
#This will work fine
logfile.write("system\n")
os.system(ZIPPROG + ' ' + PASSWORD1 + r' c:\pipetest-P1-system.zip ' + TESTFILE)

#This will work fine
print "System 2"
logfile.write("system 2\n")
os.system(ZIPPROG + ' ' + PASSWORD2 + r' c:\pipetest-P2-system.zip ' + TESTFILE)

print "os.popen"
#This will work fine
outpipe = os.popen(ZIPPROG + ' ' + PASSWORD1 + r' c:\pipetest-P1-ospopen.zip ' + TESTFILE, "r")
logfile.write("os.popen\n" + outpipe.read() + '\n')

#this will fail (lose focus)
print "os.popen 2"
outpipe = os.popen(ZIPPROG + ' ' + PASSWORD2 + r' c:\pipetest-P2-ospopen.zip ' + TESTFILE, "r")
logfile.write("os.popen 2\n" + outpipe.read() + '\n')

#This will work fine
print "os.popen4"
(inpipe, outpipe) = os.popen4(ZIPPROG + ' ' + PASSWORD1 + r' c:\pipetest-P1-ospopen4.zip ' + TESTFILE, "t")
logfile.write("os.popen4\n" + outpipe.read() + '\n')

#this will fail (lose focus)
print "os.popen4 2"
(inpipe, outpipe) = os.popen4(ZIPPROG + ' ' + PASSWORD2 + r' c:\pipetest-P2-ospopen4.zip ' + TESTFILE, "t")
logfile.write("os.popen4 2\n" + outpipe.read() + '\n')

#This will work fine
print "win32pipe.popen"
outpipe = win32pipe.popen(ZIPPROG + ' ' + PASSWORD1 + r' c:\pipetest-P1-win32popen.zip ' + TESTFILE, "r")
logfile.write("win32pipe.popen\n" + outpipe.read() + '\n')

#this will fail (lose focus)
print "win32pipe.popen 2"
outpipe = win32pipe.popen(ZIPPROG + ' ' + PASSWORD2 + r' c:\pipetest-P2-win32popen.zip ' + TESTFILE, "r")
logfile.write("win32pipe.popen 2\n" + outpipe.read() + '\n')

#This will work fine
print "win32pipe.popen4"
(inpipe, outpipe) = win32pipe.popen4(ZIPPROG + ' ' + PASSWORD1 + r' c:\pipetest-P1-win32popen4.zip ' + TESTFILE, "t")
logfile.write("win32pipe.popen4\n" + outpipe.read() + '\n')

#this will fail (lose focus)
print "win32pipe.popen4 2"
(inpipe, outpipe) = win32pipe.popen4(ZIPPROG + ' ' + PASSWORD2 + r' c:\pipetest-P2-win32popen4.zip ' + TESTFILE, "t")
logfile.write("win32pipe.popen4 2\n" + outpipe.read() + '\n')

logfile.close()





More information about the Python-list mailing list