16
16
#SANDBOX = "/tmp/webrepl/"
17
17
DEBUG = 0
18
18
19
- WEBREPL_FILE = "<2sBBQLH64s"
20
-
19
+ WEBREPL_REQ_S = "<2sBBQLH64s"
20
+ WEBREPL_PUT_FILE = 1
21
+ WEBREPL_GET_FILE = 2
21
22
22
23
def debugmsg (msg ):
23
24
if DEBUG :
@@ -102,7 +103,7 @@ def read_resp(ws):
102
103
def put_file (ws , local_file , remote_file ):
103
104
sz = os .stat (local_file )[6 ]
104
105
dest_fname = (SANDBOX + remote_file ).encode ("utf-8" )
105
- rec = struct .pack (WEBREPL_FILE , b"WA" , 1 , 0 , 0 , sz , len (dest_fname ), dest_fname )
106
+ rec = struct .pack (WEBREPL_REQ_S , b"WA" , WEBREPL_PUT_FILE , 0 , 0 , sz , len (dest_fname ), dest_fname )
106
107
debugmsg ("%r %d" % (rec , len (rec )))
107
108
ws .write (rec [:10 ])
108
109
ws .write (rec [10 :])
@@ -122,7 +123,7 @@ def put_file(ws, local_file, remote_file):
122
123
123
124
def get_file (ws , local_file , remote_file ):
124
125
src_fname = (SANDBOX + remote_file ).encode ("utf-8" )
125
- rec = struct .pack (WEBREPL_FILE , b"WA" , 2 , 0 , 0 , 0 , len (src_fname ), src_fname )
126
+ rec = struct .pack (WEBREPL_REQ_S , b"WA" , WEBREPL_GET_FILE , 0 , 0 , 0 , len (src_fname ), src_fname )
126
127
debugmsg ("%r %d" % (rec , len (rec )))
127
128
ws .write (rec )
128
129
assert read_resp (ws ) == 0
0 commit comments