From: Kumar Appaiah Date: Sun, 6 Dec 2009 05:23:11 +0000 (-0600) Subject: Update tweepyshell to prompt for password via getpass() if not provided at commandline. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=476975919b653458549d61c37512b47843937aa6;p=tweepy.git Update tweepyshell to prompt for password via getpass() if not provided at commandline. For those who aren't comfortable running processes which require passwords from the command line, provide an alternative by asking for the password with the getpass function. Signed-off-by: Joshua --- diff --git a/CHANGELOG b/CHANGELOG index 2a5376d..7f0b811 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,9 @@ during upgrade will be listed here. s.filter(track=['pizza']) # synch./blocking mode - Listener now has a "on_data" method which can be overridden to manually handle the raw stream data. ++ tweepyshell + - allow using getpass for more secure password collection + new usage: tweepyshell [password] <-- optional now 1.2 -> 1.3 [Current release] ===================== diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c208e63..1593974 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -8,3 +8,5 @@ Pascal Jürgens - Streaming API fixes Fredrik Lundh - html unescape (http://effbot.org/zone/re-sub.htm#unescape-html) +Kumar Appaiah + - tweepyshell patch diff --git a/tweepyshell b/tweepyshell index 56127d3..d47132c 100755 --- a/tweepyshell +++ b/tweepyshell @@ -5,6 +5,7 @@ import sys import code import tweepy from tweepy import API, BasicAuthHandler +from getpass import getpass """Launch an interactive shell ready for Tweepy usage @@ -14,11 +15,18 @@ It imports tweepy and creates an authenticated API instance (api) using the credentials provided. """ -if len(sys.argv) != 3: - print 'Usage: tweepyshell ' +username = None +password = None + +if len(sys.argv) == 2: + username, password = sys.argv[1], getpass() +elif len(sys.argv) == 3: + username, password = sys.argv[1], sys.argv[2] +else: + print 'Usage: tweepyshell [password]' exit(1) -api = API(BasicAuthHandler(username=sys.argv[1], password=sys.argv[2])) +api = API(BasicAuthHandler(username=username, password=password)) code.interact('', local={'tweepy': tweepy, 'api': api})