Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(845)

Unified Diff: win_toolchain/get_toolchain_if_necessary.py

Issue 1614663003: Locate appropriate "winreg" module under both native Win32 and CygWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: win_toolchain/get_toolchain_if_necessary.py
diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py
index b3cc347fd4984f079b5d503d3848afcede9f194b..07e82729eee15089c6fbe9d90f4d8e99d580a6c9 100755
--- a/win_toolchain/get_toolchain_if_necessary.py
+++ b/win_toolchain/get_toolchain_if_necessary.py
@@ -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.
"""
-import _winreg
import hashlib
import json
import optparse
@@ -39,6 +38,23 @@ import tempfile
import time
import zipfile
+# winreg isn't natively available under CygWin
+if sys.platform == "win32":
+ try:
+ import winreg
brucedawson 2016/01/21 21:03:22 Why are you importing winreg? Why not just "import
+ 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__))
DEPOT_TOOLS_PATH = os.path.join(BASEDIR, '..')
@@ -227,10 +243,10 @@ def GetInstallerName():
version APIs helpfully return a maximum of 6.2 (Windows 8).
"""
key_name = r'Software\Microsoft\Windows NT\CurrentVersion'
- key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name)
- value, keytype = _winreg.QueryValueEx(key, "CurrentVersion")
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_name)
+ value, keytype = winreg.QueryValueEx(key, "CurrentVersion")
key.Close()
- if keytype != _winreg.REG_SZ:
+ if keytype != winreg.REG_SZ:
raise Exception("Unexpected type in registry")
if value == '6.1':
# Windows 7 and Windows Server 2008 R2
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698