Skip to content

Commit 15518c6

Browse files
committed
done
1 parent 504be0b commit 15518c6

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def Embed(
9090
log_writer=sys.stderr, # the logger's writer
9191
this_coding=None, # the coding of the process which you want to debug,
9292
# default to 'gb18030' in windows, and 'utf8' in other platforms
93-
remote_coding=None, # the coding of the debugger, default to `this_coding`
93+
debugger_coding=None, # the coding of the debugger, default to `this_coding`
9494
help_info=None # a help infomation printed at the debugger's terminal when it attached,
9595
# default to the line infomation of the break point
9696
):

remote_embed.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys, socket, threading, traceback, os, inspect, subprocess, logging
1+
import sys, socket, threading, traceback, os, inspect, subprocess
22

33
PY3 = 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

191191
if __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])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup
22

3-
version = '1.0.1'
3+
version = '1.0.2'
44

55
setup(
66
name = 'remote_embed',

0 commit comments

Comments
 (0)