8000 password as CLI argument · micropython/webrepl@89650c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 89650c7

Browse files
committed
password as CLI argument
1 parent 0e1209a commit 89650c7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

webrepl_cli.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def help(rc=0):
167167
exename = sys.argv[0].rsplit("/", 1)[-1]
168168
print("%s - Perform remote file operations using MicroPython WebREPL protocol" % exename)
169169
print("Arguments:")
170-
print(" <host>:<remote_file> <local_file> - Copy remote file to local file")
171-
print(" <local_file> <host>:<remote_file> - Copy local file to remote file")
170+
print(" <host>:<remote_file> <local_file> [password] - Copy remote file to local file")
171+
print(" <local_file> <host>:<remote_file> [password] - Copy local file to remote file")
172172
print("Examples:")
173173
print(" %s script.py 192.168.4.1:/another_name.py" % exename)
174174
print(" %s script.py 192.168.4.1:/app/" % exename)
@@ -192,7 +192,7 @@ def parse_remote(remote):
192192

193193
def main():
194194

195-
if len(sys.argv) != 3:
195+
if len(sys.argv) not in [3, 4]:
196196
help(1)
197197

198198
if ":" in sys.argv[1] and ":" in sys.argv[2]:
@@ -215,8 +215,14 @@ def main():
215215
basename = src_file.rsplit("/", 1)[-1]
216216
dst_file += basename
217217

218-
if 1:
219-
print(op, host, port)
218+
if len(sys.argv) > 2:
219+
passwd = sys.argv[3]
220+
else:
221+
import getpass
222+
passwd = getpass.getpass()
223+
224+
if True:
225+
print(f"op:{op}, host:{host}, port:{port}, passwd:{passwd}.")
220226
print(src_file, "->", dst_file)
221227

222228
s = socket.socket()
@@ -230,8 +236,6 @@ def main():
230236

231237
ws = websocket(s)
232238

233-
import getpass
234-
passwd = getpass.getpass()
235239
login(ws, passwd)
236240
print("Remote WebREPL version:", get_ver(ws))
237241

0 commit comments

Comments
 (0)
0