Guest User

getGmailInfo

a guest
Feb 23rd, 2010
343
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ')
  37.     return gmail_user
  38.     return gmail_pwd
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×