[pytango] 61/483: better exception handling
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:24 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.
commit a2299b79b311df1f879ab9223d1332d3613425d5
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Wed Nov 16 06:57:38 2011 +0000
better exception handling
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@18390 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
PyTango/ipython/ipython_00_10/ipython_00_10.py | 3 +-
PyTango/ipython/ipython_00_11/ipython_00_11.py | 40 +++++++++++++++++++-------
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/PyTango/ipython/ipython_00_10/ipython_00_10.py b/PyTango/ipython/ipython_00_10/ipython_00_10.py
index bf8e8ea..e8ac3fa 100644
--- a/PyTango/ipython/ipython_00_10/ipython_00_10.py
+++ b/PyTango/ipython/ipython_00_10/ipython_00_10.py
@@ -501,7 +501,8 @@ def get_alias_list():
#-------------------------------------------------------------------------------
def __exc_handler(ip, etype, value, tb):
- if etype == PyTango.DevFailed:
+ global _TG_EXCEPTIONS
+ if etype in _TG_EXCEPTIONS:
global _TANGO_ERR
ip.user_ns[_TANGO_ERR] = etype, value, tb
if len(value.args):
diff --git a/PyTango/ipython/ipython_00_11/ipython_00_11.py b/PyTango/ipython/ipython_00_11/ipython_00_11.py
index 47ccf91..8442330 100644
--- a/PyTango/ipython/ipython_00_11/ipython_00_11.py
+++ b/PyTango/ipython/ipython_00_11/ipython_00_11.py
@@ -51,6 +51,7 @@ _TG_EXCEPTIONS = PyTango.DevFailed, PyTango.CommunicationFailed, \
_DB_SYMB = "db"
_DFT_TANGO_HOST = None
_SPOCK_STORE = "__spock_store"
+_TANGO_ERR = "__tango_error"
_SPOCK_ERR = "__spock_error"
_spock_init = False
@@ -313,14 +314,25 @@ def magic_lsserv(self, parameter_s=''):
def magic_tango_error(self, parameter_s=''):
"""Displays detailed information about the last tango error"""
- global _SPOCK_ERR
- err_info = self.user_ns.get(_SPOCK_ERR)
+ global _TANGO_ERR
+ err_info = self.user_ns.get(_TANGO_ERR)
if err_info is None:
print "No tango error reported so far."
return
print "Last tango error:"
print err_info[1]
+
+def magic_spock_error(self, parameter_s=''):
+ """Displays detailed information about the last spock error"""
+ global _SPOCK_ERR
+ err_info = self.user_ns.get(_SPOCK_ERR)
+ if err_info is None:
+ print "No error reported so far."
+ return
+ ip = IPython.ipapi.get()
+ ip.IP.InteractiveTB(*err_info, tb_offset=None)
+
_EVT_LOG = None
def __get_event_log():
global _EVT_LOG
@@ -490,17 +502,23 @@ def get_alias_list():
# Private helper methods
#-------------------------------------------------------------------------------
-def __tango_exc_handler(ip, etype, value, tb, tb_offset=None):
- global _SPOCK_ERR
- ip.user_ns[_SPOCK_ERR] = etype, value, tb, tb_offset
- if issubclass(etype, _TG_EXCEPTIONS):
+def __exc_handler(ip, etype, value, tb, tb_offset=None):
+ global _TG_EXCEPTIONS
+ if etype in _TG_EXCEPTIONS:
+ global _TANGO_ERR
+ ip.user_ns[_TANGO_ERR] = etype, value, tb, tb_offset
if len(value.args):
v = value[0]
- print v.reason,":",v.desc
+ print "%s: %s" % (v.reason ,v.desc)
else:
- print "Empty Tango " + str(etype)
- print "For more detailed information type: tango_error"
-
+ print "Empty DevFailed"
+ print "(For more detailed information type: tango_error)"
+ else:
+ global _SPOCK_ERR
+ ip.user_ns[_SPOCK_ERR] = etype, value, tb, tb_offset
+ print etype.__name__ + ": " + str(value)
+ print "(For more detailed information type: spock_error)"
+
def __safe_tango_exec(f, *args, **kwargs):
try:
return f(*args, **kwargs)
@@ -731,7 +749,7 @@ def init_pytango(ip):
ip.set_hook('complete_command', attr_completer, re_key = ".*AttributeProxy[^\w\.]+")
ip.set_hook('complete_command', attr_completer, re_key = ".*Attribute[^\w\.]+")
- ip.set_custom_exc(_TG_EXCEPTIONS, __tango_exc_handler)
+ ip.set_custom_exc((Exception,), __exc_handler)
def init_db(ip, parameter_s=''):
global _DB_SYMB
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git
More information about the debian-science-commits
mailing list