Commit c0ff2f64 authored by bcwhite@chromium.org's avatar bcwhite@chromium.org

Locate appropriate "winreg" module under both native Win32 and CygWin.

BUG=

Review URL: https://codereview.chromium.org/1614663003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298362 0039d316-1c4b-4281-b951-d872f2087c98
parent ff68735d
...@@ -26,7 +26,6 @@ future when a hypothetical VS2015 is released, the 2013 script will be ...@@ -26,7 +26,6 @@ future when a hypothetical VS2015 is released, the 2013 script will be
maintained, and a new 2015 script would be added. maintained, and a new 2015 script would be added.
""" """
import _winreg
import hashlib import hashlib
import json import json
import optparse import optparse
...@@ -39,6 +38,23 @@ import tempfile ...@@ -39,6 +38,23 @@ import tempfile
import time import time
import zipfile import zipfile
# winreg isn't natively available under CygWin
if sys.platform == "win32":
try:
import winreg
except ImportError:
import _winreg as winreg
elif sys.platform == "cygwin":
try:
import cygwinreg as winreg
except ImportError:
print ''
print 'CygWin does not natively support winreg but a replacement exists.'
print 'https://pypi.python.org/pypi/cygwinreg/'
print ''
print 'Try: easy_install cygwinreg'
print ''
raise
BASEDIR = os.path.dirname(os.path.abspath(__file__)) BASEDIR = os.path.dirname(os.path.abspath(__file__))
DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..') DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..')
...@@ -227,10 +243,10 @@ def GetInstallerName(): ...@@ -227,10 +243,10 @@ def GetInstallerName():
version APIs helpfully return a maximum of 6.2 (Windows 8). version APIs helpfully return a maximum of 6.2 (Windows 8).
""" """
key_name = r'Software\Microsoft\Windows NT\CurrentVersion' key_name = r'Software\Microsoft\Windows NT\CurrentVersion'
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name) key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_name)
value, keytype = _winreg.QueryValueEx(key, "CurrentVersion") value, keytype = winreg.QueryValueEx(key, "CurrentVersion")
key.Close() key.Close()
if keytype != _winreg.REG_SZ: if keytype != winreg.REG_SZ:
raise Exception("Unexpected type in registry") raise Exception("Unexpected type in registry")
if value == '6.1': if value == '6.1':
# Windows 7 and Windows Server 2008 R2 # Windows 7 and Windows Server 2008 R2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment