<commit_before>import urllib
import urllib2
import logging
import json

log = logging.getLogger(__name__)


class Request(object):
    def __init__(self, path, uri='https://api.digitalocean.com/v1', client_id=None, api_key=None, **kwargs):
        self.uri = uri
        self.client_id = client_id
        self.api_key = api_key
        self.path = path
        self.rq = '{uri}/{path}?{query}'.format(
            uri=self.uri, path=path,
            query=urllib.urlencode({'api_key': self.api_key, 'client_id': self.client_id}),
            **kwargs)
        log.debug("Constructed URL: %s", self.rq)

    def send(self):
        response = urllib2.urlopen(self.rq).read()<commit_msg>Handle HTTP errors.<commit_after>import urllib
import urllib2
import logging
import json

log = logging.getLogger(__name__)


class Request(object):
    def __init__(self, path, uri='https://api.digitalocean.com/v1', client_id=None, api_key=None, **kwargs):
        self.uri = uri
        self.client_id = client_id
        self.api_key = api_key
        self.path = path
        self.params = {'api_key': self.api_key, 'client_id': self.client_id}
        if kwargs:
            self.params.update(kwargs)
        self.rq = '{uri}/{path}?{query}'.format(
            uri=self.uri, path=path,
            query=urllib.urlencode(self.params)
        )
        log.debug("Constructed URL: %s", self.rq)

    def send(self):
        try:
            response = urllib2.urlopen(self.rq).read()
        except urllib2.HTTPError as err:
            response = json.loads(err.read())
            log.error(response['message'])
            return None

{'fraction_non_alphanumeric': 0.13304721030042918, 'fraction_numerical': 0.004291845493562232, 'mean_word_length': 2.5324675324675323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3577077', 'n_tokens_mistral': 534, 'n_tokens_neox': 529, 'n_words': 103}