Rename utils.utils to utils.misc to prevent Python from being confused.
Tested:
N/A
PRESUBMIT=passed
R=asharif
DELTA=506 (234 added, 210 deleted, 62 changed)
OCL=59036-p2
RCL=59059-p2
RDATE=2012/03/12 13:50:53
P4 change: 42672835
diff --git a/v14/build_benchmarks.py b/v14/build_benchmarks.py
index 1f0b783..41079f8 100755
--- a/v14/build_benchmarks.py
+++ b/v14/build_benchmarks.py
@@ -32,11 +32,11 @@
import os
import sys
import re
-import tc_enter_chroot
+
import build_chromeos
+import tc_enter_chroot
from utils import command_executer
from utils import logger
-from utils import utils
KNOWN_BENCHMARKS = [
diff --git a/v14/build_chrome_browser.py b/v14/build_chrome_browser.py
index ae63a60..0247491 100755
--- a/v14/build_chrome_browser.py
+++ b/v14/build_chrome_browser.py
@@ -14,10 +14,11 @@
import os
import shutil
import sys
+
+import build_chromeos
from utils import command_executer
from utils import logger
-from utils import utils
-import build_chromeos
+from utils import misc
cmd_executer = None
@@ -102,14 +103,14 @@
# Build image
ret = (cmd_executer.
ChrootRunCommand(options.chromeos_root,
- utils.GetBuildImageCommand(options.board)))
+ misc.GetBuildImageCommand(options.board)))
logger.GetLogger().LogFatalIf(ret, "build_image failed")
# Mod image for test
ret = (cmd_executer.
ChrootRunCommand(options.chromeos_root,
- utils.GetModImageForTestCommand(options.board)))
+ misc.GetModImageForTestCommand(options.board)))
logger.GetLogger().LogFatalIf(ret, "mod_image_for_test failed")
diff --git a/v14/build_chromeos.py b/v14/build_chromeos.py
index d82c44a..cec4255 100755
--- a/v14/build_chromeos.py
+++ b/v14/build_chromeos.py
@@ -13,10 +13,11 @@
import optparse
import os
import sys
+
import tc_enter_chroot
from utils import command_executer
from utils import logger
-from utils import utils
+from utils import misc
def Usage(parser, message):
@@ -90,12 +91,12 @@
MakeChroot(options.chromeos_root, options.clobber_chroot)
- build_packages_command = utils.GetBuildPackagesCommand(options.board)
- build_image_command = utils.GetBuildImageCommand(options.board)
- mod_image_command = utils.GetModImageForTestCommand(options.board)
+ build_packages_command = misc.GetBuildPackagesCommand(options.board)
+ build_image_command = misc.GetBuildImageCommand(options.board)
+ mod_image_command = misc.GetModImageForTestCommand(options.board)
if options.vanilla == True:
- command = utils.GetSetupBoardCommand(options.board,
+ command = misc.GetSetupBoardCommand(options.board,
usepkg=False,
force=options.clobber_board)
command += "; " + build_packages_env + " " + build_packages_command
@@ -108,11 +109,11 @@
if not os.path.isdir(options.chromeos_root + "/chroot/build/"
+ options.board) or options.clobber_board:
# Run build_tc.py from binary package
- rootdir = utils.GetRoot(argv[0])[0]
- version_number = utils.GetRoot(rootdir)[1]
+ rootdir = misc.GetRoot(argv[0])[0]
+ version_number = misc.GetRoot(rootdir)[1]
ret = cmd_executer.ChrootRunCommand(
options.chromeos_root,
- utils.GetSetupBoardCommand(options.board,
+ misc.GetSetupBoardCommand(options.board,
gcc_version="9999",
binutils_version="9999",
force=options.clobber_board))
diff --git a/v14/build_tc.py b/v14/build_tc.py
index e6dd46f..c344aef 100755
--- a/v14/build_tc.py
+++ b/v14/build_tc.py
@@ -14,19 +14,20 @@
import os
import sys
import tempfile
+
import tc_enter_chroot
from utils import command_executer
-from utils import utils
+from utils import misc
class ToolchainPart(object):
def __init__(self, name, source_path, chromeos_root, board, incremental,
build_env):
self._name = name
- self._source_path = utils.CanonicalizePath(source_path)
+ self._source_path = misc.CanonicalizePath(source_path)
self._chromeos_root = chromeos_root
self._board = board
- self._ctarget = utils.GetCtargetFromBoard(self._board,
+ self._ctarget = misc.GetCtargetFromBoard(self._board,
self._chromeos_root)
self._ce = command_executer.GetCommandExecuter()
self._mask_file = os.path.join(
@@ -199,11 +200,11 @@
options, _ = parser.parse_args(argv)
- chromeos_root = utils.CanonicalizePath(options.chromeos_root)
+ chromeos_root = misc.CanonicalizePath(options.chromeos_root)
if options.gcc_dir:
- gcc_dir = utils.CanonicalizePath(options.gcc_dir)
+ gcc_dir = misc.CanonicalizePath(options.gcc_dir)
if options.gdb_dir:
- gdb_dir = utils.CanonicalizePath(options.gdb_dir)
+ gdb_dir = misc.CanonicalizePath(options.gdb_dir)
if options.unmount_only:
options.mount_only = False
elif options.mount_only:
diff --git a/v14/command_executer_timeout_test.py b/v14/command_executer_timeout_test.py
index 9a10540..446651d 100755
--- a/v14/command_executer_timeout_test.py
+++ b/v14/command_executer_timeout_test.py
@@ -2,19 +2,14 @@
#
# Copyright 2010 Google Inc. All Rights Reserved.
-"""Script to wrap run_remote_tests.sh script.
-
-This script can login to the chromeos machine using the test private key.
-"""
-
__author__ = "asharif@google.com (Ahmad Sharif)"
import optparse
import os
import re
import sys
+
from utils import command_executer
-from utils import utils
def Usage(parser, message):
diff --git a/v14/compare_benchmarks.py b/v14/compare_benchmarks.py
index e583aa7..e63dfea 100755
--- a/v14/compare_benchmarks.py
+++ b/v14/compare_benchmarks.py
@@ -17,16 +17,16 @@
__author__ = "bjanakiraman@google.com (Bhaskar Janakiraman)"
+import glob
+import math
import optparse
import os
import re
import sys
-import glob
-import math
-import run_tests
+
import image_chromeos
+import run_tests
from utils import command_executer
-from utils import utils
from utils import logger
BENCHDIRS = "%s/default/default/*/gcc-4.4.3-glibc-2.11.1-grte-k8-opt/ref/*/results.txt"
diff --git a/v14/crb/crb_driver.py b/v14/crb/crb_driver.py
index 0343302..6cf7af3 100755
--- a/v14/crb/crb_driver.py
+++ b/v14/crb/crb_driver.py
@@ -1,17 +1,22 @@
+#!/usr/bin/python2.6
+#
+# Copyright 2010 Google Inc. All Rights Reserved.
+
import datetime
-from email.mime.text import MIMEText
import optparse
import os
import smtplib
import sys
import time
+from email.mime.text import MIMEText
+
from autotest_gatherer import AutotestGatherer as AutotestGatherer
from autotest_run import AutotestRun as AutotestRun
from machine_manager_singleton import MachineManagerSingleton as MachineManagerSingleton
from utils import logger
-from utils import utils
from utils.file_utils import FileUtils
+
def CanonicalizeChromeOSRoot(chromeos_root):
chromeos_root = os.path.expanduser(chromeos_root)
if os.path.isfile(os.path.join(chromeos_root,
diff --git a/v14/crosperf/autotest_runner.py b/v14/crosperf/autotest_runner.py
index 5df71ac..3b91d81 100644
--- a/v14/crosperf/autotest_runner.py
+++ b/v14/crosperf/autotest_runner.py
@@ -1,9 +1,8 @@
#!/usr/bin/python
-
+#
# Copyright 2011 Google Inc. All Rights Reserved.
from utils import command_executer
-from utils import utils
class AutotestRunner(object):
diff --git a/v14/crosperf/perf_processor.py b/v14/crosperf/perf_processor.py
index 031f35d..5be3155 100644
--- a/v14/crosperf/perf_processor.py
+++ b/v14/crosperf/perf_processor.py
@@ -1,11 +1,11 @@
#!/usr/bin/python
-
+#
# Copyright 2011 Google Inc. All Rights Reserved.
import os
import re
+
from utils import command_executer
-from utils import utils
class PerfProcessor(object):
diff --git a/v14/crosperf/results_cache.py b/v14/crosperf/results_cache.py
index b8b495e..af13f9d 100644
--- a/v14/crosperf/results_cache.py
+++ b/v14/crosperf/results_cache.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-
+#
# Copyright 2011 Google Inc. All Rights Reserved.
import getpass
@@ -8,11 +8,12 @@
import os
import pickle
import re
+
from image_checksummer import ImageChecksummer
from perf_processor import PerfProcessor
from utils import command_executer
from utils import logger
-from utils import utils
+
SCRATCH_DIR = "/home/%s/cros_scratch" % getpass.getuser()
RESULTS_FILE = "results.txt"
diff --git a/v14/fdo_scripts/divide_and_merge_profiles.py b/v14/fdo_scripts/divide_and_merge_profiles.py
index 6f4ce4f..2cd80d5 100755
--- a/v14/fdo_scripts/divide_and_merge_profiles.py
+++ b/v14/fdo_scripts/divide_and_merge_profiles.py
@@ -1,19 +1,22 @@
-#!/usr/bin/python
+#!/usr/bin/python2.6
+#
+# Copyright 2011 Google Inc. All Rights Reserved.
-# Script to divide and merge profiles.
+"""Script to divide and merge profiles."""
+
import copy
import optparse
import os
import pickle
import re
import sys
+import tempfile
+
import build_chrome_browser
import lock_machine
import run_tests
-import tempfile
from utils import command_executer
from utils import logger
-from utils import utils
class ProfileMerger:
diff --git a/v14/fdo_scripts/divide_and_merge_profiles_test.py b/v14/fdo_scripts/divide_and_merge_profiles_test.py
index 30d1c94..fdd203e 100755
--- a/v14/fdo_scripts/divide_and_merge_profiles_test.py
+++ b/v14/fdo_scripts/divide_and_merge_profiles_test.py
@@ -2,19 +2,14 @@
#
# Copyright 2010 Google Inc. All Rights Reserved.
-"""lock_machine.py related unit-tests.
-
-MachineManagerTest tests MachineManager.
-"""
-
__author__ = "asharif@google.com (Ahmad Sharif)"
-
import os
import tempfile
import unittest
+
from utils import command_executer
-from utils import utils
+from utils import misc
class DivideAndMergeProfilesTest(unittest.TestCase):
@@ -24,7 +19,7 @@
print self._program_dir
self._writeProgram()
self._writeMakefile()
- with utils.WorkingDirectory(self._program_dir):
+ with misc.WorkingDirectory(self._program_dir):
self._ce.RunCommand("make")
num_profile_dirs = 2
self._profile_dirs = []
@@ -34,7 +29,7 @@
" %s/program" %
(profile_dir.count("/"),
self._program_dir))
- with utils.WorkingDirectory(profile_dir):
+ with misc.WorkingDirectory(profile_dir):
self._ce.RunCommand(command)
self._profile_dirs.append(profile_dir)
self._merge_program = "/home/build/static/projects/crosstool/profile-merge/v14.5/profile_merge.par"
diff --git a/v14/fdo_scripts/profile_cycler.py b/v14/fdo_scripts/profile_cycler.py
index c59ac61..e026069 100755
--- a/v14/fdo_scripts/profile_cycler.py
+++ b/v14/fdo_scripts/profile_cycler.py
@@ -1,21 +1,25 @@
-#!/usr/bin/python
+#!/usr/bin/python2.6
+#
+# Copyright 2011 Google Inc. All Rights Reserved.
-# Script to profile a page cycler, and get it back to the host.
+"""Script to profile a page cycler, and get it back to the host."""
+
import copy
-import cros_login
import optparse
import os
import pickle
import re
import sys
-import build_chrome_browser
-import lock_machine
-import run_tests
import tempfile
import time
+
+import build_chrome_browser
+import cros_login
+import lock_machine
+import run_tests
from utils import command_executer
from utils import logger
-from utils import utils
+from utils import misc
class CyclerProfiler:
@@ -141,7 +145,7 @@
# Strip out the initial prefix for the Chrome directory before doing the
# copy.
- chrome_dir_prefix = utils.GetChromeSrcDir()
+ chrome_dir_prefix = misc.GetChromeSrcDir()
command = "mkdir -p %s" % dest_dir
self._ce.RunCommand(command)
diff --git a/v14/fdo_scripts/vanilla_vs_fdo.py b/v14/fdo_scripts/vanilla_vs_fdo.py
index a81b1a0..4d00582 100644
--- a/v14/fdo_scripts/vanilla_vs_fdo.py
+++ b/v14/fdo_scripts/vanilla_vs_fdo.py
@@ -1,13 +1,17 @@
-#!/usr/bin/python
+#!/usr/bin/python2.6
+#
+# Copyright 2011 Google Inc. All Rights Reserved.
-# Script to profile a page cycler, and get it back to the host.
+"""Script to profile a page cycler, and get it back to the host."""
+
import optparse
import os
import sys
+
import build_chrome_browser
import setup_chromeos
from utils import command_executer
-from utils import utils
+from utils import misc
class FDOComparator(object):
@@ -24,13 +28,13 @@
setup_chromeos.Main(setup_chromeos_args)
def _BuildChromeOSUsingBinaries(self):
- command = utils.GetSetupBoardCommand(self._board,
+ command = misc.GetSetupBoardCommand(self._board,
usepkg=True)
ret = self._ce.ChrootRunCommand(self._chromeos_root,
command)
if ret:
raise Exception("Couldn't run setup_board!")
- command = utils.GetBuildPackagesCommand(self._board,
+ command = misc.GetBuildPackagesCommand(self._board,
True)
ret = self._ce.ChrootRunCommand(self._chromeos_root,
command)
@@ -38,9 +42,9 @@
raise Exception("Couldn't run build_packages!")
def _BuildChromeAndImage(self, env_dict):
- env_string = utils.GetEnvStringFromDict(env_dict)
- label = utils.GetFilenameFromString(env_string)
- if not utils.DoesLabelExist(self._chromeos_root, self._board, label):
+ env_string = misc.GetEnvStringFromDict(env_dict)
+ label = misc.GetFilenameFromString(env_string)
+ if not misc.DoesLabelExist(self._chromeos_root, self._board, label):
build_chrome_browser_args = ["--chromeos_root=%s" % self._chromeos_root,
"--board=%s" % self._board,
"--env=%s" %
@@ -48,7 +52,7 @@
ret = build_chrome_browser.Main(build_chrome_browser_args)
if ret:
raise Exception("Couldn't build chrome browser!")
- utils.LabelLatestImage(self._chromeos_root, self._board, label)
+ misc.LabelLatestImage(self._chromeos_root, self._board, label)
return label
def _TestLabels(self, labels):
@@ -75,7 +79,7 @@
chromeos_image: %s
}
""" % (crosperf_label,
- os.path.join(utils.GetImageDir(self._chromeos_root, self._board),
+ os.path.join(misc.GetImageDir(self._chromeos_root, self._board),
label,
"chromiumos_image.bin"))
print >>f, experiment_image
diff --git a/v14/remote_kill_test.py b/v14/remote_kill_test.py
index 0a8c5b2..e56ef20 100755
--- a/v14/remote_kill_test.py
+++ b/v14/remote_kill_test.py
@@ -15,8 +15,8 @@
import re
import sys
import subprocess
+
from utils import command_executer
-from utils import utils
def Usage(parser, message):
diff --git a/v14/remote_test.py b/v14/remote_test.py
index 35e6c86..2ef27f9 100755
--- a/v14/remote_test.py
+++ b/v14/remote_test.py
@@ -13,8 +13,9 @@
import os
import re
import sys
+
from utils import command_executer
-from utils import utils
+from utils import misc
def Usage(parser, message):
@@ -43,8 +44,8 @@
chromeos_root=options.chromeos_root,
machine=options.remote)
- version_dir_path, script_name = utils.GetRoot(sys.argv[0])
- version_dir = utils.GetRoot(version_dir_path)[1]
+ version_dir_path, script_name = misc.GetRoot(sys.argv[0])
+ version_dir = misc.GetRoot(version_dir_path)[1]
# Tests to copy directories and files to the chromeos box.
ce.CopyFiles(version_dir_path,
diff --git a/v14/repo_to_repo.py b/v14/repo_to_repo.py
index b7f94e4..744b24c 100755
--- a/v14/repo_to_repo.py
+++ b/v14/repo_to_repo.py
@@ -10,10 +10,11 @@
import socket
import sys
import tempfile
+
from automation.clients.helper import perforce
from utils import command_executer
from utils import logger
-from utils import utils
+from utils import misc
def GetCanonicalMappings(mappings):
@@ -127,7 +128,7 @@
self.mappings = mappings
def PullSources(self):
- with utils.WorkingDirectory(self._root_dir):
+ with misc.WorkingDirectory(self._root_dir):
for mapping in self.mappings:
remote_path, local_path = SplitMapping(mapping)
command = 'svn co %s/%s %s' % (self.address, remote_path, local_path)
@@ -156,12 +157,12 @@
self.gerrit = gerrit
def _CloneSources(self):
- with utils.WorkingDirectory(self._root_dir):
+ with misc.WorkingDirectory(self._root_dir):
command = 'git clone %s .' % (self.address)
return self._ce.RunCommand(command)
def PullSources(self):
- with utils.WorkingDirectory(self._root_dir):
+ with misc.WorkingDirectory(self._root_dir):
ret = self._CloneSources()
if ret: return ret
@@ -175,7 +176,7 @@
return ret
def SetupForPush(self):
- with utils.WorkingDirectory(self._root_dir):
+ with misc.WorkingDirectory(self._root_dir):
ret = self._CloneSources()
logger.GetLogger().LogFatalIf(ret, 'Could not clone git repo %s.' %
self.address)
@@ -197,7 +198,7 @@
return ret
def PushSources(self, commit_message, dry_run=False):
- with utils.WorkingDirectory(self._root_dir):
+ with misc.WorkingDirectory(self._root_dir):
push_args = ''
if dry_run:
push_args += ' -n '
@@ -223,7 +224,7 @@
if not self.mappings:
self._RsyncExcludingRepoDirs(self._root_dir, root_dir)
return
- with utils.WorkingDirectory(self._root_dir):
+ with misc.WorkingDirectory(self._root_dir):
for mapping in self.mappings:
remote_path, local_path = SplitMapping(mapping)
remote_path.rstrip('...')
diff --git a/v14/run_benchmarks.py b/v14/run_benchmarks.py
index d3271b0..9dc4900 100755
--- a/v14/run_benchmarks.py
+++ b/v14/run_benchmarks.py
@@ -31,10 +31,10 @@
import os
import re
import sys
-import run_tests
+
import image_chromeos
+import run_tests
from utils import command_executer
-from utils import utils
from utils import logger
diff --git a/v14/run_tests.py b/v14/run_tests.py
index d3ca589..075f29b 100755
--- a/v14/run_tests.py
+++ b/v14/run_tests.py
@@ -13,9 +13,9 @@
import os
import re
import sys
+
from utils import command_executer
from utils import logger
-from utils import utils
import build_chromeos
diff --git a/v14/tc_enter_chroot.py b/v14/tc_enter_chroot.py
index a1db7e6..50eb312 100755
--- a/v14/tc_enter_chroot.py
+++ b/v14/tc_enter_chroot.py
@@ -15,9 +15,11 @@
import pwd
import stat
import sys
+
from utils import command_executer
from utils import logger
-from utils import utils
+from utils import misc
+
class MountPoint:
def __init__(self, external_dir, mount_dir, owner, options=None):
@@ -155,7 +157,7 @@
mount_points = []
for tc_dir in tc_dirs:
- last_dir = utils.GetRoot(tc_dir)[1]
+ last_dir = misc.GetRoot(tc_dir)[1]
mount_point = MountPoint(tc_dir, full_mounted_tc_root + "/" + last_dir,
getpass.getuser(), "ro")
mount_points.append(mount_point)
@@ -190,7 +192,7 @@
mount_points += CreateMountPointsFromString(options.other_mounts,
chromeos_root + "/chroot/")
- last_dir = utils.GetRoot(version_dir)[1]
+ last_dir = misc.GetRoot(version_dir)[1]
# Mount the version dir (v14) at /usr/local/toolchain_root/v14
mount_point = MountPoint(version_dir, full_mounted_tc_root + "/" + last_dir,
@@ -270,7 +272,7 @@
def CreateSymlink(target, link_name):
logger.GetLogger().LogFatalIf(target.startswith("/"),
"Can't create symlink to absolute path!")
- real_from_file = utils.GetRoot(link_name)[0] + "/" + target
+ real_from_file = misc.GetRoot(link_name)[0] + "/" + target
if os.path.realpath(real_from_file) != os.path.realpath(link_name):
if os.path.exists(link_name):
command = "rm -rf " + link_name
diff --git a/v14/utils/command_executer.py b/v14/utils/command_executer.py
index bef6aba..c9a19ff 100644
--- a/v14/utils/command_executer.py
+++ b/v14/utils/command_executer.py
@@ -1,14 +1,19 @@
+#!/usr/bin/python
+#
+# Copyright 2011 Google Inc. All Rights Reserved.
+#
+
import getpass
-import logger
import os
import pty
import re
import select
import subprocess
-import sys
import tempfile
import time
-import utils
+
+import logger
+import misc
mock_default = False
@@ -242,8 +247,8 @@
cros_machine = dest_machine
command = self.RemoteAccessInitCommand(chromeos_root, cros_machine)
- src_parent, src_child = utils.GetRoot(src)
- dest_parent, dest_child = utils.GetRoot(dest)
+ src_parent, src_child = misc.GetRoot(src)
+ dest_parent, dest_child = misc.GetRoot(dest)
ssh_command = ("ssh -p ${FLAGS_ssh_port}" +
" -o StrictHostKeyChecking=no" +
" -o UserKnownHostsFile=$(mktemp)" +
diff --git a/v14/utils/logger.py b/v14/utils/logger.py
index 6f62640..1ef996e 100644
--- a/v14/utils/logger.py
+++ b/v14/utils/logger.py
@@ -2,10 +2,13 @@
#
# Copyright 2010 Google Inc. All Rights Reserved.
+# System modules
import os.path
import sys
import traceback
-import utils
+
+# Local modules
+import misc
class Logger(object):
@@ -137,7 +140,7 @@
"""Initialize a global logger. To be called only once."""
global main_logger
assert not main_logger, "The logger has already been initialized"
- rootdir, basefilename = utils.GetRoot(script_name)
+ rootdir, basefilename = misc.GetRoot(script_name)
main_logger = Logger(rootdir, basefilename, print_console)
diff --git a/v14/utils/utils.py b/v14/utils/misc.py
old mode 100755
new mode 100644
similarity index 100%
rename from v14/utils/utils.py
rename to v14/utils/misc.py
diff --git a/v14/utils/utils_test.py b/v14/utils/misc_test.py
similarity index 73%
rename from v14/utils/utils_test.py
rename to v14/utils/misc_test.py
index 3bb6017..62742e3 100644
--- a/v14/utils/utils_test.py
+++ b/v14/utils/misc_test.py
@@ -1,18 +1,21 @@
# Copyright 2012 Google Inc. All Rights Reserved.
-"""Tests for utils."""
+"""Tests for misc."""
__author__ = 'asharif@google.com (Ahmad Sharif)'
+# System modules
import re
import unittest
-import utils
+
+# Local modules
+import misc
class UtilsTest(unittest.TestCase):
def testGetFilenameFromString(self):
string = 'a /b=c"d'
- filename = utils.GetFilenameFromString(string)
+ filename = misc.GetFilenameFromString(string)
self.assertTrue(filename == 'a___bcd')
if __name__ == '__main__':