本文整理匯總了Python中twisted.protocols.basic.LineOnlyReceiver方法的典型用法代碼示例。如果您正苦於以下問題:Python basic.LineOnlyReceiver方法的具體用法?Python basic.LineOnlyReceiver怎麽用?Python basic.LineOnlyReceiver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.protocols.basic
的用法示例。
在下文中一共展示了basic.LineOnlyReceiver方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: lineLengthExceeded
# 需要導入模塊: from twisted.protocols import basic [as 別名]
# 或者: from twisted.protocols.basic import LineOnlyReceiver [as 別名]
def lineLengthExceeded(self, buffer):
"""
Drop the connection when a server response exceeds the maximum line
length (L{LineOnlyReceiver.MAX_LENGTH}).
@type buffer: L{bytes}
@param buffer: A received line which exceeds the maximum line length.
"""
# XXX - We need to be smarter about this
if self._waiting is not None:
waiting, self._waiting = self._waiting, None
waiting.errback(LineTooLong())
self.transport.loseConnection()
# POP3 Client state logic - don't touch this.
示例2: test_lineReceivedNotImplemented
# 需要導入模塊: from twisted.protocols import basic [as 別名]
# 或者: from twisted.protocols.basic import LineOnlyReceiver [as 別名]
def test_lineReceivedNotImplemented(self):
"""
When L{LineOnlyReceiver.lineReceived} is not overridden in a subclass,
calling it raises C{NotImplementedError}.
"""
proto = basic.LineOnlyReceiver()
self.assertRaises(NotImplementedError, proto.lineReceived, 'foo')
示例3: __str__
# 需要導入模塊: from twisted.protocols import basic [as 別名]
# 或者: from twisted.protocols.basic import LineOnlyReceiver [as 別名]
def __str__(self):
return repr(self)
# LineOnlyReceiver is mutable, so can't use pyrsistent
示例4: test_greaterThanMaximumLineLength
# 需要導入模塊: from twisted.protocols import basic [as 別名]
# 或者: from twisted.protocols.basic import LineOnlyReceiver [as 別名]
def test_greaterThanMaximumLineLength(self):
"""
C{LineOnlyReceiver} disconnects the transport if it receives a
line longer than its C{MAX_LENGTH} + len(delimiter).
"""
proto = LineOnlyTester()
transport = proto_helpers.StringTransport()
proto.makeConnection(transport)
proto.dataReceived(b'x' * (proto.MAX_LENGTH
+ len(proto.delimiter) + 1) + b'\r\nr')
self.assertTrue(transport.disconnecting)
示例5: __init__
# 需要導入模塊: from twisted.protocols import basic [as 別名]
# 或者: from twisted.protocols.basic import LineOnlyReceiver [as 別名]
def __init__(self):
#basic.LineOnlyReceiver.__init__(self)
self._matcher = deferral.GenericDeferrer(max_id=2**30, func=lambda id, method, params: self.sendLine(json.dumps({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': id,
})))
self.other = Proxy(self._matcher)
示例6: failResponse
# 需要導入模塊: from twisted.protocols import basic [as 別名]
# 或者: from twisted.protocols.basic import LineOnlyReceiver [as 別名]
def failResponse(self, message=''):
self.sendLine('-ERR ' + str(message))
# def sendLine(self, line):
# print 'S:', repr(line)
# basic.LineOnlyReceiver.sendLine(self, line)