Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#!/usr/bin/env python # (c) 2008 Gurpartap Singh gurpartap@gmail.com import subprocess import webbrowser username = "gurpartap@gmail.com" password = "ss" try: import libgmail except ImportError: print "libgmail is missing. Get compliant package from http://myzonelabs.com/" raise SystemExit(1) mail = libgmail.GmailAccount(username, password) print "Logging in using username %s..." % username try: mail.login() except libgmail.GmailLoginFailure: print "Login failed!\nCheck your username or password and make sure you are connected to the internet." raise SystemExit(1) else: print "Logged in successfully." if mail.getUnreadMsgCount("inbox"): folder = mail.getUnreadMessages("inbox") if len(folder) > 1: title = "%d Unread Messages!" % len(folder) msg = "Do you want to goto Inbox now?" thread_id = "" else: title = "New e-mail received!" # The following will mark your message are "read". #msg = "%s: %s" % folder[0][0].sender, folder[0][0].subject msg = "Read the message now?" thread_id = "/" + folder[0].id if subprocess.call(["g15message", "-c", "-y", "-t", title, msg]): webbrowser.open_new_tab("http://mail.google.com/mail/#inbox%s" % thread_id)
This paste will be private.
From the Design Piracy series on my blog: