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


Python datagram.split_opcode函数代码示例

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


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

示例1: test_access_violation

    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)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:13,代码来源:test_protocol.py

示例2: test_generic_backend_error

    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)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:13,代码来源:test_protocol.py

示例3: test_unsupported

    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)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:13,代码来源:test_protocol.py

示例4: test_file_exists

 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)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:7,代码来源:test_protocol.py

示例5: test_ACK_invalid_blocknum

 def test_ACK_invalid_blocknum(self):
     ack_datagram = ACKDatagram(3)
     yield self.rs.datagramReceived(ack_datagram)
     self.failIf(self.transport.disconnecting)
     err_dgram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.assert_(isinstance(err_dgram, ERRORDatagram))
     self.addCleanup(self.rs.cancel)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:7,代码来源:test_sessions.py

示例6: test_file_not_found

 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)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:7,代码来源:test_protocol.py

示例7: test_invalid_tid

 def test_invalid_tid(self):
     self.rs.startProtocol()
     data_datagram = DATADatagram(1, 'foobar')
     yield self.rs.datagramReceived(data_datagram, ('127.0.0.1', 11111))
     err_dgram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.assertEqual(err_dgram.errorcode, ERR_TID_UNKNOWN)
     self.addCleanup(self.rs.cancel)
开发者ID:deepakhajare,项目名称:maas,代码行数:7,代码来源:test_bootstrap.py

示例8: test_bad_mode

 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)
开发者ID:deepakhajare,项目名称:maas,代码行数:7,代码来源:test_protocol.py

示例9: test_invalid_tid

 def test_invalid_tid(self):
     data_datagram = DATADatagram(1, b'foobar')
     self.rs.datagramReceived(data_datagram, ('127.0.0.1', 11111))
     self.clock.advance(0.1)
     err_dgram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.assertEqual(err_dgram.errorcode, ERR_TID_UNKNOWN)
     self.addCleanup(self.rs.cancel)
开发者ID:aivins,项目名称:python-tx-tftp,代码行数:7,代码来源:test_bootstrap.py

示例10: cb

 def cb(ign):
     self.clock.advance(0.1)
     self.failIf(self.transport.disconnecting)
     data_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.assertEqual(data_datagram.data, 'line1')
     self.failIf(self.rs.completed,
                 "Got enough bytes from the reader, there is no reason to stop")
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:7,代码来源:test_sessions.py

示例11: cb_

 def cb_(ign):
     self.clock.advance(0.1)
     self.failIf(self.transport.disconnecting)
     ack_dgram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.assertEqual(ack_dgram.blocknum, 2)
     self.failIf(self.ws.completed,
                 "Data length is equal to blocksize, no reason to stop")
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:7,代码来源:test_sessions.py

示例12: datagramReceived

 def datagramReceived(self, datagram, addr):
     if self.remote[1] != addr[1]:
         self.transport.write(ERRORDatagram.from_code(ERR_TID_UNKNOWN).to_wire())
         return# Does not belong to this transfer
     datagram = TFTPDatagramFactory(*split_opcode(datagram))
     if datagram.opcode == OP_ERROR:
         return self.tftp_ERROR(datagram)
     return self._datagramReceived(datagram)
开发者ID:deepakhajare,项目名称:maas,代码行数:8,代码来源:bootstrap.py

示例13: test_failed_write

 def test_failed_write(self):
     self.writer.cancel()
     self.ws.writer = FailingWriter()
     data_datagram = DATADatagram(1, 'foobar')
     yield self.ws.datagramReceived(data_datagram)
     self.flushLoggedErrors()
     self.clock.advance(0.1)
     err_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.failUnless(isinstance(err_datagram, ERRORDatagram))
     self.failUnless(self.transport.disconnecting)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:10,代码来源:test_sessions.py

示例14: test_DATA_invalid_blocknum

 def test_DATA_invalid_blocknum(self):
     self.ws.block_size = 6
     data_datagram = DATADatagram(3, 'foobar')
     yield self.ws.datagramReceived(data_datagram)
     self.writer.finish()
     self.failIf(self.target.open('r').read())
     self.failIf(self.transport.disconnecting)
     err_dgram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.assert_(isinstance(err_dgram, ERRORDatagram))
     self.addCleanup(self.ws.cancel)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:10,代码来源:test_sessions.py

示例15: test_failed_read

 def test_failed_read(self):
     self.reader.finish()
     self.rs.reader = FailingReader()
     self.rs.blocknum = 1
     ack_datagram = ACKDatagram(1)
     yield self.rs.datagramReceived(ack_datagram)
     self.flushLoggedErrors()
     self.clock.advance(0.1)
     err_datagram = TFTPDatagramFactory(*split_opcode(self.transport.value()))
     self.failUnless(isinstance(err_datagram, ERRORDatagram))
     self.failUnless(self.transport.disconnecting)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:11,代码来源:test_sessions.py


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