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

Python basic.LineReceiver类代码示例

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

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



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

示例1: connectionLost

 def connectionLost(self, why):
     self.connected = 0
     self.script_hashes.clear()
     self.factory.delConnection(self)
     LineReceiver.connectionLost(self, why)
     while self.replyQueue.waiting:
         self.replyReceived(ConnectionError("Lost connection"))
开发者ID:anthonyalmarza,项目名称:trex,代码行数:7,代码来源:protocols.py


示例2: dataReceived

    def dataReceived(self, *args, **kwargs):
        # receives the data then checks if the request is complete.
        # if it is, it calls full_Request_received
        LineReceiver.dataReceived(self, *args, **kwargs)

        if self._request_obj.complete:
            self.full_request_received()
开发者ID:amuntner,项目名称:pappy-proxy,代码行数:7,代码来源:proxy.py


示例3: sendLine

 def sendLine(self, line):
     """
     Override sendLine to add a timeout to response.
     """
     if not self._current:
         self.setTimeout(self.persistentTimeOut)
     LineReceiver.sendLine(self, line)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:7,代码来源:memcache.py


示例4: APRSProcessProtocol

class APRSProcessProtocol(ProcessProtocol):
    def __init__(self, target):
        self.__target = target
        self.__line_receiver = LineReceiver()
        self.__line_receiver.delimiter = '\n'
        self.__line_receiver.lineReceived = self.__lineReceived
        self.__last_line = None
    
    def outReceived(self, data):
        # split lines
        self.__line_receiver.dataReceived(data)
        
    def errReceived(self, data):
        # we should inherit stderr, not pipe it
        raise Exception('shouldn\'t happen')
    
    def __lineReceived(self, line):
        if line == '':  # observed glitch in output
            pass
        elif line.startswith('Enabled demodulators:'):
            pass
        elif line.startswith('$ULTW') and self.__last_line is not None:  # observed glitch in output; need to glue to previous line, I think?
            ll = self.__last_line
            self.__last_line = None
            self.__target(ll + line)
        elif line.startswith('APRS: '):
            line = line[len('APRS: '):]
            self.__last_line = line
            self.__target(line)
        else:
            # TODO: Log these properly
            print 'Not APRS line: %r' % line
开发者ID:gstark307,项目名称:shinysdr,代码行数:32,代码来源:multimon.py


示例5: RTL433ProcessProtocol

class RTL433ProcessProtocol(ProcessProtocol):
    def __init__(self, target):
        self.__target = target
        self.__line_receiver = LineReceiver()
        self.__line_receiver.delimiter = '\n'
        self.__line_receiver.lineReceived = self.__lineReceived
    
    def outReceived(self, data):
        """Implements ProcessProtocol."""
        # split lines
        self.__line_receiver.dataReceived(data)
        
    def errReceived(self, data):
        """Implements ProcessProtocol."""
        # we should inherit stderr, not pipe it
        raise Exception('shouldn\'t happen')
    
    def __lineReceived(self, line):
        # rtl_433's JSON encoder is not perfect (e.g. it will emit unescaped newlines), so protect against parse failures
        try:
            message = json.loads(line)
        except ValueError:
            log.msg('bad JSON from rtl_433: %s' % line)
            return
        log.msg('rtl_433 message: %r' % (message,))
        # rtl_433 provides a time field, but when in file-input mode it assumes the input is not real-time and generates start-of-file-relative timestamps, so we can't use them.
        wrapper = RTL433MessageWrapper(message, time.time())
        self.__target(wrapper)
开发者ID:bitglue,项目名称:shinysdr,代码行数:28,代码来源:rtl_433.py


示例6: sendLine

 def sendLine(self, line):
     if self.onXMLReceived:
         raise FoneworxException, "onXMLReceived already initialized before sending"
     self.onXMLReceived = Deferred()
     log.msg("Sending line: %s" % line, logLevel=logging.DEBUG)
     LineReceiver.sendLine(self, line)
     return self.onXMLReceived
开发者ID:sanyaade,项目名称:python-foneworx,代码行数:7,代码来源:protocol.py


示例7: connectionLost

 def connectionLost(self, reason):
     """
     Cause any outstanding commands to fail.
     """
     self._disconnected = True
     self._cancelCommands(reason)
     LineReceiver.connectionLost(self, reason)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:7,代码来源:memcache.py


示例8: dataReceived

 def dataReceived(self, data):
     if self.factory.stream_response and self.stream_response:
         self.factory.return_transport.write(data)
     LineReceiver.dataReceived(self, data)
     if not self.completed:
         if self._response_obj.complete:
             self.completed = True
             self.handle_response_end()
开发者ID:onizenso,项目名称:pappy-proxy,代码行数:8,代码来源:proxy.py


示例9: __init__

 def __init__(self):
     self.state = self.State.ANNOUNCE
     self.session = None
     self.nonce = None
     self.seq = 0
     LineReceiver.setRawMode(self)
     global video_server_connection
     video_server_connection = self
开发者ID:CryptArc,项目名称:jtvlc,代码行数:8,代码来源:jtvlc.py


示例10: connectionLost

		def connectionLost(self, reason):
			""" ups... stop reactor """
			LineReceiver.connectionLost(self, reason)
			print "Connection lost: ", reason.getErrorMessage()
			try:
				reactor.stop()
			except ReactorNotRunning:
				print " - reactor not running, so we are not stopping it" 
开发者ID:nickers,项目名称:sw-dolev,代码行数:8,代码来源:communication_client.py


示例11: connectionMade

 def connectionMade(self):
     ProcessProtocol.connectionMade(self)
     LineReceiver.connectionMade(self)
     self.transport.disconnecting = False #erm. Needs this to fix a bug in Twisted?
     self.send_to_client("hello", [self.communicator.mod.name])
     if not self.messages_not_acknowledged:
         self.client_started_processing_at = time.time()
     self.messages_not_acknowledged += 1
开发者ID:dmoggles,项目名称:pymudclient,代码行数:8,代码来源:client.py


示例12: connectionMade

    def connectionMade(self):
        """
        Notify our factory that we're ready to accept connections.
        """
        LineReceiver.connectionMade(self)

        if self.factory.deferred is not None:
            self.factory.deferred.callback(self)
            self.factory.deferred = None
开发者ID:Crackpot,项目名称:gftop,代码行数:9,代码来源:iwproxypool.py


示例13: dataReceived

    def dataReceived(self, *args, **kwargs):
        # receives the data then checks if the request is complete.
        # if it is, it calls full_Request_received
        LineReceiver.dataReceived(self, *args, **kwargs)

        if self._request_obj.complete:
            try:
                self.full_request_received()
            except PappyException as e:
                print str(e)
开发者ID:MahaKoala,项目名称:pappy-proxy,代码行数:10,代码来源:proxy.py


示例14: create_request

 def create_request(self):
     channel = LineReceiver()
     channel.site = PixelatedSite(mock())
     request = PixelatedSite.requestFactory(channel=channel, queued=True)
     request.method = "GET"
     request.uri = "localhost"
     request.clientproto = 'HTTP/1.1'
     request.prepath = []
     request.postpath = request.uri.split('/')[1:]
     request.path = "/"
     return request
开发者ID:bwagnerr,项目名称:pixelated-user-agent,代码行数:11,代码来源:test_site.py


示例15: sendLine

 def sendLine(self, line):
     if isinstance(line, str):
         if six.PY3:
             super(StringLineReceiver, self).sendLine(line.encode())
         else:
             LineReceiver.sendLine(self, line.encode())
     elif isinstance(line, bytes):
         if six.PY3:
             super(StringLineReceiver, self).sendLine(line)
         else:
             LineReceiver.sendLine(self, line)
     else:
         raise RuntimeError("Only str and bytes are allowed.")
开发者ID:2php,项目名称:veles,代码行数:13,代码来源:network_common.py


示例16: __init__

 def __init__(self, svc=None):
     self.lineReceiver = LineReceiver()
     self.lineReceiver.delimiter = '\n'
     self.lineReceiver.lineReceived = self.lineReceived
     self.svc = svc
     self.isReady = False
     self.completionDeferred = Deferred()
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:7,代码来源:subpostgres.py


示例17: sendLine

    def sendLine(self, line):
        self.log.info('SEND: ' + line)

        for regex, callback in self.send_line_hooks:
            if regex.match(line) is not None:
                callback(self, line)

        return LineReceiver.sendLine(self, line)
开发者ID:pombredanne,项目名称:twisted-lock,代码行数:8,代码来源:lock.py


示例18: CommandReceiver

class CommandReceiver(channel.ChannelReceiver):

    def __init__(self):
        self.lineReceiver = LineReceiver()
        self.lineReceiver.lineReceived = self.lineReceived

    def lineReceived(self, line):
        cmd, data = line.split(':', 1)
        self.commandReceived(cmd.strip(), data.strip())

    def commandReceived(self, cmd, data):
        raise NotImplementedError

    def sendCommand(self, cmd, data):
        return self.send(self.cmd_channel, '%s: %s\r\n' % (cmd, data))

    def channeReceived(self, channel, type, data):
        if channel == self.cmd_channel:
            self.lineReceiver.dataReceived(data)
开发者ID:scottietie,项目名称:nowin_core,代码行数:19,代码来源:command.py


示例19: __init__

 def __init__(self, server_name, connected_deferred):
     self.__proxy_obj = None
     self.__server_name = server_name
     self.__connected_deferred = connected_deferred
     self.__line_receiver = LineReceiver()
     self.__line_receiver.delimiter = '\n'
     self.__line_receiver.lineReceived = self.__lineReceived
     self.__waiting_for_responses = []
     self.__receive_cmd = None
     self.__receive_arg = None
开发者ID:bitglue,项目名称:shinysdr,代码行数:10,代码来源:__init__.py


示例20: LineBuffer

class LineBuffer(object):
    """
    A line-buffering wrapper for L{GreenletTransport}s (or any other object
    with C{read} and C{write} methods). Call L{readLine} to get the next line,
    call L{writeLine} to write a line.
    """
    def __init__(self, transport, delimiter="\r\n"):
        """
        @param transport: The transport from which to read bytes and to which
            to write them!
        @type transport: L{GreenletTransport}
        @param delimiter: The line delimiter to split lines on.
        @type delimiter: C{str}
        """
        self.delimiter = delimiter
        self.transport = transport
        self.receiver = LineReceiver()
        self.receiver.delimiter = delimiter
        self.lines = []
        self.receiver.lineReceived = self.lines.append

    def writeLine(self, data):
        """
        Write some data to the transport followed by the delimiter.
        """
        self.transport.write(data + self.delimiter)

    def readLine(self):
        """
        Return a line of data from the transport.
        """
        while not self.lines:
            self.receiver.dataReceived(self.transport.read())
        return self.lines.pop(0)

    def __iter__(self):
        """
        Yield the result of L{readLine} forever.
        """
        while True:
            yield self.readLine()
开发者ID:radix,项目名称:corotwine,代码行数:41,代码来源:protocol.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python loopback.loopbackAsync函数代码示例发布时间:2022-05-27
下一篇:
Python basic.FileSender类代码示例发布时间: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