apprenticeharper / DeDRM_tools

DeDRM tools for ebooks
14.52k stars 1.51k forks source link

Noisy Error Messages #1924

Open miloofcroton opened 2 years ago

miloofcroton commented 2 years ago

I'm using DeDRM in a script that runs on a large number of ebooks, which might be epub or a DRMed format. If it's not DRM, I get very loud error logs, which obfuscate useful errors for me.

As an example, for a single file:

calibre_plugins.dedrm.DeDRMError: DeDRM v7.2.1: Couldn't decrypt after 0.4 seconds. DRM free perhaps?
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 175, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 644, in run
    decrypted_ebook = self.ePubDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 420, in ePubDecrypt
    raise DeDRMError("{0} v{1}: Couldn't decrypt after {2:.1f} seconds. DRM free perhaps?".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))
calibre_plugins.dedrm.DeDRMError: DeDRM v7.2.1: Couldn't decrypt after 1.0 seconds. DRM free perhaps?
Running file type plugin DeDRM failed with traceback:
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 175, in _run_filetype_plugins
  File "calibre_plugins.dedrm.__init__", line 644, in run
    decrypted_ebook = self.ePubDecrypt(path_to_ebook)
  File "calibre_plugins.dedrm.__init__", line 420, in ePubDecrypt
    raise DeDRMError("{0} v{1}: Couldn't decrypt after {2:.1f} seconds. DRM free perhaps?".format(PLUGIN_NAME, PLUGIN_VERSION,time.time()-self.starttime))

Is there anything that can be done about this? Maybe create an option to suppress all errors (the opposite of verbose mode)?

Leseratte10 commented 2 years ago

There doesn't seem to be an existing option to silence these logs, no, so you would need to modify the plugin yourself. Just edit the init.py file and find all the places where a DeDRMError is raised. Removing these (and replacing them with a return or something) would probably get rid of most of these error logs.

miloofcroton commented 2 years ago

I think the simpler answer for me is to just pipe stderr to /dev/null.

Leseratte10 commented 2 years ago

Yeah, that works as well, if you don't want to / need to see any of the other potential error messages from the plugin.