Quantcast
Channel: MobileRead Forums
Viewing all articles
Browse latest Browse all 50094

Some unexpected Calibre behavior

$
0
0
Today, I found that an old but stable and working Calibre installation suddenly ceased to fetch metadata.

The error was pervasive, with every metadata source:
Code:

ERROR: Download failed: Failed to download metadata. Click Show Details to see details
...
  File "<string>", line 15, in <module>
ImportError: cannot import name _

In case I'm not the only person running an ancient Calibre, the solution is:
1. Add the single line `127.0.0.1 code.calibre-ebook.com` to `C:\Windows\System32\drivers\etc`

2. Rename or Delete the file `Calibre Settings\metadata-sources-cache.json'

The reason for this error are with the dynamic code execution that Calibre does when it checks updates. This mechanism does not check a version number so it will run python code intended for new Calibre releases on old versions.

That mechanism is in the Updates plugin at https://github.com/kovidgoyal/calibr...rces/update.py
Note that this plugin is expressly forbidden to be disabled in the Calibre UI!

The code will fetch `https://code.calibre-ebook.com/metadata-sources/hashes.json` (which, despite the file name, is `bzip2` compressed. It can be expanded with `bzcat`. If a hash in this download doesn't match the previous hashes, calibre will fetch the updated python code from `https://code.calibre-ebook.com/metadata-sources/<NAME>` (eg, google, amazon, etc)
Then, it will pass that code directly to `exec()`

I was worried when I first looked at this, because `code.calibre-ebook.com` has a strange certificate - fortunately it is self-signed so that only people with the private key can dynamically run Python code on every Calibre installation.

The initial error was because the new plugins all use the Python "throwaway" syntax in an import:
Code:

from calibre.utils.localization import _
Fortunately I'm not paranoid, and I don't believe that any actor would POSSIBLY compel a software developer to serve specific code to a specific IP range, and anyone who can think of counter examples is a conspiracy theorist.

Viewing all articles
Browse latest Browse all 50094

Latest Images

Trending Articles



Latest Images