Update tweepyshell to prompt for password via getpass() if not provided at commandline.
authorKumar Appaiah <akumar@debian.org>
Sun, 6 Dec 2009 05:23:11 +0000 (23:23 -0600)
committerJoshua <jroesslein@gmail.com>
Sun, 6 Dec 2009 05:23:11 +0000 (23:23 -0600)
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 <jroesslein@gmail.com>
CHANGELOG
CONTRIBUTORS
tweepyshell

index 2a5376d8fc5aebd340ef4fc3f8f58d1766aa7da1..7f0b81103df4d9347d77910358ffce38e47851e8 100644 (file)
--- 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 <username> [password] <-- optional now
 
 1.2 -> 1.3 [Current release]
 =====================
index c208e630636a3c204e7b4d8a9dd66c64487ad3a2..15939744fe340354e55195fd6cf1f453a40f2510 100644 (file)
@@ -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
index 56127d3916b567d45a1f662030a7f408cc35b10c..d47132cab0f3e31c89e3efee5a7fbfb3af3c41d0 100755 (executable)
@@ -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> <password>'
+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 <username> [password]'
     exit(1)
 
-api = API(BasicAuthHandler(username=sys.argv[1], password=sys.argv[2]))
+api = API(BasicAuthHandler(username=username, password=password))
 
 code.interact('<Tweepy shell>', local={'tweepy': tweepy, 'api': api})