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

Side by Side Diff: tools/telemetry/telemetry/core/util.py

Issue 321773002: [PowerProfiler] Make sure correct version of pySerial is imported with monsoon profiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
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
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)
qsr 2014/06/11 12:24:21 Do we really want to reinsert if it is already in
vivekg 2014/06/11 12:41:41 The reason for removing the existing path is to as
qsr 2014/06/11 13:20:54 What is the use case where it would be in the sys
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
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
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/util_unittest.py » ('j') | tools/telemetry/telemetry/core/util_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698