Home | History | Annotate | Download | only in perf_tools
      1 # Copyright (c) 2012 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 """A library for Chrome GPU test code."""
      5 import os
      6 import sys
      7 
      8 
      9 def _RemoveAllStalePycFiles():
     10   for dirname, _, filenames in os.walk(os.path.dirname(__file__)):
     11     if '.svn' in dirname or '.git' in dirname:
     12       continue
     13     for filename in filenames:
     14       root, ext = os.path.splitext(filename)
     15       if ext != '.pyc':
     16         continue
     17 
     18       pyc_path = os.path.join(dirname, filename)
     19       py_path = os.path.join(dirname, root + '.py')
     20       if not os.path.exists(py_path):
     21         os.remove(pyc_path)
     22 
     23     if not os.listdir(dirname):
     24       os.removedirs(dirname)
     25 
     26 
     27 def Init():
     28   telemetry_path = os.path.join(os.path.dirname(__file__),
     29                                 os.pardir, os.pardir, 'telemetry')
     30   absolute_telemetry_path = os.path.abspath(telemetry_path)
     31   sys.path.append(absolute_telemetry_path)
     32   telemetry_tools_path = os.path.join(os.path.dirname(__file__),
     33                                       os.pardir, os.pardir, 'telemetry_tools')
     34   absolute_telemetry_tools_path = os.path.abspath(telemetry_tools_path)
     35   sys.path.append(absolute_telemetry_tools_path)
     36 
     37 
     38 _RemoveAllStalePycFiles()
     39 Init()
     40