本文整理汇总了Python中pyndn.Interest.toUri方法的典型用法代码示例。如果您正苦于以下问题:Python Interest.toUri方法的具体用法?Python Interest.toUri怎么用?Python Interest.toUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Interest
的用法示例。
在下文中一共展示了Interest.toUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [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: main
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [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"))
示例3: expressProfileRequest
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [as 别名]
def expressProfileRequest(self,deviceName):
profileRequest = Interest(deviceName.append("profile"))
profileRequest.setInterestLifetimeMilliseconds(3000)
dump("Request device Profile: ", profileRequest.toUri())
#sign profile request with configuration token
self._accessControlManager.signInterestWithHMACKey(profileRequest,self._newDevice['configurationToken'])
self.face.expressInterest(profileRequest, self.onProfile, self.onProfileRequestTimeout)
示例4: main
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [as 别名]
def main():
if len(sys.argv) < 2:
print("argv error: please input turnOn, turnOff or status")
exit(1)
else:
cmd = sys.argv[1]
loop = asyncio.get_event_loop()
#face = ThreadsafeFace(loop, "localhost")
face = Face("localhost")
# Counter will stop the ioService after callbacks for all expressInterest.
counter = Counter(loop, 3)
seed = HMACKey(0,0,"seed","seedName")
# Try to fetch anything.
name1 = Name("/home/sensor/LED/0/"+cmd+"/0/0")
commandTokenName = '/home/sensor/LED/0/'+cmd+'/token/0'
commandTokenKey = hmac.new(seed.getKey(), commandTokenName, sha256).digest()
accessTokenName = '/home/sensor/LED/0/'+cmd+'/token/0/user/Tom/token/0'
accessTokenKey = hmac.new(commandTokenKey, accessTokenName, sha256).digest()
accessToken = HMACKey(0,0,accessTokenKey,accessTokenName)
dump("seed.getKey() :",seed.getKey())
dump("commandTokenName :",commandTokenName)
dump("commandTokenKey :",base64.b64encode(commandTokenKey))
dump("accessTokenName :",accessTokenName)
dump("accessTokenKey :",base64.b64encode(accessTokenKey))
interest = Interest(name1)
interest.setInterestLifetimeMilliseconds(3000)
a = AccessControlManager()
a.signInterestWithHMACKey(interest,accessToken)
dump("Express name ", interest.toUri())
face.expressInterest(interest, counter.onData, counter.onTimeout)
"""
name2 = Name("/home/sensor/LED/T0829374723/turnOff")
dump("Express name ", name2.toUri())
face.expressInterest(name2, counter.onData, counter.onTimeout)
"""
while counter._callbackCount < 1:
face.processEvents()
# We need to sleep for a few milliseconds so we don't use 100% of the CPU.
time.sleep(2)
face.shutdown()
示例5: main
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [as 别名]
def main():
seg = 0
if len(sys.argv) < 3:
print("argv error: please input capture or capture with #seg")
exit(1)
elif len(sys.argv) == 2:
cmd = sys.argv[1]
else:
cmd = sys.argv[1]
seg = sys.argv[2]
loop = asyncio.get_event_loop()
#face = ThreadsafeFace(loop, "localhost")
face = Face("localhost")
# Counter will stop the ioService after callbacks for all expressInterest.
counter = Counter(loop, 3)
seed = HMACKey(0,0,"seed","seedName")
# Try to fetch anything.
import time
r = time.time()
name1 = Name("/home/security/camera/0/"+cmd)
name1.appendTimestamp(int(r))
name1.appendSegment(int(seg))
interest = Interest(name1)
interest.setInterestLifetimeMilliseconds(3000)
dump("Express name ", interest.toUri())
face.expressInterest(interest, counter.onData, counter.onTimeout)
"""
name2 = Name("/home/sensor/LED/T0829374723/turnOff")
dump("Express name ", name2.toUri())
face.expressInterest(name2, counter.onData, counter.onTimeout)
"""
while counter._callbackCount < 1:
face.processEvents()
# We need to sleep for a few milliseconds so we don't use 100% of the CPU.
time.sleep(2)
face.shutdown()
示例6: expressBootstrapInterest
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [as 别名]
def expressBootstrapInterest(self):
#generate bootstrap name /home/controller/bootstrap/<device-parameters>
bootstrapName = Name(self._bootstrapPrefix)
deviceParameters = {}
deviceParameters["category"] = self._deviceProfile.getCategory()
deviceParameters["serialNumber"] = self. _deviceProfile.getSerialNumber()
deviceParameters["type"] = self._deviceProfile.getType()
bootstrapName.append(json.dumps(deviceParameters))
bootstrapInterest = Interest(bootstrapName)
bootstrapInterest.setInterestLifetimeMilliseconds(3000)
self._accessControlManager.signInterestWithHMACKey(bootstrapInterest,self._bootstrapKey)
dump("Express bootstrap interest : ",bootstrapInterest.toUri())
self.face.expressInterest(bootstrapInterest, self.onBootstrapData, self.onBootstrapTimeout)
示例7: deviceListRequest
# 需要导入模块: from pyndn import Interest [as 别名]
# 或者: from pyndn.Interest import toUri [as 别名]
def deviceListRequest():
loop = asyncio.get_event_loop()
#face = ThreadsafeFace(loop, "localhost")
face = Face("localhost")
# Counter will stop the ioService after callbacks for all expressInterest.
counter = Counter(loop, 3)
while True:
username = raw_input('Login username: ')
if not len(username)>0:
print("Username can't be blank")
continue
else:
break
while True:
password = raw_input("Login password: ")
if not len(password)>0:
print("Username can't be blank")
continue
else:
break
userHMACKey = HMACKey(0,0,password,"userHMACKey")
interestName = Name("/home/controller/deviceList/user/"+username)
interest = Interest(interestName)
a = AccessControlManager()
a.signInterestWithHMACKey(interest,userHMACKey)
dump("Express interst :",interest.toUri())
face.expressInterest(interest,counter.onData,counter.onTimeout)
while counter._callbackCount < 1:
face.processEvents()
# We need to sleep for a few milliseconds so we don't use 100% of the CPU.
time.sleep(2)
face.shutdown()