[BangPypers] ReadError: opening tar file
murugadoss
murugadoss2884 at gmail.com
Fri Jun 4 12:18:56 CEST 2010
Further, on debug i got to know in tarfile.py (library file) function open(
) (Line 1147) where it is return the file attributes is failing, I am not
able to make out the exact reason, why it is failing in 64-bit M/c , but the
same is working in 32-bit M/c
I have attached the part code with the mail,
File: tarfile.py
Line:1147
if mode in ("r", "r:*"):
# Find out which *open() is appropriate for opening the file.
for comptype in cls.OPEN_METH:
func = getattr(cls, cls.OPEN_METH[comptype])
print "func",func
if fileobj is not None:
saved_pos = fileobj.tell()
try:
print "func1",func(name, "r", fileobj)
return func(name, "r", fileobj)
except (ReadError, CompressionError):
if fileobj is not None:
fileobj.seek(saved_pos)
continue
raise ReadError("file could not be opened successfully")
I have added few prints for debugging, please ignore it.
output :
tarfile.is_tarfile(tar)
func <bound method type.gzopen of <class 'tarfile.TarFile'>>
func1 func <bound method type.taropen of <class 'tarfile.TarFile'>>
func1 func <bound method type.bz2open of <class 'tarfile.TarFile'>>
func1
False
As u can see, the "func(name, "r", fileobj)", is returning none.
The same test output in 32bit Mc:
tarfile.is_tarfile(tar)
func <bound method type.gzopen of <class 'tarfile.TarFile'>>
func1 <tarfile.TarFile object at 0xb7f028ac>
True
Any information on this will be very useful.
If i am wrong. Please correct me
Thank u
--
Thanks & Regards
V.Murugadoss
On Fri, Jun 4, 2010 at 2:57 PM, murugadoss <murugadoss2884 at gmail.com> wrote:
> Hello,
>
> I am trying to extract a tar file. while doing this i check the valid tar
> file using is_tarfile( ).
> It is working fine in a 32-bit linux machine with python 2.5.4 version and
> when i try it out in a 64-bit linux pc, i end up saying file is
> invalid(false). This machine was using python 2.4 and now i have upgraded to
> 2.5.4 version and I am using python 2.5.4.
>
> I went through the library file, tarfile.py and found in is_tarfile(), is
> opening the tarfile using tarfile.open.
> >>>tar = /root/testtar.tar.gz
> >>> import tarfile
> >>> tarfile.is_tarfile(tar)
> False
> >>> tarfile.open(tar)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/local/lib/python2.5/tarfile.py", line 1153, in open
> raise ReadError("file could not be opened successfully")
> tarfile.ReadError: file could not be opened successfully
>
> Can anyone please help me
>
> --
> Thanks & Regards
> V.Murugadoss
>
More information about the BangPypers
mailing list