#!/usr/bin/env python

import tweepy
import os
import colors
import utils
from twitter import Twitter

class StreamWatcherListener(tweepy.StreamListener):

	twitter = None
	
	def on_status(self, status):
		try:
			self.twitter.print_status(status)
		except:
			pass
			
	def on_error(self, status_code):
		print utils.colorize('An error has occurred! Status code = %s' % status_code, "B_RED")
	
	def on_timeout(self):
		print utils.colorize('Connection lost due to timeout.', "RED")
		
	def __init__(self, twitter):
		self.twitter = twitter
