<commit_before># coding=utf-8

"""
Collect the Mesos stats for the local node.

#### Dependencies
 * urlib2
"""

import urllib2

try:
    import json
except ImportError:
    import simplejson as json

import diamond.collector


class MesosCollector(diamond.collector.Collector):
    def get_default_config_help(self):
        config_help = super(MesosCollector,
                            self).get_default_config_help()
        config_help.update({
            'host': "",
            'port': "",
        })
        return config_help

    def get_default_config(self):
        """
        Returns the default collector settings
        """
        config = super(MesosCollector, self).get_default_config()
        config.update({
            'host': '127.0.0.1',
            'port': 5050,
            'path': 'metrics/snapshot',
        })
        return config

    def _get(self, host, port, path):
        """
        Execute a Marathon API call.
        """
        url = 'http://%s:%i/%s' % (host, port, path)
        try:
            response = urllib2.urlopen(url)
        except Exception, err:
            self.log.error("%s: %s", url, err)
            return False

        try:
            doc = json.load(response)
        except (TypeError, ValueError):
            self.log.error("Unable to parse response from Mesos as a"
                           + " json object")
            return False

        return doc

    def collect(self):
        if json is None:
            self.log.error('Unable to import json')<commit_msg>Fix URL building problem<commit_after># coding=utf-8

"""
Collect the Mesos stats for the local node.

#### Dependencies
 * urlib2
"""

import urllib2

try:
    import json
except ImportError:
    import simplejson as json

import diamond.collector


class MesosCollector(diamond.collector.Collector):
    def get_default_config_help(self):
        config_help = super(MesosCollector,
                            self).get_default_config_help()
        config_help.update({
            'host': "",
            'port': "",
        })
        return config_help

    def get_default_config(self):
        """
        Returns the default collector settings
        """
        config = super(MesosCollector, self).get_default_config()
        config.update({
            'host': '127.0.0.1',
            'port': 5050,
            'path': 'metrics/snapshot',
        })
        return config

    def _get(self, host, port, path):
        """
        Execute a Marathon API call.
        """
        url = 'http://%s:%s/%s' % (host, port, path)
        try:
            response = urllib2.urlopen(url)
        except Exception, err:
            self.log.error("%s: %s", url, err)
            return False

        try:
            doc = json.load(response)
        except (TypeError, ValueError):
            self.log.error("Unable to parse response from Mesos as a"
                           + " json object")
            return False

        return doc

    def collect(self):
        if json is None:
            self.log.error('Unable to import json')
{'fraction_non_alphanumeric': 0.10920840064620356, 'fraction_numerical': 0.009046849757673668, 'mean_word_length': 1.7495559502664297, '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': '2109364', 'n_tokens_mistral': 894, 'n_tokens_neox': 863, 'n_words': 228}