def main():

    parser = OptionParser()

    parser.add_option("-c", "--config", dest="config_path", help="load config from FILE", metavar="FILE")
    parser.add_option("-d", "--debug", action="store_true", dest="debug", help="enable debug mode")
    parser.add_option("-k", "--keywords", dest="keywords", help="specifies keywords to track")
    parser.add_option("-l", "--locations", dest="locations", help="specifies a set of bounding boxes to track")
    parser.add_option("-r", "--raw", action="store_true", dest="raw", help="output raw tweet")
    options, args = parser.parse_args()

    if not options.config_path:
        parser.error("No config path specified.")

    if not options.keywords:
        keywords = None
    else:
        keywords = options.keywords.split(",")

    if not options.locations:
        locations = None
    else:
        locations = map(float, options.locations.split(","))

    # Load authorisation config.

    auth = authorisation.get_auth_from_file(options.config_path)

    if options.debug:
        tweepy.debug()

    # Create a streaming API and set a timeout value of 60 seconds

    if options.raw:
        listener = RawStreamListener()
    else:
        listener = CustomStreamListener()

    streaming_api = tweepy.streaming.Stream(auth, listener, timeout=60)

    streaming_api.filter(follow=None, track=keywords, locations=locations)
parser.add_option('-c', '--config',
        dest='config_path',
        help='load config from FILE', metavar="FILE")
parser.add_option('-d', '--debug',
        action='store_true',
        dest='debug',
        help='enable debug mode')
options, args = parser.parse_args()

if not options.config_path:
    parser.error("No config path specified.")

# Load authorisation config.

auth = authorisation.get_auth_from_file(options.config_path)

class CustomStreamListener(tweepy.StreamListener):

    def on_status(self, status):
        
        # We'll simply print some values in a tab-delimited format
        # suitable for capturing to a flat file but you could opt 
        # store them elsewhere, retweet select statuses, etc.

        try:
            print "%s\t%s\t%s\t%s" % (status.text, 
                                      status.author.screen_name, 
                                      status.created_at, 
                                      status.source,)
        except Exception, e: