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: Marti Bolivar <marti@opensourcefoundries.com>
diff --git a/scripts/support/runner/arc.py b/scripts/support/runner/arc.py
index 99b2311..c3647c9 100644
--- a/scripts/support/runner/arc.py
+++ b/scripts/support/runner/arc.py
@@ -96,7 +96,7 @@
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))
diff --git a/scripts/support/runner/bossac.py b/scripts/support/runner/bossac.py
index 394a9c3..cbf24b4 100644
--- a/scripts/support/runner/bossac.py
+++ b/scripts/support/runner/bossac.py
@@ -46,7 +46,7 @@
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')
diff --git a/scripts/support/runner/core.py b/scripts/support/runner/core.py
index 2f38186..b66b535 100644
--- a/scripts/support/runner/core.py
+++ b/scripts/support/runner/core.py
@@ -225,9 +225,15 @@
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.'''
diff --git a/scripts/support/runner/dfu.py b/scripts/support/runner/dfu.py
index 5dda9d8..95353b9 100644
--- a/scripts/support/runner/dfu.py
+++ b/scripts/support/runner/dfu.py
@@ -58,7 +58,7 @@
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')
diff --git a/scripts/support/runner/esp32.py b/scripts/support/runner/esp32.py
index 0dcacae..38f6fbe 100644
--- a/scripts/support/runner/esp32.py
+++ b/scripts/support/runner/esp32.py
@@ -67,7 +67,7 @@
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')
diff --git a/scripts/support/runner/jlink.py b/scripts/support/runner/jlink.py
index f20fbe6..3822173 100644
--- a/scripts/support/runner/jlink.py
+++ b/scripts/support/runner/jlink.py
@@ -79,7 +79,7 @@
def print_gdbserver_message(self):
print('JLink GDB server running on port {}'.format(self.gdb_port))
- def run(self, command, **kwargs):
+ def do_run(self, command, **kwargs):
if command not in {'debug', 'debugserver'}:
raise ValueError('{} is not supported'.format(command))
diff --git a/scripts/support/runner/nios2.py b/scripts/support/runner/nios2.py
index 480e1ed..a18d2e3 100644
--- a/scripts/support/runner/nios2.py
+++ b/scripts/support/runner/nios2.py
@@ -76,7 +76,7 @@
cpu_sof=cpu_sof, zephyr_base=zephyr_base,
gdb=gdb, tui=tui, 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))
diff --git a/scripts/support/runner/nrfjprog.py b/scripts/support/runner/nrfjprog.py
index f11ab8f..0ebed7b 100644
--- a/scripts/support/runner/nrfjprog.py
+++ b/scripts/support/runner/nrfjprog.py
@@ -60,7 +60,7 @@
return snrs[value - 1]
- def run(self, command, **kwargs):
+ def do_run(self, command, **kwargs):
if command != 'flash':
raise ValueError('only flash is supported')
diff --git a/scripts/support/runner/openocd.py b/scripts/support/runner/openocd.py
index c171449..23b727e 100644
--- a/scripts/support/runner/openocd.py
+++ b/scripts/support/runner/openocd.py
@@ -134,7 +134,7 @@
telnet_port=telnet_port, gdb_port=gdb_port,
gdb=gdb, tui=tui, 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))
diff --git a/scripts/support/runner/pyocd.py b/scripts/support/runner/pyocd.py
index 384b8c1..d5e7831 100644
--- a/scripts/support/runner/pyocd.py
+++ b/scripts/support/runner/pyocd.py
@@ -107,7 +107,7 @@
tui=tui, bin_name=bin_name, elf_name=elf_name,
board_id=board_id, daparg=daparg, 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))
diff --git a/scripts/support/runner/qemu.py b/scripts/support/runner/qemu.py
index 07de6f2..4852268 100644
--- a/scripts/support/runner/qemu.py
+++ b/scripts/support/runner/qemu.py
@@ -20,6 +20,6 @@
'''Create runner. No environment dependencies.'''
return QemuBinaryRunner()
- def run(self, command, **kwargs):
+ def do_run(self, command, **kwargs):
if command == 'debugserver':
print('Detached GDB server')
diff --git a/scripts/support/runner/xtensa.py b/scripts/support/runner/xtensa.py
index c86d2a2..35d3057 100644
--- a/scripts/support/runner/xtensa.py
+++ b/scripts/support/runner/xtensa.py
@@ -35,7 +35,7 @@
return XtensaBinaryRunner(xt_gdb, elf_name)
- def run(self, command, **kwargs):
+ def do_run(self, command, **kwargs):
if command != 'debug':
raise ValueError('Only debug is supported')