本文整理汇总了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)