summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin
diff options
context:
space:
mode:
authorNoDRM <[email protected]>2023-06-24 09:53:55 +0200
committerNoDRM <[email protected]>2023-06-24 09:53:55 +0200
commitf86cff285be1ed43c296e4adc2c3899ca14fd64b (patch)
tree5da7f44df1e602b260edc045f793af3fd5099bd0 /DeDRM_plugin
parenta553a71f459b299f2bb3c9cfd7f83799fb9fbe55 (diff)
Fix python2 issues in Kindle and Nook code (#355)
Diffstat (limited to 'DeDRM_plugin')
-rw-r--r--DeDRM_plugin/ignoblekeyNookStudy.py17
-rw-r--r--DeDRM_plugin/kindlekey.py5
-rw-r--r--DeDRM_plugin/topazextract.py2
3 files changed, 20 insertions, 4 deletions
diff --git a/DeDRM_plugin/ignoblekeyNookStudy.py b/DeDRM_plugin/ignoblekeyNookStudy.py
index 6a5f1cf..4cf5246 100644
--- a/DeDRM_plugin/ignoblekeyNookStudy.py
+++ b/DeDRM_plugin/ignoblekeyNookStudy.py
@@ -54,15 +54,26 @@ def getNookLogFiles():
paths = set()
if 'LOCALAPPDATA' in os.environ.keys():
# Python 2.x does not return unicode env. Use Python 3.x
- path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
+ if sys.version_info[0] == 2:
+ path = winreg.ExpandEnvironmentStrings(u"%LOCALAPPDATA%")
+ else:
+ path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
if os.path.isdir(path):
paths.add(path)
if 'USERPROFILE' in os.environ.keys():
# Python 2.x does not return unicode env. Use Python 3.x
- path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Local"
+ if sys.version_info[0] == 2:
+ path = winreg.ExpandEnvironmentStrings(u"%USERPROFILE%")+u"\\AppData\\Local"
+ else:
+ path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Local"
+
if os.path.isdir(path):
paths.add(path)
- path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Roaming"
+
+ if sys.version_info[0] == 2:
+ path = winreg.ExpandEnvironmentStrings(u"%USERPROFILE%")+u"\\AppData\\Roaming"
+ else:
+ path = winreg.ExpandEnvironmentStrings("%USERPROFILE%")+"\\AppData\\Roaming"
if os.path.isdir(path):
paths.add(path)
# User Shell Folders show take precedent over Shell Folders if present
diff --git a/DeDRM_plugin/kindlekey.py b/DeDRM_plugin/kindlekey.py
index 60a6065..14e4ed1 100644
--- a/DeDRM_plugin/kindlekey.py
+++ b/DeDRM_plugin/kindlekey.py
@@ -279,7 +279,10 @@ if iswindows:
path = ""
if 'LOCALAPPDATA' in os.environ.keys():
# Python 2.x does not return unicode env. Use Python 3.x
- path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
+ if sys.version_info[0] == 2:
+ path = winreg.ExpandEnvironmentStrings(u"%LOCALAPPDATA%")
+ else:
+ path = winreg.ExpandEnvironmentStrings("%LOCALAPPDATA%")
# this is just another alternative.
# path = getEnvironmentVariable('LOCALAPPDATA')
if not os.path.isdir(path):
diff --git a/DeDRM_plugin/topazextract.py b/DeDRM_plugin/topazextract.py
index 1eaa2a5..8848bd9 100644
--- a/DeDRM_plugin/topazextract.py
+++ b/DeDRM_plugin/topazextract.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
+from __future__ import print_function
+
# topazextract.py
# Mostly written by some_updates based on code from many others