473,569 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

zipfile.py, fp.seek(-22,2) error

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 seek(-22,2). Looks
to me like zipfile.py is trying to come back 22 bytes from the end of
file.

# python
Python 2.4.2 (#1, Oct 27 2005, 15:13:45)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
import zipfile
zf=zipfile.ZipF ile("testdoc.od t") Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.4/zipfile.py", line 210, in __init__
self._GetConten ts()
File "/usr/local/lib/python2.4/zipfile.py", line 230, in _GetContents
self._RealGetCo ntents()
File "/usr/local/lib/python2.4/zipfile.py", line 240, in
_RealGetContent s
endrec = _EndRecData(fp)
File "/usr/local/lib/python2.4/zipfile.py", line 83, in _EndRecData
fpin.seek(-22, 2) # Assume no archive comment.
IOError: [Errno 22] Invalid argument
ff=open("testdo c.odt","r")
ff.seek(-22,2) Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 22] Invalid argument ff.seek(0,2)
ff.seek(22,1)
ff.seek(22,2)
ff.seek(-22,2) Traceback (most recent call last):
File "<stdin>", line 1, in ?
IOError: [Errno 22] Invalid argument
on a windows machine using python 2.4.2 zipfile.py works fine.

Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
on win32

IDLE 1.1.2 import zipfile
zf=zipfile.ZipF ile("testdoc.od t")
ff=open("testdo c.odt","r")
ff.seek(-22,2)
ff.seek(0,0)
ff.seek(0,2)
ff.seek(-22,2)

here is a windows machine using python 2.3.2 (cygwin)

$ python
Python 2.3.2 (#1, Oct 9 2003, 12:03:29)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright" , "credits" or "license" for more information. ff=open("testdo c.odt","r")
ff.seek(-22,2)
ff.seek(0,2)
ff.seek(22,2)
ff.seek(0,0)
ff.seek(-22,2)
import zipfile
zf=zipfile.ZipF ile("testdoc.od t")


seek doesn't mind going -22 from the end on a windows machine but hates
doing it on a linux machine....

any idears????

Thanks and Best,

Waitman Gobble

Nov 6 '05 #1
1 4207
ok, i figured it out. the file i was trying to read on the linux
machine was 0b. lol. i guess the "invalid argument" error was throwing
me off.

Nov 6 '05 #2

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

Similar topics

1
2910
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... --------------------------------------------------------------------- dynamite4_db_archive.py", line 45, in ? file.write(name, os.path.basename(name),...
2
1538
by: Renzo | last post by:
Hi, I'm working to create a backup function for a software; in particular, from a directory with 12300 files (Jpg, medium size = 250KB / total size = 2.90GB), i have to create a zip file. I've decided to use the standard "zipfile" library to do that. This is the code: zipName = path.join(config.get('server.xbakPath'), 'backup.zip')...
5
2443
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. However when I try opening the files using zlib or zipfile modules I get the following error: Traceback (most recent call last):
11
7574
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'))
1
1757
by: Ritesh Raj Sarraf | last post by:
Hi, I've got a problem here. def compress_the_file(zip_file_name, files_to_compress, sSourceDir): """ Condenses all the files into one single file for easy transfer """ try:
3
4876
bvdet
by: bvdet | last post by:
Following is an example that may provide a solution to you: """ Function makeArchive is a wrapper for the Python class zipfile.ZipFile 'fileList' is a list of file names - full path each name 'archive' is the file name for the archive with a full path """ import zipfile, os def makeArchive(fileList, archive):
0
1658
by: Rocky Zhou | last post by:
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)
5
5141
by: Neil Crighton | last post by:
I'm using the zipfile library to read a zip file in Windows, and it seems to be adding too many newlines to extracted files. I've found that for extracted text-encoded files, removing all instances of '\r' in the extracted file seems to fix the problem, but I can't find an easy solution for binary files. The code I'm using is something...
1
2180
by: John Machin | last post by:
On Jun 4, 8:06 pm, jwesonga <crazylun...@gmail.comwrote: Nothing is ever as it seems. Let's try to work backwards from the error message ... and we don't need your magnificent script, just the traceback will do for now, so: The error says that you are trying to seek 22 bytes backwards from the
0
7711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7938
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7694
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5245
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3679
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2128
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1236
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.