Example #1
0
 def write_conciliation_table(self, root):
     """ Rendering of the conflicts table """
     div_elt = root.findmeld('conflicts_div_mid')
     # get data for table
     data = [{
         'namespec': process.namespec(),
         'rowspan': len(process.addresses) if idx == 0 else 0,
         'address': address,
         'uptime': process.infos[address]['uptime']
     } for process in self.supvisors.context.conflicts()
             for idx, address in enumerate(process.addresses)]
     addressIterator = div_elt.findmeld('tr_mid').repeat(data)
     for tr_elt, item in addressIterator:
         # set process name
         elt = tr_elt.findmeld('name_td_mid')
         rowspan = item['rowspan']
         if rowspan > 0:
             namespec = item['namespec']
             elt.attrib['rowspan'] = str(rowspan)
             elt.content(namespec)
         else:
             elt.replace('')
         # set address
         address = item['address']
         elt = tr_elt.findmeld('caddress_a_mid')
         elt.attributes(href='http://{}:{}/address.html'.format(
             address, self.server_port()))
         elt.content(address)
         # set uptime
         elt = tr_elt.findmeld('uptime_td_mid')
         elt.content(simple_gmtime(item['uptime']))
         # set detailed process action links
         for action in self.process_methods.keys():
             elt = tr_elt.findmeld(action + '_a_mid')
             elt.attributes(
                 href='index.html?namespec={}&address={}&action={}'.
                 format(urllib.quote(namespec), address, action))
         # set process action links
         td_elt = tr_elt.findmeld('strategy_td_mid')
         if rowspan > 0:
             td_elt.attrib['rowspan'] = str(rowspan)
             strategy_iterator = td_elt.findmeld(
                 'local_strategy_li_mid').repeat(self.strategies)
             for li_elt, item in strategy_iterator:
                 elt = li_elt.findmeld('local_strategy_a_mid')
                 # conciliation requests MUST be sent to MASTER
                 elt.attributes(
                     href='http://{}:{}/index.html?namespec={}&action={}'
                     .format(self.supvisors.context.master_address,
                             self.server_port(), urllib.quote(namespec),
                             item))
                 elt.content(item.title())
         else:
             td_elt.replace('')
Example #2
0
 def write_conciliation_table(self, root):
     """ Rendering of the conflicts table. """
     div_elt = root.findmeld('conflicts_div_mid')
     # get data for table
     data = [{'namespec': process.namespec(),
              'rowspan': len(process.addresses) if idx == 0 else 0,
              'address': address, 'uptime': process.infos[address]['uptime']}
         for process in self.supvisors.context.conflicts()
         for idx, address in enumerate(process.addresses)]
     addressIterator = div_elt.findmeld('tr_mid').repeat(data)
     for tr_elt, item in addressIterator:
         # set process name
         elt = tr_elt.findmeld('name_td_mid')
         rowspan = item['rowspan']
         if rowspan > 0:
             namespec = item['namespec']
             elt.attrib['rowspan'] = str(rowspan)
             elt.content(namespec)
         else:
             elt.replace('')
         # set address
         address = item['address']
         elt = tr_elt.findmeld('caddress_a_mid')
         elt.attributes(href='http://{}:{}/procaddress.html'.format(
             address, self.server_port()))
         elt.content(address)
         # set uptime
         elt = tr_elt.findmeld('uptime_td_mid')
         elt.content(simple_gmtime(item['uptime']))
         # set detailed process action links
         for action in self.process_methods.keys():
             elt = tr_elt.findmeld(action + '_a_mid')
             elt.attributes(href='index.html?namespec={}&address={}&action={}'.format(
                 urllib.quote(namespec), address, action))
         # set process action links
         td_elt = tr_elt.findmeld('strategy_td_mid')
         if rowspan > 0:
             td_elt.attrib['rowspan'] = str(rowspan)
             strategy_iterator = td_elt.findmeld(
                 'local_strategy_li_mid').repeat(self.strategies)
             for li_elt, item in strategy_iterator:
                 elt = li_elt.findmeld('local_strategy_a_mid')
                 # conciliation requests MUST be sent to MASTER
                 elt.attributes(href='http://{}:{}/index.html?namespec={}&action={}'.format(
                     self.supvisors.context.master_address, self.server_port(),
                     urllib.quote(namespec), item))
                 elt.content(item.title())
         else:
             td_elt.replace('')
Example #3
0
 def test_gmtime(self):
     """ Test the display of gm time. """
     from supvisors.utils import simple_gmtime
     self.assertEqual('07:07:00', simple_gmtime(1476947220.416198))
Example #4
0
 def test_gmtime(self):
     """ Test the values set at construction. """
     from supvisors.utils import simple_gmtime
     self.assertEqual('07:07:00', simple_gmtime(1476947220.416198))
Example #5
0
 def test_gmtime(self):
     """ Test the display of gm time. """
     from supvisors.utils import simple_gmtime
     self.assertEqual('07:07:00', simple_gmtime(1476947220.416198))