4397. [bug] Update Windows python support. [RT #42538]

(cherry picked from commit 9f5443280f)
This commit is contained in:
Mark Andrews
2016-06-24 16:13:30 +10:00
parent 7e609eff3d
commit 63533a891f
12 changed files with 175 additions and 23 deletions

View File

@@ -19,7 +19,8 @@ import os
import sys
sys.path.insert(0, os.path.dirname(sys.argv[0]))
sys.path.insert(1, os.path.join('@prefix@', 'lib'))
if os.name != 'nt':
sys.path.insert(1, os.path.join('@prefix@', 'lib'))
import isc.checkds

View File

@@ -19,7 +19,8 @@ import os
import sys
sys.path.insert(0, os.path.dirname(sys.argv[0]))
sys.path.insert(1, os.path.join('@prefix@', 'lib'))
if os.name != 'nt':
sys.path.insert(1, os.path.join('@prefix@', 'lib'))
import isc.coverage

View File

@@ -31,13 +31,32 @@ def prefix(bindir=''):
if os.name != 'nt':
return os.path.join('@prefix@', bindir)
hklm = win32con.HKEY_LOCAL_MACHINE
bind_subkey = "Software\\ISC\\BIND"
sam = win32con.KEY_READ
h_key = None
key_found = True
# can fail if the registry redirected for 32/64 bits
try:
h_key = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, bind_subkey)
h_key = win32api.RegOpenKeyEx(hklm, bind_subkey, 0, sam)
except:
key_found = False
# retry for 32 bit python with 64 bit bind9
if not key_found:
key_found = True
sam64 = sam | win32con.KEY_WOW64_64KEY
try:
h_key = win32api.RegOpenKeyEx(hklm, bind_subkey, 0, sam64)
except:
key_found = False
# retry 64 bit python with 32 bit bind9
if not key_found:
key_found = True
sam32 = sam | win32con.KEY_WOW64_32KEY
try:
h_key = win32api.RegOpenKeyEx(hklm, bind_subkey, 0, sam32)
except:
key_found = False
if key_found:
try:
(named_base, _) = win32api.RegQueryValueEx(h_key, "InstallDir")
@@ -56,4 +75,7 @@ def shellquote(s):
version = '@BIND9_VERSION@'
sysconfdir = '@expanded_sysconfdir@'
if os.name != 'nt':
sysconfdir = '@expanded_sysconfdir@'
else:
sysconfdir = prefix('etc')