From 2533bc65e9dfe276ec2ad3aafa844522f076cec0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 27 Aug 2009 13:23:09 -0600 Subject: [PATCH] Add a new Debug option that will allow you to debug the different stages of the conversion pipeline. Available when converting a single book at a time. --- src/calibre/gui2/convert/debug.py | 61 + src/calibre/gui2/convert/debug.ui | 78 + src/calibre/gui2/convert/single.py | 4 + src/calibre/gui2/images/debug.svg | 2896 ++++++++++++++++++++++++++++ src/calibre/gui2/tools.py | 4 + src/calibre/manual/faq.rst | 2 +- 6 files changed, 3044 insertions(+), 1 deletion(-) create mode 100644 src/calibre/gui2/convert/debug.py create mode 100644 src/calibre/gui2/convert/debug.ui create mode 100644 src/calibre/gui2/images/debug.svg diff --git a/src/calibre/gui2/convert/debug.py b/src/calibre/gui2/convert/debug.py new file mode 100644 index 0000000000..fbf5372aa9 --- /dev/null +++ b/src/calibre/gui2/convert/debug.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +import os + +from PyQt4.Qt import SIGNAL + +from calibre.gui2.convert.debug_ui import Ui_Form +from calibre.gui2.convert import Widget +from calibre.gui2 import error_dialog, choose_dir + +class DebugWidget(Widget, Ui_Form): + + TITLE = _('Debug') + ICON = ':/images/debug.svg' + HELP = _('Debug the conversion process.') + + def __init__(self, parent, get_option, get_help, db=None, book_id=None): + Widget.__init__(self, parent, 'debug', + ['debug_pipeline'] + ) + self.db, self.book_id = db, book_id + self.initialize_options(get_option, get_help, db, book_id) + self.connect(self.button_debug_dir, SIGNAL('clicked()'), + self.set_debug_dir) + self.connect(self.button_clear, SIGNAL('clicked()'), + self.clear_debug_dir) + + def clear_debug_dir(self): + self.opt_debug_pipeline.setText('') + + def set_debug_dir(self): + x = choose_dir(self, 'conversion debug dir', _('Choose debug folder')) + if x: + self.opt_debug_pipeline.setText(x) + + def pre_commit_check(self): + try: + x = unicode(self.opt_debug_pipeline.text()).strip() + x = os.path.abspath(x) + if x: + if not os.path.exists(x): + os.makedirs(x) + test = os.path.join(x, 'test') + open(test, 'wb').close() + os.remove(test) + except: + import traceback + det_msg = traceback.format_exc() + error_dialog(self, _('Invalid debug directory'), + _('Failed to create debug directory')+': '+ + unicode(self.opt_debug_pipeline.text()), + det_msg=det_msg, show=True) + return False + return True + diff --git a/src/calibre/gui2/convert/debug.ui b/src/calibre/gui2/convert/debug.ui new file mode 100644 index 0000000000..65bc8206eb --- /dev/null +++ b/src/calibre/gui2/convert/debug.ui @@ -0,0 +1,78 @@ + + + Form + + + + 0 + 0 + 436 + 382 + + + + Form + + + + + + Choose a folder to put the debug output into. If you specify a folder, calibre will place a lot of debug output into it. This will be useful in understanding the conversion process and figuring out the correct values for conversion parameters like Table of Contents and Chapter Detection. + + + true + + + + + + + true + + + + + + + Choose debug folder + + + ... + + + + :/images/document_open.svg:/images/document_open.svg + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + ... + + + + :/images/clear_left.svg:/images/clear_left.svg + + + + + + + + + + diff --git a/src/calibre/gui2/convert/single.py b/src/calibre/gui2/convert/single.py index b995c3e3a2..8b461ed936 100644 --- a/src/calibre/gui2/convert/single.py +++ b/src/calibre/gui2/convert/single.py @@ -19,6 +19,8 @@ from calibre.gui2.convert.look_and_feel import LookAndFeelWidget from calibre.gui2.convert.page_setup import PageSetupWidget from calibre.gui2.convert.structure_detection import StructureDetectionWidget from calibre.gui2.convert.toc import TOCWidget +from calibre.gui2.convert.debug import DebugWidget + from calibre.ebooks.conversion.plumber import Plumber, supported_input_formats from calibre.customize.ui import available_output_formats @@ -139,6 +141,7 @@ class Config(ResizableDialog, Ui_Dialog): ps = widget_factory(PageSetupWidget) sd = widget_factory(StructureDetectionWidget) toc = widget_factory(TOCWidget) + debug = widget_factory(DebugWidget) output_widget = None name = self.plumber.output_plugin.name.lower().replace(' ', '_') @@ -173,6 +176,7 @@ class Config(ResizableDialog, Ui_Dialog): widgets.append(input_widget) if output_widget is not None: widgets.append(output_widget) + widgets.append(debug) for w in widgets: self.stack.addWidget(w) self.connect(w, SIGNAL('set_help(PyQt_PyObject)'), diff --git a/src/calibre/gui2/images/debug.svg b/src/calibre/gui2/images/debug.svg new file mode 100644 index 0000000000..247f11d3b3 --- /dev/null +++ b/src/calibre/gui2/images/debug.svg @@ -0,0 +1,2896 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index 25c7a7f363..91a25ca426 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -126,6 +126,10 @@ def convert_bulk_ebook(parent, db, book_ids, out_format=None): OptionRecommendation.HIGH)) temp_files.append(d.cover_file) + for x in list(lrecs): + if x[0] == 'debug_pipeline': + lrecs.remove(x) + desc = _('Convert book %d of %d (%s)') % (i + 1, total, repr(mi.title)) args = [in_file, out_file.name, lrecs] diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst index 36a262ab5c..c3914bdb81 100644 --- a/src/calibre/manual/faq.rst +++ b/src/calibre/manual/faq.rst @@ -142,7 +142,7 @@ Why doesn't |app| have a column for foo? How do I move my |app| library from one computer to another? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Simply copy the |app| library folder from the old to the new computer. You can find out what the library folder is by clicking Preferences. The very first item is the path tot he library folder. Now on the new computer, start |app| for the first time. It will run the Welcome Wizard asking you for the location of the |app| library. Point it to the previously copied folder. +Simply copy the |app| library folder from the old to the new computer. You can find out what the library folder is by clicking Preferences. The very first item is the path to the library folder. Now on the new computer, start |app| for the first time. It will run the Welcome Wizard asking you for the location of the |app| library. Point it to the previously copied folder. Note that if you are transferring between different types of computers (for example Windows to OS X) then after doing the above you should also go to Preferences->Advanced and click the Check database integrity button. It will warn you about missing files, if any, which you should then transfer by hand.