Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / __init__.py
blobe91b2f8cb15bceaaa117912c0d0f0c5bf5e7f804
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """A library for cross-platform browser tests."""
6 import os
7 import sys
10 # Ensure Python >= 2.7.
11 if sys.version_info < (2, 7):
12 print >> sys.stderr, 'Need Python 2.7 or greater.'
13 sys.exit(-1)
16 def _JoinPath(*path_parts):
17 return os.path.abspath(os.path.join(*path_parts))
20 def _AddDirToPythonPath(*path_parts):
21 path = _JoinPath(*path_parts)
22 assert os.path.isdir(path), 'Not a valid path: %s' % path
23 if path not in sys.path:
24 # Some call sites that use Telemetry assume that sys.path[0] is the
25 # directory containing the script, so we add these extra paths to right
26 # after sys.path[0].
27 sys.path.insert(1, path)
30 # Add Catapult dependencies to our path.
31 # util depends on py_utils, so we can't use it to get the catapult dir.
32 _CATAPULT_DIR = os.path.join(
33 os.path.dirname(os.path.abspath(__file__)), '..', '..')
34 _AddDirToPythonPath(_CATAPULT_DIR, 'common', 'py_utils')
35 _AddDirToPythonPath(_CATAPULT_DIR, 'dependency_manager')
36 _AddDirToPythonPath(_CATAPULT_DIR, 'devil')
37 _AddDirToPythonPath(_CATAPULT_DIR, 'systrace')
38 _AddDirToPythonPath(_CATAPULT_DIR, 'tracing')
39 _AddDirToPythonPath(_CATAPULT_DIR, 'common', 'py_trace_event')
40 _AddDirToPythonPath(_CATAPULT_DIR, 'common', 'battor')
41 _AddDirToPythonPath(_CATAPULT_DIR, 'tracing', 'tracing_build')
42 _AddDirToPythonPath(_CATAPULT_DIR, 'third_party', 'py_vulcanize')
45 from telemetry.core import util
46 from telemetry.internal.util import global_hooks
48 # Add Catapult third party dependencies into our path.
49 _AddDirToPythonPath(util.GetCatapultThirdPartyDir(), 'typ')
50 # Required by websocket-client.
51 _AddDirToPythonPath(util.GetCatapultThirdPartyDir(), 'six')
53 # Add Telemetry third party dependencies into our path.
54 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'altgraph')
55 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'mock')
56 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'modulegraph')
57 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'mox3')
58 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'png')
59 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'pyfakefs')
60 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'pyserial')
61 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'web-page-replay')
62 _AddDirToPythonPath(util.GetTelemetryThirdPartyDir(), 'websocket-client')
64 # Install Telemtry global hooks.
65 global_hooks.InstallHooks()