Improve performance of log viewer

This commit is contained in:
Kovid Goyal 2008-10-21 19:07:21 -07:00
parent 69f79f163d
commit 568c8067f0
3 changed files with 13 additions and 7 deletions

View File

@ -18,13 +18,19 @@
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QTextEdit" name="log" > <widget class="QPlainTextEdit" name="log" >
<property name="undoRedoEnabled" > <property name="undoRedoEnabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="lineWrapMode" >
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly" > <property name="readOnly" >
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="maximumBlockCount" >
<number>400</number>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -188,6 +188,6 @@ class DetailView(QDialog, Ui_Dialog):
def update(self): def update(self):
self.log.setHtml(self.job.gui_text()) self.log.setPlainText(self.job.gui_text())
vbar = self.log.verticalScrollBar() vbar = self.log.verticalScrollBar()
vbar.setValue(vbar.maximum()) vbar.setValue(vbar.maximum())

View File

@ -588,11 +588,11 @@ class Job(object):
if self.description: if self.description:
if not isinstance(self.description, unicode): if not isinstance(self.description, unicode):
self.description = self.description.decode('utf-8', 'replace') self.description = self.description.decode('utf-8', 'replace')
ans[0] += u'<b>%s</b>'%self.description ans[0] += u'**%s**'%self.description
if self.exception is not None: if self.exception is not None:
header = unicode(self.exception.__class__.__name__) if \ header = unicode(self.exception.__class__.__name__) if \
hasattr(self.exception, '__class__') else u'Error' hasattr(self.exception, '__class__') else u'Error'
header = u'<b>%s</b>'%header header = u'**%s**'%header
header += u': ' header += u': '
try: try:
header += unicode(self.exception) header += unicode(self.exception)
@ -600,15 +600,15 @@ class Job(object):
header += unicode(repr(self.exception)) header += unicode(repr(self.exception))
ans.append(header) ans.append(header)
if self.traceback: if self.traceback:
ans.append(u'<b>Traceback</b>:') ans.append(u'**Traceback**:')
ans.extend(self.traceback.split('\n')) ans.extend(self.traceback.split('\n'))
if self.log: if self.log:
ans.append(u'<b>Log</b>:') ans.append(u'**Log**:')
if isinstance(self.log, str): if isinstance(self.log, str):
self.log = unicode(self.log, 'utf-8', 'replace') self.log = unicode(self.log, 'utf-8', 'replace')
ans.extend(self.log.split('\n')) ans.extend(self.log.split('\n'))
return '<br>'.join(ans) return '\n'.join(ans)
class ParallelJob(Job): class ParallelJob(Job):