def aggregate_events_in_window(self): self.window_slices = [] last_prcess_window = {} for p in self.process_slices: process_name, start, end = p app = self.get_application(process_name) main_windows = [] for i in range(start, end+1): me = self.filter_events[i] flag, window_name = is_main_window(me, app) if flag: main_windows.append((i, window_name)) if len(main_windows)<=0: if process_name in last_prcess_window: self.window_slices.append((process_name, last_prcess_window[process_name], start, end)) continue slices = util.list_slice(main_windows, lambda k:k[1]) for sidx, s in enumerate(slices): idx1 = main_windows[s[1]][0] idx2 = main_windows[s[2]][0] window_name = s[0] if sidx == 0: idx1 = start if sidx == len(slices)-1: idx2 = end else: idx2 = main_windows[slices[sidx+1][1]-1][0] self.window_slices.append((process_name, s[0], idx1, idx2)) if len(self.window_slices)>0: last_prcess_window[process_name] = self.window_slices[-1][1]
def aggregate_events_in_process(self): self.process_slices = util.list_slice(self.filter_events, lambda k:k['process_name'])