<commit_before>import tweepy
import logging
from application.twitter.listener import TwitterStreamingListener


class TwitterInterface(object):

    def __init__(self, consumer_key, secret_key, access_token, secret_access_token, hashtags):
        """
        Twitter Interface constructor. This class is used as an interface to the Twitter Listener
        :param consumer_key: Check Out Twitter Documentation
        :param secret_key: Check Out Twitter Documentation
        :param access_token: Check Out Twitter Documentation
        :param secret_access_token: Check Out Twitter Documentation
        :param hashtags: List of Hashtags / Words
        """
        self.auth = tweepy.OAuthHandler(consumer_key, secret_key)
        self.auth.set_access_token(access_token, secret_access_token)
        self.listener = TwitterStreamingListener()
        self.hashtags = hashtags
        self.process_name = "Twitter: " + "-".join(hashtags)
        self.stream = tweepy.streaming.Stream(self.auth, self.listener)

    def test_auth(self):
        """
        Simple Function used to check if authorization object is valid or not
        :return: True / False
        """
        try:
            tweepy.API(self.auth).rate_limit_status()
        except Exception as e:
            logging.error("Error trying to connect the object: " + str(self))
            logging.error(e)
            raise Exception(e)

    def start(self, process_manager):
        """
        Create new Twitter Listener Process<commit_msg>verify_credentials method in test auth<commit_after>import tweepy
import logging
from application.twitter.listener import TwitterStreamingListener


class TwitterInterface(object):

    def __init__(self, consumer_key, secret_key, access_token, secret_access_token, hashtags):
        """
        Twitter Interface constructor. This class is used as an interface to the Twitter Listener
        :param consumer_key: Check Out Twitter Documentation
        :param secret_key: Check Out Twitter Documentation
        :param access_token: Check Out Twitter Documentation
        :param secret_access_token: Check Out Twitter Documentation
        :param hashtags: List of Hashtags / Words
        """
        self.auth = tweepy.OAuthHandler(consumer_key, secret_key)
        self.auth.set_access_token(access_token, secret_access_token)
        self.listener = TwitterStreamingListener()
        self.hashtags = hashtags
        self.process_name = "Twitter: " + "-".join(hashtags)
        self.stream = tweepy.streaming.Stream(self.auth, self.listener)

    def test_auth(self):
        """
        Simple Function used to check if authorization object is valid or not
        :return: True / False
        """
        try:
            tweepy.API(self.auth).verify_credentials()
        except Exception as e:
            logging.error("Error trying to connect the object: " + str(self))
            logging.error(e)
            raise Exception(e)

    def start(self, process_manager):
        """
        Create new Twitter Listener Process
{'fraction_non_alphanumeric': 0.07465618860510806, 'fraction_numerical': 0.0, 'mean_word_length': 2.823529411764706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7036232', 'n_tokens_mistral': 805, 'n_tokens_neox': 782, 'n_words': 237}