From 2bb57c80760ddad7f88a82d21747881f9fe5e9a9 Mon Sep 17 00:00:00 2001 From: Laurent Ghigonis Date: Wed, 27 Feb 2013 19:56:39 +0100 Subject: add skylog, tool to log skype users status changes to stdout in CSV format --- skylog/skydbg.py | 31 ++++++++++++++++++++++++++++++ skylog/skylog.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 skylog/skydbg.py create mode 100644 skylog/skylog.py (limited to 'skylog') diff --git a/skylog/skydbg.py b/skylog/skydbg.py new file mode 100644 index 0000000..0a2d171 --- /dev/null +++ b/skylog/skydbg.py @@ -0,0 +1,31 @@ +# skydbg v0.1 +# Logs all skype notifications +# Usage: python skydbg.py >> dbg.log & +# 2013, Laurent Ghigonis + +import Skype4Py +import time +import sys +import atexit + +do_exit = False + +def cb_exit(): + print sys.stderr, "cb_exit()" + print "EXIT" + +def cb_notify(notification): + t = time.strftime("%Y%m%d-%H%M%S", time.localtime()) + print "%s %s" % (t, notification) + sys.stdout.flush() + +atexit.register(cb_exit) +skype = Skype4Py.Skype() +skype.RegisterEventHandler('Notify', cb_notify) +skype.Attach() +print >> sys.stderr, 'Started' + +while True: + time.sleep(0.1) + if do_exit is True: + break diff --git a/skylog/skylog.py b/skylog/skylog.py new file mode 100644 index 0000000..6e02a66 --- /dev/null +++ b/skylog/skylog.py @@ -0,0 +1,58 @@ +# skylog.py v0.4 +# Logs skype users status changes to stdout in CSV format +# On startup all online users are added to CSV +# On startup, exit and local user status change, lines from simulated user +# "syslog-info" are added to CSV +# Format: 20130219-154801,Marimounette,OFFLINE +# Usage: python skylog.py >> skylog.csv & +# 2013, Laurent Ghigonis + +import Skype4Py +import time +import sys +import atexit + +do_exit = False + +def cb_exit(): + print sys.stderr, "cb_exit()" + print_csv("<<> sys.stderr, "cb_attachmentstatus: %s" % status + if status != Skype4Py.apiAttachSuccess: + print >> sys.stderr, "Disconnected from skype ! exiting" + do_exit = True + +def cb_userstatus(status): + print_csv("***skylog-info", status) + +def cb_onlinestatus(user, status): + print_csv(user.Handle, status) + +def print_csv(user, status): + t = time.strftime("%Y%m%d-%H%M%S", time.localtime()) + print "%s,%s,%s" % (t, user, status) + sys.stdout.flush() + +def print_online_users(skype): + for f in skype.Friends: + if f.OnlineStatus != Skype4Py.cusOffline: + print_csv(f.Handle, f.OnlineStatus) + +atexit.register(cb_exit) +skype = Skype4Py.Skype() +skype.RegisterEventHandler('AttachmentStatus', cb_attachmentstatus) +skype.RegisterEventHandler('UserStatus', cb_userstatus) +skype.RegisterEventHandler('OnlineStatus', cb_onlinestatus) +skype.Attach() +print >> sys.stderr, 'Started' +print_csv(">>>skylog-info", "STARTUP") + +print_online_users(skype) +while True: + time.sleep(0.1) + if do_exit is True: + break -- cgit v1.2.3-59-g8ed1b