10000 webrepl_cli.py: get_file: Hide debug output/add progress indicator. · micropython/webrepl@6098058 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6098058

Browse files
author
Paul Sokolovsky
committed
webrepl_cli.py: get_file: Hide debug output/add progress indicator.
Similar to put_file.
1 parent 1be8085 commit 6098058

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

webrepl_cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,11 @@ def put_file(ws, local_file, remote_file):
123123
def get_file(ws, local_file, remote_file):
124124
src_fname = (SANDBOX + remote_file).encode("utf-8")
125125
rec = struct.pack(WEBREPL_FILE, b"WA", 2, 0, 0, 0, len(src_fname), src_fname)
126-
print(rec, len(rec))
126+
debugmsg("%r %d" % (rec, len(rec)))
127127
ws.write(rec)
128128
assert read_resp(ws) == 0
129129
with open(local_file, "wb") as f:
130+
cnt = 0
130131
while True:
131132
(sz,) = struct.unpack("<H", ws.read(2))
132133
if sz == 0:
@@ -135,8 +136,12 @@ def get_file(ws, local_file, remote_file):
135136
buf = ws.read(sz)
136137
if not buf:
137138
raise OSError()
139+
cnt += len(buf)
138140
f.write(buf)
139141
sz -= len(buf)
142+
sys.stdout.write("Received %d bytes\r" % cnt)
143+
sys.stdout.flush()
144+
print()
140145
assert read_resp(ws) == 0
141146

142147

0 commit comments

Comments
 (0)
0