def start_samp_proxy():
    """Starts (registers) and returns a SAMP proxy"""
    import os
    import xmlrpclib
    lockfile = os.path.expanduser('~/.samp')
    if not os.path.exists(lockfile):
        raise RuntimeError('A running SAMP hub was not found.')
    else:
        HUB_PARAMS = {}
        for line in open(lockfile):
            if not line.startswith('#'):
                key, value = line.split('=', 1)
                HUB_PARAMS[key] = value.strip()
    s = xmlrpclib.ServerProxy(HUB_PARAMS['samp.hub.xmlrpc.url'])
    metadata = {'samp.name': 'PyBDSM', 'samp.description.text':
        'PyBDSM: the Python Blob Detection and Source Measurement software'}
    result = s.samp.hub.register(HUB_PARAMS['samp.secret'])
    private_key = result['samp.private-key']
    s.samp.hub.declareMetadata(private_key, metadata)
    return s, private_key
