<commit_before># -*- coding: utf-8 -*-
'''
    :codeauthor: <NAME>
    :copyright: © 2013 by the SaltStack Team, see AUTHORS for more details.
    :license: Apache 2.0, see LICENSE for more details.


    salt.grains.external_ip
    ~~~~~~~~~~~~~~~~~~~~~~~

    Return the external IP address reported by boucha.saltstack.com
'''

# Import Python Libs
import requests
from pprint import pprint

# Import salt libs
from salt.utils.validate.net import ipv4_addr as _ipv4_addr

# Import errors
from requests.exceptions import Timeout, ConnectionError, HTTPError


def external_ip():
    '''
    Return the external IP address
    '''
    check_url = 'http://boucha.saltstack.com:8080'
    __opts__ = {}

    if __opts__.get('request_external_ip', True):
        try:
            r = requests.get(check_url, timeout=0.1)
            ip_addr = r.json()
            pprint(ip_addr)
            return {'external_ip': ip_addr['ip_addr']}
        except Timeout as exc:
            print('Timeout exceeded: {0}'.format(exc))
        except (ConnectionError, HTTPError) as exc:
            print('Connection error: {0}'.format(exc))

    return {'external_ip': None}


#external_ip()
<commit_msg>add logging, set up module to be a grain<commit_after># -*- coding: utf-8 -*-
'''
    :codeauthor: <NAME>
    :copyright: © 2013 by the SaltStack Team, see AUTHORS for more details.
    :license: Apache 2.0, see LICENSE for more details.


    salt.grains.external_ip
    ~~~~~~~~~~~~~~~~~~~~~~~

    Return the external IP address reported by boucha.saltstack.com
'''

# Import Python Libs
import logging
import requests
from pprint import pprint

# Import salt libs
from salt.utils.validate.net import ipv4_addr as _ipv4_addr

# Import errors
from requests.exceptions import Timeout, ConnectionError, HTTPError

log = logging.getLogger(__name__)

def external_ip():
    '''
    Return the external IP address
    '''
    check_url = 'http://boucha.saltstack.com:8080'

    if __opts__.get('request_external_ip', False):
        try:
            r = requests.get(check_url, timeout=0.1)
            ip_addr = r.json()
            return {'external_ip': ip_addr['ip_addr']}
        except Timeout as exc:
            log.debug('Timeout exceeded: {0}'.format(exc))
        except (ConnectionError, HTTPError) as exc:
            log.debug('Connection error: {0}'.format(exc))

    return {'external_ip': None}

{'fraction_non_alphanumeric': 0.12646076794657762, 'fraction_numerical': 0.014190317195325543, 'mean_word_length': 2.995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2431069', 'n_tokens_mistral': 747, 'n_tokens_neox': 719, 'n_words': 213}