CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by harski on Wed 31st Aug 22:46 (modification of post by view diff)
download | new post

  1. #!/usr/bin/env python3
  2.  
  3. """
  4. Version 110412
  5. Improved error-handling and modified to use python3
  6. Written by Tuomo Hartikainen <hartitu@gmail.com>
  7. Feel free to distribute or modify in any way you like.
  8. """
  9.  
  10. import os
  11.  
  12. #Enter your username and password below enclosed with double quotes
  13. # eg. username="username" and password="password"
  14. username=""
  15. password=""
  16.  
  17. def fetchInfo(username, password):
  18.         """ Takes username and password as parameter. Checks
  19.             the site for mail and returns the count of new
  20.             messages. Returns -1 on error.
  21.         """
  22.  
  23.         mail = 0       
  24.  
  25.         wget = "wget -q -O - https://"+username+":"+password+"@mail.google.com/mail/feed/atom --no-check-certificate"
  26.  
  27.         #Do the dirty work
  28.         temp = os.popen(wget)
  29.         msg = temp.read()
  30.         index = msg.find("<fullcount>")
  31.         index2 = msg.find("</fullcount>")
  32.  
  33.         try:
  34.                 mail = int(msg[index+11:index2])
  35.         except:
  36.                 mail = -1       
  37.        
  38.         return mail
  39.  
  40.  
  41. messages = fetchInfo(username, password)
  42. if messages != -1:
  43.         print(str(messages), "messages")
  44. else:
  45.         #An error happened. Deal with it
  46.         print("Error fetching mail")

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me