diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2022-09-30 23:43:23 +1000 |
---|---|---|
committer | Jim Mussared <jim.mussared@gmail.com> | 2022-10-01 22:44:24 +1000 |
commit | 7705b9b9d50b3665de135f314fd1f8cb5d0641f0 (patch) | |
tree | 0cb5208170c603ab70d911f8fe2681af7a479f83 /tools/pyboard.py | |
parent | 12ca918eb2ac062f6e6df0772e528eef9d050cb7 (diff) |
tools/pyboard.py: Handle unsupported fs command.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tools/pyboard.py')
-rwxr-xr-x | tools/pyboard.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/pyboard.py b/tools/pyboard.py index 043f4f06f..55c00fbca 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -621,23 +621,28 @@ def filesystem_command(pyb, args, progress_callback=None, verbose=False): dest2 = fname_cp_dest(src2, fname_remote(dest)) op(src2, dest2, progress_callback=progress_callback) else: - op = { + ops = { "cat": pyb.fs_cat, "ls": pyb.fs_ls, "mkdir": pyb.fs_mkdir, "rm": pyb.fs_rm, "rmdir": pyb.fs_rmdir, "touch": pyb.fs_touch, - }[cmd] + } + if cmd not in ops: + raise PyboardError("'{}' is not a filesystem command".format(cmd)) if cmd == "ls" and not args: args = [""] for src in args: src = fname_remote(src) if verbose: print("%s :%s" % (cmd, src)) - op(src) + ops[cmd](src) except PyboardError as er: - print(str(er.args[2], "ascii")) + if len(er.args) > 1: + print(str(er.args[2], "ascii")) + else: + print(er) pyb.exit_raw_repl() pyb.close() sys.exit(1) |