Commit 0fba4bf2 authored by Martí Bolívar's avatar Martí Bolívar Committed by Anas Nashif
Browse files

scripts: runner: refactor run() implementation



Have the subclasses implement a do_run() method instead, which run()
delegates to. This will make it possible to handle common
functionality in the superclass before runner-specific methods are
called. It is a prerequisite for tasks like loading the build time
configuration to add device tree awareness.

Signed-off-by: default avatarMarti Bolivar <marti@opensourcefoundries.com>
parent 5b0167ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ class ArcBinaryRunner(ZephyrBinaryRunner):
                               tcl_port=tcl_port, telnet_port=telnet_port,
                               gdb_port=gdb_port, debug=debug)

    def run(self, command, **kwargs):
    def do_run(self, command, **kwargs):
        if command not in {'flash', 'debug', 'debugserver'}:
            raise ValueError('{} is not supported'.format(command))

+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ class BossacBinaryRunner(ZephyrBinaryRunner):
        return BossacBinaryRunner(bin_name, bossac=bossac, port=port,
                                  debug=debug)

    def run(self, command, **kwargs):
    def do_run(self, command, **kwargs):
        if command != 'flash':
            raise ValueError('only flash is supported')

+8 −2
Original line number Diff line number Diff line
@@ -225,9 +225,15 @@ class ZephyrBinaryRunner(abc.ABC):
        environment variables expected by that script are used to build
        the flasher in a backwards-compatible manner.'''

    @abc.abstractmethod
    def run(self, command, **kwargs):
        '''Run a command ('flash', 'debug', 'debugserver').
        '''Runs command ('flash', 'debug', 'debugserver').

        This is the main entry point to this runner.'''
        self.do_run(command, **kwargs)

    @abc.abstractmethod
    def do_run(self, command, **kwargs):
        '''Concrete runner; run() delegates to this. Implement in subclasses.

        In case of an unsupported command, raise a ValueError.'''

+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class DfuUtilBinaryRunner(ZephyrBinaryRunner):
        output = output.decode(sys.getdefaultencoding())
        return self.list_pattern in output

    def run(self, command, **kwargs):
    def do_run(self, command, **kwargs):
        if command != 'flash':
            raise ValueError('only flash is supported')

+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class Esp32BinaryRunner(ZephyrBinaryRunner):
                                 flash_mode=flash_mode, espidf=espidf,
                                 debug=debug)

    def run(self, command, **kwargs):
    def do_run(self, command, **kwargs):
        if command != 'flash':
            raise ValueError('only flash is supported')

Loading