Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import glob | 4 import glob |
| 5 import imp | 5 import imp |
| 6 import inspect | 6 import inspect |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import socket | 9 import socket |
| 10 import sys | 10 import sys |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 __file__, os.pardir, os.pardir, os.pardir)) | 28 __file__, os.pardir, os.pardir, os.pardir)) |
| 29 | 29 |
| 30 | 30 |
| 31 def GetUnittestDataDir(): | 31 def GetUnittestDataDir(): |
| 32 return os.path.join(GetTelemetryDir(), 'unittest_data') | 32 return os.path.join(GetTelemetryDir(), 'unittest_data') |
| 33 | 33 |
| 34 | 34 |
| 35 def GetChromiumSrcDir(): | 35 def GetChromiumSrcDir(): |
| 36 return os.path.normpath(os.path.join(GetTelemetryDir(), os.pardir, os.pardir)) | 36 return os.path.normpath(os.path.join(GetTelemetryDir(), os.pardir, os.pardir)) |
| 37 | 37 |
| 38 def InsertDirInPythonPath(index, *path_parts): | |
|
tonyg
2014/06/09 16:13:35
Dave should review this part. I wonder whether we
dtu
2014/06/09 20:14:05
+1 to this suggestion, we don't need an extra func
| |
| 39 path = os.path.abspath(os.path.join(*path_parts)) | |
| 40 if os.path.isdir(path): | |
| 41 if path in sys.path: | |
| 42 sys.path.remove(path) | |
| 43 sys.path.insert(index, path) | |
| 38 | 44 |
| 39 def AddDirToPythonPath(*path_parts): | 45 def AddDirToPythonPath(*path_parts): |
| 40 path = os.path.abspath(os.path.join(*path_parts)) | 46 path = os.path.abspath(os.path.join(*path_parts)) |
| 41 if os.path.isdir(path) and path not in sys.path: | 47 if os.path.isdir(path) and path not in sys.path: |
| 42 sys.path.append(path) | 48 sys.path.append(path) |
| 43 | 49 |
| 44 _counter = [0] | 50 _counter = [0] |
| 45 def _GetUniqueModuleName(): | 51 def _GetUniqueModuleName(): |
| 46 _counter[0] += 1 | 52 _counter[0] += 1 |
| 47 return "page_set_module_" + str(_counter[0]) | 53 return "page_set_module_" + str(_counter[0]) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 """ | 164 """ |
| 159 name, ext = os.path.splitext(base_name) | 165 name, ext = os.path.splitext(base_name) |
| 160 assert ext == '', 'base_name cannot contain file extension.' | 166 assert ext == '', 'base_name cannot contain file extension.' |
| 161 index = 0 | 167 index = 0 |
| 162 while True: | 168 while True: |
| 163 output_name = '%s_%03d' % (name, index) | 169 output_name = '%s_%03d' % (name, index) |
| 164 if not glob.glob(output_name + '.*'): | 170 if not glob.glob(output_name + '.*'): |
| 165 break | 171 break |
| 166 index = index + 1 | 172 index = index + 1 |
| 167 return output_name | 173 return output_name |
| OLD | NEW |