tango-controls / fandango

Functional tools for PyTango / Tango Control System http://www.tango-controls.org/resources/howto/how-fandango/
7 stars 9 forks source link

Error in creation of ServersDict #2

Closed LJBD closed 7 years ago

LJBD commented 7 years ago

I'm trying to create a ServersDict containing just one dserver. I'm using the following code for that:

from logging import Logger, DEBUG, StreamHandler
import fandango

if __name__ == '__main__':
    logger = Logger('get_classes_test', DEBUG)
    console_handler = StreamHandler()
    logger.addHandler(console_handler)
    sd = fandango.ServersDict('Sardana/bl04bm', logger=logger, tango_host="tango.bl04.cps.uj.edu.pl:10000")
    print "SERV DICT:", sd

It outputs the following things:

/usr/bin/python2.7 /home/tango/PycharmProjects/test/fandango_tests/get_classes_test.py
ServersDict(Sardana/bl04bm,,,,,False,WARNING,<logging.Logger object at 0x7f39a3863610>,tango.bl04.cps.uj.edu.pl:10000)
loading by Sardana/bl04bm server_name
get_devs_from_db(dserver/Sardana/bl04bm)
loading from tango:10000/Sardana/bl04bm server
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 217, in get_database_device
    td = get_device(dev_name,use_tau=use_tau)
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 203, in get_device
    return PyTango.DeviceProxy(dev)
  File "/usr/lib64/python2.7/site-packages/tango/device_proxy.py", line 164, in __DeviceProxy__init__
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/fandango/servers.py", line 355, in load_from_servers_list
    ss.init_from_db(self.db)
  File "/usr/lib/python2.7/site-packages/fandango/servers.py", line 109, in init_from_db
    di = get_device_info('dserver/'+self.name,db=self._db) #get_server_info() must be combined with get_device_info to obtain the real name of the launcher
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 253, in get_device_info
    dev,db,vals,traceback.format_exc()))
Exception: get_device_info(dserver/Sardana/bl04bm,Database(tango.bl04.cps.uj.edu.pl, 10000),None): Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 245, in get_device_info
    dd = get_database_device(db=db)
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 222, in get_database_device
    return td
UnboundLocalError: local variable 'td' referenced before assignment

    return DeviceProxy.__init_orig__(self, *args, **kwargs)
ConnectionFailed: DevFailed[
DevError[
    desc = TRANSIENT CORBA system exception: TRANSIENT_NoUsableProfile
  origin = Connection::connect
  reason = API_CorbaException
severity = ERR]

DevError[
    desc = Failed to connect to database on host tango with port 10000
  origin = Connection::connect
  reason = API_CantConnectToDatabase
severity = ERR]
]
exception loading Sardana/bl04bm server: get_device_info(dserver/Sardana/bl04bm,Database(tango.bl04.cps.uj.edu.pl, 10000),None): Traceback (m...
load_from_servers_list(1) took 45.075146 seconds
1 servers loaded
SERV DICT: The status of device servers is:

It seems that it tries to connect to a Tango Host on tango:1000 which is not correct - it should use the full name specified in constructor. It also takes really long time to get that information (45 seconds).

Can you please verify if that indeed is a problem?

LJBD commented 7 years ago

Here is a log without my logger:

/usr/bin/python2.7 /home/tango/PycharmProjects/test/fandango_tests/get_classes_test.py
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 217, in get_database_device
    td = get_device(dev_name,use_tau=use_tau)
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 203, in get_device
    return PyTango.DeviceProxy(dev)
  File "/usr/lib64/python2.7/site-packages/tango/device_proxy.py", line 164, in __DeviceProxy__init__
    return DeviceProxy.__init_orig__(self, *args, **kwargs)
ConnectionFailed: DevFailed[
DevError[
    desc = TRANSIENT CORBA system exception: TRANSIENT_NoUsableProfile
  origin = Connection::connect
  reason = API_CorbaException
severity = ERR]

DevError[
    desc = Failed to connect to database on host tango with port 10000
  origin = Connection::connect
  reason = API_CantConnectToDatabase
severity = ERR]
]
ServersDict.WARNING 2017-01-05 16:08:43.852 exception loading Sardana/bl04bm server: get_device_info(dserver/Sardana/bl04bm,Database(tango.bl04.cps.uj.edu.pl, 10000),None): Traceback (m...
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/fandango/servers.py", line 355, in load_from_servers_list
    ss.init_from_db(self.db)
  File "/usr/lib/python2.7/site-packages/fandango/servers.py", line 109, in init_from_db
    di = get_device_info('dserver/'+self.name,db=self._db) #get_server_info() must be combined with get_device_info to obtain the real name of the launcher
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 253, in get_device_info
    dev,db,vals,traceback.format_exc()))
Exception: get_device_info(dserver/Sardana/bl04bm,Database(tango.bl04.cps.uj.edu.pl, 10000),None): Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 245, in get_device_info
    dd = get_database_device(db=db)
  File "/usr/lib/python2.7/site-packages/fandango/tango.py", line 222, in get_database_device
    return td
UnboundLocalError: local variable 'td' referenced before assignment

SERV DICT: The status of device servers is:
sergirubio commented 7 years ago

Ups, it's clearly a problem of hostname resolution

I'm going to try to reproduce and tell you something

Sergi

On 01/05/2017 04:11 PM, Łukasz Dudek wrote:

Here is a log without my logger:

/usr/bin/python2.7/home/tango/PycharmProjects/test/fandango_tests/get_classes_test.py Traceback (most recent call last): File"/usr/lib/python2.7/site-packages/fandango/tango.py", line217,in get_database_device td= get_device(dev_name,use_tau=use_tau) File"/usr/lib/python2.7/site-packages/fandango/tango.py", line203,in get_device return PyTango.DeviceProxy(dev) File"/usr/lib64/python2.7/site-packages/tango/device_proxy.py", line164,in DeviceProxyinit return DeviceProxy.init_orig__(self,*args,**kwargs) ConnectionFailed: DevFailed[ DevError[ desc =TRANSIENT CORBA system exception:TRANSIENT_NoUsableProfile origin = Connection::connect reason =API_CorbaException severity =ERR]

DevError[ desc = Failed to connect to database on host tangowith port10000 origin = Connection::connect reason =API_CantConnectToDatabase severity =ERR] ] ServersDict.WARNING 2017-01-05 16:08:43.852 exception loading Sardana/bl04bm server: get_device_info(dserver/Sardana/bl04bm,Database(tango.bl04.cps.uj.edu.pl,10000),None): Traceback (m... Traceback (most recent call last): File"/usr/lib/python2.7/site-packages/fandango/servers.py", line355,in load_from_servers_list ss.init_from_db(self.db) File"/usr/lib/python2.7/site-packages/fandango/servers.py", line109,in init_from_db di = get_device_info('dserver/'+self.name,db=self._db)#get_server_info() must be combined with get_device_info to obtain the real name of the launcher File"/usr/lib/python2.7/site-packages/fandango/tango.py", line253,in get_device_info dev,db,vals,traceback.format_exc())) Exception: get_device_info(dserver/Sardana/bl04bm,Database(tango.bl04.cps.uj.edu.pl,10000),None): Traceback (most recent call last): File"/usr/lib/python2.7/site-packages/fandango/tango.py", line245,in get_device_info dd= get_database_device(db=db) File"/usr/lib/python2.7/site-packages/fandango/tango.py", line222,in get_database_device return td UnboundLocalError: local variable'td' referenced before assignment

SERV DICT: The status of device serversis:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tango-controls/fandango/issues/2#issuecomment-270666658, or mute the thread https://github.com/notifications/unsubscribe-auth/ARkKqd-a1T6ytUjtroeezJCkq-CD0gQrks5rPQgIgaJpZM4LbxUa.

sergirubio commented 7 years ago

I just pushed a patch in master; can you update your sources and try again?

The cause of the bug was a workaround to avoid problems in Tango<8; now I made this check conditional to the Tango version.

Sergi

LJBD commented 7 years ago

Yes, it's working, thank you very much!