<commit_before>import os
import requests
from subprocess import Popen, PIPE, CalledProcessError
from threading import Timer
from framework.logging.logger import Logger
from datetime import datetime
from blessings import Terminal
t = Terminal()


class Logcat(object):

    def __int__(self):

        super(Logcat, self).__init__()

    @staticmethod
    def http_handler(output):

        """
        Handler for submitting logs to the
        logcat web service
        """

        try:
            with open("{0}/framework/config".format(os.getcwd()), "r") as config:
                ip = config.readline()
                config.close()

            # Populate POST request
            # with output from
            # Logcat
            #
            data = {"data": output}

            # TODO - 07/26/2015
            # Remove hardcoded string and add to enums
            #
            r = requests.post("http://{0}:5000/services/logcat/update".format(ip.strip("\n")), data=data)

            if r.text == "Success":
                print(t.green("[{0}] ".format(datetime.now()) +
                              t.yellow("Success!")))
            else:
                print(t.green("[{0}] ".format(datetime.now()) +
                              t.red("Error! ") +
                              "Check flask.log"))

        except IOError as e:
            raise e

        except requests.ConnectionError as e:
            print(t.red("[{0}] ".format(datetime.now()) +
                        e.response))
            Logger.do_logger(e.response)

        return

    def timeout(self, process):

        """
        Callback to handle process
        timeouts
        """

        if process.poll() is None:
            print(t.green("[{0}] ".format(datetime.now()) +
                  t.red("adb logcat is taking too long to execute!")))

            process.kill()

        # Call
        # http_handler() with output
        #
        out = process.communicate()
        self.http_handler(out)
<commit_msg>Fixed up processing handling<commit_after>import os
import requests
from subprocess import Popen, PIPE, CalledProcessError
from threading import Timer
from framework.logging.logger import Logger
from datetime import datetime
from blessings import Terminal
t = Terminal()


class Logcat(object):

    def __int__(self):

        super(Logcat, self).__init__()

    @staticmethod
    def http_handler(output):

        """
        Handler for submitting logs to the
        logcat web service
        """

        try:
            with open("{0}/framework/config".format(os.getcwd()), "r") as config:
                ip = config.readline()
                config.close()

            # Populate POST request
            # with output from
            # Logcat
            #
            data = {"data": output}

            # TODO - 07/26/2015
            # Remove hardcoded string and add to enums
            #
            r = requests.post("http://{0}:5000/services/logcat/update".format(ip.strip("\n")), data=data)

            if r.text == "Success":
                print(t.green("[{0}] ".format(datetime.now()) +
                              t.yellow("Success!")))
            else:
                print(t.green("[{0}] ".format(datetime.now()) +
                              t.red("Error! ") +
                              "Check flask.log"))

        except IOError as e:
            print(t.red("[{0}] ".format(datetime.now()) +
                        e))
            Logger.do_logger(e)

        except requests.ConnectionError as e:
            print(t.red("[{0}] ".format(datetime.now()) +
                        e.response))
            Logger.do_logger(e.response)

        return

    def timeout(self, process):

        """
        Callback to handle process
        timeouts
        """

        if process.poll() is None:
            print(t.green("[{0}] ".format(datetime.now()) +
                  t.yellow("Gathering logs ...")))

        # Call
        # http_handler() with output
        #
        out = process.communicate()
        self.http_handler(out)

{'fraction_non_alphanumeric': 0.12082825822168088, 'fraction_numerical': 0.009013398294762484, 'mean_word_length': 1.5408415841584158, 'pattern_counts': {'":': 4, '<': 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': '2628392', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1045, 'n_words': 266}