summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-02-25 07:25:32 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-02-25 07:25:32 (GMT)
commitcabe6f143c92e47b3ef2fdf8fe949a97ec9ffcd7 (patch)
tree3eb2b62cf509f57902b75727bbb77aa0fccbe61a /tools
parent181aad66660c0f6582507ab1c92c78bb350171de (diff)
tools: wasptool: Fix binary downloads for a specific special case
Currently if the binary file being downloaded contains single quote characters then it gets wrapped differently by repr() so we have to add additional cases to strip the wrapper. Fix this the "obvious" way... where by "obvious" I mean almost anything but. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/wasptool10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/wasptool b/tools/wasptool
index c80a5b7..befcd98 100755
--- a/tools/wasptool
+++ b/tools/wasptool
@@ -254,7 +254,15 @@ def handle_binary_download(c, tname, fname):
while True:
draw_pbar(100 * bytes_read / sz, verbose)
reply = c.run_command('repr(f.read(24))')
- data = eval(reply.replace('\\\\', '\\').strip('"'))
+ reply = reply.replace('\\\\', '\\')
+ if reply.startswith('"'):
+ # "b'..CONTENT..'"
+ reply = reply[1:-1]
+ elif reply.startswith("'"):
+ # 'b\'..CONTENT..\''
+ reply = reply[1:-1].replace("\\'", "'")
+ data = print(reply)
+ data = eval(reply)
if len(data) == 0:
break
bytes_read += len(data)