From bbd6fe7d6b7e6b87a356d3c956103074ee950271 Mon Sep 17 00:00:00 2001 From: Roy Keyes Date: Mon, 3 Feb 2014 01:19:14 -0700 Subject: [PATCH 1/2] Get Gmail password without echoing to commandline. Using getpass.getpass(). --- ch03/gmail/gmail.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ch03/gmail/gmail.py b/ch03/gmail/gmail.py index 58adc32..48ac98b 100755 --- a/ch03/gmail/gmail.py +++ b/ch03/gmail/gmail.py @@ -3,7 +3,7 @@ # This is a command line utility for slurping emails from gmail and storing them as avro documents. # I uses the GmailSlurper class, which in turn uses email utils. -import os, sys, getopt +import os, sys, getopt, getpass from lepl.apps.rfc3696 import Email from gmail_slurper import GmailSlurper @@ -35,7 +35,11 @@ def main(): output_path = None single_id = None arg_check = dict() - + + # Request password without echoing to commandline. + if '-p' not in sys.argv[1:]: + password = getpass.getpass() + for o, a in opts: if o == "-m": mode = a From 81bdfeebf61f22548951080b201ee813a1833b73 Mon Sep 17 00:00:00 2001 From: Roy Keyes Date: Tue, 4 Feb 2014 00:14:13 -0700 Subject: [PATCH 2/2] Fixed arg check for non-echo password in gmail.py. --- ch03/gmail/gmail.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ch03/gmail/gmail.py b/ch03/gmail/gmail.py index 48ac98b..b458bb0 100755 --- a/ch03/gmail/gmail.py +++ b/ch03/gmail/gmail.py @@ -39,6 +39,7 @@ def main(): # Request password without echoing to commandline. if '-p' not in sys.argv[1:]: password = getpass.getpass() + arg_check['-p'] = 1 for o, a in opts: if o == "-m":