def _locate_killers(self): start_traces = self.tracereader.apps_started() killer_instances = dict() to_kill = list() for (trace_fn, app_name) in start_traces: # Figure out which class will stop it killcls = None for (cmd, action) in tr.TraceReader(trace_fn).read(): if cmd == settings.RUN_TYPE_TYPE and action: killcls = RUNNER_CLS_MAPPING.get(action) break # Did we find a class that can do it? if killcls: if killcls in killer_instances: killer = killer_instances[killcls] else: killer = killcls( self.cfg, self.component_name, self.trace_dir, ) killer_instances[killcls] = killer to_kill.append((app_name, killer)) else: msg = "Could not figure out which class to use to stop (%s, %s)" % ( app_name, trace_fn) raise excp.StopException(msg) return to_kill
def _find_session(self, app_name, trace_fn): session_id = None for (key, value) in tr.TraceReader(trace_fn).read(): if key == SESSION_ID and value: session_id = value if not session_id: msg = "Could not find a screen session id for %s in file [%s]" % ( app_name, trace_fn) raise excp.StopException(msg) return session_id
def __init__(self, *args, **kargs): ComponentBase.__init__(self, *args, **kargs) self.tracereader = tr.TraceReader( tr.trace_fn(self.trace_dir, tr.IN_TRACE))
def is_installed(self): return tr.TraceReader(tr.trace_fn(self.trace_dir, tr.IN_TRACE)).exists()
def is_started(self): return tr.TraceReader(tr.trace_fn(self.trace_dir, tr.START_TRACE)).exists()