From: Joshua Roesslein Date: Tue, 8 Dec 2009 07:29:07 +0000 (-0600) Subject: Add option to tweepyshell to enable debug mode. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9de342ad7cb8fef058457b545341d7861c0ea077;p=tweepy.git Add option to tweepyshell to enable debug mode. --- diff --git a/CHANGELOG b/CHANGELOG index a001f22..c1d73c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,9 +17,11 @@ during upgrade will be listed here. + tweepyshell - allow using getpass for more secure password collection new usage: tweepyshell [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] ===================== diff --git a/tweepyshell b/tweepyshell index d47132c..6062a79 100755 --- a/tweepyshell +++ b/tweepyshell @@ -3,9 +3,10 @@ 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 @@ -15,18 +16,22 @@ It imports tweepy and creates an authenticated API instance (api) 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] ') +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 [password]' - exit(1) + auth = None -api = API(BasicAuthHandler(username=username, password=password)) +if options.debug: + tweepy.debug() -code.interact('', local={'tweepy': tweepy, 'api': api}) +code.interact('', local={'tweepy': tweepy, 'api': API(auth)})