472,373 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 software developers and data experts.

Error from zipfile

Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, then read in and processed by
zipfile. I've tried adding the flag to allow 64 bit and even using
uncompressed zip files. Niether fixes the problem.

The zip file and contents were created on linux. To be certain that
was not the issue I have emptied the zip file, created a new one,
opend all the files in wordpad and saved them, then put the contents
into the new file. Still no joy.

Any help would be greatly appreciated. On linux I'm running python 2.5
and on windows it is 2.4.

Thanks,

Wesley Brooks.
Jul 1 '08 #1
2 1249
On Tue, 01 Jul 2008 16:38:23 +0100, Wesley Brooks wrote:
Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, […]
Are you sure you read and save the file in binary mode, especially on
windows!?

Ciao,
Marc 'BlackJack' Rintsch
Jul 1 '08 #2
On Jul 2, 1:38 am, "Wesley Brooks" <wesbro...@gmail.comwrote:
Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, then read in and processed by
zipfile.
If "saved as per usual" means something like open('foo.zip',
'w').write(the_string) then this is highly likely to be your
problem. Use 'wb'. Get into the habit of using the 'b' flag on
binary files in your scripts (whether reading or writing) and they'll
be much more portable.

Something to check: on the Linux side, do
wc -l foo.zip
(that option's 'L'.lower()) to get the number of pseudo-lines in your
zip file, and compare the sizes of the file on Linux and Windows. What
do you see?

HTH,
John
Jul 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
1
by: LC | last post by:
Hi, I'm having a problem using the zipfile module in Windows 2000 sp4. When I use it to zip a small file it works fine, but large file doesnt. Here's the error msg i get......
19
by: Gerson Kurz | last post by:
AAAAAAAARG I hate the way python handles unicode. Here is a nice problem for y'all to enjoy: say you have a variable thats unicode directory = u"c:\temp" Its unicode not because you want it...
0
by: Ian Cook | last post by:
Hi, I'm new to python so please excuse me if this is a 'dumb' question. I want to use the ZipFile module to UPDATE, rather than append, or create a new zip file. Does anyone know how this can...
1
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a...
5
by: Waguy | last post by:
Hi all, I am new to python and want to create a process to unzip large numbers of zip files I get from a SOAP application. The files all have a ZIP extention and can be unzipped using WinZip. ...
11
by: Hari Sekhon | last post by:
I do import zipfile zip=zipfile.ZipFile('d:\somepath\cdimage.zip') zip.namelist() then either of the two: A) file('someimage.iso','w').write(zip.read('someimage.iso'))
5
by: OriginalBrownster | last post by:
This will probably sound like a very dumb question. I am trying to zip some files within a directory. I want to zip all the files within a directory called "temp" and have the zip archive...
8
by: =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post by:
I made a C/S network program, the client receive the zip file from the server, and read the data into a variable. how could I process the zipfile directly without saving it into file. In the...
3
by: towers | last post by:
Hi I'm probably doing something stupid but I've run into a problem whereby I'm trying to add a csv file to a zip archive - see example code below. The csv just has several rows with carriage...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.