<s> import time <EOL> from getpass import getpass <EOL> from textwrap import TextWrapper <EOL> import tweepy <EOL> class StreamWatcherListener ( tweepy . StreamListener ) : <EOL> status_wrapper = TextWrapper ( width = <NUM_LIT> , initial_indent = '<STR_LIT:U+0020>' , subsequent_indent = '<STR_LIT:U+0020>' ) <EOL> def on_status ( self , status ) : <EOL> try : <EOL> print self . status_wrapper . fill ( status . text ) <EOL> print '<STR_LIT>' % ( status . author . screen_name , status . created_at , status . source ) <EOL> except : <EOL> pass <EOL> def on_error ( self , status_code ) : <EOL> print '<STR_LIT>' % status_code <EOL> return True <EOL> def on_timeout ( self ) : <EOL> print '<STR_LIT>' <EOL> def main ( ) : <EOL> username = raw_input ( '<STR_LIT>' ) <EOL> password = getpass ( '<STR_LIT>' ) <EOL> stream = tweepy . Stream ( username , password , StreamWatcherListener ( ) , timeout = None ) <EOL> valid_modes = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> while True : <EOL> mode = raw_input ( '<STR_LIT>' ) <EOL> if mode in valid_modes : <EOL> break <EOL> print '<STR_LIT>' <EOL> if mode == '<STR_LIT>' : <EOL> stream . sample ( ) <EOL> elif mode == '<STR_LIT>' : <EOL> follow_list = raw_input ( '<STR_LIT>' ) . strip ( ) <EOL> track_list = raw_input ( '<STR_LIT>' ) . strip ( ) <EOL> if follow_list : <EOL> follow_list = [ u for u in follow_list . split ( '<STR_LIT:U+002C>' ) ] <EOL> else : <EOL> follow_list = None <EOL> if track_list : <EOL> track_list = [ k for k in track_list . split ( '<STR_LIT:U+002C>' ) ] <EOL> else : <EOL> track_list = None <EOL> stream . filter ( follow_list , track_list ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> try : <EOL> main ( ) <EOL> except KeyboardInterrupt : <EOL> print '<STR_LIT>' </s>
