import sys from gi.repository import GObject from gi.repository import TelepathyLogger from gi.repository import TelepathyGLib as Tp def events_cb(mgr, result, d): result, events = mgr.get_filtered_events_finish(result) for e in events: sender = e.get_sender() print "<%s> %s" % (sender.get_alias(), e.get_message()) sys.exit(0) def fetch_logs(account, contact): mgr = TelepathyLogger.LogManager.dup_singleton() target = TelepathyLogger.Entity.new(contact, TelepathyLogger.EntityType.CONTACT, contact, "") mgr.get_filtered_events_async(account, target, TelepathyLogger.EventTypeMask.TEXT, 10, None, None, events_cb, None) def account_mgr_prepared(account_mgr, result, d): account_mgr.prepare_finish(result) account, contact = d for a in account_mgr.get_valid_accounts(): if a.get_path_suffix() == account: fetch_logs(a, contact) return print "Can't find account %s" % account sys.exit(1) if __name__ == '__main__': if len(sys.argv) != 3: print "Usage: %s [account] [contact]" % sys.argv[0] sys.exit(1) loop = GObject.MainLoop() account_mgr = Tp.AccountManager.dup() account_mgr.prepare_async([], account_mgr_prepared, (sys.argv[1], sys.argv[2])) loop.run()