def checkDocument(cfg, fd):

    server = re.sub(r'^https?://', '', cfg.server)

    if cfg.atdlang != '':
        server = cfg.atdlang + '.' + server

    if cfg.server.startswith('https'):
        service = httplib.HTTPSConnection(server, cfg.port)
    else:
        service = httplib.HTTPConnection(server, cfg.port)

    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    if cfg.username:
        headers["Authorization"] = "Basic %s" % \
            (base64.b64encode("%s:%s" % (cfg.username, cfg.password)))

    params = {'key': cfg.key, 'data': fd.read()}
    if cfg.lang != '':
        params['lang'] = cfg.lang

    service.request(method='POST',
                    url='/checkDocument',
                    body=urllib.urlencode(params),
                    headers=headers)
    response = service.getresponse()
    if response.status != httplib.OK:
        service.close()
        raise Exception('Unexpected response code from AtD server %s: %d' %
                        (cfg.server, response.status))

    print(response.read())
    et = ElementTree.fromstring(response.read())
    service.close()

    errs = et.findall('message')
    if len(errs) > 0:
        raise Exception('Server returned an error: %s' % errs[0].text)
    return [Error(e) for e in et.findall('error')]
Invoke checkDocument service and return a list of errors.
dataset/ETHPy150Open lpenz/atdtool/atdtool/__init__.py/checkDocument