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

Unified Diff: win_toolchain/get_toolchain_if_necessary.py

Issue 1181943003: make `python build/vs_toolchain.py update` work a bit better on non-windows (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 6 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 b06daf6c53f516647bb23e3b593e040165530236..9f434cc7468e47a2d59239e4471d4e42cdae8ce7 100755
--- a/win_toolchain/get_toolchain_if_necessary.py
+++ b/win_toolchain/get_toolchain_if_necessary.py
@@ -48,7 +48,7 @@ except ImportError:
# on bare VM that doesn't have a full depot_tools.
pass
-if sys.platform != 'cygwin':
+if sys.platform == 'win32':
import ctypes.wintypes
GetFileAttributes = ctypes.windll.kernel32.GetFileAttributesW
GetFileAttributes.argtypes = (ctypes.wintypes.LPWSTR,)
@@ -56,10 +56,11 @@ if sys.platform != 'cygwin':
FILE_ATTRIBUTE_HIDDEN = 0x2
FILE_ATTRIBUTE_SYSTEM = 0x4
-
def IsHidden(file_path):
"""Returns whether the given |file_path| has the 'system' or 'hidden'
attribute set."""
+ if sys.platform != 'win32':
+ return False
Nico 2015/06/12 05:29:05 …so I have to do this, which means the hashes will
scottmg 2015/06/12 16:59:12 I had forgotten why. The long ago rationale was he
Nico 2015/06/12 17:04:29 No, I just saw that the hash didn't match and figu
p = GetFileAttributes(file_path)
assert p != 0xffffffff
return bool(p & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM))
@@ -144,7 +145,7 @@ def HaveSrcInternalAccess():
def LooksLikeGoogler():
"""Checks for a USERDOMAIN environment variable of 'GOOGLE', which
probably implies the current user is a Googler."""
- return os.environ.get('USERDOMAIN').upper() == 'GOOGLE'
+ return os.environ.get('USERDOMAIN', '').upper() == 'GOOGLE'
def CanAccessToolchainBucket():
@@ -216,12 +217,12 @@ def DoTreeMirror(target_dir, tree_sha1):
with zipfile.ZipFile(local_zip, 'r', zipfile.ZIP_DEFLATED, True) as zf:
zf.extractall(target_dir)
if temp_dir:
- subprocess.check_call('rmdir /s/q "%s"' % temp_dir, shell=True)
+ shutil.rmtree(temp_dir, ignore_errors=True)
scottmg 2015/06/12 16:59:12 This function is terrible, and fails for files mar
Nico 2015/06/12 17:04:29 TIL! Could the onerror handler in the first reply
scottmg 2015/06/12 17:13:56 Looks like it, but it seems longer than an if win:
def main():
- if not sys.platform.startswith(('cygwin', 'win32')):
- return 0
+ #if not sys.platform.startswith(('cygwin', 'win32')):
+ #return 0
parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
parser.add_option('--output-json', metavar='FILE',
@@ -280,11 +281,12 @@ def main():
sys.stdout.flush()
DelayBeforeRemoving(target_dir)
# This stays resident and will make the rmdir below fail.
- with open(os.devnull, 'wb') as nul:
- subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'],
- stdin=nul, stdout=nul, stderr=nul)
+ if sys.platform in ('win32', 'cygwin'):
+ with open(os.devnull, 'wb') as nul:
+ subprocess.call(['taskkill', '/f', '/im', 'mspdbsrv.exe'],
+ stdin=nul, stdout=nul, stderr=nul)
if os.path.isdir(target_dir):
- subprocess.check_call('rmdir /s/q "%s"' % target_dir, shell=True)
+ shutil.rmtree(target_dir, ignore_errors=True);
DoTreeMirror(target_dir, desired_hashes[0])
« 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