+ tweepyshell
- allow using getpass for more secure password collection
new usage: tweepyshell <username> [password] <-- optional now
+ - enable debug mode with '-d' flag
+ API
- retweet() method now works correctly
- Added local trends method: trends_available() and trends_location()
++ tweepy.debug() enables httplib debug mode
1.2 -> 1.3 [Current release]
=====================
import sys
import code
+from getpass import getpass
+from optparse import OptionParser
import tweepy
from tweepy import API, BasicAuthHandler
-from getpass import getpass
"""Launch an interactive shell ready for Tweepy usage
using the credentials provided.
"""
-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]
+opt = OptionParser(usage='tweepyshell [options] <username> <password>')
+opt.add_option('-d', '--debug',
+ action='store_true',
+ dest='debug',
+ help='enable debug mode')
+options, args = opt.parse_args()
+
+if len(args) == 1:
+ auth = BasicAuthHandler(sys.argv[1], getpass())
+elif len(args) == 2:
+ auth = BasicAuthHandler(sys.argv[1], sys.argv[2])
else:
- print 'Usage: tweepyshell <username> [password]'
- exit(1)
+ auth = None
-api = API(BasicAuthHandler(username=username, password=password))
+if options.debug:
+ tweepy.debug()
-code.interact('<Tweepy shell>', local={'tweepy': tweepy, 'api': api})
+code.interact('<Tweepy shell>', local={'tweepy': tweepy, 'api': API(auth)})