def fetch_webpage_visit_event(gui_trace_elt): timestamp = gui_trace_elt['_id'] desktop_state = DesktopState.from_mongodb(gui_trace_elt) active_w = desktop_state.get_first_active_window() # ignore non-existent or empty URLs: if hasattr(active_w, 'browserURL') and active_w.browserURL: prettified_URL = active_w.browserURL # urlparse needs a URL to start with something like 'http://' if not prettified_URL.startswith('http://') and \ not prettified_URL.startswith('https://'): prettified_URL = 'http://' + prettified_URL prettified_title = active_w.title # special hacks for Google Chrome: if prettified_title.endswith(' - Google Chrome'): prettified_title = prettified_title[:(-1 * len(' - Google Chrome'))] if prettified_title == 'New Tab': return None if active_w.browserURL == u'\u200b': # weird EMPTY URL string in Chrome return None return WebpageVisitEvent(prettified_title, prettified_URL, timestamp) return None
def fetch_active_gui_window_event(gui_trace_elt): timestamp = gui_trace_elt['_id'] desktop_state = DesktopState.from_mongodb(gui_trace_elt) if desktop_state.num_active_windows() > 0: return ActiveGUIWindowEvent(desktop_state, timestamp) else: return None
else: break else: try: jmpIdx = int(k) if 0 <= jmpIdx < len(lst): idx = (jmpIdx - 1) except ValueError: if idx < len(lst) - 1: idx += 1 # Each element is a (datetime object, DesktopState instance) timesAndStates = [] if __name__ == "__main__": session_name = sys.argv[1] c = Connection() db = c.burrito_db gui_col = db.gui_trace for dat in gui_col.find({'session_tag': session_name}, sort=[('_id', ASCENDING)]): evt_time = dat['_id'] dt = DesktopState.from_mongodb(dat) timesAndStates.append((evt_time, dt)) interactive_print(timesAndStates)
db = c.burrito_db clipboard_col = db.clipboard_trace gui_col = db.gui_trace #for evt in clipboard_col.find(sort=[('_id', DESCENDING)], limit=1): for evt in clipboard_col.find(sort=[('_id', DESCENDING)]): print evt['_id'] src_desktop_cur = gui_col.find({'_id': evt['src_desktop_id']}) dst_desktop_cur = gui_col.find({'_id': evt['dst_desktop_id']}) # sanity checks assert src_desktop_cur.count() == 1, evt['src_desktop_id'] assert dst_desktop_cur.count() == 1, evt['dst_desktop_id'] src_desktop_json = src_desktop_cur[0] dst_desktop_json = dst_desktop_cur[0] src_desktop = DesktopState.from_mongodb(src_desktop_json) dst_desktop = DesktopState.from_mongodb(dst_desktop_json) print "Contents:", evt['contents'] print "Src app:", src_desktop[src_desktop_json['active_app_id']] print " window:", src_desktop[src_desktop_json['active_app_id']][ src_desktop_json['active_window_index']].title print "Dst app:", dst_desktop[dst_desktop_json['active_app_id']] print " window:", dst_desktop[dst_desktop_json['active_app_id']][ dst_desktop_json['active_window_index']].title print
c = Connection() db = c.burrito_db clipboard_col = db.clipboard_trace gui_col = db.gui_trace #for evt in clipboard_col.find(sort=[('_id', DESCENDING)], limit=1): for evt in clipboard_col.find(sort=[('_id', DESCENDING)]): print evt['_id'] src_desktop_cur = gui_col.find({'_id': evt['src_desktop_id']}) dst_desktop_cur = gui_col.find({'_id': evt['dst_desktop_id']}) # sanity checks assert src_desktop_cur.count() == 1, evt['src_desktop_id'] assert dst_desktop_cur.count() == 1, evt['dst_desktop_id'] src_desktop_json = src_desktop_cur[0] dst_desktop_json = dst_desktop_cur[0] src_desktop = DesktopState.from_mongodb(src_desktop_json) dst_desktop = DesktopState.from_mongodb(dst_desktop_json) print "Contents:", evt['contents'] print "Src app:", src_desktop[src_desktop_json['active_app_id']] print " window:", src_desktop[src_desktop_json['active_app_id']][src_desktop_json['active_window_index']].title print "Dst app:", dst_desktop[dst_desktop_json['active_app_id']] print " window:", dst_desktop[dst_desktop_json['active_app_id']][dst_desktop_json['active_window_index']].title print