本文整理汇总了Python中pyndn.Data.setMetaInfo方法的典型用法代码示例。如果您正苦于以下问题:Python Data.setMetaInfo方法的具体用法?Python Data.setMetaInfo怎么用?Python Data.setMetaInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Data
的用法示例。
在下文中一共展示了Data.setMetaInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copy_fields
# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import setMetaInfo [as 别名]
def test_copy_fields(self):
data = Data(self.freshData.getName())
data.setContent(self.freshData.getContent())
data.setMetaInfo(self.freshData.getMetaInfo())
self.credentials.signData(data)
freshDump = dumpData(data)
self.assertTrue(dataDumpsEqual(freshDump, initialDump), 'Freshly created data does not match original dump')
示例2: capture
# 需要导入模块: from pyndn import Data [as 别名]
# 或者: from pyndn.Data import setMetaInfo [as 别名]
def capture(self, interest, transport):
# print("capture cmd received start processing")
interestName = interest.getName()
if (interestName.size() >= 7):
#right format
segmentIndex = interestName.get(6).toSegment()
# print "request segmentIndex : ",segmentIndex
if segmentIndex == 0:
# print("a new picture")
#request a new picture
self.stream = io.BytesIO()
self.stream.flush()
self.segmentList = []
self.dataList = []
self.camera.capture(self.stream, 'jpeg')
#print("photo caputred in stream")
imageBytes = self.stream.getvalue()
print ("imageBytes %d" % len(imageBytes))
#segmentation
self.segmentNumber = len(imageBytes)/(self.segmentSize+1)+1
print("segmentNumber: %d" % self.segmentNumber)
for i in range(self.segmentNumber):
startIndex = i*self.segmentSize
if (i != self.segmentNumber -1):
segBytes = imageBytes[startIndex:(startIndex+self.segmentSize)]
else:
segBytes = imageBytes[startIndex:]
#self.segmentList.append(segBytes)
newName = interestName.getPrefix(-1).appendSegment(i)
#print newName.toUri()
data = Data(newName)
metaInfo = MetaInfo()
metaInfo.setFinalBlockId(Blob.fromRawStr(str(self.segmentNumber-1)))
data.setMetaInfo(metaInfo)
#data.setContent(Blob.fromRawStr(self.segmentList[i]))
data.setContent(Blob.fromRawStr(segBytes))
self.dataList.append(data)
self.sendData(self.dataList[0], transport, sign=False)
else:
self.sendData(self.dataList[segmentIndex], transport, sign=False)