From bcc39a8c9daba1476262f0f7b7232295f5ca3b9e Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 19 Jan 2018 16:24:59 +0000 Subject: [PATCH] artiq_flash: add --dry-run option. --- artiq/frontend/artiq_flash.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/artiq/frontend/artiq_flash.py b/artiq/frontend/artiq_flash.py index e5c68b5f7..f1903aded 100755 --- a/artiq/frontend/artiq_flash.py +++ b/artiq/frontend/artiq_flash.py @@ -41,6 +41,9 @@ Prerequisites: verbosity_args(parser) + parser.add_argument("-n", "--dry-run", + default=False, action="store_true", + help="Only show the openocd script that would be run") parser.add_argument("-H", "--host", metavar="HOSTNAME", type=str, default=None, help="SSH host where the development board is located") @@ -123,6 +126,9 @@ class Programmer: def start(self): raise NotImplementedError + def script(self): + return "\n".join(self.prog) + def do(self): self._command("exit") @@ -338,11 +344,14 @@ def main(): else: raise ValueError("invalid action", action) - try: - programmer.do() - finally: - if conv: - os.unlink(bin) + if args.dry_run: + print(programmer.script()) + else: + try: + programmer.do() + finally: + if conv: + os.unlink(bin) if __name__ == "__main__":