当前位置: 首页>>代码示例>>Python>>正文


Python Data.setMetaInfo方法代码示例

本文整理汇总了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')
开发者ID:bboalimoe,项目名称:PyNDN2,代码行数:9,代码来源:test_data_methods.py

示例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)
开发者ID:philoL,项目名称:NDN-HOME,代码行数:55,代码来源:camera.py


注:本文中的pyndn.Data.setMetaInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。