• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python protocol.TFTP类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例3: BackendCallingContext

class BackendCallingContext(unittest.TestCase):

    def setUp(self):
        super(BackendCallingContext, self).setUp()
        self.backend = ContextCapturingBackend("local", "remote")
        self.tftp = TFTP(self.backend)
        self.tftp.transport = HostTransport(("12.34.56.78", 1234))

    @inlineCallbacks
    def test_context_rrq(self):
        rrq_datagram = RRQDatagram('nonempty', 'NetASCiI', {})
        rrq_addr = ('127.0.0.1', 1069)
        error = yield self.assertFailure(
            self.tftp._startSession(rrq_datagram, rrq_addr, "octet"),
            CapturedContext)
        self.assertEqual(("get_reader", rrq_datagram.filename), error.args)
        self.assertEqual(
            {"local": self.tftp.transport.host, "remote": rrq_addr},
            error.context)

    @inlineCallbacks
    def test_context_wrq(self):
        wrq_datagram = WRQDatagram('nonempty', 'NetASCiI', {})
        wrq_addr = ('127.0.0.1', 1069)
        error = yield self.assertFailure(
            self.tftp._startSession(wrq_datagram, wrq_addr, "octet"),
            CapturedContext)
        self.assertEqual(("get_writer", wrq_datagram.filename), error.args)
        self.assertEqual(
            {"local": self.tftp.transport.host, "remote": wrq_addr},
            error.context)
开发者ID:deepakhajare,项目名称:maas,代码行数:31,代码来源:test_protocol.py


示例4: SuccessfulAsyncDispatch

class SuccessfulAsyncDispatch(unittest.TestCase):

    def setUp(self):
        self.clock = Clock()
        self.tmp_dir_path = tempfile.mkdtemp()
        with FilePath(self.tmp_dir_path).child('nonempty').open('w') as fd:
            fd.write('Something uninteresting')
        self.backend = FilesystemAsyncBackend(self.tmp_dir_path, self.clock)
        self.tftp = TFTP(self.backend, self.clock)

    def test_get_reader_defers(self):
        rrq_datagram = RRQDatagram('nonempty', 'NetASCiI', {})
        rrq_addr = ('127.0.0.1', 1069)
        rrq_mode = "octet"
        d = self.tftp._startSession(rrq_datagram, rrq_addr, rrq_mode)
        self.assertFalse(d.called)
        self.clock.advance(1)
        self.assertTrue(d.called)
        self.assertTrue(IReader.providedBy(d.result.backend))

    def test_get_writer_defers(self):
        wrq_datagram = WRQDatagram('foobar', 'NetASCiI', {})
        wrq_addr = ('127.0.0.1', 1069)
        wrq_mode = "octet"
        d = self.tftp._startSession(wrq_datagram, wrq_addr, wrq_mode)
        self.assertFalse(d.called)
        self.clock.advance(1)
        self.assertTrue(d.called)
        self.assertTrue(IWriter.providedBy(d.result.backend))
开发者ID:deepakhajare,项目名称:maas,代码行数:29,代码来源:test_protocol.py


示例5: test_non_rq_datagram

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


示例6: SuccessfulAsyncDispatch

class SuccessfulAsyncDispatch(unittest.TestCase):
    def setUp(self):
        self.clock = Clock()
        self.temp_dir = FilePath(tempfile.mkdtemp()).asBytesMode()
        with self.temp_dir.child(b"nonempty").open("w") as fd:
            fd.write(b"Something uninteresting")
        self.backend = FilesystemAsyncBackend(self.temp_dir, self.clock)
        self.tftp = TFTP(self.backend, self.clock)

    def test_get_reader_defers(self):
        rrq_datagram = RRQDatagram(b"nonempty", b"NetASCiI", {})
        rrq_addr = ("127.0.0.1", 1069)
        rrq_mode = b"octet"
        d = self.tftp._startSession(rrq_datagram, rrq_addr, rrq_mode)
        self.assertFalse(d.called)
        self.clock.advance(1)
        self.assertTrue(d.called)
        self.assertTrue(IReader.providedBy(d.result.backend))

    def test_get_writer_defers(self):
        wrq_datagram = WRQDatagram(b"foobar", b"NetASCiI", {})
        wrq_addr = ("127.0.0.1", 1069)
        wrq_mode = b"octet"
        d = self.tftp._startSession(wrq_datagram, wrq_addr, wrq_mode)
        self.assertFalse(d.called)
        self.clock.advance(1)
        self.assertTrue(d.called)
        self.assertTrue(IWriter.providedBy(d.result.backend))
开发者ID:shylent,项目名称:python-tx-tftp,代码行数:28,代码来源:test_protocol.py


示例7: 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


示例8: setUp

 def setUp(self):
     self.clock = Clock()
     self.tmp_dir_path = tempfile.mkdtemp()
     with FilePath(self.tmp_dir_path).child('nonempty').open('w') as fd:
         fd.write('Something uninteresting')
     self.backend = FilesystemAsyncBackend(self.tmp_dir_path, self.clock)
     self.tftp = TFTP(self.backend, self.clock)
开发者ID:deepakhajare,项目名称:maas,代码行数:7,代码来源:test_protocol.py


示例9: setUp

 def setUp(self):
     self.clock = Clock()
     self.temp_dir = FilePath(tempfile.mkdtemp()).asBytesMode()
     with self.temp_dir.child(b"nonempty").open("w") as fd:
         fd.write(b"Something uninteresting")
     self.backend = FilesystemAsyncBackend(self.temp_dir, self.clock)
     self.tftp = TFTP(self.backend, self.clock)
开发者ID:shylent,项目名称:python-tx-tftp,代码行数:7,代码来源:test_protocol.py


示例10: _startSession

    def _startSession(self, *args, **kwargs):
        d = TFTP._startSession(self, *args, **kwargs)

        def save_session(session):
            self.session = session
            return session

        d.addCallback(save_session)
        return d
开发者ID:deepakhajare,项目名称:maas,代码行数:9,代码来源:test_protocol.py


示例11: 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


示例12: 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


示例13: 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


示例14: test_malformed_datagram

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


示例15: test_malformed_datagram

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


示例16: datagramReceived

 def datagramReceived(self, *args, **kwargs):
     self.session = TFTP.datagramReceived(self, *args, **kwargs)
开发者ID:rvbad,项目名称:python-tx-tftp,代码行数:2,代码来源:test_protocol.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_sessions.FakeTransport类代码示例发布时间:2022-05-27
下一篇:
Python datagram.ERRORDatagram类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap