Skip to content
Browse files

Fixes for TCL support, with XML namespaces

Also, commands not implemented are raised as a specific error.
  • Loading branch information...
1 parent 38a3f09 commit d39ff68b1d10c8c2ae0776bf45f12c15ac3de420 @joonty committed Dec 18, 2012
Showing with 40 additions and 12 deletions.
  1. +29 −11 plugin/python/vdebug/dbgp.py
  2. +5 −0 plugin/python/vdebug/opts.py
  3. +6 −1 plugin/python/vdebug/runner.py
View
40 plugin/python/vdebug/dbgp.py
@@ -24,17 +24,22 @@ def __parse_error(self):
in the response, then raise it as a DBGPError."""
xml = self.as_xml()
err_el = xml.find('%serror' % self.ns)
- code = err_el.get("code")
- if code is None:
- raise ResponseError(
- "Missing error code in response",
- self.response)
- msg_el = err_el.find('%smessage' % self.ns)
- if msg_el is None:
- raise ResponseError(
- "Missing error message in response",
- self.response)
- raise DBGPError(msg_el.text,code)
+ if err_el is None:
+ raise DBGPError("Could not parse error from return XML",1)
+ else:
+ code = err_el.get("code")
+ if code is None:
+ raise ResponseError(
+ "Missing error code in response",
+ self.response)
+ elif int(code) == 4:
+ raise CmdNotImplementedError('Command not implemented')
+ msg_el = err_el.find('%smessage' % self.ns)
+ if msg_el is None:
+ raise ResponseError(
+ "Missing error message in response",
+ self.response)
+ raise DBGPError(msg_el.text,code)
def get_cmd(self):
"""Get the command that created this response."""
@@ -60,8 +65,17 @@ def as_xml(self):
"""
if self.xml == None:
self.xml = ET.fromstring(self.response)
+ self.__determine_ns()
return self.xml
+ def __determine_ns(self):
+ tag_repr = str(self.xml.tag)
+ if tag_repr[0] != '{':
+ raise DBGPError('Invalid or missing XML namespace',1)
+ else:
+ ns_parts = tag_repr.split('}')
+ self.ns = ns_parts[0] + '}'
+
def __str__(self):
return self.as_string()
@@ -665,6 +679,10 @@ class DBGPError(Exception):
"""Raised when the debugger returns an error message."""
pass
+class CmdNotImplementedError(Exception):
+ """Raised when the debugger returns an error message."""
+ pass
+
class EvalError(Exception):
"""Raised when some evaluated code is invalid."""
pass
View
5 plugin/python/vdebug/opts.py
@@ -32,6 +32,11 @@ def get(cls,name,as_type = str):
raise OptionsError, "No option with key '%s'" % name
@classmethod
+ def overwrite(cls,name,value):
+ inst = cls.inst()
+ inst.options[name] = value
+
+ @classmethod
def isset(cls,name):
"""Checks whether the option exists and is set.
View
7 plugin/python/vdebug/runner.py
@@ -287,7 +287,12 @@ def close_connection(self,stop = True):
vdebug.log.Log("Closing the connection")
if stop:
if vdebug.opts.Options.get('on_close') == 'detach':
- self.api.detach()
+ try:
+ self.api.detach()
+ except vdebug.dbgp.CmdNotImplementedError:
+ self.ui.error('Detach is not supported by the debugger, stopping instead')
+ vdebug.opts.Options.overwrite('on_close','stop')
+ self.api.stop()
else:
self.api.stop()
self.api.conn.close()

0 comments on commit d39ff68

Please sign in to comment.
Something went wrong with that request. Please try again.