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]
=====================
import code
import tweepy
from tweepy import API, BasicAuthHandler
+from getpass import getpass
"""Launch an interactive shell ready for Tweepy usage
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})