MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / NetCommandFactory

Class NetCommandFactory

_pydevd_bundle/pydevd_net_command_factory_xml.py:67–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65# NetCommandFactory
66# =======================================================================================================================
67class NetCommandFactory(object):
68 def __init__(self):
69 self._additional_thread_id_to_thread_name = {}
70
71 def _thread_to_xml(self, thread):
72 """thread information as XML"""
73 name = pydevd_xml.make_valid_xml_value(thread.name)
74 cmd_text = '<thread name="%s" id="%s" />' % (quote(name), get_thread_id(thread))
75 return cmd_text
76
77 def make_error_message(self, seq, text):
78 cmd = NetCommand(CMD_ERROR, seq, text)
79 if DebugInfoHolder.DEBUG_TRACE_LEVEL > 2:
80 pydev_log.error("Error: %s" % (text,))
81 return cmd
82
83 def make_protocol_set_message(self, seq):
84 return NetCommand(CMD_SET_PROTOCOL, seq, "")
85
86 def make_thread_created_message(self, thread):
87 cmdText = "<xml>" + self._thread_to_xml(thread) + "</xml>"
88 return NetCommand(CMD_THREAD_CREATE, 0, cmdText)
89
90 def make_process_created_message(self):
91 cmdText = "<process/>"
92 return NetCommand(CMD_PROCESS_CREATED, 0, cmdText)
93
94 def make_process_about_to_be_replaced_message(self):
95 return NULL_NET_COMMAND
96
97 def make_show_cython_warning_message(self):
98 try:
99 return NetCommand(CMD_SHOW_CYTHON_WARNING, 0, "")
100 except:
101 return self.make_error_message(0, get_exception_traceback_str())
102
103 def make_custom_frame_created_message(self, frame_id, frame_description):
104 self._additional_thread_id_to_thread_name[frame_id] = frame_description
105 frame_description = pydevd_xml.make_valid_xml_value(frame_description)
106 return NetCommand(CMD_THREAD_CREATE, 0, '<xml><thread name="%s" id="%s"/></xml>' % (frame_description, frame_id))
107
108 def make_list_threads_message(self, py_db, seq):
109 """returns thread listing as XML"""
110 try:
111 threads = get_non_pydevd_threads()
112 cmd_text = ["<xml>"]
113 append = cmd_text.append
114 for thread in threads:
115 if is_thread_alive(thread):
116 append(self._thread_to_xml(thread))
117
118 for thread_id, thread_name in list(self._additional_thread_id_to_thread_name.items()):
119 name = pydevd_xml.make_valid_xml_value(thread_name)
120 append('<thread name="%s" id="%s" />' % (quote(name), thread_id))
121
122 append("</xml>")
123 return NetCommand(CMD_RETURN, seq, "".join(cmd_text))
124 except:

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 1

__init__Method · 0.72