def test_localtime(self): """ Test the display of local time. """ import time from supvisors.utils import simple_localtime time_shift = time.timezone if time.gmtime().tm_isdst else time.altzone self.assertEqual('07:07:00', simple_localtime(1476947220.416198 + time_shift))
def output_address_info(self, info): """ Print an address status. """ template = '%(addr)-20s%(state)-12s%(load)-8s%(ltime)-12s' line = template % { 'addr': info['address_name'], 'state': info['statename'], 'load': '{}%'.format(info['loading']), 'ltime': simple_localtime(info['local_time']) } self.ctl.output(line)
def write_header(self, root): """ Rendering of the header part of the Supvisors Address page """ # set address name elt = root.findmeld('address_mid') if self.supvisors.context.master: elt.attrib['class'] = 'master' elt.content(self.address) # set address state status = self.supvisors.context.addresses[self.address] elt = root.findmeld('state_mid') elt.content(status.state_string()) # set loading elt = root.findmeld('percent_mid') elt.content('{}%'.format(status.loading())) # set last tick date: remote_time and local_time should be identical since self is running on the 'remote' address elt = root.findmeld('date_mid') elt.content(simple_localtime(status.remote_time)) # write periods of statistics self.write_periods(root)
def output_address_info(self, info): """ Print an address status. """ template = '%(addr)-20s%(state)-12s%(load)-8s%(ltime)-12s' line = template % {'addr': info['address_name'], 'state': info['statename'], 'load': '{}%'.format(info['loading']), 'ltime': simple_localtime(info['local_time'])} self.ctl.output(line)