Python tarfile.RECORDSIZE Examples
The following are 12
code examples of tarfile.RECORDSIZE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tarfile
, or try the search function
.
Example #1
Source File: test_tarfile.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.mode.endswith("gz"): with gzip.GzipFile(tmpname) as fobj: data = fobj.read() elif self.mode.endswith("bz2"): dec = bz2.BZ2Decompressor() with open(tmpname, "rb") as fobj: data = fobj.read() data = dec.decompress(data) self.assertTrue(len(dec.unused_data) == 0, "found trailing data") else: with open(tmpname, "rb") as fobj: data = fobj.read() self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding")
Example #2
Source File: test_tarfile.py From BinderFilter with MIT License | 6 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.mode.endswith("gz"): fobj = gzip.GzipFile(tmpname) data = fobj.read() fobj.close() elif self.mode.endswith("bz2"): dec = bz2.BZ2Decompressor() data = open(tmpname, "rb").read() data = dec.decompress(data) self.assertTrue(len(dec.unused_data) == 0, "found trailing data") else: fobj = open(tmpname, "rb") data = fobj.read() fobj.close() self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding")
Example #3
Source File: test_tarfile.py From oss-ftp with MIT License | 6 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.mode.endswith("gz"): fobj = gzip.GzipFile(tmpname) data = fobj.read() fobj.close() elif self.mode.endswith("bz2"): dec = bz2.BZ2Decompressor() data = open(tmpname, "rb").read() data = dec.decompress(data) self.assertTrue(len(dec.unused_data) == 0, "found trailing data") else: fobj = open(tmpname, "rb") data = fobj.read() fobj.close() self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding")
Example #4
Source File: test_tarfile.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.mode.endswith("gz"): fobj = gzip.GzipFile(tmpname) data = fobj.read() fobj.close() elif self.mode.endswith("bz2"): dec = bz2.BZ2Decompressor() data = open(tmpname, "rb").read() data = dec.decompress(data) self.assertTrue(len(dec.unused_data) == 0, "found trailing data") else: fobj = open(tmpname, "rb") data = fobj.read() fobj.close() self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding")
Example #5
Source File: test_tarfile.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_padding(self): self.dst.close() if self.comp == "gz": f = gzip.GzipFile(self.dstname) s = f.read() f.close() elif self.comp == "bz2": b = bz2.BZ2Decompressor() f = file(self.dstname) s = f.read() f.close() s = b.decompress(s) self.assertEqual(len(f.unused_data), 0, "trailing data") else: f = file(self.dstname) s = f.read() f.close() self.assertEqual(s.count("\0"), tarfile.RECORDSIZE, "incorrect zero padding")
Example #6
Source File: test_tarfile.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.mode.endswith("gz"): fobj = gzip.GzipFile(tmpname) data = fobj.read() fobj.close() elif self.mode.endswith("bz2"): dec = bz2.BZ2Decompressor() data = open(tmpname, "rb").read() data = dec.decompress(data) self.assertTrue(len(dec.unused_data) == 0, "found trailing data") else: fobj = open(tmpname, "rb") data = fobj.read() fobj.close() self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding")
Example #7
Source File: test_tarfile.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.mode.endswith("gz"): fobj = gzip.GzipFile(tmpname) data = fobj.read() fobj.close() elif self.mode.endswith("bz2"): dec = bz2.BZ2Decompressor() data = open(tmpname, "rb").read() data = dec.decompress(data) self.assertTrue(len(dec.unused_data) == 0, "found trailing data") else: fobj = open(tmpname, "rb") data = fobj.read() fobj.close() self.assertTrue(data.count("\0") == tarfile.RECORDSIZE, "incorrect zero padding")
Example #8
Source File: test_tarfile.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_eof_marker(self): # Make sure an end of archive marker is written (two zero blocks). # tarfile insists on aligning archives to a 20 * 512 byte recordsize. # So, we create an archive that has exactly 10240 bytes without the # marker, and has 20480 bytes once the marker is written. with tarfile.open(tmpname, self.mode) as tar: t = tarfile.TarInfo("foo") t.size = tarfile.RECORDSIZE - tarfile.BLOCKSIZE tar.addfile(t, io.BytesIO(b"a" * t.size)) with self.open(tmpname, "rb") as fobj: self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2)
Example #9
Source File: test_tarfile.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.decompressor: dec = self.decompressor() with open(tmpname, "rb") as fobj: data = fobj.read() data = dec.decompress(data) self.assertFalse(dec.unused_data, "found trailing data") else: with self.open(tmpname) as fobj: data = fobj.read() self.assertEqual(data.count(b"\0"), tarfile.RECORDSIZE, "incorrect zero padding")
Example #10
Source File: test_tarfile.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.decompressor: dec = self.decompressor() with open(tmpname, "rb") as fobj: data = fobj.read() data = dec.decompress(data) self.assertFalse(dec.unused_data, "found trailing data") else: with self.open(tmpname) as fobj: data = fobj.read() self.assertEqual(data.count(b"\0"), tarfile.RECORDSIZE, "incorrect zero padding")
Example #11
Source File: test_tarfile.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_eof_marker(self): # Make sure an end of archive marker is written (two zero blocks). # tarfile insists on aligning archives to a 20 * 512 byte recordsize. # So, we create an archive that has exactly 10240 bytes without the # marker, and has 20480 bytes once the marker is written. with tarfile.open(tmpname, self.mode) as tar: t = tarfile.TarInfo("foo") t.size = tarfile.RECORDSIZE - tarfile.BLOCKSIZE tar.addfile(t, io.BytesIO(b"a" * t.size)) with self.open(tmpname, "rb") as fobj: self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2)
Example #12
Source File: test_tarfile.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_stream_padding(self): # Test for bug #1543303. tar = tarfile.open(tmpname, self.mode) tar.close() if self.decompressor: dec = self.decompressor() with open(tmpname, "rb") as fobj: data = fobj.read() data = dec.decompress(data) self.assertFalse(dec.unused_data, "found trailing data") else: with self.open(tmpname) as fobj: data = fobj.read() self.assertEqual(data.count(b"\0"), tarfile.RECORDSIZE, "incorrect zero padding")