Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > zipfile.py, fp.seek(-22,2) error

Reply
Thread Tools

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

 
 
Waitman Gobble
Guest
Posts: n/a
 
      11-06-2005
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.ZipFile("testdoc.odt")

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.4/zipfile.py", line 210, in __init__
self._GetContents()
File "/usr/local/lib/python2.4/zipfile.py", line 230, in _GetContents
self._RealGetContents()
File "/usr/local/lib/python2.4/zipfile.py", line 240, in
_RealGetContents
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("testdoc.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.ZipFile("testdoc.odt")
>>> ff=open("testdoc.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("testdoc.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.ZipFile("testdoc.odt")
>>>


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

 
Reply With Quote
 
 
 
 
Waitman Gobble
Guest
Posts: n/a
 
      11-06-2005
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xffc Thread 0x228 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-30-2006 03:16 PM
Error connecting to SQLExpress 2005 locally (error: 26 - Error Locating Server/Instance Specified) hfk0 ASP .Net 2 03-27-2006 08:43 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 1 03-24-2006 04:20 PM
ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x8fc Thread 0x934 DBC 0x437b94 Jet'. ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr bazzer ASP .Net 0 03-24-2006 02:22 PM
Error 500: ERROR: Cannot forward. Writer or Stream already obtained. Error JavaQueries Java 1 03-01-2005 06:30 PM



Advertisments