1- import sys , socket , threading , traceback , os , inspect , subprocess , logging
1+ import sys , socket , threading , traceback , os , inspect , subprocess
22
33PY3 = sys .version_info [0 ] == 3
44
@@ -44,14 +44,14 @@ def Embed(
4444 popup = None ,
4545 log_writer = sys .stderr ,
4646 this_coding = None ,
47- remote_coding = None ,
47+ debugger_coding = None ,
4848 help_info = None
4949):
5050 if this_coding is None :
5151 this_coding = 'gb18030' if os .name == 'nt' else 'utf8'
5252
53- if remote_coding is None :
54- remote_coding = this_coding
53+ if debugger_coding is None :
54+ debugger_coding = this_coding
5555
5656 def embed ():
5757 log = Log (log_writer )
@@ -95,20 +95,20 @@ def embed():
9595 def send (s ):
9696 if not PY3 :
9797 if type (s ) is unicode :
98- s = s .encode (remote_coding )
98+ s = s .encode (debugger_coding )
9999 else :
100100 if type (s ) is not str :
101101 s = str (s )
102- if this_coding != remote_coding :
103- s = s .decode (this_coding ).encode (remote_coding )
102+ if this_coding != debugger_coding :
103+ s = s .decode (this_coding ).encode (debugger_coding )
104104 else :
105105 if type (s ) is str :
106- s = s .encode (remote_coding )
106+ s = s .encode (debugger_coding )
107107 elif type (s ) is bytes :
108- if this_coding != remote_coding :
109- s = s .decode (this_coding ).encode (remote_coding )
108+ if this_coding != debugger_coding :
109+ s = s .decode (this_coding ).encode (debugger_coding )
110110 else :
111- s = str (s ).encode (remote_coding )
111+ s = str (s ).encode (debugger_coding )
112112 try :
113113 conn .sendall (s )
114114 except socket .error :
@@ -118,8 +118,8 @@ def recv():
118118 code = conn .recv (1024 )
119119 if not code :
120120 raise Disconnect
121- if this_coding != remote_coding :
122- code = code .decode (remote_coding ).encode (this_coding )
121+ if this_coding != debugger_coding :
122+ code = code .decode (debugger_coding ).encode (this_coding )
123123 return code .strip ()
124124
125125 try :
@@ -190,13 +190,15 @@ def _popup(popup, host, port):
190190
191191if __name__ == '__main__' :
192192 # runs in windows('gb18030'), attaches from linux('utf8')
193- embed = Embed ('0.0.0.0' , 9999 , this_coding = 'gb18030' , remote_coding = 'utf8' )
193+ # embed = Embed('0.0.0.0', 9999, this_coding='gb18030', debugger_coding='utf8')
194+
195+ embed = Embed (popup = './test/nc.exe' )
194196
195197 a = 2
196198
197199 def func (x , y , z ):
198- print (a , x , y , z )
200+ print (a , x , y , z ); sys . stdout . flush ()
199201 embed ()
200- print (a , x , y , z )
202+ print (a , x , y , z ); sys . stdout . flush ()
201203
202204 func (1 , 2 , [3 ])
0 commit comments