Exemplo n.º 1
0
 def update(self, state):
     if state.board_info:
         self.board_label.set_text('{} ({})'.format(state.board_info,
                                                    state.board_revision))
     else:
         self.board_label.set_text(state.board_revision)
     self.serial_label.set_text(state.board_serial)
     self.os_label.set_text('{} {}'.format(state.os_name, state.os_version))
     self.python_label.set_text('{} (on {})'.format(state.py_version,
                                                    state.platform))
     if not state.stats:
         self.clock_label.set_text('-')
         self.disk_bar.update(())
         self.swap_bar.update(())
         self.memory_bar.update(())
         self.load_bar.update(())
         self.temperature_bar.update(())
     else:
         self.clock_label.set_text(format_timedelta(state.clock_skew))
         latest = state.stats[-1]
         self.disk_bar.maximum = latest.disk_size
         self.swap_bar.maximum = latest.swap_size
         self.memory_bar.maximum = latest.mem_size
         self.disk_bar.update(invert(state.stats, 'disk_free', 'disk_size'))
         self.swap_bar.update(invert(state.stats, 'swap_free', 'swap_size'))
         self.memory_bar.update(invert(state.stats, 'mem_free', 'mem_size'))
         self.load_bar.update(extract(state.stats, 'load_average'))
         self.temperature_bar.update(extract(state.stats, 'cpu_temp'))
Exemplo n.º 2
0
def since(timestamp):
    """
    Return a nicely formatted string indicating the number of hours minutes and
    seconds since *timestamp*.

    :param datetime.datetime timestamp:
        The timestamp from which to measure a duration.
    """
    if timestamp is None:
        return '-'
    else:
        return format_timedelta(datetime.now(tz=UTC) - timestamp)
Exemplo n.º 3
0
 def update(self, state):
     if state.board_info:
         self.board_label.set_text('{} ({})'.format(state.board_info,
                                                    state.board_revision))
     else:
         self.board_label.set_text(state.board_revision)
     self.serial_label.set_text(state.board_serial)
     self.os_label.set_text('{} {}'.format(state.os_name, state.os_version))
     if not state.stats:
         self.disk_bar.update(())
         self.swap_bar.update(())
         self.memory_bar.update(())
         self.queue_bar.update({})
         self.builds_bar.update({})
         self.downloads_bar.update(())
         self.load_bar.update(())
         self.temperature_bar.update(())
         self.builds_size_label.set_text('-')
         self.builds_time_label.set_text('-')
         self.files_count_label.set_text('-')
     else:
         latest = state.stats[-1]
         self.disk_bar.maximum = latest.disk_size
         self.swap_bar.maximum = latest.swap_size
         self.memory_bar.maximum = latest.mem_size
         self.disk_bar.update(invert(state.stats, 'disk_free', 'disk_size'))
         self.swap_bar.update(invert(state.stats, 'swap_free', 'swap_size'))
         self.memory_bar.update(invert(state.stats, 'mem_free', 'mem_size'))
         self.queue_bar.update(state.stats[-1].builds_pending)
         self.builds_bar.update(state.stats[-1].builds_last_hour)
         self.downloads_bar.update(
             extract(state.stats, 'downloads_last_hour'))
         self.load_bar.update(extract(state.stats, 'load_average'))
         self.temperature_bar.update(extract(state.stats, 'cpu_temp'))
         self.builds_size_label.set_text(format_size(latest.builds_size))
         self.builds_time_label.set_text(
             format_timedelta(latest.builds_time))
         self.files_count_label.set_text('{:,}'.format(latest.files_count))
Exemplo n.º 4
0
 def update(self, state):
     super().update(state)
     self._label = 'Uptime: {}'.format(
         format_timedelta(datetime.now(tz=UTC) - state.first_seen))
Exemplo n.º 5
0
 def stat_label(self, stat, raw):
     if raw is None:
         return 'No build'
     else:
         return 'Build Time: {}'.format(format_timedelta(raw))
Exemplo n.º 6
0
 def stat_label(self, stat, raw):
     if raw is None:
         return 'Time Skew: ?'
     else:
         return 'Time Skew: {}'.format(format_timedelta(raw))