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


Python File.partialSize方法代码示例

本文整理汇总了Python中File.File.partialSize方法的典型用法代码示例。如果您正苦于以下问题:Python File.partialSize方法的具体用法?Python File.partialSize怎么用?Python File.partialSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File.File的用法示例。


在下文中一共展示了File.partialSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testInsert

# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import partialSize [as 别名]
 def testInsert(self):
     fdao = FileDAO()
     file = File()
     file.hash = self.hash
     file.size = 555555 
     file.partialSize = 55555
     file.bestname = 'nomedoarquivonarede.ext'
     fid = fdao.insert(file)
     assert fid != -1, 'error inserting file'
开发者ID:tassia,项目名称:DonkeySurvey,代码行数:11,代码来源:FileTestCase.py

示例2: find

# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import partialSize [as 别名]
 def find(self, id):
     self.cursor.execute("""SELECT * FROM """+self.tablename+""" WHERE id = %s""", (id,))
     rs = self.cursor.fetchall()
     if not rs:
         return None
     file = File()
     for row in rs:
         file.id = row[0]
         file.hash = row[1] 
         file.size = row[2] 
         file.partialSize = row[3] 
         file.bestName = row[4] 
     return file
开发者ID:tassia,项目名称:DonkeySurvey,代码行数:15,代码来源:FileDAO.py

示例3: findByHash

# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import partialSize [as 别名]
 def findByHash(self, hash):
     query = "SELECT * FROM %s WHERE hash = '%s'" % (self.tablename, hash)
     self.cursor.execute(query)
     rs = self.cursor.fetchall()
     if not rs:
         return None
     file = File()
     for row in rs:
         file.id = row[0]
         file.hash = row[1] 
         file.size = row[2] 
         file.partialSize = row[3] 
         file.bestName = row[4] 
     return file
开发者ID:tassia,项目名称:DonkeySurvey,代码行数:16,代码来源:FileDAO.py

示例4: decode

# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import partialSize [as 别名]

#.........这里部分代码省略.........


        # Message: ClientState
        # Action: none
        elif self.msg.opcode is 16:
            self.msg.decode_msg_16(self.msg.raw_data)

        # Message: ConsoleMessage
        # Action: handle wanted info (commands 'vd' and 'vc')
        elif self.msg.opcode is 19:
            cmd, id, result = self.msg.decode_msg_19(self.msg.raw_data)
            if cmd == "vd":               # id = file_id, result = file_sources
                self.file_sources[id] = result
                logging.debug("File-[Sources]: %s" % (self.file_sources))
                for src in result:
                    if src not in self.source_id_hash:
                        cmd = "vc %d" % (src)
                        self.listener.send_cmd(cmd)
            if cmd == "vc" and result:    # id = source_id, result = (source, address)
                source = result[0]
                address = result[1]
                for file in self.file_sources:
                    if int(id) in self.file_sources[file]:
                        if int(file) in self.file_id_hash:
                            fileHash = self.file_id_hash[int(file)]
                            fdao = FileDAO()
                            fileId = fdao.findByHash(fileHash).id
                if source.hash == "00000000000000000000000000000000":
                    logging.debug("IP-no-hash: %s",address.ip)
                    adao = AddressDAO()
                    addressId = adao.insertOrUpdate(address)
                    if addressId:
                        ahf = AddressHasFileDAO()
                        ahf.insert(addressId, fileId)
                        logging.debug("FileHash: %s, FileId: %s, AddressId: %s" % (fileHash, fileId, addressId))
                    else:
                        logging.debug("AddressId is null")
                else:
                    self.source_id_hash[id]=source.hash
                    logging.debug("File [id-hash]: %s" % (self.file_id_hash))
                    logging.debug("Source [id-hash]: %s" % (self.source_id_hash))
                    logging.debug("File-[Sources]: %s" % (self.file_sources))
                    srcdao = SourceDAO()
        	    sourceId = srcdao.insertOrUpdate(source)
                    if sourceId:
                        shf = SourceHasFileDAO()
                        shf.insertOrUpdate(sourceId, fileId, "0")
                        logging.debug("FileHash: %s, FileId: %s, SourceId: %s" % (fileHash, fileId, sourceId))
                    else:
    	                logging.debug("SourceId is null")

        # Message: NetworkInfo
        # Action: none
        elif self.msg.opcode is 20:
            self.msg.decode_msg_20(self.msg.raw_data)

        # Message: UserInfo
        # Action: never received
        elif self.msg.opcode is 21:
            self.msg.decode_msg_21(self.msg.raw_data)

        # Message: ServerInfo
        # Action: none
        elif self.msg.opcode is 26:
            server_id = self.msg.decode_msg_26(self.msg.raw_data)
            #self.listener.send('<lhl', [32, server_id])

        # Message: FileDownloadUpdate
        # Action: update and persist session on database
        elif self.msg.opcode is 46:
            file_id, size = self.msg.decode_msg_46(self.msg.raw_data)
            fdao = FileDAO()
            file = File()
            file.hash = self.file_id_hash[file_id]
            file.partialSize = size
            fdao.insertOrUpdate(file)

        # Message: SharedFileInfo
        # Action: none
        elif self.msg.opcode is 48:
            file_id = self.msg.decode_msg_48(self.msg.raw_data)
            self.listener.send('<lhl', [OPCODE("GetFileInfo"), file_id])

        # Message: FileRemoveSource
        # Action: none
        elif self.msg.opcode is 50:
            self.msg.decode_msg_50(self.msg.raw_data)

        # Message: FileInfo
        # Action: populate file related entities and send 'vd' to get file sources
        elif self.msg.opcode is 52:
            file, file_id = self.msg.decode_msg_52(self.msg.raw_data)
            self.file_id_hash[file_id]=file.hash
            logging.debug("File [id-hash]: %s" % (self.file_id_hash))
            fdao = FileDAO()
	    fileId = fdao.insertOrUpdate(file)
            if fileId is None:
	        logging.debug("FileId is null")
            cmd = "vd %d" % (file_id) 
            self.listener.send_cmd(cmd) 
开发者ID:tassia,项目名称:DonkeySurvey,代码行数:104,代码来源:MessageHandler.py


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