Python2 had old-style classes (no "(object)"), and new style classes (with
"object"). Under Py3 this is a noop, so let's drop it to make the code
a bit shorter.
https://bugzilla.redhat.com/show_bug.cgi?id=1903583 sports the following traceback:
Traceback (most recent call last):
File "/usr/bin/ebook-convert", line 20, in <module>
sys.exit(main())
File "/usr/lib64/calibre/calibre/ebooks/conversion/cli.py", line 401, in main
plumber.run()
File "/usr/lib64/calibre/calibre/ebooks/conversion/plumber.py", line 1135, in run
pr(0., _('Running transforms on e-book...'))
File "/usr/lib64/calibre/calibre/ebooks/conversion/plumber.py", line 67, in __call__
self.global_reporter(global_frac, msg)
File "/usr/lib64/calibre/calibre/ebooks/conversion/cli.py", line 288, in __call__
self.log('%d%% %s'%(percent, msg))
File "/usr/lib64/calibre/calibre/utils/logging.py", line 179, in __call__
self.info(*args, **kwargs)
File "/usr/lib64/calibre/calibre/utils/logging.py", line 171, in print_with_flush
self.flush()
File "/usr/lib64/calibre/calibre/utils/logging.py", line 191, in flush
o.flush()
File "/usr/lib64/calibre/calibre/utils/logging.py", line 53, in flush
self.stream.flush()
BrokenPipeError: [Errno 32] Datenübergabe unterbrochen (broken pipe)
If logging fails because somebody closed the output pipe, this is not an error.
Let's just ignore this this silently.
I removed the two .flush() implementations because those two classes inherit
from Stream.
https://bugzilla.redhat.com/show_bug.cgi?id=1922761 reports the following
failure:
Traceback (most recent call last):
File "/bin/ebook-edit", line 20, in <module>
sys.exit(ebook_edit())
File "/usr/lib64/calibre/calibre/gui_launch.py", line 119, in ebook_edit
main(args)
File "/usr/lib64/calibre/calibre/gui2/tweak_book/main.py", line 98, in main
_run(args)
File "/usr/lib64/calibre/calibre/gui2/tweak_book/main.py", line 66, in _run
from calibre.gui2.tweak_book.ui import Main
File "/usr/lib64/calibre/calibre/gui2/tweak_book/ui.py", line 29, in <module>
from calibre.gui2.tweak_book.boss import Boss
File "/usr/lib64/calibre/calibre/gui2/tweak_book/boss.py", line 28, in <module>
from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish
File "/usr/lib64/calibre/calibre/ebooks/oeb/polish/main.py", line 20, in <module>
from calibre.ebooks.oeb.polish.jacket import (
File "/usr/lib64/calibre/calibre/ebooks/oeb/polish/jacket.py", line 9, in <module>
from calibre.ebooks.conversion.config import load_defaults
File "/usr/lib64/calibre/calibre/ebooks/conversion/config.py", line 20, in <module>
os.makedirs(config_dir)
File "/usr/lib64/python3.9/os.py", line 225, in makedirs
mkdir(name, mode)
FileExistsError: [Errno 17] Arquivo existe: '/home/vinicius/.config/calibre/conversion'
I assume that the user had two calibre instances started, and they raced on
the check and creation of the directory. Let's use os.makedirs(exist_ok=True).
(added in Python 3.2).
Also, only create the directories when saving/reading the file, not when the
module is imported.