How to use the ltk.logger.logger.api_response function in ltk

To help you get started, we’ve selected a few ltk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Lingotek / filesystem-connector / python2 / ltk / apicalls.py View on Github external
except KeyError:
        content_length = 'No content-length header'
    log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
                                                    length=content_length)
    logger.api_call(log)

    if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
        try:
            import json
            response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
        except ValueError:
            response_info = 'No json response available'
        logger.api_response(response_info)
    elif 'content-length' in response.headers and response.headers['content-length'] != '0':
        if response.headers['content-type'] == 'application/zip':
            logger.api_response('Zip file')
        else:
            logger.api_response(response.content.decode('UTF-8'))
github Lingotek / filesystem-connector / python2 / ltk / apicalls.py View on Github external
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
                                                    length=content_length)
    logger.api_call(log)

    if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
        try:
            import json
            response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
        except ValueError:
            response_info = 'No json response available'
        logger.api_response(response_info)
    elif 'content-length' in response.headers and response.headers['content-length'] != '0':
        if response.headers['content-type'] == 'application/zip':
            logger.api_response('Zip file')
        else:
            logger.api_response(response.content.decode('UTF-8'))
github Lingotek / filesystem-connector / python3 / ltk / apicalls.py View on Github external
log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
                                                    length=content_length)
    logger.api_call(log)

    if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
        try:
            import json
            response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
        except ValueError:
            response_info = 'No json response available'
        logger.api_response(response_info)
    elif 'content-length' in response.headers and response.headers['content-length'] != '0':
        if response.headers['content-type'] == 'application/zip':
            logger.api_response('Zip file')
        else:
            logger.api_response(response.content.decode('UTF-8'))
github Lingotek / filesystem-connector / python2 / ltk / apicalls.py View on Github external
def log_api(method, uri, response):
    try:
        content_length = response.headers['content-length']
    except KeyError:
        content_length = 'No content-length header'
    log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
                                                    length=content_length)
    logger.api_call(log)
    try:
        import json
        response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
    except ValueError:
        response_info = 'No json response available'
    logger.api_response(response_info)
github Lingotek / filesystem-connector / python3 / ltk / apicalls.py View on Github external
def log_api(method, uri, response):
    try:
        content_length = response.headers['content-length']
    except KeyError:
        content_length = 'No content-length header'
    log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
                                                    length=content_length)
    logger.api_call(log)

    if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
        try:
            import json
            response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
        except ValueError:
            response_info = 'No json response available'
        logger.api_response(response_info)
    elif 'content-length' in response.headers and response.headers['content-length'] != '0':
        if response.headers['content-type'] == 'application/zip':
            logger.api_response('Zip file')
        else:
            logger.api_response(response.content.decode('UTF-8'))
github Lingotek / filesystem-connector / python2 / ltk / apicalls.py View on Github external
def log_api(method, uri, response):
    try:
        content_length = response.headers['content-length']
    except KeyError:
        content_length = 'No content-length header'
    log = '{method} {uri} {status} {length}'.format(method=method, uri=uri, status=response.status_code,
                                                    length=content_length)
    logger.api_call(log)

    if 'content-type' in response.headers and response.headers['content-type'].find("json") != -1:
        try:
            import json
            response_info = json.dumps(response.json(), indent=4, separators=(',', ': '))
        except ValueError:
            response_info = 'No json response available'
        logger.api_response(response_info)
    elif 'content-length' in response.headers and response.headers['content-length'] != '0':
        if response.headers['content-type'] == 'application/zip':
            logger.api_response('Zip file')
        else:
            logger.api_response(response.content.decode('UTF-8'))