コード例 #1
0
ファイル: archive.py プロジェクト: EMSL-MSC/pacifica-2.0
	def next_header(self):
		res = _myemsl_archive.archive_read_next_header2(self._a, self._ae._ae)
		if res == _myemsl_archive.ARCHIVE_EOF:
			return None
		if res != _myemsl_archive.ARCHIVE_OK:
			raise ArchiveException("next_header failed. %s", res)
		return self._ae
コード例 #2
0
 def next_header(self):
     res = _myemsl_archive.archive_read_next_header2(self._a, self._ae._ae)
     if res == _myemsl_archive.ARCHIVE_EOF:
         return None
     if res != _myemsl_archive.ARCHIVE_OK:
         raise ArchiveException("next_header failed. %s", res)
     return self._ae
コード例 #3
0
	def test_truncated_file(self):
		h = hashlib.sha1()
		r = archive.archive_read_open_filename(self.a, "testdata3.tar", 10240)
		self.failIf(r != archive.ARCHIVE_OK, "Failed to open testdata3.tar")
		while (archive.archive_read_next_header2(self.a, self.ae) == archive.ARCHIVE_OK):
			(e, d) = archive.myemsl_archive_read_data(self.a, 10240)
			while(e == 0 and len(d) > 0):
				h.update(d)
				(e, d) = archive.myemsl_archive_read_data(self.a, 10240)
			file_hash = h.hexdigest()
			sha1 = '51c15743ad61d2ceb55a05efb073d73fc9a759cb'
			self.failIf(file_hash == sha1, "Data verify failed. Sha1 sums match. %s != %s" %(file_hash, sha1))
			self.failIf(e == 0, "Error did not show up.")
コード例 #4
0
	def test_extract(self):
		h = hashlib.sha1()
		r = archive.archive_read_open_filename(self.a, "testdata.tar", 10240)
		self.failIf(r != archive.ARCHIVE_OK, "Failed to open testdata.tar")
		while (archive.archive_read_next_header2(self.a, self.ae) == archive.ARCHIVE_OK):
			(e, d) = archive.myemsl_archive_read_data(self.a, 10240)
			self.failIf(e != 0, "Failure during data read %s" %(e))
			while(len(d) > 0):
				h.update(d)
				(e, d) = archive.myemsl_archive_read_data(self.a, 10240)
				self.failIf(e != 0, "Failure during data read %s" %(e))
			file_hash = h.hexdigest()
			sha1 = '51c15743ad61d2ceb55a05efb073d73fc9a759cb'
			self.failIf(file_hash != sha1, "Data verify failed. Sha1 sums don't match. %s != %s" %(file_hash, sha1))
コード例 #5
0
	def test_direntry(self):
		h = hashlib.sha1()
		r = archive.archive_read_open_filename(self.a, "dirtest.tar", 10240)
		self.failIf(r != archive.ARCHIVE_OK, "Failed to open dirtest.tar")
		while (archive.archive_read_next_header2(self.a, self.ae) == archive.ARCHIVE_OK):
			name = archive.archive_entry_pathname(self.ae)
			if name == 'a/' or name == 'a/b/':
				type = archive.AE_IFDIR
			elif name == 'a/c':
				type = archive.AE_IFREG
			else:
				self.fail("Unknown filename %s" %(name))
			ft = archive.myemsl_archive_entry_filetype(self.ae)
			archive.archive_read_data_skip(self.a)
			self.failIf(ft != type, "Wrong type.")
コード例 #6
0
 def test_direntry(self):
     h = hashlib.sha1()
     r = archive.archive_read_open_filename(self.a, "dirtest.tar", 10240)
     self.failIf(r != archive.ARCHIVE_OK, "Failed to open dirtest.tar")
     while (archive.archive_read_next_header2(
             self.a, self.ae) == archive.ARCHIVE_OK):
         name = archive.archive_entry_pathname(self.ae)
         if name == 'a/' or name == 'a/b/':
             type = archive.AE_IFDIR
         elif name == 'a/c':
             type = archive.AE_IFREG
         else:
             self.fail("Unknown filename %s" % (name))
         ft = archive.myemsl_archive_entry_filetype(self.ae)
         archive.archive_read_data_skip(self.a)
         self.failIf(ft != type, "Wrong type.")
コード例 #7
0
 def test_truncated_file(self):
     h = hashlib.sha1()
     r = archive.archive_read_open_filename(self.a, "testdata3.tar", 10240)
     self.failIf(r != archive.ARCHIVE_OK, "Failed to open testdata3.tar")
     while (archive.archive_read_next_header2(
             self.a, self.ae) == archive.ARCHIVE_OK):
         (e, d) = archive.myemsl_archive_read_data(self.a, 10240)
         while (e == 0 and len(d) > 0):
             h.update(d)
             (e, d) = archive.myemsl_archive_read_data(self.a, 10240)
         file_hash = h.hexdigest()
         sha1 = '51c15743ad61d2ceb55a05efb073d73fc9a759cb'
         self.failIf(
             file_hash == sha1,
             "Data verify failed. Sha1 sums match. %s != %s" %
             (file_hash, sha1))
         self.failIf(e == 0, "Error did not show up.")
コード例 #8
0
 def test_extract(self):
     h = hashlib.sha1()
     r = archive.archive_read_open_filename(self.a, "testdata.tar", 10240)
     self.failIf(r != archive.ARCHIVE_OK, "Failed to open testdata.tar")
     while (archive.archive_read_next_header2(
             self.a, self.ae) == archive.ARCHIVE_OK):
         (e, d) = archive.myemsl_archive_read_data(self.a, 10240)
         self.failIf(e != 0, "Failure during data read %s" % (e))
         while (len(d) > 0):
             h.update(d)
             (e, d) = archive.myemsl_archive_read_data(self.a, 10240)
             self.failIf(e != 0, "Failure during data read %s" % (e))
         file_hash = h.hexdigest()
         sha1 = '51c15743ad61d2ceb55a05efb073d73fc9a759cb'
         self.failIf(
             file_hash != sha1,
             "Data verify failed. Sha1 sums don't match. %s != %s" %
             (file_hash, sha1))