python unzip At first, I tried to use 'os.popen3("unzip ...") like this: fin, fout, ferr = os.popen3("unzip -o -d %s %s" % (dest, zipfile)) strerr = ferr.read() # This makes the program hanging up if strerr: print >> sys.stderr, strerr outlog.error(strerr)
I want to know is this caused by the 'unzip' command does not print 'EOF'? or any other reasons? At last I did this to do 'unzip': import zipfile def _extract_all(self, destdir): namelist = self.namelist() namelist.sort() for name in namelist: if name.endswith('/'): print name os.mkdir(os.path.join(destdir, name)) else: outfile = open(os.path.join(destdir, name), 'wb') outfile.write(self.read(name)) outfile.close() zipfile.ZipFile.extract_all = _extract_all def unzip(...): zipo = zipfile.ZipFile(zipfn, 'r') zipo.extract_all(dest) But I still want to know the reason why can't os.popen3("unzip ...") be used. Thanks.
-- http://mail.python.org/mailman/listinfo/python-list