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


Python basic.LineReceiver类代码示例

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


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


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