本文整理汇总了Python中pyndn.Interest.getExclude方法的典型用法代码示例。如果您正苦于以下问题:Python Interest.getExclude方法的具体用法?Python Interest.getExclude怎么用?Python Interest.getExclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Interest
的用法示例。
在下文中一共展示了Interest.getExclude方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def main():
interest = Interest()
interest.wireDecode(TlvInterest)
dump("Interest:")
dumpInterest(interest)
encoding = interest.wireEncode()
dump("")
dump("Re-encoded interest", encoding.toHex())
reDecodedInterest = Interest()
reDecodedInterest.wireDecode(encoding)
dump("Re-decoded Interest:")
dumpInterest(reDecodedInterest)
freshInterest = Interest(Name("/ndn/abc"))
freshInterest.setMustBeFresh(False)
dump(freshInterest.toUri())
freshInterest.setMinSuffixComponents(4)
freshInterest.setMaxSuffixComponents(6)
freshInterest.getKeyLocator().setType(KeyLocatorType.KEY_LOCATOR_DIGEST)
freshInterest.getKeyLocator().setKeyData(bytearray(
[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F]))
freshInterest.getExclude().appendComponent(Name("abc")[0]).appendAny()
freshInterest.setInterestLifetimeMilliseconds(30000)
freshInterest.setChildSelector(1)
freshInterest.setMustBeFresh(True);
freshInterest.setScope(2)
reDecodedFreshInterest = Interest()
reDecodedFreshInterest.wireDecode(freshInterest.wireEncode())
dump("")
dump("Re-decoded fresh Interest:")
dumpInterest(reDecodedFreshInterest)
示例2: test_set_removes_nonce
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def test_set_removes_nonce(self):
# Ensure that changing a value on an interest clears the nonce.
self.assertFalse(self.referenceInterest.getNonce().isNull())
interest = Interest(self.referenceInterest)
# Change a child object.
interest.getExclude().clear()
self.assertTrue(interest.getNonce().isNull(), 'Interest should not have a nonce after changing fields')
示例3: test_find_by_interest
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def test_find_by_interest(self):
self.anchorContainer.insert("group1", self.certificatePath1, 400.0)
interest = Interest(self.identity1.getName())
self.assertTrue(self.anchorContainer.find(interest) != None)
interest1 = Interest(self.identity1.getName().getPrefix(-1))
self.assertTrue(self.anchorContainer.find(interest1) != None)
interest2 = Interest(Name(self.identity1.getName()).appendVersion(1))
self.assertTrue(self.anchorContainer.find(interest2) == None)
certificate3 = self.fixture.addCertificate(
self.identity1.getDefaultKey(), "3")
certificate4 = self.fixture.addCertificate(
self.identity1.getDefaultKey(), "4")
certificate5 = self.fixture.addCertificate(
self.identity1.getDefaultKey(), "5")
certificate3Copy = CertificateV2(certificate3)
self.anchorContainer.insert("group2", certificate3Copy)
self.anchorContainer.insert("group3", certificate4)
self.anchorContainer.insert("group4", certificate5)
interest3 = Interest(certificate3.getKeyName())
foundCertificate = self.anchorContainer.find(interest3)
self.assertTrue(foundCertificate != None)
self.assertTrue(interest3.getName().isPrefixOf(foundCertificate.getName()))
self.assertTrue(certificate3.getName().equals(foundCertificate.getName()))
interest3.getExclude().appendComponent(
certificate3.getName().get(CertificateV2.ISSUER_ID_OFFSET))
foundCertificate = self.anchorContainer.find(interest3)
self.assertTrue(foundCertificate != None)
self.assertTrue(interest3.getName().isPrefixOf(foundCertificate.getName()))
self.assertTrue(not foundCertificate.getName().equals(certificate3.getName()))
示例4: main
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def main():
interest = Interest()
interest.wireDecode(TlvInterest)
dump("Interest:")
dumpInterest(interest)
# Set the name again to clear the cached encoding so we encode again.
interest.setName(interest.getName())
encoding = interest.wireEncode()
dump("")
dump("Re-encoded interest", encoding.toHex())
reDecodedInterest = Interest()
reDecodedInterest.wireDecode(encoding)
dump("Re-decoded Interest:")
dumpInterest(reDecodedInterest)
freshInterest = Interest(Name("/ndn/abc"))
freshInterest.setMustBeFresh(False)
dump(freshInterest.toUri())
freshInterest.setMinSuffixComponents(4)
freshInterest.setMaxSuffixComponents(6)
freshInterest.getKeyLocator().setType(KeyLocatorType.KEY_LOCATOR_DIGEST)
freshInterest.getKeyLocator().setKeyData(bytearray(
[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F]))
freshInterest.getExclude().appendComponent(Name("abc")[0]).appendAny()
freshInterest.setInterestLifetimeMilliseconds(30000)
freshInterest.setChildSelector(1)
freshInterest.setMustBeFresh(True);
freshInterest.setScope(2)
identityStorage = MemoryIdentityStorage()
privateKeyStorage = MemoryPrivateKeyStorage()
keyChain = KeyChain(IdentityManager(identityStorage, privateKeyStorage),
SelfVerifyPolicyManager(identityStorage))
# Initialize the storage.
keyName = Name("/testname/DSK-123")
certificateName = keyName.getSubName(0, keyName.size() - 1).append(
"KEY").append(keyName[-1]).append("ID-CERT").append("0")
identityStorage.addKey(keyName, KeyType.RSA, Blob(DEFAULT_RSA_PUBLIC_KEY_DER))
privateKeyStorage.setKeyPairForKeyName(
keyName, KeyType.RSA, DEFAULT_RSA_PUBLIC_KEY_DER, DEFAULT_RSA_PRIVATE_KEY_DER)
# Make a Face just so that we can sign the interest.
face = Face("localhost")
face.setCommandSigningInfo(keyChain, certificateName)
face.makeCommandInterest(freshInterest)
reDecodedFreshInterest = Interest()
reDecodedFreshInterest.wireDecode(freshInterest.wireEncode())
dump("")
dump("Re-decoded fresh Interest:")
dumpInterest(reDecodedFreshInterest)
keyChain.verifyInterest(
reDecodedFreshInterest, makeOnVerified("Freshly-signed Interest"),
makeOnVerifyFailed("Freshly-signed Interest"))
示例5: onDeviceResponse
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def onDeviceResponse(interest, data):
updatedInterest = Interest(interest)
deviceSerial = str(data.getContent())
if len(deviceSerial) > 0:
foundDevices.append(deviceSerial)
updatedInterest.getExclude().appendComponent(Name.Component(deviceSerial))
# else ignore the malformed response
self.face.expressInterest(updatedInterest, onDeviceResponse, onDeviceTimeout)
示例6: test_redecode_implicit_digest_exclude
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def test_redecode_implicit_digest_exclude(self):
# Check that we encode and decode correctly with an implicit digest exclude.
interest = Interest(Name("/A"))
interest.getExclude().appendComponent(Name("/sha256digest=" +
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f").get(0))
dump = dumpInterest(interest)
encoding = interest.wireEncode()
reDecodedInterest = Interest()
reDecodedInterest.wireDecode(encoding)
redecodedDump = dumpInterest(reDecodedInterest)
self.assertTrue(interestDumpsEqual(dump, redecodedDump),
"Re-decoded interest does not match original")
示例7: createFreshInterest
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def createFreshInterest():
freshInterest = Interest(Name("/ndn/abc"))
freshInterest.setMustBeFresh(False)
freshInterest.setMinSuffixComponents(4)
freshInterest.setMaxSuffixComponents(6)
freshInterest.getKeyLocator().setType(KeyLocatorType.KEY_LOCATOR_DIGEST)
freshInterest.getKeyLocator().setKeyData(bytearray(
[0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F]))
freshInterest.getExclude().appendComponent(Name("abc")[0]).appendAny()
freshInterest.setInterestLifetimeMilliseconds(30000)
freshInterest.setChildSelector(1)
freshInterest.setMustBeFresh(True);
freshInterest.setScope(2)
return freshInterest
示例8: expressInterestPirAndRepeat
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def expressInterestPirAndRepeat(self):
self.log.debug("callbackCountUniqueData: " + str(self._callbackCountUniqueData) + ", callbackCountTimeout: " + str(self._callbackCountTimeout))
# Express interest for each pir we have discovered
for pir in self.getPirs():
interest = Interest(Name(pir.id))
interest.setExclude(pir.status.getExclude())
interest.setInterestLifetimeMilliseconds(1000.0)
interest.setChildSelector(1)
self.face.expressInterest(interest, self.onDataPir, self.onTimeoutPir)
self._countExpressedInterests += 1
debugStr = "Sent interest: " + interest.getName().toUri()
debugStr += "\tExclude: " + interest.getExclude().toUri()
debugStr += "\tLifetime: " + str(interest.getInterestLifetimeMilliseconds())
self.log.debug(debugStr)
# Reschedule again in 0.5 sec
self.loop.call_later(1.0, self.expressInterestPirAndRepeat)
示例9: test_matches_data
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import getExclude [as 别名]
def test_matches_data(self):
interest = Interest(Name("/A"))
interest.setMinSuffixComponents(2)
interest.setMaxSuffixComponents(2)
interest.getKeyLocator().setType(KeyLocatorType.KEYNAME)
interest.getKeyLocator().setKeyName(Name("/B"))
interest.getExclude().appendComponent(Name.Component("J"))
interest.getExclude().appendAny()
data = Data(Name("/A/D"))
signature = Sha256WithRsaSignature()
signature.getKeyLocator().setType(KeyLocatorType.KEYNAME)
signature.getKeyLocator().setKeyName(Name("/B"))
data.setSignature(signature)
self.assertEqual(interest.matchesData(data), True)
# Check violating MinSuffixComponents.
data1 = Data(data)
data1.setName(Name("/A"))
self.assertEqual(interest.matchesData(data1), False)
interest1 = Interest(interest)
interest1.setMinSuffixComponents(1)
self.assertEqual(interest1.matchesData(data1), True)
# Check violating MaxSuffixComponents.
data2 = Data(data)
data2.setName(Name("/A/E/F"))
self.assertEqual(interest.matchesData(data2), False)
interest2 = Interest(interest)
interest2.setMaxSuffixComponents(3)
self.assertEqual(interest2.matchesData(data2), True)
# Check violating PublisherPublicKeyLocator.
data3 = Data(data)
signature3 = Sha256WithRsaSignature()
signature3.getKeyLocator().setType(KeyLocatorType.KEYNAME)
signature3.getKeyLocator().setKeyName(Name("/G"))
data3.setSignature(signature3)
self.assertEqual(interest.matchesData(data3), False)
interest3 = Interest(interest)
interest3.getKeyLocator().setType(KeyLocatorType.KEYNAME)
interest3.getKeyLocator().setKeyName(Name("/G"))
self.assertEqual(interest3.matchesData(data3), True)
data4 = Data(data)
data4.setSignature(DigestSha256Signature())
self.assertEqual(interest.matchesData(data4), False)
interest4 = Interest(interest)
interest4.setKeyLocator(KeyLocator())
self.assertEqual(interest4.matchesData(data4), True)
# Check violating Exclude.
data5 = Data(data)
data5.setName(Name("/A/J"))
self.assertEqual(interest.matchesData(data5), False)
interest5 = Interest(interest)
interest5.getExclude().clear()
interest5.getExclude().appendComponent(Name.Component("K"))
interest5.getExclude().appendAny()
self.assertEqual(interest5.matchesData(data5), True)
# Check violating Name.
data6 = Data(data)
data6.setName(Name("/H/I"))
self.assertEqual(interest.matchesData(data6), False)
data7 = Data(data)
data7.setName(Name("/A/B"))
interest7 = Interest(
Name("/A/B/sha256digest=" +
"54008e240a7eea2714a161dfddf0dd6ced223b3856e9da96792151e180f3b128"))
self.assertEqual(interest7.matchesData(data7), True)
# Check violating the implicit digest.
interest7b = Interest(
Name("/A/B/%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00" +
"%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"))
self.assertEqual(interest7b.matchesData(data7), False)
# Check excluding the implicit digest.
interest8 = Interest(Name("/A/B"))
interest8.getExclude().appendComponent(interest7.getName().get(2))
self.assertEqual(interest8.matchesData(data7), False)