By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 941 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

python unzip: os.popen3("unzip ...") or import zipfile?

P: n/a
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 =
# This makes the program hanging up
if strerr:
print >sys.stderr, 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()
for name in namelist:
if name.endswith('/'):
print name
os.mkdir(os.path.join(destdir, name))
outfile = open(os.path.join(destdir, name), 'wb')
zipfile.ZipFile.extract_all = _extract_all

def unzip(...):
zipo = zipfile.ZipFile(zipfn, 'r')

But I still want to know the reason why can't os.popen3("unzip ...")
be used.


Apr 2 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.