From 2791ba033286814c1de0097533e4434891e51ee3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 5 Dec 2014 18:53:26 +0530 Subject: [PATCH] Workaround for FileType plugins that override the output streams with buggy implementations --- src/calibre/customize/ui.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/customize/ui.py b/src/calibre/customize/ui.py index ca44fa4691..77da5f7a23 100644 --- a/src/calibre/customize/ui.py +++ b/src/calibre/customize/ui.py @@ -149,14 +149,16 @@ def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'): if is_disabled(plugin): continue plugin.site_customization = customization.get(plugin.name, '') + oo, oe = sys.stdout, sys.stderr # Some file type plugins out there override the output streams with buggy implementations with plugin: try: nfp = plugin.run(path_to_file) if not nfp: nfp = path_to_file except: - print 'Running file type plugin %s failed with traceback:'%plugin.name - traceback.print_exc() + print >>oe, 'Running file type plugin %s failed with traceback:'%plugin.name + traceback.print_exc(file=oe) + sys.stdout, sys.stderr = oo, oe x = lambda j : os.path.normpath(os.path.normcase(j)) if occasion == 'postprocess' and x(nfp) != x(path_to_file): shutil.copyfile(nfp, path_to_file)