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

Unified Diff: tools/utils.py

Issue 350483003: Build Tools Cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more fixes as reviewed by ricow Created 6 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 | « tools/testing/webdriver_test_setup.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/utils.py
diff --git a/tools/utils.py b/tools/utils.py
index f8fe68cf100b3da76a90a507dfe75de028e7272e..60db842acf62ddacd11e33ae9f0adc3003dd32ca 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
@@ -11,8 +11,8 @@ import platform
import re
import shutil
import subprocess
-import sys
import tempfile
+import sys
class Version(object):
def __init__(self, channel, major, minor, patch, prerelease,
@@ -26,20 +26,20 @@ class Version(object):
# Try to guess the host operating system.
def GuessOS():
- id = platform.system()
- if id == "Linux":
+ os_id = platform.system()
+ if os_id == "Linux":
return "linux"
- elif id == "Darwin":
+ elif os_id == "Darwin":
return "macos"
- elif id == "Windows" or id == "Microsoft":
+ elif os_id == "Windows" or os_id == "Microsoft":
# On Windows Vista platform.system() can return "Microsoft" with some
# versions of Python, see http://bugs.python.org/issue1082 for details.
return "win32"
- elif id == 'FreeBSD':
+ elif os_id == 'FreeBSD':
return 'freebsd'
- elif id == 'OpenBSD':
+ elif os_id == 'OpenBSD':
return 'openbsd'
- elif id == 'SunOS':
+ elif os_id == 'SunOS':
return 'solaris'
else:
return None
@@ -47,22 +47,23 @@ def GuessOS():
# Try to guess the host architecture.
def GuessArchitecture():
- id = platform.machine()
- if id.startswith('arm'):
+ os_id = platform.machine()
+ if os_id.startswith('arm'):
return 'arm'
- elif id.startswith('aarch64'):
+ elif os_id.startswith('aarch64'):
return 'arm64'
- elif id.startswith('mips'):
+ elif os_id.startswith('mips'):
return 'mips'
- elif (not id) or (not re.match('(x|i[3-6])86', id) is None):
+ elif (not os_id) or (not re.match('(x|i[3-6])86', os_id) is None):
return 'ia32'
- elif id == 'i86pc':
+ elif os_id == 'i86pc':
return 'ia32'
- elif '64' in id:
+ elif '64' in os_id:
return 'x64'
else:
guess_os = GuessOS()
- print "Warning: Guessing architecture %s based on os %s\n" % (id, guess_os)
+ print "Warning: Guessing architecture %s based on os %s\n"\
+ % (os_id, guess_os)
if guess_os == 'win32':
return 'ia32'
return None
@@ -97,7 +98,7 @@ def GuessVisualStudioPath():
defaultExecutable = "devenv.com"
if not IsWindows():
- return (defaultPath, defaultExecutable)
+ return defaultPath, defaultExecutable
keyNamesAndExecutables = [
# Pair for non-Express editions.
@@ -122,7 +123,7 @@ def GuessVisualStudioPath():
while True:
try:
subkeyName = _winreg.EnumKey(key, subkeyCounter)
- subkeyCounter = subkeyCounter + 1
+ subkeyCounter += 1
except WindowsError:
# Reached end of enumeration. Moving on the next key.
break
@@ -140,7 +141,7 @@ def GuessVisualStudioPath():
if not isExpress and subkeyName == '10.0':
# Stop search since if we found non-Express VS2010 version
# installed, which is preferred version.
- return (installDir, executable)
+ return installDir, executable
else:
version = float(subkeyName)
# We prefer higher version of Visual Studio and given equal
@@ -172,7 +173,7 @@ def ReadLinesFrom(name):
# Filters out all arguments until the next '--' argument
# occurs.
-def ListArgCallback(option, opt_str, value, parser):
+def ListArgCallback(option, value, parser):
if value is None:
value = []
@@ -187,7 +188,7 @@ def ListArgCallback(option, opt_str, value, parser):
# Filters out all argument until the first non '-' or the
# '--' argument occurs.
-def ListDartArgCallback(option, opt_str, value, parser):
+def ListDartArgCallback(option, value, parser):
if value is None:
value = []
@@ -254,11 +255,11 @@ def GetBuildConf(mode, arch, conf_os=None):
cross_build = 'X'
return '%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper())
-def GetBuildDir(host_os, target_os):
+def GetBuildDir(host_os):
return BUILD_ROOT[host_os]
-def GetBuildRoot(host_os, mode=None, arch=None, target_os=None):
- build_root = GetBuildDir(host_os, target_os)
+def GetBuildRoot(host_os, mode=None, arch=None):
+ build_root = GetBuildDir(host_os)
if mode:
build_root = os.path.join(build_root, GetBuildConf(mode, arch))
return build_root
@@ -315,8 +316,8 @@ def GetUserName():
return os.environ.get(key, '')
def ReadVersionFile():
- def match_against(pattern, content):
- match = re.search(pattern, content, flags=re.MULTILINE)
+ def match_against(pattern, file_content):
+ match = re.search(pattern, file_content, flags=re.MULTILINE)
if match:
return match.group(1)
return None
@@ -410,7 +411,7 @@ def RewritePathSeparator(path, workspace):
# Paths in test files are always specified using '/'
# as the path separator. Replace with the actual
# path separator before use.
- if ('/' in path):
+ if '/' in path:
split_path = path.split('/')
path = os.sep.join(split_path)
path = os.path.join(workspace, path)
@@ -434,7 +435,7 @@ def ParseTestOptionsMultiple(pattern, source, workspace):
for match in matches:
if len(match) > 0:
result.append(
- [RewritePathSeparator(o, workspace) for o in match.split(' ')]);
+ [RewritePathSeparator(o, workspace) for o in match.split(' ')])
else:
result.append([])
return result
@@ -452,7 +453,7 @@ def ConfigureJava():
if proc.wait() != 0:
return None
new = stdout.strip()
- current = os.getenv('JAVA_HOME', default=new)
+ current = os.getenv('JAVA_HOME', new)
if current != new:
sys.stderr.write('Please set JAVA_HOME to %s\n' % new)
os.putenv('JAVA_HOME', new)
@@ -469,14 +470,14 @@ def Daemonize():
return False
os.setsid()
if os.fork() > 0:
- os._exit(0)
+ exit(0)
raise
return True
-def PrintError(str):
+def PrintError(string):
"""Writes and flushes a string to stderr."""
- sys.stderr.write(str)
+ sys.stderr.write(string)
sys.stderr.write('\n')
@@ -488,7 +489,7 @@ def CheckedUnlink(name):
PrintError("os.unlink() " + str(e))
-def Main(argv):
+def Main():
print "GuessOS() -> ", GuessOS()
print "GuessArchitecture() -> ", GuessArchitecture()
print "GuessCpus() -> ", GuessCpus()
@@ -536,7 +537,7 @@ def ExecuteCommand(cmd):
output = pipe.communicate()
if pipe.returncode != 0:
raise Exception('Execution failed: ' + str(output))
- return (pipe.returncode, output)
+ return pipe.returncode, output
def DartBinary():
@@ -590,4 +591,4 @@ class ChangedWorkingDirectory(object):
if __name__ == "__main__":
import sys
- Main(sys.argv)
+ Main()
« no previous file with comments | « tools/testing/webdriver_test_setup.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698