mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Workaround for FileType plugins that override the output streams with buggy implementations
This commit is contained in:
parent
7523c6b99b
commit
2791ba0332
@ -149,14 +149,16 @@ def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'):
|
|||||||
if is_disabled(plugin):
|
if is_disabled(plugin):
|
||||||
continue
|
continue
|
||||||
plugin.site_customization = customization.get(plugin.name, '')
|
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:
|
with plugin:
|
||||||
try:
|
try:
|
||||||
nfp = plugin.run(path_to_file)
|
nfp = plugin.run(path_to_file)
|
||||||
if not nfp:
|
if not nfp:
|
||||||
nfp = path_to_file
|
nfp = path_to_file
|
||||||
except:
|
except:
|
||||||
print 'Running file type plugin %s failed with traceback:'%plugin.name
|
print >>oe, 'Running file type plugin %s failed with traceback:'%plugin.name
|
||||||
traceback.print_exc()
|
traceback.print_exc(file=oe)
|
||||||
|
sys.stdout, sys.stderr = oo, oe
|
||||||
x = lambda j : os.path.normpath(os.path.normcase(j))
|
x = lambda j : os.path.normpath(os.path.normcase(j))
|
||||||
if occasion == 'postprocess' and x(nfp) != x(path_to_file):
|
if occasion == 'postprocess' and x(nfp) != x(path_to_file):
|
||||||
shutil.copyfile(nfp, path_to_file)
|
shutil.copyfile(nfp, path_to_file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user