本文整理汇总了Python中tftp.protocol.TFTP.datagramReceived方法的典型用法代码示例。如果您正苦于以下问题:Python TFTP.datagramReceived方法的具体用法?Python TFTP.datagramReceived怎么用?Python TFTP.datagramReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tftp.protocol.TFTP
的用法示例。
在下文中一共展示了TFTP.datagramReceived方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_mode
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_bad_mode(self):
tftp = TFTP(DummyBackend(), _clock=self.clock)
tftp.transport = self.transport
wrq_datagram = WRQDatagram('foobar', 'badmode', {})
tftp.datagramReceived(wrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_ILLEGAL_OP)
示例2: test_non_rq_datagram
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_non_rq_datagram(self):
tftp = TFTP(DummyBackend(), _clock=self.clock)
tftp.transport = self.transport
ack_datagram = ACKDatagram(14)
tftp.datagramReceived(ack_datagram.to_wire(), ("127.0.0.1", 1111))
self.failIf(self.transport.disconnecting)
self.failIf(self.transport.value())
示例3: test_file_exists
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_file_exists(self):
tftp = TFTP(BackendFactory(FileExists("Already have one")), _clock=self.clock)
tftp.transport = self.transport
wrq_datagram = WRQDatagram('foobar', 'netascii', {})
tftp.datagramReceived(wrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_FILE_EXISTS)
示例4: test_file_not_found
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_file_not_found(self):
tftp = TFTP(BackendFactory(FileNotFound("Not found")), _clock=self.clock)
tftp.transport = self.transport
rrq_datagram = RRQDatagram('foobar', 'netascii', {})
tftp.datagramReceived(rrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_FILE_NOT_FOUND)
示例5: test_access_violation
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_access_violation(self):
tftp = TFTP(BackendFactory(AccessViolation("No!")), _clock=self.clock)
tftp.transport = self.transport
wrq_datagram = WRQDatagram('foobar', 'netascii', {})
tftp.datagramReceived(wrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_ACCESS_VIOLATION)
self.transport.clear()
rrq_datagram = RRQDatagram('foobar', 'octet', {})
tftp.datagramReceived(rrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_ACCESS_VIOLATION)
示例6: test_unsupported
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_unsupported(self):
tftp = TFTP(BackendFactory(Unsupported("I don't support you")), _clock=self.clock)
tftp.transport = self.transport
wrq_datagram = WRQDatagram('foobar', 'netascii', {})
tftp.datagramReceived(wrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_ILLEGAL_OP)
self.transport.clear()
rrq_datagram = RRQDatagram('foobar', 'octet', {})
tftp.datagramReceived(rrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_ILLEGAL_OP)
示例7: test_generic_backend_error
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_generic_backend_error(self):
tftp = TFTP(BackendFactory(BackendError("A backend that couldn't")), _clock=self.clock)
tftp.transport = self.transport
rrq_datagram = RRQDatagram('foobar', 'netascii', {})
tftp.datagramReceived(rrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_NOT_DEFINED)
self.transport.clear()
rrq_datagram = RRQDatagram('foobar', 'octet', {})
tftp.datagramReceived(rrq_datagram.to_wire(), ('127.0.0.1', 1111))
error_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
self.assertEqual(error_datagram.errorcode, ERR_NOT_DEFINED)
示例8: test_malformed_datagram
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_malformed_datagram(self):
tftp = TFTP(BackendFactory(), _clock=self.clock)
tftp.datagramReceived('foobar', ('127.0.0.1', 1111))
self.failIf(self.transport.disconnecting)
self.failIf(self.transport.value())
示例9: test_malformed_datagram
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def test_malformed_datagram(self):
tftp = TFTP(BackendFactory(), _clock=self.clock)
tftp.datagramReceived(b"foobar", ("127.0.0.1", 1111))
self.assertFalse(self.transport.disconnecting)
self.assertFalse(self.transport.value())
示例10: datagramReceived
# 需要导入模块: from tftp.protocol import TFTP [as 别名]
# 或者: from tftp.protocol.TFTP import datagramReceived [as 别名]
def datagramReceived(self, *args, **kwargs):
self.session = TFTP.datagramReceived(self, *args, **kwargs)