mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix display of job output in GUI
This commit is contained in:
parent
126fec5c7d
commit
9dcad3216a
@ -39,7 +39,7 @@ from lxml import html
|
|||||||
from PyQt4.Qt import QApplication, QPixmap
|
from PyQt4.Qt import QApplication, QPixmap
|
||||||
|
|
||||||
from calibre.ebooks.html import Processor, merge_metadata, get_filelist,\
|
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.ebooks.epub import config as common_config, tostring
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from calibre.ebooks.metadata.toc import TOC
|
from calibre.ebooks.metadata.toc import TOC
|
||||||
@ -77,7 +77,7 @@ def check(opf_path, pretty_print):
|
|||||||
|
|
||||||
for path in html_files:
|
for path in html_files:
|
||||||
base = os.path.dirname(path)
|
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()):
|
for element, attribute, link, pos in list(root.iterlinks()):
|
||||||
link = to_unicode(link)
|
link = to_unicode(link)
|
||||||
plink = Link(link, base)
|
plink = Link(link, base)
|
||||||
|
@ -188,6 +188,6 @@ class DetailView(QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.log.setPlainText(self.job.gui_text())
|
self.log.setPlainText(self.job.console_text())
|
||||||
vbar = self.log.verticalScrollBar()
|
vbar = self.log.verticalScrollBar()
|
||||||
vbar.setValue(vbar.maximum())
|
vbar.setValue(vbar.maximum())
|
||||||
|
@ -567,15 +567,13 @@ class Job(object):
|
|||||||
return 'ERROR'
|
return 'ERROR'
|
||||||
|
|
||||||
def console_text(self):
|
def console_text(self):
|
||||||
ans = [u'Error in job: ']
|
ans = [u'Job: ']
|
||||||
if self.description:
|
if self.description:
|
||||||
ans[0] += self.description
|
ans[0] += self.description
|
||||||
if self.log:
|
if self.exception is not None:
|
||||||
if isinstance(self.log, str):
|
|
||||||
self.log = unicode(self.log, 'utf-8', 'replace')
|
|
||||||
ans.append(self.log)
|
|
||||||
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'**%s**'%header
|
||||||
header += u': '
|
header += u': '
|
||||||
try:
|
try:
|
||||||
header += unicode(self.exception)
|
header += unicode(self.exception)
|
||||||
@ -583,7 +581,13 @@ 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(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)
|
||||||
return (u'\n'.join(ans)).encode('utf-8')
|
return (u'\n'.join(ans)).encode('utf-8')
|
||||||
|
|
||||||
def gui_text(self):
|
def gui_text(self):
|
||||||
@ -611,7 +615,7 @@ class Job(object):
|
|||||||
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 '\n'.join(ans)
|
return '<br>'.join(ans)
|
||||||
|
|
||||||
|
|
||||||
class ParallelJob(Job):
|
class ParallelJob(Job):
|
||||||
|
@ -213,7 +213,7 @@ def upload_src_tarball():
|
|||||||
check_call('scp dist/calibre-*.tar.gz divok:%s/'%DOWNLOADS)
|
check_call('scp dist/calibre-*.tar.gz divok:%s/'%DOWNLOADS)
|
||||||
|
|
||||||
def stage_one():
|
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')
|
os.mkdir('build')
|
||||||
shutil.rmtree('docs')
|
shutil.rmtree('docs')
|
||||||
os.mkdir('docs')
|
os.mkdir('docs')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user