Chromium Code Reviews| Index: systrace/systrace/__init__.py |
| diff --git a/systrace/systrace/__init__.py b/systrace/systrace/__init__.py |
| index ca3e206fdd8f2b8e5facc81da817abd7d2ca143e..50116a02e9a717c2bccf86ef489966fb402bebfb 100644 |
| --- a/systrace/systrace/__init__.py |
| +++ b/systrace/systrace/__init__.py |
| @@ -1,3 +1,25 @@ |
| # Copyright 2016 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import os |
| +import sys |
| + |
| +def _JoinPath(*path_parts): |
| + return os.path.abspath(os.path.join(*path_parts)) |
| + |
| + |
| +def _AddDirToPythonPath(*path_parts): |
| + path = _JoinPath(*path_parts) |
| + if os.path.isdir(path) and path not in sys.path: |
| + # Some call sites that use Telemetry assume that sys.path[0] is the |
| + # directory containing the script, so we add these extra paths to right |
| + # after sys.path[0]. |
| + sys.path.insert(1, path) |
| + |
| +_CATAPULT_DIR = os.path.join( |
| + os.path.dirname(os.path.abspath(__file__)), '..', '..') |
|
Zhen Wang
2016/03/24 22:13:05
nit: s/'..'/os.path.pardir
alexandermont
2016/03/24 23:54:09
Done
|
| +_AddDirToPythonPath(_CATAPULT_DIR, 'catapult_base') |
| +_AddDirToPythonPath(_CATAPULT_DIR, 'systrace') |
| +_AddDirToPythonPath(_CATAPULT_DIR, 'devil') |
|
Zhen Wang
2016/03/24 22:13:05
Put this in alphabetic order.
alexandermont
2016/03/24 23:54:09
Done
|
| +_AddDirToPythonPath(_CATAPULT_DIR, 'tools', 'py_trace_event') |
| +_AddDirToPythonPath(_CATAPULT_DIR, 'tools', 'py_trace_event', 'py_trace_event') |