<commit_before>import os
import urllib2
import util


class Service(object):

    service_name = None
    display_name = None
    service_process = None
    service_path = None

    def __init__(self, service_name, display_name, service_process, service_path):
        self.service_name = service_name
        self.display_name = display_name
        self.service_process = service_process
        self.service_path = service_path

    def get_service_data(self):
        data = {}
        data['service_name'] = self.service_name
        data['display_name'] = self.display_name
        data['service_status'] = self.get_service_status()
        data['service_path'] = self.get_service_path()
        return data

    def get_service_status(self):
        if not self._is_service_installed():
            return "not_installed"
        elif self._is_service_running():
            return "running"
        else:
            return "unavailable"

    def _is_service_installed(self):
        return True

    def _is_service_running(self):
        return util.is_process_running(self.service_process) and self._is_service_path_available()

    def _is_service_path_available(self):
        dns = "http://127.0.0.1:80" + str(self.service_path)
        running_error_codes = [401, 403]
        try:
            urllib2.urlopen(dns)
            return True
        except urllib2.HTTPError, e:
            return e.code in running_error_codes
        except:
            return False

    def get_service_path(self):
        return self.service_path


class GVLCmdLineService(Service):

    def __init__(self, service_name, display_name, service_process, service_path):
        super(GVLCmdLineService, self).__init__(service_name, display_name, service_process, service_path)

    # override
    def _is_service_installed(self):
        return os.path.exists("/home/researcher")
<commit_msg>Fixed ssh service detection.<commit_after>import os
import urllib2
import util


class Service(object):

    service_name = None
    display_name = None
    service_process = None
    service_path = None

    def __init__(self, service_name, display_name, service_process, service_path):
        self.service_name = service_name
        self.display_name = display_name
        self.service_process = service_process
        self.service_path = service_path

    def get_service_data(self):
        data = {}
        data['service_name'] = self.service_name
        data['display_name'] = self.display_name
        data['service_status'] = self.get_service_status()
        data['service_path'] = self.get_service_path()
        return data

    def get_service_status(self):
        if not self._is_service_installed():
            return "not_installed"
        elif self._is_service_running():
            return "running"
        else:
            return "unavailable"

    def _is_service_installed(self):
        return True

    def _is_service_running(self):
        if self.service_path:
            return util.is_process_running(self.service_process) and self._is_service_path_available()
        else:
            return util.is_process_running(self.service_process)

    def _is_service_path_available(self):
        dns = "http://127.0.0.1:80" + str(self.service_path)
        running_error_codes = [401, 403]
        try:
            urllib2.urlopen(dns)
            return True
        except urllib2.HTTPError, e:
            return e.code in running_error_codes
        except:
            return False

    def get_service_path(self):
        return self.service_path


class GVLCmdLineService(Service):

    def __init__(self, service_name, display_name, service_process, service_path):
        super(GVLCmdLineService, self).__init__(service_name, display_name, service_process, service_path)

    # override
    def _is_service_installed(self):
        return os.path.exists("/home/researcher")

{'fraction_non_alphanumeric': 0.08141321044546851, 'fraction_numerical': 0.008704557091653867, 'mean_word_length': 2.77487922705314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4789352', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1125, 'n_words': 230}