- add sources.
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / __init__.py
1 # Copyright (c) 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.
4
5 """A library for cross-platform browser tests."""
6
7 import inspect
8 import os
9 import sys
10
11 from telemetry.core.browser import Browser
12 from telemetry.core.browser_options import BrowserFinderOptions
13 from telemetry.core.tab import Tab
14
15 from telemetry.page.page_measurement import PageMeasurement
16 from telemetry.page.page_runner import Run as RunPage
17
18 __all__ = []
19
20 # Find all local vars that are classes or functions and make sure they're in the
21 # __all__ array so they're included in docs.
22 for x in dir():
23   if x.startswith('_'):
24     continue
25   if x in (inspect, os, sys):
26     continue
27   m = sys.modules[__name__]
28   if (inspect.isclass(getattr(m, x)) or
29       inspect.isfunction(getattr(m, x))):
30     __all__.append(x)
31
32
33 def RemoveAllStalePycFiles(base_dir):
34   for dirname, _, filenames in os.walk(base_dir):
35     if '.svn' in dirname or '.git' in dirname:
36       continue
37     for filename in filenames:
38       root, ext = os.path.splitext(filename)
39       if ext != '.pyc':
40         continue
41
42       pyc_path = os.path.join(dirname, filename)
43       py_path = os.path.join(dirname, root + '.py')
44       if os.path.exists(py_path):
45         continue
46
47       try:
48         os.remove(pyc_path)
49       except OSError:
50         # Avoid race, in case we're running simultaneous instances.
51         pass
52
53     if os.listdir(dirname):
54       continue
55
56     try:
57       os.removedirs(dirname)
58     except OSError:
59       # Avoid race, in case we're running simultaneous instances.
60       pass
61
62
63 RemoveAllStalePycFiles(os.path.dirname(__file__))