1

I should just unzip RESULT folder inside of output.tgz archive

#!/usr/bin/python
import os, sys, tarfile, gzip


    def unZip(self,file, filename,dire):  
        tar = tarfile.open(filename,"r:gz")
        for file in tar.getmembers():
       if file.name.startswith("RESULT"):
               tar.extract(file,dire)
               print 'Done.'



def main():
    utilities = ZipUtil()
    filename = 'output.tgz'
    directory = str(sys.argv[1]);
    path = os.path.join(directory, filename)
    utilities.unZip(directory,path,directory)

    main()

and I'm getting this error

  File "/usr/lib64/python2.7/tarfile.py", line 1805, in getmembers
    self._load()        # all members, we first have to
  File "/usr/lib64/python2.7/tarfile.py", line 2380, in _load
    tarinfo = self.next()
  File "/usr/lib64/python2.7/tarfile.py", line 2315, in next
    self.fileobj.seek(self.offset)
  File "/usr/lib64/python2.7/gzip.py", line 429, in seek
    self.read(1024)
  File "/usr/lib64/python2.7/gzip.py", line 256, in read
    self._read(readsize)
  File "/usr/lib64/python2.7/gzip.py", line 303, in _read
    self._read_eof()
  File "/usr/lib64/python2.7/gzip.py", line 342, in _read_eof
    hex(self.crc)))
IOError: CRC check failed 0xccf8af55 != 0x43cb4d43L

There are many questions like this but still now answer for this proble. The file output.tgz is downloaded and it might be corrupted this is why I guess its not working. But is there anyway around to tell tar to open it. THnak a lot!

  • does it work without python? with tar and gunzip ? – oz123 Feb 18 '14 at 11:43
  • no it returs error as well. gzip: stdin: unexpected end of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now – user3082058 Feb 18 '14 at 11:48
  • possible duplicate of [How can I recover files from a corrupted .tar.gz archive?](http://stackoverflow.com/questions/201392/how-can-i-recover-files-from-a-corrupted-tar-gz-archive) – Martin Tournoij Feb 18 '14 at 11:54
  • The code should work as is. You can create a tar file locally to test it. – Ricardo Cárdenes Feb 18 '14 at 12:06

0 Answers0