Skip to content

Commit e241c69

Browse files
committed
webrepl_cli.py: Add basic support for Python 2.7.
Output is still printed differently in same cases due to bytes/str difference, but otherwise get and put both work.
1 parent 43078da commit e241c69

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

webrepl_cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import sys
34
import os
45
import struct
@@ -90,7 +91,7 @@ def read_resp(ws):
9091

9192
def put_file(ws, local_file, remote_file):
9293
sz = os.stat(local_file)[6]
93-
dest_fname = bytes(SANDBOX + remote_file, "utf-8")
94+
dest_fname = (SANDBOX + remote_file).encode("utf-8")
9495
rec = struct.pack(WEBREPL_FILE, b"WA", 1, 0, 0, sz, len(dest_fname), dest_fname)
9596
print(rec, len(rec))
9697
ws.write(rec[:10])
@@ -105,7 +106,7 @@ def put_file(ws, local_file, remote_file):
105106
assert read_resp(ws) == 0
106107

107108
def get_file(ws, local_file, remote_file):
108-
src_fname = bytes(SANDBOX + remote_file, "utf-8")
109+
src_fname = (SANDBOX + remote_file).encode("utf-8")
109110
rec = struct.pack(WEBREPL_FILE, b"WA", 2, 0, 0, 0, len(src_fname), src_fname)
110111
print(rec, len(rec))
111112
ws.write(rec)

0 commit comments

Comments
 (0)