Hello Guys,

 

I'm having a MASSIVE headache today with zip files, I had it working a while
ago but it all seems to have stopped in the past 30 minutes and I can't
figure out why.

 

I'm simply trying to write a function that will unzip a file, simple as
that. I've currently got this code:

 

Import zipfile

 

              zip = zipfile.ZipFile('Media/Media.zip', 'r')

              unzip(zip)

              zip.close()

 

def unzip(zip):

       for name in zip.namelist():

              newname = 'Media/%s' % (name)

              file(newname, 'wb').write(zip.read(name))

 

Now when I try and run this i get the following error message:

 

  File "/usr/lib/python2.4/zipfile.py", line 242, in _RealGetContents

    raise BadZipfile, "File is not a zip file"

zipfile.BadZipfile: File is not a zip file

 

However, if I copy the zip file off the unit client onto my windows box and
unzip it and it works absolutely perfectly, all the files are extracted as I
would expect, which leads me to think the zip file is fine, and i must just
be missing something in my code.

 

Any ideas guys? I'm tearing my hair out here.

 

Rob

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to