[riot-notifications] [RIOT-OS/RIOT] riotnode: initial import of shell interaction spawn (#11406)

Gaƫtan Harter notifications at github.com
Wed Apr 17 12:18:06 CEST 2019


Without looking at the implementation, I am more thinking about a wrapper around `node` or the `expect` instance than as a base class to `expect`.
I do not really want to go with the inheritance scheme here and do more composition.

    shell =  MyTermClass(node)
    shell.reboot()


One of the reason is it could allow having different wrappers for the same instance. Which is way better for namespacing.

    udp_server = MyUDPServer(node)
    tcp_server = MyTCPServer(node)

    udp_server.listen('1234')
    tcp_server.listen('80')

    udp_server.packet_callback = test_udp_cb
    tcp_server.packet_callback = test_tcp_cb

Otherwise every method must be namespaced `shell.tcp_server_listen()` which feels weird.
And multiple inheritance leads to issues when you cannot really substitute an object for the other anymore.

This still allows to do composed objects with a separate class, that would here be the `mixins`:

    class MySuperClassUnderTest():
        def __init__(self, node):
                self.tcp_server = TCPServerShell(node)
                self.udp_server = UDPServerShell(node)


I am just not sure where to put the `Shell` but I think I would still prefer to use the shell as a composition and have maybe a provided class already if you really want to just inherit from it.

    class BasicShellClass():
        SHELL_CLASS = RiotNodeShell
        def __init__(self, node):
            self.shell = self.SHELL_CLASS(node)
        # maybe with calls being forwarded directly to the shell class to be able to do
        # basicshell.wait_ready()

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11406#issuecomment-484025184
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190417/7fcbfbb5/attachment.html>


More information about the notifications mailing list