summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-10 14:49:36 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-10 14:49:36 (GMT)
commite79625685dea9d4dd0b99a071c2f89b23fb6e541 (patch)
treedb1a17f02c118fb31906c6437d5a4fe5f16b3549 /tools
parent6de86a64ede68976fb0fc91b5da4db5b2a1cef26 (diff)
wasptool: Allow files to be renamed during an upload
For example: ./tools/wasptool --upload docs/main/chrono.py --as main.py Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/wasptool20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/wasptool b/tools/wasptool
index 30d020e..4b5b4d9 100755
--- a/tools/wasptool
+++ b/tools/wasptool
@@ -207,10 +207,13 @@ def check_rtc(c):
c.expect('>>> ')
-def handle_binary_upload(c, fname):
+def handle_binary_upload(c, fname, tname):
verbose = bool(c.logfile)
- c.sendline(f'f = open("{os.path.basename(fname)}", "wb")')
+ if not tname:
+ tname = os.path.basename(fname)
+
+ c.sendline(f'f = open("{tname}", "wb")')
c.expect('>>> ')
# Absorb the file to be uploaded
@@ -234,9 +237,12 @@ def handle_binary_upload(c, fname):
c.sendline('f.close()')
c.expect('>>> ')
-def handle_upload(c, fname):
+def handle_upload(c, fname, tname):
verbose = bool(c.logfile)
+ if not tname:
+ tname = os.path.basename(fname)
+
c.sendline('from shell import upload')
c.expect('>>> ')
@@ -244,7 +250,7 @@ def handle_upload(c, fname):
if not verbose:
print(f'Uploading {fname}:')
- c.sendline(f'upload("{os.path.basename(fname)}")')
+ c.sendline(f'upload("{tname}")')
c.expect('=== ')
paste(c, f, verbose)
c.send('\x04')
@@ -254,6 +260,8 @@ def handle_upload(c, fname):
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Wasp-os command and control client')
+ parser.add_argument('--as', dest='upload_as', default=None,
+ help="Filename to use on the target (e.g. wasptool --upload docs/main/chrono.py --as main.py")
parser.add_argument('--bootloader', action='store_true',
help="Reboot into the bootloader mode for OTA update")
parser.add_argument('--binary', action='store_true',
@@ -326,9 +334,9 @@ if __name__ == '__main__':
if args.upload:
if args.binary:
- handle_binary_upload(console, args.upload)
+ handle_binary_upload(console, args.upload, args.upload_as)
else:
- handle_upload(console, args.upload)
+ handle_upload(console, args.upload, args.upload_as)
if args.console:
console.close()