diff options
author | Derek Tracy <[email protected]> | 2021-02-24 20:54:39 -0500 |
---|---|---|
committer | NoDRM <[email protected]> | 2021-11-16 21:22:13 +0100 |
commit | 1545d76803da31873e3dd956b34776ca37874c36 (patch) | |
tree | 59d2246770c638e64ca753beee37cec9ba7f42fd /Other_Tools | |
parent | d9353bdd9372f607d9ab8a8059ee4469541406a8 (diff) |
Support Python 2.7 and Python 3 winreg imports on Windows
Diffstat (limited to 'Other_Tools')
4 files changed, 16 insertions, 4 deletions
diff --git a/Other_Tools/DRM_Key_Scripts/Adobe_Digital_Editions/adobekey.pyw b/Other_Tools/DRM_Key_Scripts/Adobe_Digital_Editions/adobekey.pyw index bc33567..cbc3038 100644 --- a/Other_Tools/DRM_Key_Scripts/Adobe_Digital_Editions/adobekey.pyw +++ b/Other_Tools/DRM_Key_Scripts/Adobe_Digital_Editions/adobekey.pyw @@ -129,7 +129,10 @@ if iswindows: c_long, c_ulong from ctypes.wintypes import LPVOID, DWORD, BOOL - import winreg + try: + import winreg + except ImportError: + import _winreg as winreg def _load_crypto_libcrypto(): from ctypes.util import find_library diff --git a/Other_Tools/DRM_Key_Scripts/Barnes_and_Noble_ePubs/ignoblekey.pyw b/Other_Tools/DRM_Key_Scripts/Barnes_and_Noble_ePubs/ignoblekey.pyw index 7365c94..f6a93eb 100644 --- a/Other_Tools/DRM_Key_Scripts/Barnes_and_Noble_ePubs/ignoblekey.pyw +++ b/Other_Tools/DRM_Key_Scripts/Barnes_and_Noble_ePubs/ignoblekey.pyw @@ -98,7 +98,10 @@ def getNookLogFiles(): logFiles = [] found = False if iswindows: - import winreg + try: + import winreg + except ImportError: + import _winreg as winreg # some 64 bit machines do not have the proper registry key for some reason # or the python interface to the 32 vs 64 bit registry is broken diff --git a/Other_Tools/DRM_Key_Scripts/Kindle_for_Mac_and_PC/kindlekey.pyw b/Other_Tools/DRM_Key_Scripts/Kindle_for_Mac_and_PC/kindlekey.pyw index 4837627..99b8d22 100644 --- a/Other_Tools/DRM_Key_Scripts/Kindle_for_Mac_and_PC/kindlekey.pyw +++ b/Other_Tools/DRM_Key_Scripts/Kindle_for_Mac_and_PC/kindlekey.pyw @@ -177,7 +177,10 @@ if iswindows: create_unicode_buffer, create_string_buffer, CFUNCTYPE, addressof, \ string_at, Structure, c_void_p, cast - import winreg + try: + import winreg + except ImportError: + import _winreg as winreg MAX_PATH = 255 kernel32 = windll.kernel32 advapi32 = windll.advapi32 diff --git a/Other_Tools/Kobo/obok.py b/Other_Tools/Kobo/obok.py index 98608c5..6f87114 100644 --- a/Other_Tools/Kobo/obok.py +++ b/Other_Tools/Kobo/obok.py @@ -346,7 +346,10 @@ class KoboLibrary(object): if (self.kobodir == u""): # step 4. we haven't found a device with serials, so try desktop apps if sys.platform.startswith('win'): - import winreg + try: + import winreg + except ImportError: + import _winreg as winreg if sys.getwindowsversion().major > 5: if 'LOCALAPPDATA' in os.environ.keys(): # Python 2.x does not return unicode env. Use Python 3.x |