saved_pos = fileobj.tell()
try:
return func(name, "r", fileobj, **kwargs)
- except (ReadError, CompressionError), e:
+ except (ReadError, CompressionError):
if fileobj is not None:
fileobj.seek(saved_pos)
continue
else:
size_left = max_size_to_write = tarinfo.size
- data_written = 0
-
# iterate, one iteration per volume (usually only one volume)
while tarinfo.volume_offset < tarinfo.size:
copyfileobj(fileobj, self.fileobj, max_size_to_write)
else:
if sys.platform != "os2emx":
os.chown(targetpath, u, g)
- except EnvironmentError, e:
+ except EnvironmentError:
raise ExtractError("could not change owner")
def chmod(self, tarinfo, targetpath):
if hasattr(os, 'chmod'):
try:
os.chmod(targetpath, tarinfo.mode)
- except EnvironmentError, e:
+ except EnvironmentError:
raise ExtractError("could not change mode")
def utime(self, tarinfo, targetpath):
return
try:
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
- except EnvironmentError, e:
+ except EnvironmentError:
raise ExtractError("could not change modification time")
#--------------------------------------------------------------------------
-import sys, os, unittest, hashlib, random, string
+import os, unittest, hashlib, string
from deltatar.tarfile import TarFile, PAX_FORMAT
assert os.path.exists("big")
assert hash == self.md5sum("big")
-
- def test_volume_extract2(self):
- '''
- Create a volume with gnu tar command and extract it with our tarfile lib
- '''
- # create the content of the file to compress and hash it
- hash = self.create_file("big", 5*1024*1024)
-
- # create the tar file with volumes
- os.system("tar cM -L 3M big --file=sample.tar --file=sample.tar.1")
-
- # check that the tar volumes were correctly created
- assert os.path.exists("sample.tar")
- assert os.path.exists("sample.tar.1")
- assert not os.path.exists("sample.tar.2")
-
- os.unlink("big")
- assert not os.path.exists("big")
-
- # extract and check output
- tarobj = TarFile.open("sample.tar",
- mode="r",
- new_volume_handler=new_volume_handler)
- tarobj.extractall()
- tarobj.close()
- assert os.path.exists("big")
- assert hash == self.md5sum("big")
-
-
def test_multiple_files_volumes_extract(self):
# creates a multivolume tar file with multiple files and extracts it