Advertisement
Guest User

getGmailInfo

a guest
Feb 24th, 2010
1,244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. def getGmailInfo():
  2.     global gmail_user
  3.     global gmail_pwd
  4.    
  5.     while True:
  6.         hasgmail = raw_input('Do you have a Gmail account? (enter "yes" or "no"): ')
  7.         if hasgmail.lower() == 'yes':
  8.             break
  9.         elif hasgmail.lower() == 'no':
  10.             print 'Press enter to get one. This program will pause and a web browser will open'
  11.             raw_input('')
  12.             saveout = os.dup(2)
  13.             os.close(2)
  14.             os.open(os.devnull, os.O_RDWR)
  15.             try:
  16.                 webbrowser.open_new_tab('https://www.google.com/accounts/NewAccount?service=mail')
  17.             finally:
  18.                 break
  19.         else:
  20.             print 'Please enter either "yes" or "no" (without the quotation marks.'            
  21.  
  22.     while True:
  23.         gmail_user = raw_input('Please enter your Gmail username: ')
  24.         if gmail_user.lower() == 'quit' or gmail_user.lower() == '"quit"':
  25.             sys.exit(0) # this allows the user to quit if they need to make a gmail
  26.         if len(gmail_user.split('@')) != 2:     #checks for stuff after @
  27.             print 'Error. Please enter a valid email address'
  28.         elif gmail_user.split('@')[-1] != 'gmail.com':  #checks for gmail email
  29.             print 'Error. Please enter a gmail address.'
  30.         else:
  31.             print 'Email accepted.'
  32.             break
  33.    
  34.     gmail_pwd = getpass.getpass('Please enter your Gmail password (it is not\
  35. displayed for security reasons, but I can assure you that you\'re still\
  36. entering it) Then press enter. ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement