[BangPypers] ReadError: opening tar file

Anand Balachandran Pillai abpillai at gmail.com
Fri Jun 4 12:35:47 CEST 2010


On Fri, Jun 4, 2010 at 11:27 AM, 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
>

I have a test tar file named f.tar.gz.

>>> import tarfile
>>> tarfile.open('f.tar.gz')
<tarfile.TarFile object at 0x7f8a652fdad0>
>>> tarfile.is_tarfile('f.tar.gz')
True

and for you,

>>>tar = /root/testtar.tar.gz
>>> import tarfile
>>> tarfile.is_tarfile(tar)
False

So your "tar file" is not a real tar file. No wonder it is failing
to open. Does it take rocket science to figure this out ?


>
> Can anyone please help me
>

Yes, only you can help yourself now. Spend time learning!


>
> --
> Thanks & Regards
> V.Murugadoss
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--Anand


More information about the BangPypers mailing list