<commit_before>from libcloud.types import NodeState, Node, InvalidCredsException
from libcloud.interface import INodeDriver
from zope.interface import implements
import base64
import httplib
import struct
import socket
import hashlib
from xml.etree import ElementTree as ET

API_HOST = 'api.slicehost.com'

class SlicehostConnection(object):
  def __init__(self, key):

    self.key = key

    self.api = httplib.HTTPSConnection("%s:%d" % (API_HOST, 443))

  def _headers(self):
    return { 'Authorization': ('Basic %s'
                               % (base64.b64encode('%s:' % self.key))) }

  def make_request(self, path, data=''):
    self.api.request('GET', path, headers=self._headers())
    return self.api.getresponse()

  def slices(self):
    return Response(self.make_request('/slices.xml'))

class Response(object):
  def __init__(self, http_response):
    if int(http_response.status) == 401:
      raise InvalidCredsException()

    self.http_response = http_response
    self.http_xml = http_response.read()

class SlicehostNodeDriver(object):

  implements(INodeDriver)

  def __init__(self, creds):
    self.creds = creds
    self.api = SlicehostConnection(creds.key)

  def _is_private_subnet(self, ip):
    private_subnets = [ {'subnet': '10.0.0.0', 'mask': '255.0.0.0'},
                        {'subnet': '172.16.0.0', 'mask': '172.16.0.0'},
                        {'subnet': '192.168.0.0', 'mask': '192.168.0.0'} ]

    ip = struct.unpack('I',socket.inet_aton(ip))[0]

    for network in private_subnets:
      subnet = struct.unpack('I',socket.inet_aton(network['subnet']))[0]
      mask = struct.unpack('I',socket.inet_aton(network['mask']))[0]<commit_msg>Add kwarg method='GET' for make_request()<commit_after>from libcloud.types import NodeState, Node, InvalidCredsException
from libcloud.interface import INodeDriver
from zope.interface import implements
import base64
import httplib
import struct
import socket
import hashlib
from xml.etree import ElementTree as ET

API_HOST = 'api.slicehost.com'

class SlicehostConnection(object):
  def __init__(self, key):

    self.key = key

    self.api = httplib.HTTPSConnection("%s:%d" % (API_HOST, 443))

  def _headers(self):
    return { 'Authorization': ('Basic %s'
                               % (base64.b64encode('%s:' % self.key))) }

  def make_request(self, path, data='', method='GET'):
    self.api.request(method, path, headers=self._headers())
    return self.api.getresponse()

  def slices(self):
    return Response(self.make_request('/slices.xml'))

class Response(object):
  def __init__(self, http_response):
    if int(http_response.status) == 401:
      raise InvalidCredsException()

    self.http_response = http_response
    self.http_xml = http_response.read()

class SlicehostNodeDriver(object):

  implements(INodeDriver)

  def __init__(self, creds):
    self.creds = creds
    self.api = SlicehostConnection(creds.key)

  def _is_private_subnet(self, ip):
    private_subnets = [ {'subnet': '10.0.0.0', 'mask': '255.0.0.0'},
                        {'subnet': '172.16.0.0', 'mask': '172.16.0.0'},
                        {'subnet': '192.168.0.0', 'mask': '192.168.0.0'} ]

    ip = struct.unpack('I',socket.inet_aton(ip))[0]

    for network in private_subnets:
      subnet = struct.unpack('I',socket.inet_aton(network['subnet']))[0]
      mask = struct.unpack('I',socket.inet_aton(network['mask']))[0]
{'fraction_non_alphanumeric': 0.14705019078368065, 'fraction_numerical': 0.032873495744056354, 'mean_word_length': 3.6178861788617884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 12, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7567132', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1120, 'n_words': 232}