mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-11-16 19:06:09 +06:00
Changes to make obok work on win
_winreg renamed to winreg in python 3 os.popen3() replaced by subprocess.Popen()
This commit is contained in:
parent
21d4811bfe
commit
7f758566d3
|
@ -409,12 +409,12 @@ elif isosx:
|
||||||
cmdline = cmdline.encode(sys.getfilesystemencoding())
|
cmdline = cmdline.encode(sys.getfilesystemencoding())
|
||||||
p2 = subprocess.Popen(cmdline, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
|
p2 = subprocess.Popen(cmdline, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
|
||||||
out1, out2 = p2.communicate()
|
out1, out2 = p2.communicate()
|
||||||
reslst = out1.split('\n')
|
reslst = out1.split(b'\n')
|
||||||
cnt = len(reslst)
|
cnt = len(reslst)
|
||||||
ActDatPath = "activation.dat"
|
ActDatPath = b"activation.dat"
|
||||||
for j in range(cnt):
|
for j in range(cnt):
|
||||||
resline = reslst[j]
|
resline = reslst[j]
|
||||||
pp = resline.find('activation.dat')
|
pp = resline.find(b'activation.dat')
|
||||||
if pp >= 0:
|
if pp >= 0:
|
||||||
ActDatPath = resline
|
ActDatPath = resline
|
||||||
break
|
break
|
||||||
|
@ -474,7 +474,7 @@ def cli_main():
|
||||||
sys.stderr=SafeUnbuffered(sys.stderr)
|
sys.stderr=SafeUnbuffered(sys.stderr)
|
||||||
argv=unicode_argv()
|
argv=unicode_argv()
|
||||||
progname = os.path.basename(argv[0])
|
progname = os.path.basename(argv[0])
|
||||||
print("{0} v{1}\nCopyright © 2009-2013 i♥cabbages and Apprentice Alf".format(progname,__version__))
|
print("{0} v{1}\nCopyright © 2009-2020 i♥cabbages, Apprentice Harper et al.".format(progname,__version__))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv[1:], "h")
|
opts, args = getopt.getopt(argv[1:], "h")
|
||||||
|
@ -494,7 +494,9 @@ def cli_main():
|
||||||
|
|
||||||
if len(args) == 1:
|
if len(args) == 1:
|
||||||
# save to the specified file or directory
|
# save to the specified file or directory
|
||||||
outpath = os.path.abspath(args[0])
|
outpath = args[0]
|
||||||
|
if not os.path.isabs(outpath):
|
||||||
|
outpath = os.path.abspath(outpath)
|
||||||
else:
|
else:
|
||||||
# save to the same directory as the script
|
# save to the same directory as the script
|
||||||
outpath = os.path.dirname(argv[0])
|
outpath = os.path.dirname(argv[0])
|
||||||
|
|
|
@ -353,7 +353,7 @@ class KoboLibrary(object):
|
||||||
|
|
||||||
if (self.kobodir == u""):
|
if (self.kobodir == u""):
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
import _winreg as winreg
|
import winreg
|
||||||
if sys.getwindowsversion().major > 5:
|
if sys.getwindowsversion().major > 5:
|
||||||
if 'LOCALAPPDATA' in os.environ.keys():
|
if 'LOCALAPPDATA' in os.environ.keys():
|
||||||
# Python 2.x does not return unicode env. Use Python 3.x
|
# Python 2.x does not return unicode env. Use Python 3.x
|
||||||
|
@ -444,8 +444,8 @@ class KoboLibrary(object):
|
||||||
macaddrs = []
|
macaddrs = []
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
c = re.compile('\s(' + '[0-9a-f]{2}-' * 5 + '[0-9a-f]{2})(\s|$)', re.IGNORECASE)
|
c = re.compile('\s(' + '[0-9a-f]{2}-' * 5 + '[0-9a-f]{2})(\s|$)', re.IGNORECASE)
|
||||||
(p_in, p_out, p_err) = os.popen3('ipconfig /all')
|
output = subprocess.Popen('ipconfig /all', shell=True, stdout=subprocess.PIPE, text=True).stdout
|
||||||
for line in p_out:
|
for line in output:
|
||||||
m = c.search(line)
|
m = c.search(line)
|
||||||
if m:
|
if m:
|
||||||
macaddrs.append(re.sub("-", ":", m.group(1)).upper())
|
macaddrs.append(re.sub("-", ":", m.group(1)).upper())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user