<commit_before>import socket
import os

try:
    from django.conf import settings
except ImportError:
    settings = None

from client import StatsClient


__all__ = ['StatsClient', 'statsd']

VERSION = (0, 4, 0)
__version__ = '.'.join(map(str, VERSION))


if settings:
    try:
        host = getattr(settings, 'STATSD_HOST', 'localhost')
        port = getattr(settings, 'STATSD_PORT', 8125)
        prefix = getattr(settings, 'STATSD_PREFIX', None)
        statsd = StatsClient(host, port, prefix)
    except (socket.error, socket.gaierror, ImportError):
        try:
            host = os.environ['STATSD_HOST']
            port = os.environ['STATSD_PORT']
            prefix = os.environ.get('STATSD_PREFIX')
            statsd = StatsClient(host, port, prefix)
        except (socket.error, socket.gaierror, KeyError):
            statsd = None
<commit_msg>Make sure port is an int<commit_after>import socket
import os

try:
    from django.conf import settings
except ImportError:
    settings = None

from client import StatsClient


__all__ = ['StatsClient', 'statsd']

VERSION = (0, 4, 0)
__version__ = '.'.join(map(str, VERSION))


if settings:
    try:
        host = getattr(settings, 'STATSD_HOST', 'localhost')
        port = getattr(settings, 'STATSD_PORT', 8125)
        prefix = getattr(settings, 'STATSD_PREFIX', None)
        statsd = StatsClient(host, port, prefix)
    except (socket.error, socket.gaierror, ImportError):
        try:
            host = os.environ['STATSD_HOST']
            port = int(os.environ['STATSD_PORT'])
            prefix = os.environ.get('STATSD_PREFIX')
            statsd = StatsClient(host, port, prefix)
        except (socket.error, socket.gaierror, KeyError):
            statsd = None

{'fraction_non_alphanumeric': 0.11595866819747416, 'fraction_numerical': 0.008036739380022962, 'mean_word_length': 2.8733333333333335, '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': '5587459', 'n_tokens_mistral': 548, 'n_tokens_neox': 535, 'n_words': 139}