tools/pyboard.py: Handle unsupported fs command.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
12ca918eb2
commit
7705b9b9d5
@ -621,23 +621,28 @@ def filesystem_command(pyb, args, progress_callback=None, verbose=False):
|
|||||||
dest2 = fname_cp_dest(src2, fname_remote(dest))
|
dest2 = fname_cp_dest(src2, fname_remote(dest))
|
||||||
op(src2, dest2, progress_callback=progress_callback)
|
op(src2, dest2, progress_callback=progress_callback)
|
||||||
else:
|
else:
|
||||||
op = {
|
ops = {
|
||||||
"cat": pyb.fs_cat,
|
"cat": pyb.fs_cat,
|
||||||
"ls": pyb.fs_ls,
|
"ls": pyb.fs_ls,
|
||||||
"mkdir": pyb.fs_mkdir,
|
"mkdir": pyb.fs_mkdir,
|
||||||
"rm": pyb.fs_rm,
|
"rm": pyb.fs_rm,
|
||||||
"rmdir": pyb.fs_rmdir,
|
"rmdir": pyb.fs_rmdir,
|
||||||
"touch": pyb.fs_touch,
|
"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:
|
if cmd == "ls" and not args:
|
||||||
args = [""]
|
args = [""]
|
||||||
for src in args:
|
for src in args:
|
||||||
src = fname_remote(src)
|
src = fname_remote(src)
|
||||||
if verbose:
|
if verbose:
|
||||||
print("%s :%s" % (cmd, src))
|
print("%s :%s" % (cmd, src))
|
||||||
op(src)
|
ops[cmd](src)
|
||||||
except PyboardError as er:
|
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.exit_raw_repl()
|
||||||
pyb.close()
|
pyb.close()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user