mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-04 03:27:00 -05: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 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)
 | 
			
		||||
 | 
			
		||||
@ -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())
 | 
			
		||||
 | 
			
		||||
@ -567,15 +567,13 @@ 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.log:
 | 
			
		||||
            if isinstance(self.log, str):
 | 
			
		||||
                self.log = unicode(self.log, 'utf-8', 'replace')
 | 
			
		||||
            ans.append(self.log)
 | 
			
		||||
        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)
 | 
			
		||||
@ -583,7 +581,13 @@ class Job(object):
 | 
			
		||||
                header += unicode(repr(self.exception))
 | 
			
		||||
            ans.append(header)
 | 
			
		||||
            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')
 | 
			
		||||
    
 | 
			
		||||
    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):
 | 
			
		||||
 | 
			
		||||
@ -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')
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user