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


Python FilesProp.getAllFileProp方法代码示例

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


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

示例1: SendHandler

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getAllFileProp [as 别名]
 def SendHandler(self):
     """
     Send next portion of data if it is time to do it. Used internally.
     """
     log.debug('SendHandler called')
     for file_props in FilesProp.getAllFileProp():
         if not file_props.direction:
             # it's socks5 bytestream
             continue
         sid = file_props.sid
         if file_props.direction[:2] == '|>':
             # We waitthat other part accept stream
             continue
         if file_props.direction[0] == '>':
             if file_props.paused:
                 continue
             if not file_props.connected:
                 #TODO: Reply with out of order error
                 continue
             chunk = file_props.fp.read(file_props.block_size)
             if chunk:
                 datanode = nbxmpp.Node(nbxmpp.NS_IBB + ' data', {
                     'sid': file_props.transport_sid,
                     'seq': file_props.seq}, base64.b64encode(chunk.encode(
                     'utf-8')).decode('utf-8'))
                 file_props.seq += 1
                 file_props.started = True
                 if file_props.seq == 65536:
                     file_props.seq = 0
                 self.last_sent_ibb_id = self.connection.send(
                     nbxmpp.Protocol(name='iq', to=file_props.direction[1:],
                     typ='set', payload=[datanode]))
                 current_time = time.time()
                 file_props.elapsed_time += current_time - file_props.last_time
                 file_props.last_time = current_time
                 file_props.received_len += len(chunk)
                 gajim.socks5queue.progress_transfer_cb(self.name,
                     file_props)
             else:
                 # notify the other side about stream closing
                 # notify the local user about sucessfull send
                 # delete the local stream
                 self.connection.send(nbxmpp.Protocol('iq',
                     file_props.direction[1:], 'set',
                     payload=[nbxmpp.Node(nbxmpp.NS_IBB + ' close',
                     {'sid': file_props.transport_sid})]))
                 file_props.completed = True
开发者ID:irl,项目名称:gajim,代码行数:49,代码来源:bytestream.py

示例2: stop_all_active_file_transfers

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getAllFileProp [as 别名]
 def stop_all_active_file_transfers(self, contact):
     """
     Stop all active transfer to or from the given contact
     """
     for file_props in FilesProp.getAllFileProp():
         if is_transfer_stopped(file_props):
             continue
         receiver_jid = unicode(file_props.receiver)
         if contact.get_full_jid() == receiver_jid:
             file_props.error = -5
             self.remove_transfer(file_props)
             from common.connection_handlers_events import \
                 FileRequestErrorEvent
             gajim.nec.push_incoming_event(FileRequestErrorEvent(None,
                 conn=self, jid=contact.jid, file_props=file_props,
                 error_msg=''))
         sender_jid = unicode(file_props.sender)
         if contact.get_full_jid() == sender_jid:
             file_props.error = -3
             self.remove_transfer(file_props)
开发者ID:jabber-at,项目名称:gajim,代码行数:22,代码来源:bytestream.py

示例3: find_transfer_by_jid

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getAllFileProp [as 别名]
 def find_transfer_by_jid(self, account, jid):
     """
     Find all transfers with peer 'jid' that belong to 'account'
     """
     active_transfers = [[], []] # ['senders', 'receivers']
     allfp = FilesProp.getAllFileProp()
     for file_props in allfp:
         if file_props.type_ == 's' and file_props.tt_account == account:
             # 'account' is the sender
             receiver_jid = file_props.receiver.split('/')[0]
             if jid == receiver_jid and not is_transfer_stopped(file_props):
                 active_transfers[0].append(file_props)
         elif file_props.type_ == 'r' and file_props.tt_account == account:
             # 'account' is the recipient
             sender_jid = file_props.sender.split('/')[0]
             if jid == sender_jid and not is_transfer_stopped(file_props):
                 active_transfers[1].append(file_props)
         else:
             raise Exception('file_props has no type')
     return active_transfers
开发者ID:irl,项目名称:gajim,代码行数:22,代码来源:filetransfers_window.py

示例4: IBBAllIqHandler

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getAllFileProp [as 别名]
 def IBBAllIqHandler(self, conn, stanza):
     """
     Handle remote side reply about if it agree or not to receive our
     datastream.
     Used internally. Raises xmpppy event specfiying if the data transfer
     is agreed upon.
     """
     syn_id = stanza.getID()
     log.debug('IBBAllIqHandler called syn_id->%s' % syn_id)
     for file_props in FilesProp.getAllFileProp():
         if not file_props.direction or not file_props.connected:
             # It's socks5 bytestream
             # Or we closed the IBB stream
             continue
         if file_props.syn_id == syn_id:
             if stanza.getType() == 'error':
                 if file_props.direction[0] == '<':
                     conn.Event('IBB', 'ERROR ON RECEIVE', file_props)
                 else:
                     conn.Event('IBB', 'ERROR ON SEND', file_props)
             elif stanza.getType() == 'result':
                 if file_props.direction[0] == '|':
                     file_props.direction = file_props.direction[1:]
                     self.SendHandler()
                 else:
                     conn.send(nbxmpp.Error(stanza,
                         nbxmpp.ERR_UNEXPECTED_REQUEST))
             break
     else:
         if stanza.getTag('data'):
             sid = stanza.getTagAttr('data', 'sid')
             file_props = FilesProp.getFilePropByTransportSid(self.name, sid)
             if file_props.connected and self.IBBMessageHandler(conn,
             stanza):
                 reply = stanza.buildReply('result')
                 reply.delChild('data')
                 conn.send(reply)
                 raise nbxmpp.NodeProcessed
         elif syn_id == self.last_sent_ibb_id:
             self.SendHandler()
开发者ID:jabber-at,项目名称:gajim,代码行数:42,代码来源:bytestream.py

示例5: remove_all_transfers

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getAllFileProp [as 别名]
 def remove_all_transfers(self):
     """
     Stop and remove all active connections from the socks5 pool
     """
     for file_props in FilesProp.getAllFileProp():
         self.remove_transfer(file_props, remove_from_list=False)
开发者ID:jabber-at,项目名称:gajim,代码行数:8,代码来源:bytestream.py


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