| 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 20 matching lines...) Expand all Loading... |
| 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 | 38 |
| 39 def AddDirToPythonPath(*path_parts): | 39 def AddDirToPythonPath(*path_parts): |
| 40 path = os.path.abspath(os.path.join(*path_parts)) | 40 path = os.path.abspath(os.path.join(*path_parts)) |
| 41 if os.path.isdir(path) and path not in sys.path: | 41 if os.path.isdir(path): |
| 42 sys.path.append(path) | 42 if path in sys.path: |
| 43 sys.path.remove(path) |
| 44 sys.path.insert(0, path) |
| 43 | 45 |
| 44 _counter = [0] | 46 _counter = [0] |
| 45 def _GetUniqueModuleName(): | 47 def _GetUniqueModuleName(): |
| 46 _counter[0] += 1 | 48 _counter[0] += 1 |
| 47 return "page_set_module_" + str(_counter[0]) | 49 return "page_set_module_" + str(_counter[0]) |
| 48 | 50 |
| 49 def GetPythonPageSetModule(file_path): | 51 def GetPythonPageSetModule(file_path): |
| 50 return imp.load_source(_GetUniqueModuleName(), file_path) | 52 return imp.load_source(_GetUniqueModuleName(), file_path) |
| 51 | 53 |
| 52 | 54 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 """ | 160 """ |
| 159 name, ext = os.path.splitext(base_name) | 161 name, ext = os.path.splitext(base_name) |
| 160 assert ext == '', 'base_name cannot contain file extension.' | 162 assert ext == '', 'base_name cannot contain file extension.' |
| 161 index = 0 | 163 index = 0 |
| 162 while True: | 164 while True: |
| 163 output_name = '%s_%03d' % (name, index) | 165 output_name = '%s_%03d' % (name, index) |
| 164 if not glob.glob(output_name + '.*'): | 166 if not glob.glob(output_name + '.*'): |
| 165 break | 167 break |
| 166 index = index + 1 | 168 index = index + 1 |
| 167 return output_name | 169 return output_name |
| OLD | NEW |