• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python log.callWithLogger函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.python.log.callWithLogger函数的典型用法代码示例。如果您正苦于以下问题:Python callWithLogger函数的具体用法?Python callWithLogger怎么用?Python callWithLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: doKEvent

    def doKEvent(self, timeout):
        """
        Poll the kqueue for new events.
        """
        if timeout is None:
            timeout = 1

        try:
            l = self._kq.control([], len(self._selectables), timeout)
        except OSError as e:
            if e[0] == errno.EINTR:
                return
            else:
                raise

        _drdw = self._doWriteOrRead
        for event in l:
            fd = event.ident
            try:
                selectable = self._selectables[fd]
            except KeyError:
                # Handles the infrequent case where one selectable's
                # handler disconnects another.
                continue
            else:
                log.callWithLogger(selectable, _drdw, selectable, fd, event)
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:26,代码来源:kqreactor.py


示例2: read

    def read(self, fd):
        if not self.watcher:
            return
        w = self.watcher
        # doRead can cause self.shutdown to be called so keep
        # a reference to self.watcher

        def _read():
            #Don't call me again, until the data has been read
            self.notifier.setEnabled(False)
            why = None
            try:
                why = w.doRead()
                inRead = True
            except:
                inRead = False
                log.err()
                why = sys.exc_info()[1]
            if why:
                self.reactor._disconnectSelectable(w, why, inRead)
            elif self.watcher:
                self.notifier.setEnabled(True)
                # Re enable notification following sucessfull read
            self.reactor._iterate(fromqt=True)
        log.callWithLogger(w, _read)
开发者ID:joepie91,项目名称:aether-public,代码行数:25,代码来源:qt5reactor.py


示例3: ssh_CHANNEL_DATA

    def ssh_CHANNEL_DATA(self, packet):
        """
        The other side is sending us data.  Payload::
            uint32 local channel number
            string data

        Check to make sure the other side hasn't sent too much data (more
        than what's in the window, or more than the maximum packet size).  If
        they have, close the channel.  Otherwise, decrease the available
        window and pass the data to the channel's dataReceived().
        """
        localChannel, dataLength = struct.unpack('>2L', packet[:8])
        channel = self.channels[localChannel]
        # XXX should this move to dataReceived to put client in charge?
        if (dataLength > channel.localWindowLeft or
           dataLength > channel.localMaxPacket): # more data than we want
            log.callWithLogger(channel, log.msg, 'too much data')
            self.sendClose(channel)
            return
            #packet = packet[:channel.localWindowLeft+4]
        data = common.getNS(packet[4:])[0]
        channel.localWindowLeft -= dataLength
        if channel.localWindowLeft < channel.localWindowSize / 2:
            self.adjustWindow(channel, channel.localWindowSize - \
                                       channel.localWindowLeft)
            #log.msg('local window left: %s/%s' % (channel.localWindowLeft,
            #                                    channel.localWindowSize))
        log.callWithLogger(channel, channel.dataReceived, data)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:28,代码来源:connection.py


示例4: _ioEventCallback

 def _ioEventCallback(self, source, condition):
     """
     Called by event loop when an I/O event occurs.
     """
     log.callWithLogger(
         source, self._doReadOrWrite, source, source, condition)
     return True  # True = don't auto-remove the source
开发者ID:audoe,项目名称:twisted,代码行数:7,代码来源:_glibbase.py


示例5: disconnectAll

 def disconnectAll(self):
     """Disconnect every reader, and writer in the system.
     """
     selectables = self.removeAll()
     for reader in selectables:
         log.callWithLogger(reader, reader.connectionLost,
                            failure.Failure(main.CONNECTION_LOST))
开发者ID:jdb,项目名称:twisted,代码行数:7,代码来源:base.py


示例6: dataReceived

 def dataReceived(self, data):
     self.buf = self.buf+data
     if not self.gotVersion:
         parts = self.buf.split('\n')
         for p in parts:
             if p[: 4] == 'SSH-':
                 self.gotVersion = 1
                 self.otherVersionString = p.strip()
                 if p.split('-')[1]not in('1.99', '2.0'): # bad version
                     self.sendDisconnect(DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED, 'bad version %s'%p.split('-')[1])
                     return
                 i = parts.index(p)
                 self.buf = '\n'.join(parts[i+1:])
     packet = self.getPacket()
     while packet:
         messageNum = ord(packet[0])
         if messageNum < 50:
             messageType = messages[messageNum][4:]
             f = getattr(self, 'ssh_%s'%messageType, None)
             if f:
                 f(packet[1:])
             else:
                 log.msg("couldn't handle %s"%messageType)
                 log.msg(repr(packet[1:]))
                 self.sendUnimplemented()
         elif self.service:
             log.callWithLogger(self.service, self.service.packetReceived,
                                              ord(packet[0]), packet[1:])
         else:
             log.msg("couldn't handle %s"%messageNum)
             log.msg(repr(packet[1:]))
             self.sendUnimplemented()
         packet = self.getPacket()
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:33,代码来源:transport.py


示例7: doRead

    def doRead(self):
        """
        Some data is available for reading on ZeroMQ descriptor.

        ZeroMQ is signalling that we should process some events,
        we're starting to receive incoming messages.

        Implementation of :tm:`IReadDescriptor
        <internet.interfaces.IReadDescriptor>`.
        """
        if self.read_scheduled is not None:
            if not self.read_scheduled.called:
                self.read_scheduled.cancel()
            self.read_scheduled = None

        while True:
            if self.factory is None:  # disconnected
                return

            events = self.socket.get(constants.EVENTS)

            if (events & constants.POLLIN) != constants.POLLIN:
                return

            try:
                message = self._readMultipart()
            except error.ZMQError as e:
                if e.errno == constants.EAGAIN:
                    continue

                raise e

            log.callWithLogger(self, self.messageReceived, message)
开发者ID:vmarkovtsev,项目名称:txZMQ,代码行数:33,代码来源:connection.py


示例8: doKEvent

    def doKEvent(self, timeout):
        """
        Poll the kqueue for new events.
        """
        if timeout is None:
            timeout = 1

        try:
            events = self._kq.control([], len(self._selectables), timeout)
        except OSError as e:
            # Since this command blocks for potentially a while, it's possible
            # EINTR can be raised for various reasons (for example, if the user
            # hits ^C).
            if e.errno == errno.EINTR:
                return
            else:
                raise

        _drdw = self._doWriteOrRead
        for event in events:
            fd = event.ident
            try:
                selectable = self._selectables[fd]
            except KeyError:
                # Handles the infrequent case where one selectable's
                # handler disconnects another.
                continue
            else:
                log.callWithLogger(selectable, _drdw, selectable, fd, event)
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:29,代码来源:kqreactor.py


示例9: doPoll

    def doPoll(self, timeout):
        """
        Poll the poller for new events.
        """
        if timeout is None:
            timeout = -1  # Wait indefinitely.

        try:
            # Limit the number of events to the number of io objects we're
            # currently tracking (because that's maybe a good heuristic) and
            # the amount of time we block to the value specified by our
            # caller.
            l = self._poller.poll(timeout, len(self._selectables))
        except IOError as err:
            if err.errno == errno.EINTR:
                return
            # See epoll_wait(2) for documentation on the other conditions
            # under which this can fail.  They can only be due to a serious
            # programming error on our part, so let's just announce them
            # loudly.
            raise

        _drdw = self._doReadOrWrite
        for fd, event in l:
            try:
                selectable = self._selectables[fd]
            except KeyError:
                pass
            else:
                log.callWithLogger(selectable, _drdw, selectable, fd, event)
开发者ID:AmirKhooj,项目名称:VTK,代码行数:30,代码来源:epollreactor.py


示例10: ssh_CHANNEL_OPEN

 def ssh_CHANNEL_OPEN(self, packet):
     channelType, rest = common.getNS(packet)
     senderChannel, windowSize, maxPacket = struct.unpack('>3L', rest[: 12])
     packet = rest[12:]
     try:
         channel = self.getChannel(channelType, windowSize, maxPacket, packet)
         localChannel = self.localChannelID
         self.localChannelID+=1
         channel.id = localChannel
         self.channels[localChannel] = channel
         self.channelsToRemoteChannel[channel] = senderChannel
         self.localToRemoteChannel[localChannel] = senderChannel
         self.transport.sendPacket(MSG_CHANNEL_OPEN_CONFIRMATION, 
             struct.pack('>4L', senderChannel, localChannel, 
                 channel.localWindowSize, 
                 channel.localMaxPacket)+channel.specificData)
         log.callWithLogger(channel, channel.channelOpen, '')
     except Exception, e:
         log.msg('channel open failed')
         log.err(e)
         if isinstance(e, error.ConchError):
             reason, textualInfo = e.args[0], e.data
         else:
             reason = OPEN_CONNECT_FAILED
             textualInfo = "unknown failure"
         self.transport.sendPacket(MSG_CHANNEL_OPEN_FAILURE, 
                             struct.pack('>2L', senderChannel, reason)+ \
                            common.NS(textualInfo)+common.NS(''))
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:28,代码来源:connection.py


示例11: ssh_CHANNEL_EXTENDED_DATA

    def ssh_CHANNEL_EXTENDED_DATA(self, packet):
        """
        The other side is sending us exteneded data.  Payload::
            uint32  local channel number
            uint32  type code
            string  data

        Check to make sure the other side hasn't sent too much data (more
        than what's in the window, or or than the maximum packet size).  If
        they have, close the channel.  Otherwise, decrease the available
        window and pass the data and type code to the channel's
        extReceived().
        """
        localChannel, typeCode, dataLength = struct.unpack('>3L', packet[:12])
        channel = self.channels[localChannel]
        if (dataLength > channel.localWindowLeft or
                dataLength > channel.localMaxPacket):
            log.callWithLogger(channel, log.msg, 'too much extdata')
            self.sendClose(channel)
            return
        data = common.getNS(packet[8:])[0]
        channel.localWindowLeft -= dataLength
        if channel.localWindowLeft < channel.localWindowSize / 2:
            self.adjustWindow(channel, channel.localWindowSize -
                                       channel.localWindowLeft)
        log.callWithLogger(channel, channel.extReceived, typeCode, data)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:26,代码来源:connection.py


示例12: _invoke_callback

 def _invoke_callback(self, fd, events):
     if fd not in self._fds:
         return
     (reader, writer) = self._fds[fd]
     if reader:
         err = None
         if reader.fileno() == -1:
             err = error.ConnectionLost()
         elif events & IOLoop.READ:
             err = log.callWithLogger(reader, reader.doRead)
         if err is None and events & IOLoop.ERROR:
             err = error.ConnectionLost()
         if err is not None:
             self.removeReader(reader)
             reader.readConnectionLost(failure.Failure(err))
     if writer:
         err = None
         if writer.fileno() == -1:
             err = error.ConnectionLost()
         elif events & IOLoop.WRITE:
             err = log.callWithLogger(writer, writer.doWrite)
         if err is None and events & IOLoop.ERROR:
             err = error.ConnectionLost()
         if err is not None:
             self.removeWriter(writer)
             writer.writeConnectionLost(failure.Failure(err))
开发者ID:756613351,项目名称:tornado,代码行数:26,代码来源:twisted.py


示例13: ssh_CHANNEL_FAILURE

 def ssh_CHANNEL_FAILURE(self, packet):
     localChannel = struct.unpack('>L', packet[: 4])[0]
     if self.deferreds.get(localChannel):
         d = self.deferreds[localChannel].pop(0)
         log.callWithLogger(self.channels[localChannel],
                            d.errback, 
                            error.ConchError('channel request failed'))
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:7,代码来源:connection.py


示例14: _runPendingEvents

 def _runPendingEvents(self, pending_events):
     # pending_events is a list of (fd, mode) pairs.
     while pending_events:
         fd, mode = pending_events.pop()
         if fd in self._selectables:
             selectable = self._selectables[fd]
             log.callWithLogger(selectable,
                     self._doReadOrWrite, fd, mode, selectable)
开发者ID:breezechen,项目名称:syncless,代码行数:8,代码来源:reactor.py


示例15: ssh_CHANNEL_OPEN_FAILURE

 def ssh_CHANNEL_OPEN_FAILURE(self, packet):
     localChannel, reasonCode = struct.unpack('>2L', packet[: 8])
     reasonDesc = common.getNS(packet[8:])[0]
     channel = self.channels[localChannel]
     del self.channels[localChannel]
     channel.conn = self
     reason = error.ConchError(reasonDesc, reasonCode)
     log.callWithLogger(channel, channel.openFailed, reason)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:8,代码来源:connection.py


示例16: ssh_CHANNEL_CLOSE

 def ssh_CHANNEL_CLOSE(self, packet):
     localChannel = struct.unpack('>L', packet[: 4])[0]
     channel = self.channels[localChannel]
     if channel.remoteClosed:
         return
     log.callWithLogger(channel, channel.closeReceived)
     channel.remoteClosed = 1
     if channel.localClosed and channel.remoteClosed:
         self.channelClosed(channel)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:9,代码来源:connection.py


示例17: ssh_CHANNEL_OPEN_CONFIRMATION

 def ssh_CHANNEL_OPEN_CONFIRMATION(self, packet):
     localChannel, remoteChannel, windowSize, maxPacket = struct.unpack('>4L', packet[: 16])
     specificData = packet[16:]
     channel = self.channels[localChannel]
     channel.conn = self
     self.localToRemoteChannel[localChannel] = remoteChannel
     self.channelsToRemoteChannel[channel] = remoteChannel
     channel.remoteWindowLeft = windowSize
     channel.remoteMaxPacket = maxPacket
     log.callWithLogger(channel, channel.channelOpen, specificData)
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:10,代码来源:connection.py


示例18: ssh_CHANNEL_EOF

    def ssh_CHANNEL_EOF(self, packet):
        """
        The other side is not sending any more data.  Payload::
            uint32  local channel number

        Notify the channel by calling its eofReceived() method.
        """
        localChannel = struct.unpack('>L', packet[:4])[0]
        channel = self.channels[localChannel]
        log.callWithLogger(channel, channel.eofReceived)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:10,代码来源:connection.py


示例19: resolve_cb

        def resolve_cb(result):
            if add_service:
                method = protocol.addService

            else:
                # remove the service from the list before calling back the proto
                _registered_services.remove(info)
                method = protocol.removeService

            # call it with the reader instance to make things cleaner
            log.callWithLogger(reader, method, info)
开发者ID:jdcumpson,项目名称:txbonjour,代码行数:11,代码来源:discovery.py


示例20: ssh_CHANNEL_SUCCESS

    def ssh_CHANNEL_SUCCESS(self, packet):
        """
        Our channel request to the other other side succeeded.  Payload::
            uint32  local channel number

        Get the C{Deferred} out of self.deferreds and call it back.
        """
        localChannel = struct.unpack('>L', packet[:4])[0]
        if self.deferreds.get(localChannel):
            d = self.deferreds[localChannel].pop(0)
            log.callWithLogger(self.channels[localChannel],
                               d.callback, '')
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:12,代码来源:connection.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.debug函数代码示例发布时间:2022-05-27
下一篇:
Python log.addObserver函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap