
Untitled
By: a guest on
Aug 5th, 2012 | syntax:
None | size: 1.59 KB | hits: 10 | expires: Never
File exists error - Python tarfile
import tarfile
tar = tarfile.open('/tmp/blah.tar.gz', 'r:gz')
tar.extractall()
tar.close()
In [26]: tar.extractall()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/home/bubuzzz/Projects/secude/java/jdk/<ipython console> in <module>()
/usr/lib/python2.7/tarfile.pyc in extractall(self, path, members)
2044 tarinfo = copy.copy(tarinfo)
2045 tarinfo.mode = 0700
-> 2046 self.extract(tarinfo, path)
2047
2048 # Reverse sort directories.
/usr/lib/python2.7/tarfile.pyc in extract(self, member, path)
2081
2082 try:
-> 2083 self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
2084 except EnvironmentError, e:
2085 if self.errorlevel > 0:
/usr/lib/python2.7/tarfile.pyc in _extract_member(self, tarinfo, targetpath)
2165 self.makedev(tarinfo, targetpath)
2166 elif tarinfo.islnk() or tarinfo.issym():
-> 2167 self.makelink(tarinfo, targetpath)
2168 elif tarinfo.type not in SUPPORTED_TYPES:
2169 self.makeunknown(tarinfo, targetpath)
/usr/lib/python2.7/tarfile.pyc in makelink(self, tarinfo, targetpath)
2240 # For systems that support symbolic and hard links.
2241 if tarinfo.issym():
-> 2242 os.symlink(tarinfo.linkname, targetpath)
2243 else:
2244 # See extract().
OSError: [Errno 17] File exists