def status_icons(self): """ Fetch Status Icons """ output = copy.deepcopy(self._status_icons) insert_icon = None if len(self.platforms.select_nodes('active')): current_url = self.url() if self.url('live_data') in current_url: # Display Options Icon # display_options_icon = StatusIcon('Table Display Options', DISPLAY_OPTIONS_MODES, enable_legend=False) def _display_options_message(): _output = '<h3>' + display_options_icon.title + '</h3>' group = self.get_group() _output += template('table_units', group=group, page_type='live') return _output display_options_icon.status_message = _display_options_message insert_icon = display_options_icon elif self.url('logs_data') in current_url: # Log Export Icon # log_export_icon = StatusIcon('Log Export', LOG_EXPORT_MODES, enable_legend=False) def _log_export_message(): group = self.get_group() _output = self.template_html(None, 'log_export', group=group) return _output log_export_icon.status_message = _log_export_message insert_icon = log_export_icon if insert_icon is not None: _old_current_icon = insert_icon.current_icon def _insert_icon_current_icon(): active_nodes = self.platforms.select_nodes('active') active_state = int(bool(len(active_nodes))) return _old_current_icon(active_state) insert_icon.current_icon = _insert_icon_current_icon output.insert_before(output.keys()[0], (insert_icon.internal_name, insert_icon)) return output
def __init__(self, **kwargs): super(StatusIcons, self).__init__(**kwargs) self._status_icons = OrderedDict() # Warnings Icon # # FIXME: More elegant way to do this? warnings_icon = StatusIcon('Warnings', WARNINGS_MODES) def _warnings_message(): output = '' warnings = self.platforms.warnings() if len(warnings): output += template('warnings', warnings=warnings, status_icon=warnings_icon) return output warnings_icon.status_message = _warnings_message warnings_old_current_icon = warnings_icon.current_icon def _warnings_icon(): warnings_state = self.platforms.warnings_state() LOGGER.debug('warnings_state: ' + str(warnings_state)) return warnings_old_current_icon(warnings_state) warnings_icon.current_icon = _warnings_icon self._status_icons[warnings_icon.internal_name] = warnings_icon # Power Consumption Icon # power_consumption_icon = StatusIcon('Power Consumption', POWER_MODES) power_consumption_old_current_icon = power_consumption_icon.current_icon def _power_consumption_icon(): power_consumption_state = self.manager.networks[ 0].power_consumption_state() return power_consumption_old_current_icon(power_consumption_state) power_consumption_icon.current_icon = _power_consumption_icon self._status_icons[ power_consumption_icon.internal_name] = power_consumption_icon # System Status Icon # system_status_icon = StatusIcon('System Status', SYSTEM_MODES) self._status_icons[ system_status_icon.internal_name] = system_status_icon