8000 better packet dump format · jasonwangmvp/PyMySQL@c09ba86 · GitHub
[go: up one dir, main page]

Skip to content

Commit c09ba86

Browse files
committed
better packet dump format
1 parent 7d97090 commit c09ba86

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pymysql/connections.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,18 @@ def is_ascii(data):
117117

118118
try:
119119
print("packet length:", len(data))
120-
print("method call[1]:", sys._getframe(1).f_code.co_name)
121-
print("method call[2]:", sys._getframe(2).f_code.co_name)
122-
print("method call[3]:", sys._getframe(3).f_code.co_name)
123-
print("method call[4]:", sys._getframe(4).f_code.co_name)
124-
print("method call[5]:", sys._getframe(5).f_code.co_name)
125-
print("-" * 88)
120+
for i in range(1, 6):
121+
f = sys._getframe(i)
122+
print("call[%d]: %s (line %d)" % (i, f.f_code.co_name, f.f_lineno))
123+
print("-" * 66)
126124
except ValueError:
127125
pass
128126
dump_data = [data[i:i+16] for i in range_type(0, min(len(data), 256), 16)]
129127
for d in dump_data:
130128
print(' '.join(map(lambda x: "{:02X}".format(byte2int(x)), d)) +
131129
' ' * (16 - len(d)) + ' ' * 2 +
132-
' '.join(map(lambda x: "{}".format(is_ascii(x)), d)))
133-
print("-" * 88)
130+
''.join(map(lambda x: "{}".format(is_ascii(x)), d)))
131+
print("-" * 66)
134132
print()
135133

136134

0 commit comments

Comments
 (0)
0