def runDataCollector():
    """
    create stream to listen to twitter for keywords
    when keyword is detected tweet is handled by DataCollector instance
    :return: nothing
    """
    # Authenticate and connect to twitter
    auth = OAuthHandler(ckey, csecret)
    auth.set_access_token(atoken, asecret)
    twitterStream = Stream(auth, DataCollector())
    print('Starting Data Collector Process')
    try:
        # DataCollector to capture data containing keywords
        twitterStream.filter(track=keyword_list)
    except TweepError as e:
        logger.logging.critical("Critical error from Twitter Stream")
        # Wait 5 seconds and attempt to restart DataCollector
        i = 5
        print('Error during data collection, attempting to restart in:')
        while i > 0:
            print(str(i))
            i -= 1
            time.sleep(1)
        twitterStream.filter(track=keyword_list)
    except:
        logger.logging.critical('Unknown exception occurred when running tweepy')
        email_sender.send_email("Flu-Traker-Alert", "ALERT", "Data Collector has stopped working");
def runDataCollector():
    """
    create stream to listen to twitter for keywords
    when keyword is detected tweet is handled by DataCollector instance
    :return: nothing
    """
    # Authenticate and connect to twitter
    auth = OAuthHandler(ckey, csecret)
    auth.set_access_token(atoken, asecret)
    twitterStream = Stream(auth, DataCollector())
    print('Starting Data Collector Process')
    try:
        # DataCollector to capture data containing keywords
        twitterStream.filter(track=keyword_list)
    except TweepError as e:
        logger.logging.critical("Critical error from Twitter Stream")
        # Wait 5 seconds and attempt to restart DataCollector
        i = 5
        print('Error during data collection, attempting to restart in:')
        while i > 0:
            print(str(i))
            i -= 1
            time.sleep(1)
        twitterStream.filter(track=keyword_list)
    except:
        logger.logging.critical(
            'Unknown exception occurred when running tweepy')
        email_sender.send_email("Flu-Traker-Alert", "ALERT",
                                "Data Collector has stopped working")
def send_email():
    """
    Sends email when user submits message
    :return: Nothing
    """
    email = str(request.values.get('email'))
    subject = str(request.values.get('subject'))
    message = str(request.values.get('message'))
    email_sender.send_email(email, subject, message)
    values = {'data': "sent"}
    return jsonify(values)