The other day one of my friends Ankur , made a python script to get updates via sms using twitter account.
Check here :http://tinyurl.com/djbnon
I have changed the script to use Gmail SMTP instead .
Enjoy
import dbus,base64,urllib2,urllib from dbus.mainloop.glib import DBusGMainLoop import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email import Encoders import os ver = "v1.0" gmail_user = "" #Gmail Username gmail_pwd = "" #Gmail Password gmail_alias=" "+gmail_user #Gmail Nickname gateway="" # Check http://tinyurl.com/d5ghcv def mailz(text): mail = MIMEMultipart() mail['From'] = gmail_alias mail['To'] = gateway mail.attach(MIMEText(text)) mailServer = smtplib.SMTP("smtp.gmail.com", 587) mailServer.ehlo() mailServer.starttls() mailServer.ehlo() mailServer.login(gmail_user, gmail_pwd) mailServer.sendmail(gmail_user, gateway, mail.as_string()) mailServer.close() DBusGMainLoop(set_as_default=True) s = dbus.SessionBus() kt = s.get_object("org.ktorrent.ktorrent","/core") def update(k): torrent = s.get_object("org.ktorrent.ktorrent","/torrent/"+k) name = torrent.get_dbus_method("name","org.ktorrent.torrent") mailz("ktorrent: finished " +name()) kt.connect_to_signal("finished",update) import gobject loop = gobject.MainLoop() loop.run()
hey … this is a very nice script…though i wanted to know how do you obtain the value of the connection parameter in the get_object() call … if i need to make a similar script for any desktop application then how do i obtain the connection name and also the parameters like /core that you’ve used…