本文整理汇总了Python中pyndn.Name.appendVersion方法的典型用法代码示例。如果您正苦于以下问题:Python Name.appendVersion方法的具体用法?Python Name.appendVersion怎么用?Python Name.appendVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Name
的用法示例。
在下文中一共展示了Name.appendVersion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateVersionedName
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import appendVersion [as 别名]
def generateVersionedName(self):
fullName = Name(self.dataName)
# currently we need to provide the version ourselves when we
# poke the repo
ts = int(time.time()*1000)
fullName.appendVersion(int(ts))
return fullName
示例2: test_management
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import appendVersion [as 别名]
#.........这里部分代码省略.........
else:
self.fail("Did not throw the expected exception")
self.assertEqual(0, id._getKeys().size())
# Create another key.
self._fixture._keyChain.createKey(id)
# The added key becomes the default key.
try:
id.getDefaultKey()
except Exception as ex:
self.fail("Unexpected exception: " + str(ex))
key2 = id.getDefaultKey()
self.assertTrue(key2 != None)
self.assertTrue(not key2.getName().equals(key1Name))
self.assertEqual(1, id._getKeys().size())
try:
key2.getDefaultCertificate()
except Exception as ex:
self.fail("Unexpected exception: " + str(ex))
# Create a third key.
key3 = self._fixture._keyChain.createKey(id)
self.assertTrue(not key3.getName().equals(key2.getName()))
# The added key will not be the default key, because the default key already exists.
self.assertTrue(id.getDefaultKey().getName().equals(key2.getName()))
self.assertEqual(2, id._getKeys().size())
try:
key3.getDefaultCertificate()
except Exception as ex:
self.fail("Unexpected exception: " + str(ex))
# Delete the certificate.
self.assertEqual(1, key3._getCertificates().size())
key3Cert1 = list(key3._getCertificates()._certificates.values())[0]
key3CertName = key3Cert1.getName()
self._fixture._keyChain.deleteCertificate(key3, key3CertName)
self.assertEqual(0, key3._getCertificates().size())
try:
key3.getDefaultCertificate()
self.fail("Did not throw the expected exception")
except Pib.Error:
pass
else:
self.fail("Did not throw the expected exception")
# Add a certificate.
self._fixture._keyChain.addCertificate(key3, key3Cert1)
self.assertEqual(1, key3._getCertificates().size())
try:
key3.getDefaultCertificate()
except Exception as ex:
self.fail("Unexpected exception: " + str(ex))
# Overwriting the certificate should work.
self._fixture._keyChain.addCertificate(key3, key3Cert1)
self.assertEqual(1, key3._getCertificates().size())
# Add another certificate.
key3Cert2 = CertificateV2(key3Cert1)
key3Cert2Name = Name(key3.getName())
key3Cert2Name.append("Self")
key3Cert2Name.appendVersion(1)
key3Cert2.setName(key3Cert2Name)
self._fixture._keyChain.addCertificate(key3, key3Cert2)
self.assertEqual(2, key3._getCertificates().size())
# Set the default certificate.
self.assertTrue(key3.getDefaultCertificate().getName().equals(key3CertName))
self._fixture._keyChain.setDefaultCertificate(key3, key3Cert2)
self.assertTrue(key3.getDefaultCertificate().getName().equals(key3Cert2Name))
# Set the default key.
self.assertTrue(id.getDefaultKey().getName().equals(key2.getName()))
self._fixture._keyChain.setDefaultKey(id, key3)
self.assertTrue(id.getDefaultKey().getName().equals(key3.getName()))
# Set the default identity.
id2 = self._fixture._keyChain.createIdentityV2(identity2Name)
self.assertTrue(self._fixture._keyChain.getPib().getDefaultIdentity().getName()
.equals(id.getName()))
self._fixture._keyChain.setDefaultIdentity(id2)
self.assertTrue(self._fixture._keyChain.getPib().getDefaultIdentity().getName()
.equals(id2.getName()))
# Delete an identity.
self._fixture._keyChain.deleteIdentity(id)
# TODO: Implement identity validity.
# # The identity instance should not be valid anymore.
# BOOST_CHECK(!id)
try:
self._fixture._keyChain.getPib().getIdentity(identityName)
self.fail("Did not throw the expected exception")
except Pib.Error:
pass
else:
self.fail("Did not throw the expected exception")
self.assertTrue(not (identityName in
self._fixture._keyChain.getPib()._identities._identities))
示例3: Thread
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import appendVersion [as 别名]
publisher = Thread(target=publisher_loop, name="Data publisher", args=(publisher_face,))
publisher.start()
try:
# sleep a second, like the repo-ng test
time.sleep(1)
while not done:
#pick a random data name
data_part = suffix# str(randint(0,N))
fullName = Name(data_prefix).append(Name(data_part))
# currently we need to provide the version ourselves when we
# poke the repo
ts = int(time.time()*1000)
fullName.appendVersion(int(ts))
versionComponent = fullName.get(-1)
versionStr = versionComponent.toEscapedString()
logger.debug('inserting: ' + versionStr)
if shouldCollectStats:
insertTable.append({'version':versionStr, 'insert_request':time.time()})
data = generateData(fullName)
dataCache.add(data)
if shouldCollectStats:
info = getInfoForVersion(versionStr)
if info is not None:
info['insert_complete'] = time.time()
time.sleep(0.1)
print '.',