Home | History | Annotate | Download | only in bin
      1 import os, sys
      2 import common
      3 
      4 from autotest_lib.client.common_lib import utils, error, profiler_manager
      5 
      6 
      7 class profilers(profiler_manager.profiler_manager):
      8     def load_profiler(self, profiler, args, dargs):
      9         prof_dir = os.path.join(self.job.autodir, "profilers", profiler)
     10 
     11         try:
     12             self.job.install_pkg(profiler, "profiler", prof_dir)
     13         except error.PackageInstallError:
     14             pass
     15 
     16         if not os.path.exists(prof_dir):
     17             raise profiler_manager.ProfilerNotPresentError(profiler)
     18 
     19         profiler_module = common.setup_modules.import_module(
     20             profiler, "autotest_lib.client.profilers.%s" % profiler)
     21 
     22         newprofiler = getattr(profiler_module, profiler)(self.job)
     23 
     24         newprofiler.name = profiler
     25         newprofiler.bindir = os.path.join(prof_dir)
     26         newprofiler.srcdir = os.path.join(newprofiler.bindir, 'src')
     27         newprofiler.tmpdir = os.path.join(self.tmpdir, profiler)
     28         newprofiler.initialize(*args, **dargs)
     29         utils.update_version(newprofiler.srcdir, newprofiler.preserve_srcdir,
     30                              newprofiler.version, newprofiler.setup,
     31                              *args, **dargs)
     32 
     33         return newprofiler
     34