當前位置: 首頁>>代碼示例>>Python>>正文


Python ECDriver.get_metadata方法代碼示例

本文整理匯總了Python中pyeclib.ec_iface.ECDriver.get_metadata方法的典型用法代碼示例。如果您正苦於以下問題:Python ECDriver.get_metadata方法的具體用法?Python ECDriver.get_metadata怎麽用?Python ECDriver.get_metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pyeclib.ec_iface.ECDriver的用法示例。


在下文中一共展示了ECDriver.get_metadata方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_metadata_formatted

# 需要導入模塊: from pyeclib.ec_iface import ECDriver [as 別名]
# 或者: from pyeclib.ec_iface.ECDriver import get_metadata [as 別名]
    def check_metadata_formatted(self, k, m, ec_type, chksum_type):

        if ec_type not in VALID_EC_TYPES:
            return

        filesize = 1024 * 1024 * 3
        file_str = ''.join(random.choice(ascii_letters)
                           for i in range(filesize))
        file_bytes = file_str.encode('utf-8')

        pyeclib_driver = ECDriver(k=k, m=m, ec_type=ec_type,
                                  chksum_type=chksum_type)

        fragments = pyeclib_driver.encode(file_bytes)

        f = 0
        for fragment in fragments:
            metadata = pyeclib_driver.get_metadata(fragment, 1)
            if 'index' in metadata:
                self.assertEqual(metadata['index'], f)
            else:
                self.assertTrue(False)

            if 'chksum_mismatch' in metadata:
                self.assertEqual(metadata['chksum_mismatch'], 0)
            else:
                self.assertTrue(False)

            if 'backend_id' in metadata:
                self.assertEqual(metadata['backend_id'], ec_type)
            else:
                self.assertTrue(False)

            if 'orig_data_size' in metadata:
                self.assertEqual(metadata['orig_data_size'], 3145728)
            else:
                self.assertTrue(False)

            if 'chksum_type' in metadata:
                self.assertEqual(metadata['chksum_type'], 'crc32')
            else:
                self.assertTrue(False)

            if 'backend_version' not in metadata:
                self.assertTrue(False)

            if 'chksum' not in metadata:
                self.assertTrue(False)

            if 'size' not in metadata:
                self.assertTrue(False)

            f += 1
開發者ID:openstack,項目名稱:pyeclib,代碼行數:55,代碼來源:test_pyeclib_api.py

示例2: check_metadata_formatted

# 需要導入模塊: from pyeclib.ec_iface import ECDriver [as 別名]
# 或者: from pyeclib.ec_iface.ECDriver import get_metadata [as 別名]
    def check_metadata_formatted(self, k, m, ec_type, chksum_type):

        if ec_type not in VALID_EC_TYPES:
            return

        filesize = 1024 * 1024 * 3
        file_str = "".join(random.choice(ascii_letters) for i in range(filesize))
        file_bytes = file_str.encode("utf-8")

        pyeclib_driver = ECDriver(k=k, m=m, ec_type=ec_type, chksum_type=chksum_type)

        fragments = pyeclib_driver.encode(file_bytes)

        f = 0
        for fragment in fragments:
            metadata = pyeclib_driver.get_metadata(fragment, 1)
            if "index" in metadata:
                self.assertEqual(metadata["index"], f)
            else:
                self.assertTrue(False)

            if "chksum_mismatch" in metadata:
                self.assertEqual(metadata["chksum_mismatch"], 0)
            else:
                self.assertTrue(False)

            if "backend_id" in metadata:
                self.assertEqual(metadata["backend_id"], ec_type)
            else:
                self.assertTrue(False)

            if "orig_data_size" in metadata:
                self.assertEqual(metadata["orig_data_size"], 3145728)
            else:
                self.assertTrue(False)

            if "chksum_type" in metadata:
                self.assertEqual(metadata["chksum_type"], "crc32")
            else:
                self.assertTrue(False)

            if "backend_version" not in metadata:
                self.assertTrue(False)

            if "chksum" not in metadata:
                self.assertTrue(False)

            if "size" not in metadata:
                self.assertTrue(False)

            f += 1
開發者ID:tsg-,項目名稱:pyeclib,代碼行數:53,代碼來源:test_pyeclib_api.py

示例3: test_get_metadata_formatted

# 需要導入模塊: from pyeclib.ec_iface import ECDriver [as 別名]
# 或者: from pyeclib.ec_iface.ECDriver import get_metadata [as 別名]
    def test_get_metadata_formatted(self):
        pyeclib_driver = ECDriver(k=12, m=2, ec_type="jerasure_rs_vand", chksum_type="inline_crc32")
        
        filesize = 1024 * 1024 * 3
        file_str = ''.join(random.choice(ascii_letters) for i in range(filesize))
        file_bytes = file_str.encode('utf-8')
        
        fragments = pyeclib_driver.encode(file_bytes)

        i = 0
        for fragment in fragments:
          metadata = pyeclib_driver.get_metadata(fragment, 1)
          if metadata.has_key('index'):
            self.assertEqual(metadata['index'], i)
          else:
            self.assertTrue(false)
          
          if metadata.has_key('chksum_mismatch'):
            self.assertEqual(metadata['chksum_mismatch'], 0)
          else:
            self.assertTrue(false)
          
          if metadata.has_key('backend_id'):
            self.assertEqual(metadata['backend_id'], 'jerasure_rs_vand')
          else:
            self.assertTrue(false)
          
          if metadata.has_key('orig_data_size'):
            self.assertEqual(metadata['orig_data_size'], 3145728)
          else:
            self.assertTrue(false)
          
          if metadata.has_key('chksum_type'):
            self.assertEqual(metadata['chksum_type'], 'crc32')
          else:
            self.assertTrue(false)
          
          if not metadata.has_key('backend_version'):
            self.assertTrue(false)
          
          if not metadata.has_key('chksum'):
            self.assertTrue(false)

          if not metadata.has_key('size'):
            self.assertTrue(false)

          i += 1
開發者ID:wawani82,項目名稱:SwiftER-pyeclib,代碼行數:49,代碼來源:test_pyeclib_api.py


注:本文中的pyeclib.ec_iface.ECDriver.get_metadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。