Extracting a file from a tarball

Boudreau, Emile Emile.Boudreau at cognos.com
Tue Apr 3 13:26:54 EDT 2007


I am trying to extract one file from a tarball, without success. This is
the code I'm using to open the tarball and extract the file:

tar = tarfile.open(component+'-win32-app-'+bestVersion+'-dev.tar.gz',
'r')
extractedFile = tar.extractfile('symbols.xml')

And this is my error:

Traceback (most recent call last):
  File "C:\CognosInstalls\AutoTest\PollDir.py", line 121, in <module>
    main()
  File "C:\CognosInstalls\AutoTest\PollDir.py", line 119, in main
    extract('c:\\', 'I:\\daily\\'+components[i], components[i])
  File "C:\CognosInstalls\AutoTest\PollDir.py", line 27, in extract
    filelike = tar.extractfile('symbols.xml')
  File "C:\Python25\lib\tarfile.py", line 1488, in extract
    tarinfo = self.getmember(member)
  File "C:\Python25\lib\tarfile.py", line 1171, in getmember
    raise KeyError("filename %r not found" % name)
KeyError: "filename 'symbols.xml' not found"

I know that the tarball contants this file "symbols.xml" but I don't
understand why it's not extracting it. Any help will be greatly
appreciated.

Thanks,

Emile Boudreau
 
     This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070403/6beb44b9/attachment.html>


More information about the Python-list mailing list