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


Python FilesProp.getFilePropByTransportSid方法代码示例

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


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

示例1: IBBMessageHandler

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getFilePropByTransportSid [as 别名]
 def IBBMessageHandler(self, conn, stanza):
     """
     Receive next portion of incoming datastream and store it write
     it to temporary file. Used internally.
     """
     sid = stanza.getTagAttr('data', 'sid')
     seq = stanza.getTagAttr('data', 'seq')
     data = stanza.getTagData('data')
     log.debug('ReceiveHandler called sid->%s seq->%s' % (sid, seq))
     try:
         seq = int(seq)
         data = base64.decodestring(data)
     except Exception:
         seq = ''
         data = ''
     err = None
     file_props = FilesProp.getFilePropByTransportSid(self.name, sid)
     if file_props is None:
         err = nbxmpp.ERR_ITEM_NOT_FOUND
     else:
         if not data:
             err = nbxmpp.ERR_BAD_REQUEST
         elif seq <> file_props.seq:
             err = nbxmpp.ERR_UNEXPECTED_REQUEST
         else:
             log.debug('Successfull receive sid->%s %s+%s bytes' % (sid,
                 file_props.fp.tell(), len(data)))
             file_props.seq += 1
             file_props.started = True
             file_props.fp.write(data)
             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(data)
             gajim.socks5queue.progress_transfer_cb(self.name, file_props)
             if file_props.received_len >= file_props.size:
                 file_props.completed = True
     if err:
         log.debug('Error on receive: %s' % err)
         conn.send(nbxmpp.Error(nbxmpp.Iq(to=stanza.getFrom(),
             frm=stanza.getTo(),
             payload=[nbxmpp.Node(nbxmpp.NS_IBB + ' close')]), err, reply=0))
     else:
         return True
开发者ID:jabber-at,项目名称:gajim,代码行数:46,代码来源:bytestream.py

示例2: StreamCloseHandler

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getFilePropByTransportSid [as 别名]
 def StreamCloseHandler(self, conn, stanza):
     """
     Handle stream closure due to all data transmitted.
     Raise xmpppy event specifying successfull data receive.
     """
     sid = stanza.getTagAttr('close', 'sid')
     log.debug('StreamCloseHandler called sid->%s' % sid)
     # look in sending files
     file_props = FilesProp.getFilePropByTransportSid(self.name, sid)
     if file_props:
         reply = stanza.buildReply('result')
         reply.delChild('close')
         conn.send(reply)
         # look in receiving files
         file_props.fp.close()
         file_props.completed = file_props.received_len >= file_props.size
         if not file_props.completed:
             file_props.error = -1
         gajim.socks5queue.complete_transfer_cb(self.name, file_props)
     else:
         conn.send(nbxmpp.Error(stanza, nbxmpp.ERR_ITEM_NOT_FOUND))
开发者ID:jabber-at,项目名称:gajim,代码行数:23,代码来源:bytestream.py

示例3: IBBAllIqHandler

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getFilePropByTransportSid [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

示例4: StreamOpenHandler

# 需要导入模块: from common.file_props import FilesProp [as 别名]
# 或者: from common.file_props.FilesProp import getFilePropByTransportSid [as 别名]
 def StreamOpenHandler(self, conn, stanza):
     """
     Handles opening of new incoming stream. Used internally.
     """
     err = None
     sid = stanza.getTagAttr('open', 'sid')
     blocksize = stanza.getTagAttr('open', 'block-size')
     log.debug('StreamOpenHandler called sid->%s blocksize->%s' % (sid,
         blocksize))
     file_props = FilesProp.getFilePropByTransportSid(self.name, sid)
     try:
         blocksize = int(blocksize)
     except:
         err = nbxmpp.ERR_BAD_REQUEST
     if not sid or not blocksize:
         err = nbxmpp.ERR_BAD_REQUEST
     elif not file_props:
         err = nbxmpp.ERR_UNEXPECTED_REQUEST
     if err:
         rep = nbxmpp.Error(stanza, err)
     else:
         log.debug("Opening stream: id %s, block-size %s" % (sid, blocksize))
         rep = nbxmpp.Protocol('iq', stanza.getFrom(), 'result',
             stanza.getTo(), {'id': stanza.getID()})
         file_props.block_size = blocksize
         file_props.direction = '<'
         file_props.seq = 0
         file_props.received_len = 0
         file_props.last_time = time.time()
         file_props.error = 0
         file_props.paused = False
         file_props.connected = True
         file_props.completed = False
         file_props.disconnect_cb = None
         file_props.continue_cb = None
         file_props.syn_id = stanza.getID()
         file_props.fp = open(file_props.file_name, 'w')
     conn.send(rep)
开发者ID:jabber-at,项目名称:gajim,代码行数:40,代码来源:bytestream.py


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