From 5451766f0a3e5153d1863576b2bd435b1b2a3591 Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Thu, 16 Dec 2021 14:28:55 +0100 Subject: [PATCH] Ignore HTTP500 in optional notifications --- calibre-plugin/__init__.py | 2 ++ calibre-plugin/libadobe.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index 6bd35c7..6d74f93 100644 --- a/calibre-plugin/__init__.py +++ b/calibre-plugin/__init__.py @@ -33,6 +33,8 @@ # fix ACSM files from Google Play books (no metadata node), # allow converting an anonymous auth to an AdobeID auth, # update python-cryptography from 3.4.8 to 36.0.1, update python-rsa from 4.7.2 to 4.8. +# Currently in development: +# Ignore fatal HTTP errors during optional fulfillment notifications. PLUGIN_NAME = "DeACSM" PLUGIN_VERSION_TUPLE = (0, 0, 15) diff --git a/calibre-plugin/libadobe.py b/calibre-plugin/libadobe.py index 522134c..24bcb74 100644 --- a/calibre-plugin/libadobe.py +++ b/calibre-plugin/libadobe.py @@ -271,7 +271,13 @@ def sendPOSTHTTPRequest(URL: str, document: bytes, type: str, returnRC = False): ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url=URL, headers=headers, data=document) - handler = urllib.request.urlopen(req, context=ctx) + try: + handler = urllib.request.urlopen(req, context=ctx) + except urllib.error.HTTPError as err: + # This happens with HTTP 500 and related errors. + print("Post request caused HTTPError %d" % (err.code)) + return err.code, "Post request caused HTTPException" + ret_code = handler.getcode() if (ret_code == 204 and returnRC):