<commit_before>'''
Created on 27 Sep 2015

@author: matt
'''
import logging
import suds.client
import suds.transport as transport
from constants import *
from _ssl import SSLError

logger = logging.getLogger(__name__)
suds_version = float(suds.__version__[:3])
logger.debug('Suds Version %s', suds_version)

if suds_version < 0.7:
    raise Exception('Suds version not supported {}'.format(suds_version))

import requests
import functools
import traceback
try:
    import cStringIO as StringIO
except ImportError:
    import StringIO


def get_zone_info(username):
    client = suds.client.Client(url=AUTOTASK_API_BASE_URL)
    return client.service.getZoneInfo(username)


def get_zone_url(username):
    zone_info = get_zone_info(username)
    return zone_info.URL


def get_zone_id(username):
    zone_info = get_zone_info(username)
    return zone_info.CI


def get_zone_wsdl(username):
    url = get_zone_url(username)
    return url.replace('asmx','wsdl')


def disable_warnings():
    import requests.packages
    requests.packages.urllib3.disable_warnings()
    
    
def connect(**kwargs):
    client_options = kwargs.setdefault('client_options',{})
    if DISABLE_SSL_WARNINGS:
        disable_warnings()
    if USE_REQUEST_TRANSPORT_TYPE:
        session = requests.Session()
        session.auth = (kwargs['username'],kwargs['password'])        
        transport = client_options.setdefault('transport',RequestsTransport(session))
    client_options.setdefault('url',get_zone_wsdl(kwargs['username']))
    obj = kwargs.get('atws_version',Connection)
    return obj(**kwargs)


def handle_errors(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):<commit_msg>if username is not found, the URL returned is None type. now throws an exception that explains the most likely cause.<commit_after>'''
Created on 27 Sep 2015

@author: matt
'''
import logging
import suds.client
import suds.transport as transport
from constants import *
from _ssl import SSLError

logger = logging.getLogger(__name__)
suds_version = float(suds.__version__[:3])
logger.debug('Suds Version %s', suds_version)

if suds_version < 0.7:
    raise Exception('Suds version not supported {}'.format(suds_version))

import requests
import functools
import traceback
try:
    import cStringIO as StringIO
except ImportError:
    import StringIO


def get_zone_info(username):
    client = suds.client.Client(url=AUTOTASK_API_BASE_URL)
    return client.service.getZoneInfo(username)


def get_zone_url(username):
    zone_info = get_zone_info(username)
    return zone_info.URL


def get_zone_id(username):
    zone_info = get_zone_info(username)
    return zone_info.CI


def get_zone_wsdl(username):
    url = get_zone_url(username)
    try:
        return url.replace('asmx','wsdl')
    except AttributeError:
        raise ValueError('Username:{} failed to resolve to a zone'.format(username))


def disable_warnings():
    import requests.packages
    requests.packages.urllib3.disable_warnings()
    
    
def connect(**kwargs):
    client_options = kwargs.setdefault('client_options',{})
    if DISABLE_SSL_WARNINGS:
        disable_warnings()
    if USE_REQUEST_TRANSPORT_TYPE:
        session = requests.Session()
        session.auth = (kwargs['username'],kwargs['password'])        
        transport = client_options.setdefault('transport',RequestsTransport(session))
    client_options.setdefault('url',get_zone_wsdl(kwargs['username']))
    obj = kwargs.get('atws_version',Connection)
    return obj(**kwargs)


def handle_errors(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
{'fraction_non_alphanumeric': 0.10275689223057644, 'fraction_numerical': 0.00556947925368978, 'mean_word_length': 4.517665130568356, 'pattern_counts': {'":': 0, '<': 5, '<?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': '721069', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1092, 'n_words': 250}