Show IP address and PORT number for implmentations that have them.

This commit is contained in:
Ferdi Franceschini
2014-07-10 05:35:41 +10:00
parent 9be5cc4cec
commit 8953273dac

View File

@ -202,13 +202,17 @@ class InstConfigData(object):
self.config_dict = defaultdict(dict)
#imp_dict: dict of implementations indexed by optype,
# {optype: [impname] }
# {optype: []|[none:impname,...] }
self.imp_dict = defaultdict(list)
#opt_dict: dict of configuration options as defined below,
# {optname:{'enabled':T/F/Always, 'imptype':optype,'selected_imp':dflt}}
self.opt_dict = defaultdict(dict)
#imp_ip_dict: Maps each implementation to an ip and port if it has one.
# {imp, {ip:'q4.q3.q2.q1', port:'nnnn', ...}
self.imp_ip_dict = defaultdict(dict)
#imp2opt_dict: Maps each implementation to an option or None,
# {imp: opt/None}
self.imp2opt_dict = {}
@ -291,6 +295,13 @@ class InstConfigData(object):
if self.file_parser.has_option(sect, 'imptype'):
imptype = self.file_parser.get(sect, 'imptype')
self.imp_dict[imptype].append(sect)
if self.file_parser.has_option(sect, 'ip'):
ip_address = self.file_parser.get(sect, 'ip')
self.imp_ip_dict[sect]['ip'] = ip_address
if self.file_parser.has_option(sect, 'port'):
port = self.file_parser.get(sect, 'port')
self.imp_ip_dict[sect]['port'] = port
if sect not in self.imp2opt_dict:
self.imp2opt_dict[sect] = 'none'
@ -520,6 +531,19 @@ class InstConfigManager(object):
on_state_change=self.imp_statechange,
user_data=opt)
for imp, button in rb_lw.button_dict.iteritems():
if imp != 'none':
if 'ip' in self.cf_dat.imp_ip_dict[imp]:
address = self.cf_dat.imp_ip_dict[imp]['ip']
if 'port' in self.cf_dat.imp_ip_dict[imp]:
port = self.cf_dat.imp_ip_dict[imp]['port']
address += ':'
address += port
button.set_label('{0:20}{1}'.format(imp, address))
else:
button.set_label('{0}'.format(imp))
return rb_lw
def cf_statechange(self, button, new_state):
@ -573,7 +597,7 @@ class InstConfigManager(object):
"""Update label on the configuration option when it's implementation is
changed.
"""
imp = button.get_label()
imp = button.get_label().split()[0]
if new_state == True:
self.cf_dat.set_imp(opt, imp)
opt_button = self.opt_lw.button_dict[opt]