def __init__(self, name, params): self.logger = logging.getLogger(self.__class__.__name__) self.pluginParams = params self.name = name self.name_lower = name.lower() self.moduleName = self.name_lower.capitalize() self.subject_aggregated = False self.subject_aggregated_default = False self.paths = paths.paths_dict() self.plugin_base = PluginBase(package='ExperimentRunner.plugins') if self.name_lower == 'android' or self.name_lower == 'trepn' or self.name_lower == 'batterystats': plugin_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Plugins') self.plugin_source = self.plugin_base.make_plugin_source(searchpath=[plugin_path]) self.pluginModule = self.plugin_source.load_plugin(self.moduleName) self.currentProfiler = getattr(self.pluginModule, self.moduleName)(params, self.paths) self.name = self.name_lower else: plugin_path = os.path.join(paths.CONFIG_DIR, 'Plugins') if os.path.isdir(plugin_path): copyfile(os.path.join(paths.ROOT_DIR, 'ExperimentRunner', 'Plugins', 'Profiler.py'), os.path.join( plugin_path, 'Profiler.py')) self.plugin_source = self.plugin_base.make_plugin_source(searchpath=[plugin_path]) self.pluginModule = self.plugin_source.load_plugin(self.name) self.currentProfiler = getattr(self.pluginModule, self.name)(params, self.paths) else: raise ImportError self.logger.debug('%s: Initialized' % self.name)
def test_paths_dict(self): string_config = 'test/dir/1' string_output = 'test/dir/2' string_base = 'test/dir/3' string_original = 'test/dir/4' paths.CONFIG_DIR = string_config paths.OUTPUT_DIR = string_output paths.BASE_OUTPUT_DIR = string_base paths.ORIGINAL_CONFIG_DIR = string_original paths_dict = paths.paths_dict() assert paths_dict['ROOT_DIR'] == op.dirname(op.abspath(paths.__file__)) assert paths_dict['CONFIG_DIR'] == string_config assert paths_dict['OUTPUT_DIR'] == string_output assert paths_dict['BASE_OUTPUT_DIR'] == string_base assert paths_dict['ORIGINAL_CONFIG_DIR'] == string_original
def __init__(self, name, params): self.logger = logging.getLogger(self.__class__.__name__) self.pluginParams = params self.name = name self.name_lower = name.lower() self.moduleName = self.name_lower.capitalize() self.subject_aggregated = False self.subject_aggregated_default = False self.paths = paths.paths_dict() self.plugin_base = PluginBase(package='AndroidRunner.plugins') # Check lower-cased plugin directory's sub-directories for the the requested plugin name runner_plugin_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'Plugins') if self.name_lower in self.list_subdir(runner_plugin_path): self.plugin_source = self.plugin_base.make_plugin_source( searchpath=[os.path.join(runner_plugin_path, self.name_lower)]) self.pluginModule = self.plugin_source.load_plugin(self.moduleName) self.currentProfiler = getattr(self.pluginModule, self.moduleName)(params, self.paths) self.name = self.name_lower else: config_plugin_path = os.path.join(paths.CONFIG_DIR, 'Plugins') if os.path.isdir(config_plugin_path): copyfile( os.path.join(paths.ROOT_DIR, 'AndroidRunner', 'Plugins', 'Profiler.py'), os.path.join(config_plugin_path, 'Profiler.py')) self.plugin_source = self.plugin_base.make_plugin_source( searchpath=[config_plugin_path]) self.pluginModule = self.plugin_source.load_plugin(self.name) self.currentProfiler = getattr(self.pluginModule, self.name)(params, self.paths) else: raise ImportError self.logger.debug('%s: Initialized' % self.name)