<commit_before>import sys
import time
import hmac
import hashlib
import binascii
import urlparse
import urllib
import json
import yaml

import click
import requests

from scalrtools import settings


requests.packages.urllib3.disable_warnings()

def request(method, request_uri, payload=None, data=None):
    scheme = settings.API_SCHEME
    api_host = settings.API_HOST
    time_iso8601 = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
    try:
        query_string = urllib.urlencode(sorted(payload.items())) if payload else ''
        body = json.dumps(yaml.safe_load(data)) if data else '' #XXX

        assert settings.API_KEY_ID, "No Key ID"
        assert settings.API_SECRET_KEY, "No Secret key"

        string_to_sign = "%s\n%s\n%s\n%s\n%s" % (method.upper(), time_iso8601, request_uri, query_string, body)
        #string_to_sign = "%s\n%s\n%s\n%s\n%s" % ("GET", time_iso8601, request_uri, query_string, "")
        print "stringToSign:"
        print string_to_sign
        digest = hmac.new(settings.API_SECRET_KEY, string_to_sign, hashlib.sha256).digest()
        signature = binascii.b2a_base64(digest).strip()

        headers = dict()
        headers['Content-Type'] = 'application/json; charset=utf-8'
        headers['X-Scalr-Key-Id'] = settings.API_KEY_ID
        headers['X-Scalr-Date'] = time_iso8601<commit_msg>requests quickfix<commit_after>import sys
import time
import hmac
import hashlib
import binascii
import urlparse
import urllib
import json
import yaml

import click
import requests

from scalrtools import settings

try:
    requests.packages.urllib3.disable_warnings()
except:
    pass

def request(method, request_uri, payload=None, data=None):
    scheme = settings.API_SCHEME
    api_host = settings.API_HOST
    time_iso8601 = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
    try:
        query_string = urllib.urlencode(sorted(payload.items())) if payload else ''
        body = json.dumps(yaml.safe_load(data)) if data else '' #XXX

        assert settings.API_KEY_ID, "No Key ID"
        assert settings.API_SECRET_KEY, "No Secret key"

        string_to_sign = "%s\n%s\n%s\n%s\n%s" % (method.upper(), time_iso8601, request_uri, query_string, body)
        #string_to_sign = "%s\n%s\n%s\n%s\n%s" % ("GET", time_iso8601, request_uri, query_string, "")
        print "stringToSign:"
        print string_to_sign
        digest = hmac.new(settings.API_SECRET_KEY, string_to_sign, hashlib.sha256).digest()
        signature = binascii.b2a_base64(digest).strip()

        headers = dict()
        headers['Content-Type'] = 'application/json; charset=utf-8'
        headers['X-Scalr-Key-Id'] = settings.API_KEY_ID
        headers['X-Scalr-Date'] = time_iso8601
{'fraction_non_alphanumeric': 0.12532252119424991, 'fraction_numerical': 0.019904165130851456, 'mean_word_length': 3.6472602739726026, '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': '1640986', 'n_tokens_mistral': 980, 'n_tokens_neox': 928, 'n_words': 189}