I have an little script which logs users that login to my Pidgin/MSN account
#!/usr/bin/env python
def log_names(buddy):
name = str(purple.PurpleBuddyGetName(buddy))
account = purple.PurpleAccountGetUsername(purple.PurpleBuddyGetAccount(buddy))
if account == u'[email protected]':
try: log[name] += 1
except KeyError: log[name] = 1
log.sync()
import dbus, gobject, shelve
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
log = shelve.open('pidgin.log')
obj = bus.get_object('im.pidgin.purple.PurpleService',
'/im/pidgin/purple/PurpleObject')
purple = dbus.Interface(obj, 'im.pidgin.purple.PurpleInterface')
bus.add_signal_receiver(log_names,
dbus_interface='im.pidgin.purple.PurpleInterface',
signal_name='BuddySignedOn')
loop = gobject.MainLoop()
loop.run()
I wanna add a simple interactive console to this which allows me to query the data from the log object, but I'm stuck at how I would implement it
Do I use threads of some kind or am I able to use some sort of call back within gobject.MainLoop()
?