Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 1.59 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. File exists error - Python tarfile
  2. import tarfile
  3. tar = tarfile.open('/tmp/blah.tar.gz', 'r:gz')
  4. tar.extractall()
  5. tar.close()
  6.        
  7. In [26]: tar.extractall()
  8. ---------------------------------------------------------------------------
  9. OSError                                   Traceback (most recent call last)
  10.  
  11. /home/bubuzzz/Projects/secude/java/jdk/<ipython console> in <module>()
  12.  
  13. /usr/lib/python2.7/tarfile.pyc in extractall(self, path, members)
  14.    2044                 tarinfo = copy.copy(tarinfo)
  15.    2045                 tarinfo.mode = 0700
  16. -> 2046             self.extract(tarinfo, path)
  17.    2047
  18.    2048         # Reverse sort directories.
  19.  
  20.  
  21. /usr/lib/python2.7/tarfile.pyc in extract(self, member, path)
  22.    2081
  23.    2082         try:
  24. -> 2083             self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
  25.    2084         except EnvironmentError, e:
  26.    2085             if self.errorlevel > 0:
  27.  
  28. /usr/lib/python2.7/tarfile.pyc in _extract_member(self, tarinfo, targetpath)
  29.    2165             self.makedev(tarinfo, targetpath)
  30.    2166         elif tarinfo.islnk() or tarinfo.issym():
  31. -> 2167             self.makelink(tarinfo, targetpath)
  32.    2168         elif tarinfo.type not in SUPPORTED_TYPES:
  33.    2169             self.makeunknown(tarinfo, targetpath)
  34.  
  35. /usr/lib/python2.7/tarfile.pyc in makelink(self, tarinfo, targetpath)
  36.    2240             # For systems that support symbolic and hard links.
  37.  
  38.    2241             if tarinfo.issym():
  39. -> 2242                 os.symlink(tarinfo.linkname, targetpath)
  40.    2243             else:
  41.    2244                 # See extract().
  42.  
  43.  
  44. OSError: [Errno 17] File exists