def fill(self): sessions = self.client.call('session', 'list') cookie = self.client.getCookie() self.checkboxes = [] self.sessions = [session for session in sessions if ('cookie' not in session) or (session['cookie'] != cookie)] if not sessions: return False self.sessions.sort(key=lambda session: session['idle']) table = self.ui.session_table table.setRowCount(len(self.sessions)) for row, session in enumerate(self.sessions): user = session['user'] creation = fuzzyDatetime(parseDatetime(session['creation'])) idle = timedelta(seconds=session['idle']) idle = fuzzyTimedelta(idle) if 'login' in user: login = user['login'] else: login = u"<%s>" % tr("anonymous") application = user['client_name'] application = APPLICATION_NAME.get(application, application) if 'client_release' in user: application += ' (%s)' % (user['client_release'],) columns = ( login, user['host'], application, creation, idle) checkbox = QCheckBox(self) if 'cookie' not in session: checkbox.setEnabled(False) self.connect(checkbox, SIGNAL("toggled(bool)"), self.toggleSession) table.setCellWidget(row, 0, checkbox) self.checkboxes.append(checkbox) for column, text in enumerate(columns): table.setItem(row, 1 + column, QTableWidgetItem(text)) table.resizeColumnsToContents() self.ui.destroy_button.setEnabled(False)
def __process_logs(self, logs): """ Does everything that has to be done with logs -Write them on the console. -take any relevant action returns True if there are other messages to process False if all messages have been processed """ has_more = True if len(logs) == 0: if self._interval < _MAX_INTERVAL: self._interval *= 2 for log in logs: self._interval = _BASE_INTERVAL self._last_read_index += 1 timestamp, message_type, content = log timestamp = parseDatetime(timestamp) if message_type == PHASE_CHANGE: has_more = self._change_phase(timestamp, content) elif message_type in ERRORS: self._display_err(timestamp, content) elif message_type in (GLOBAL_ERROR, GLOBAL_WARNING): colors = {GLOBAL_ERROR:COLOR_ERROR ,GLOBAL_WARNING:COLOR_WARNING} format, substitutions = content message = tr(format) % substitutions self.display_message(timestamp, message, color=colors[message_type]) elif message_type in COMPONENT_LISTS: self._process_component_list(timestamp, message_type, content) elif message_type in COMPONENT_FIRED: self._set_last_fired_component(content) message = tr("%(COMPONENT_NAME)s is being configured") % { "COMPONENT_NAME": self._last_fired_component_formatted} splash_message = self._last_fired_component self._component_counter += 1 if self._rollback_occurred: components = self._rolled_back_component_list else: components = self._applied_component_list if components: progress = " (%s/%s)" % (self._component_counter, len(components)) message += progress splash_message += progress self.logWithTimestamp(timestamp, message) self.splash.setText(splash_message) elif COMPONENT_MESSAGE == message_type: format, substitutions = content message = tr(format) % substitutions message = htmlColor(message, COLOR_VERBOSE) message = tr("%s: %s") % ( self._last_fired_component, unicode(message)) self.logWithTimestamp(timestamp, message) else: # unknow message type message = tr("%s (unknown message type: '%s')") message = message % (content, message_type) message = htmlColor(message, COLOR_INVALID) self.logWithTimestamp(timestamp, message) return has_more