<commit_before>import requests, json, logging, time
from random import randint
from decimal import Decimal

from django.conf import settings

url = "http://localhost:8069"
timeout = 300
logger = logging.getLogger('ocp')

FAIRCOIN_DIVISOR = Decimal("100000000.00")

# Send command to the daemon.
def send_command(cmd, params = [] ):
    if params == '': params = []
    random_id = randint(1,10000)
    headers = {'content-type': 'application/json'}
    data = json.dumps({'method': cmd, 'params': params, 'jsonrpc': '2.0', 'id': random_id })
    logger.debug('Command: %s (params: %s)' %(cmd, params))

    try:
        response = requests.post(url, headers=headers, data=data, timeout=timeout)
    except requests.exceptions.ConnectionError as e:
        logger.error("Cannot connect to faircoin daemon: %s" % e)
        return "ERROR"
    except requests.exceptions.Timeout as e:
        logger.error("Timeout connecting to faircoin daemon: %s" % e)
        return "ERROR"

    try:
        r = response.json()
        if int(response.status_code) == 200:
            logger.debug('Response: %s' %(r['result']))
            out = r['result']
        else:
            out = 'ERROR'
    except:
        out = 'ERROR'

    return out

# Check if wallet is connected to the electum network.
def is_connected():
    response = send_command('is_connected', '')<commit_msg>log response errors<commit_after>import requests, json, logging, time
from random import randint
from decimal import Decimal

from django.conf import settings

url = "http://localhost:8069"
timeout = 300
logger = logging.getLogger('ocp')

FAIRCOIN_DIVISOR = Decimal("100000000.00")

# Send command to the daemon.
def send_command(cmd, params = [] ):
    if params == '': params = []
    random_id = randint(1,10000)
    headers = {'content-type': 'application/json'}
    data = json.dumps({'method': cmd, 'params': params, 'jsonrpc': '2.0', 'id': random_id })
    logger.debug('Command: %s (params: %s)' %(cmd, params))

    try:
        response = requests.post(url, headers=headers, data=data, timeout=timeout)
    except requests.exceptions.ConnectionError as e:
        logger.error("Cannot connect to faircoin daemon: %s" % e)
        return "ERROR"
    except requests.exceptions.Timeout as e:
        logger.error("Timeout connecting to faircoin daemon: %s" % e)
        return "ERROR"

    try:
        r = response.json()
        if int(response.status_code) == 200:
            logger.debug('Response: %s' %(r['result']))
            out = r['result']
        else:
            logger.debug('Error Response: %s' %(str(r)))
            out = 'ERROR'
    except:
        logger.debug('Error Json: %s' %(str(response)))
        out = 'ERROR'

    return out

# Check if wallet is connected to the electum network.
def is_connected():
    response = send_command('is_connected', '')
{'fraction_non_alphanumeric': 0.13790689534476724, 'fraction_numerical': 0.020301015050752536, 'mean_word_length': 3.1004304160688667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5854691', 'n_tokens_mistral': 907, 'n_tokens_neox': 860, 'n_words': 250}