<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_name_DID(name, proxy=None, hostport=None):
 """ Get the DID for a name or subdomain Return the DID string on success Return None if not found """

    assert proxy or hostport, 'Need proxy or hostport'
    if proxy is None:
        proxy = connect_hostport(hostport)

    did_schema = {
        'type': 'object',
        'properties': {
            'did': {
                'type': 'string'
            }
        },
        'required': [ 'did' ],
    }

    schema = json_response_schema(did_schema)
    resp = {}
    try:
        resp = proxy.get_name_DID(name)
        resp = json_validate(schema, resp)
        if json_is_error(resp):
            return resp

        # DID must be well-formed
        assert parse_DID(resp['did'])

    except ValidationError as ve:
        if BLOCKSTACK_DEBUG:
            log.exception(ve)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp
    
    except AssertionError as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        resp = {'error': 'Server replied an unparseable DID'}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return resp['did']