From b2b88abd062b38309dde6498ab432bc7b701a3ae Mon Sep 17 00:00:00 2001 From: Florian Bach Date: Wed, 11 May 2022 06:46:35 +0200 Subject: [PATCH] Cleanup --- calibre-plugin/libadobe.py | 12 +++++++++--- calibre-plugin/libadobeFulfill.py | 5 ++--- calibre-plugin/libadobeImportAccount.py | 10 ++-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/calibre-plugin/libadobe.py b/calibre-plugin/libadobe.py index 7ec439a..d47618d 100644 --- a/calibre-plugin/libadobe.py +++ b/calibre-plugin/libadobe.py @@ -325,12 +325,18 @@ def sendPOSTHTTPRequest(URL, document, type, returnRC = False): except uliberror.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" + if returnRC: + return err.code, "Post request caused HTTPException" + else: + return None + except uliberror.URLError as err: # This happens if the hostname cannot be resolved. print("Post request failed with URLError") - return 900, "Post request failed with URLError" - + if returnRC: + return 900, "Post request failed with URLError" + else: + return None ret_code = handler.getcode() if (ret_code == 204 and returnRC): diff --git a/calibre-plugin/libadobeFulfill.py b/calibre-plugin/libadobeFulfill.py index 7904fee..a16b5e1 100644 --- a/calibre-plugin/libadobeFulfill.py +++ b/calibre-plugin/libadobeFulfill.py @@ -144,11 +144,10 @@ def buildAuthRequest(): user_pkcs12 = base64.b64decode(activationxml.find("./%s/%s" % (adNS("credentials"), adNS("pkcs12"))).text) - try: - from calibre_plugins.deacsm.libadobe import devkey_bytes as devkey_adobe - except: from libadobe import devkey_bytes as devkey_adobe + except: + pass if devkey_adobe is not None: devkey_bytes = devkey_adobe diff --git a/calibre-plugin/libadobeImportAccount.py b/calibre-plugin/libadobeImportAccount.py index 1dd8f73..3b11769 100644 --- a/calibre-plugin/libadobeImportAccount.py +++ b/calibre-plugin/libadobeImportAccount.py @@ -34,10 +34,7 @@ def importADEactivationLinuxWine(wine_prefix_path, buildIDtoEmulate=VAR_VER_DEFA pass # Get encryption key - try: - from getEncryptionKeyLinux import GetMasterKey - except: - from calibre_plugins.deacsm.getEncryptionKeyLinux import GetMasterKey + from getEncryptionKeyLinux import GetMasterKey master_key = GetMasterKey(wine_prefix_path) @@ -120,10 +117,7 @@ def importADEactivationWindows(buildIDtoEmulate=VAR_VER_DEFAULT_BUILD_ID): return False, "Windows only!" # Get encryption key: - try: - from getEncryptionKeyWindows import GetMasterKey - except: - from calibre_plugins.deacsm.getEncryptionKeyWindows import GetMasterKey + from getEncryptionKeyWindows import GetMasterKey master_key = GetMasterKey()