Print traceback information:
#!/usr/bin/env python
import traceback
import PyTango
def func( mot):
try:
p = PyTango.DeviceProxy( mot)
except Exception as e:
print(traceback.format_exc())
return
print( "pos", p.position)
return
if __name__ == "__main__":
func( "d1_mot_notExist")
The output:
$ python pTest.py
Traceback (most recent call last):
File "pTest.py", line 8, in func
p = PyTango.DeviceProxy( mot)
File "/usr/lib/python2.7/dist-packages/tango/device_proxy.py", line 172, in __DeviceProxy__init__
return DeviceProxy.__init_orig__(self, *args, **kwargs)
DevFailed: DevFailed[
DevError[
desc = device d1_mot_notexist not defined in the database !
origin = DataBase::ImportDevice()
reason = DB_DeviceNotDefined
severity = ERR]
DevError[
desc = Failed to execute command_inout on device sys/database/2, command DbImportDevice
origin = Connection::command_inout()
reason = API_CommandFailed
severity = ERR]
DevError[
desc = Can't connect to device d1_mot_notexist
origin = DeviceProxy::DeviceProxy
reason = API_DeviceNotDefined
severity = ERR]
]