diff --git a/src/calibre/ebooks/conversion/cli.py b/src/calibre/ebooks/conversion/cli.py index 4c9b08df96..6c190759f7 100644 --- a/src/calibre/ebooks/conversion/cli.py +++ b/src/calibre/ebooks/conversion/cli.py @@ -211,6 +211,7 @@ def main(args=sys.argv): OptionRecommendation.HIGH) \ for n in parser.options_iter() if n.dest] + print recommendations plumber.merge_ui_recommendations(recommendations) plumber.run() diff --git a/src/calibre/gui2/convert/gui_conversion.py b/src/calibre/gui2/convert/gui_conversion.py new file mode 100644 index 0000000000..a4cb6c88d6 --- /dev/null +++ b/src/calibre/gui2/convert/gui_conversion.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + +import logging + +from calibre.ebooks.conversion.plumber import Plumber +from calibre.utils.logging import Log + +def gui_convert(input, output, recommendations): + plumber = Plumber(input, output, Log()) + plumber.merge_ui_recommendations(recommendations) + + plumber.run() + diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index 03ff2b150a..c83fcf4889 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -6,7 +6,9 @@ __docformat__ = 'restructuredtext en' ''' Logic for setting up conversion jobs ''' -import os + +import cPickle, os + from PyQt4.Qt import QDialog from calibre.ptempfile import PersistentTemporaryFile @@ -14,7 +16,7 @@ from calibre.gui2.convert import load_specifics from calibre.gui2.convert.single import NoSupportedInputFormats from calibre.gui2.convert.single import Config as SingleConfig -def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=None): +def convert_single_ebook(parent, db, row_ids, auto_conversion=False, out_format=None): changed = False jobs = [] bad = [] @@ -32,8 +34,6 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=N if auto_conversion: result = QDialog.Accepted - if d.output_format != out_format: - raise Exception('Output format not supported.') else: result = d.exec_() @@ -47,14 +47,10 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=N desc = _('Convert book %d of %d (%s)') % (i + 1, total, repr(mi.title)) - opts = load_specifics(db, row_id) - opts_string = '' - for opt in opts.keys(): - opts_string += ' --%s %s ' % (opt, opts[opt]) - - args = [['', in_file, out_file.name, opts_string]] + recs = cPickle.loads(d.recommendations) + args = [in_file, out_file.name, recs] temp_files = [out_file] - jobs.append(('ebook-convert', args, desc, d.output_format.upper(), row_id, temp_files)) + jobs.append(('gui_convert', args, desc, d.output_format.upper(), row_id, temp_files)) changed = True except NoSupportedInputFormats: diff --git a/src/calibre/parallel.py b/src/calibre/parallel.py index cb14c4ed20..ff1180e4b4 100644 --- a/src/calibre/parallel.py +++ b/src/calibre/parallel.py @@ -38,50 +38,21 @@ DEBUG = False #: A mapping from job names to functions that perform the jobs PARALLEL_FUNCS = { - 'any2lrf' : - ('calibre.ebooks.lrf.any.convert_from', 'main', dict(gui_mode=True), None), - 'lrfviewer' : ('calibre.gui2.lrf_renderer.main', 'main', {}, None), 'ebook-viewer' : ('calibre.gui2.viewer.main', 'main', {}, None), - 'feeds2lrf' : - ('calibre.ebooks.lrf.feeds.convert_from', 'main', {}, 'notification'), - - 'render_table' : - ('calibre.ebooks.lrf.html.table_as_image', 'do_render', {}, None), - 'render_pages' : ('calibre.ebooks.comic.input', 'render_pages', {}, 'notification'), - 'comic2lrf' : - ('calibre.ebooks.lrf.comic.convert_from', 'do_convert', {}, 'notification'), - - 'any2epub' : - ('calibre.ebooks.epub.from_any', 'any2epub', {}, None), - - 'feeds2epub' : - ('calibre.ebooks.epub.from_feeds', 'main', {}, 'notification'), - - 'comic2epub' : - ('calibre.ebooks.epub.from_comic', 'convert', {}, 'notification'), - - 'any2mobi' : - ('calibre.ebooks.mobi.from_any', 'any2mobi', {}, None), - - 'any2pdf' : - ('calibre.ebooks.pdf.from_any', 'any2pdf', {}, None), - - 'feeds2mobi' : - ('calibre.ebooks.mobi.from_feeds', 'main', {}, 'notification'), - - 'comic2mobi' : - ('calibre.ebooks.mobi.from_comic', 'convert', {}, 'notification'), - 'ebook-convert' : ('calibre.ebooks.conversion.cli', 'main', {}, None), + + + 'gui_convert' : + ('calibre.gui2.convert.gui_conversion', 'gui_convert', {}, None), }