From: Josh Roesslein Date: Mon, 2 Nov 2009 22:22:38 +0000 (-0600) Subject: Move streamwatcher and tweepyshell to examples repository. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=33fbff7f7521a3f2912defcb09ca886ee19d3667;p=tweepy.git Move streamwatcher and tweepyshell to examples repository. --- diff --git a/streamwatcher.py b/streamwatcher.py deleted file mode 100755 index 4d84f0a..0000000 --- a/streamwatcher.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python - -import time -from getpass import getpass - -import tweepy - - -class StreamWatcherListener(tweepy.StreamListener): - - def on_status(self, status): - print status.text - - def on_error(self, status_code): - print 'An error has occured! Status code = %s' % status_code - return True # keep stream alive - - def on_timeout(self): - print 'Snoozing Zzzzzz' - -# Prompt for login credentials and setup stream object -username = raw_input('Twitter username: ') -password = getpass('Twitter password: ') -stream = tweepy.Stream(username, password, StreamWatcherListener()) - -# Prompt for mode of streaming and connect -while True: - mode = raw_input('Mode? [sample/filter] ') - if mode == 'sample': - stream.sample() - break - elif mode == 'filter': - follow_list = raw_input('Users to follow (comma separated): ').strip() - track_list = raw_input('Keywords to track (comma seperated): ').strip() - if follow_list: - follow_list = [u for u in follow_list.split(',')] - else: - follow_list = None - if track_list: - track_list = [k for k in track_list.split(',')] - else: - track_list = None - stream.filter(follow_list, track_list) - break - else: - print 'Invalid choice! Try again.' - -# Run in a loop until termination -while True: - try: - if stream.running is False: - print 'Stream stopped!' - break - time.sleep(1) - except KeyboardInterrupt: - break - -# Shutdown connection -stream.disconnect() -print 'Bye!' - diff --git a/tweepyshell.py b/tweepyshell.py deleted file mode 100755 index 56127d3..0000000 --- a/tweepyshell.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -import sys - -import code -import tweepy -from tweepy import API, BasicAuthHandler - -"""Launch an interactive shell ready for Tweepy usage - -This script is handy for debugging tweepy during development -or to just play around with the library. -It imports tweepy and creates an authenticated API instance (api) -using the credentials provided. -""" - -if len(sys.argv) != 3: - print 'Usage: tweepyshell ' - exit(1) - -api = API(BasicAuthHandler(username=sys.argv[1], password=sys.argv[2])) - -code.interact('', local={'tweepy': tweepy, 'api': api}) -