Fix display of job output in GUI

This commit is contained in:
Kovid Goyal 2008-12-16 15:19:02 -08:00
parent 126fec5c7d
commit 9dcad3216a
4 changed files with 20 additions and 16 deletions

View File

@ -39,7 +39,7 @@ from lxml import html
from PyQt4.Qt import QApplication, QPixmap
from calibre.ebooks.html import Processor, merge_metadata, get_filelist,\
opf_traverse, create_metadata, rebase_toc, Link
opf_traverse, create_metadata, rebase_toc, Link, parser
from calibre.ebooks.epub import config as common_config, tostring
from calibre.ptempfile import TemporaryDirectory
from calibre.ebooks.metadata.toc import TOC
@ -77,7 +77,7 @@ def check(opf_path, pretty_print):
for path in html_files:
base = os.path.dirname(path)
root = html.fromstring(open(content(path), 'rb').read())
root = html.fromstring(open(content(path), 'rb').read(), parser=parser)
for element, attribute, link, pos in list(root.iterlinks()):
link = to_unicode(link)
plink = Link(link, base)

View File

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

View File

@ -567,23 +567,27 @@ class Job(object):
return 'ERROR'
def console_text(self):
ans = [u'Error in job: ']
ans = [u'Job: ']
if self.description:
ans[0] += self.description
if self.exception is not None:
header = unicode(self.exception.__class__.__name__) if \
hasattr(self.exception, '__class__') else u'Error'
header = u'**%s**'%header
header += u': '
try:
header += unicode(self.exception)
except:
header += unicode(repr(self.exception))
ans.append(header)
if self.traceback:
ans.append(u'**Traceback**:')
ans.extend(self.traceback.split('\n'))
if self.log:
if isinstance(self.log, str):
self.log = unicode(self.log, 'utf-8', 'replace')
ans.append(self.log)
header = unicode(self.exception.__class__.__name__) if \
hasattr(self.exception, '__class__') else u'Error'
header += u': '
try:
header += unicode(self.exception)
except:
header += unicode(repr(self.exception))
ans.append(header)
if self.traceback:
ans.append(self.traceback)
return (u'\n'.join(ans)).encode('utf-8')
def gui_text(self):
@ -611,7 +615,7 @@ class Job(object):
self.log = unicode(self.log, 'utf-8', 'replace')
ans.extend(self.log.split('\n'))
return '\n'.join(ans)
return '<br>'.join(ans)
class ParallelJob(Job):

View File

@ -213,7 +213,7 @@ def upload_src_tarball():
check_call('scp dist/calibre-*.tar.gz divok:%s/'%DOWNLOADS)
def stage_one():
check_call('sudo rm -rf build', shell=True)
check_call('sudo rm -rf build src/calibre/plugins/*', shell=True)
os.mkdir('build')
shutil.rmtree('docs')
os.mkdir('docs')