# Buggy code
def _split_routing_response(data, service):
    """
    Splits the routing responses per data center for the federator output.

    Returns a dictionary with the keys being the root URLs of the fdsnws
    endpoints and the values the data payloads for that endpoint.

    :param data: The return value from the EIDAWS routing service.
    """
    if service.lower() == "dataselect":
        key = "DATASELECTSERVICE"
    elif service.lower() == "station":
        key = "STATIONSERVICE"
    else:
        raise ValueError("Service must be 'dataselect' or 'station'.")

    split = collections.defaultdict(list)
    current_key = None
    for line in data.splitlines():
        line = line.strip()
        if not line:
            continue
        if "http://" in line:
            if key not in line:
                continue
            current_key = line[len(key) + 1 : line.find("/fdsnws")]
            continue
        # Anything before the first data center can be ignored.
        if current_key is None:
            continue
        split[current_key].append(line)

    return {k: "\n".join(v) for k, v in split.items()}


# Traceback (ValueError)
Downloading http://service.iris.edu/irisws/fedcatalog/1/query ...
Sending along the following payload:
----------------------------------------------------------------------
level=station
latitude=30
longitude=14
maxradius=10
format=request
* * * * 2017-10-20T00:00:00.000000 *
----------------------------------------------------------------------
Installed new opener with handlers: [<obspy.clients.fdsn.client.CustomRedirectHandler object at 0x7f56ff9d3cf8>]
Base URL: http://eida.gein.noa.gr
Request Headers: {'User-Agent': 'ObsPy/1.1.0rc7.post0+27.g04bbbf2540.obspy.read.isf (Linux-4.9.0-0.bpo.3-amd64-x86_64-with-debian-8.8, Python 3.6.3)'}
Installed new opener with handlers: [<obspy.clients.fdsn.client.CustomRedirectHandler object at 0x7f56ff9ee048>]
Installed new opener with handlers: [<obspy.clients.fdsn.client.CustomRedirectHandler object at 0x7f56ff9e3198>]
Installed new opener with handlers: [<obspy.clients.fdsn.client.CustomRedirectHandler object at 0x7f56ff9e38d0>]
Downloading http://eida.gein.noa.gr/fdsnws/dataselect/1/application.wadl with requesting gzip compression
Downloading http://eida.gein.noa.gr/fdsnws/event/1/application.wadl with requesting gzip compression
Base URL: http://service.iris.edu
Request Headers: {'User-Agent': 'ObsPy/1.1.0rc7.post0+27.g04bbbf2540.obspy.read.isf (Linux-4.9.0-0.bpo.3-amd64-x86_64-with-debian-8.8, Python 3.6.3)'}
Base URL: http://geofon.gfz-potsdam.de
Downloading http://eida.gein.noa.gr/fdsnws/event/1/catalogs with requesting gzip compression
Base URL: http://webservices.ingv.it
Downloading http://eida.gein.noa.gr/fdsnws/station/1/application.wadl with requesting gzip compression
Downloading http://service.iris.edu/fdsnws/event/1/catalogs with requesting gzip compression
Downloading http://service.iris.edu/fdsnws/dataselect/1/application.wadl with requesting gzip compression
Downloading http://service.iris.edu/fdsnws/station/1/application.wadl with requesting gzip compression
Request Headers: {'User-Agent': 'ObsPy/1.1.0rc7.post0+27.g04bbbf2540.obspy.read.isf (Linux-4.9.0-0.bpo.3-amd64-x86_64-with-debian-8.8, Python 3.6.3)'}
Downloading http://eida.gein.noa.gr/fdsnws/event/1/contributors with requesting gzip compression
Request Headers: {'User-Agent': 'ObsPy/1.1.0rc7.post0+27.g04bbbf2540.obspy.read.isf (Linux-4.9.0-0.bpo.3-amd64-x86_64-with-debian-8.8, Python 3.6.3)'}
Downloading http://service.iris.edu/fdsnws/event/1/contributors with requesting gzip compression
Downloading http://webservices.ingv.it/fdsnws/dataselect/1/application.wadl with requesting gzip compression
Downloading http://webservices.ingv.it/fdsnws/event/1/application.wadl with requesting gzip compression
Downloading http://webservices.ingv.it/fdsnws/station/1/application.wadl with requesting gzip compression
Downloading http://service.iris.edu/fdsnws/event/1/application.wadl with requesting gzip compression
Downloading http://geofon.gfz-potsdam.de/fdsnws/dataselect/1/application.wadl with requesting gzip compression
Downloading http://webservices.ingv.it/fdsnws/event/1/contributors with requesting gzip compression
Downloading http://geofon.gfz-potsdam.de/fdsnws/event/1/application.wadl with requesting gzip compression
Downloading http://geofon.gfz-potsdam.de/fdsnws/station/1/application.wadl with requesting gzip compression
Downloading http://webservices.ingv.it/fdsnws/event/1/catalogs with requesting gzip compression
Downloading http://geofon.gfz-potsdam.de/fdsnws/event/1/catalogs with requesting gzip compression
Downloading http://geofon.gfz-potsdam.de/fdsnws/event/1/contributors with requesting gzip compression
HTTP error 404, reason Not Found, while downloading 'http://geofon.gfz-potsdam.de/fdsnws/event/1/application.wadl': b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03]\x8e1\x0e\xc20\x0cEw\x9f\xc2\x17\xa0M\xa0\x08\xc8\x0e#\x03-\xec\x81\x18\x88\xd4&amp;`\xa7\x85\xe3c\t\x89\x01y\xf9\x92\x9f\xfe\x7f[\xe6\xcc\xd8\x98\xc6\xe1>\x17\xdc\xe51\x05\x80\xeeN\xc8\xf4\x1cI\n\x05M\x92G\xbe\x10\x86L\x82I1zG)\x98\x13\x96{\x14\x14\xe2\x89\xb8\x028\x8a\xbf)E\xc5\xc7^\xd03\xa1\x9f4\xfasOx\xe5<`}\r\x92^R\xd3D\xa9\xd4\xb6\x068|W\x1c\xfc\xbf\xfc\xe3\xd1\xc7\x8b/1\xa7\xea\xe5C\xffC\xb1\x1d\xcfC,*\xe6`n\xecjf\xcdl\xbe\xe8\xcc\xd2\x19\xeb\x9aue7\x9b\xb5\xb5\x00\xadZE\x95>\x11\x8b\x968\xb0\x95\x1e|\x00\xfa\xde\x86\x12\xf1\x00\x00\x00'
Uncompressing gzipped response for http://geofon.gfz-potsdam.de/fdsnws/station/1/application.wadl
Downloaded http://geofon.gfz-potsdam.de/fdsnws/station/1/application.wadl with HTTP code: 200
Uncompressing gzipped response for http://geofon.gfz-potsdam.de/fdsnws/dataselect/1/application.wadl
Downloaded http://geofon.gfz-potsdam.de/fdsnws/dataselect/1/application.wadl with HTTP code: 200
Uncompressing gzipped response for http://eida.gein.noa.gr/fdsnws/dataselect/1/application.wadl
Downloaded http://eida.gein.noa.gr/fdsnws/dataselect/1/application.wadl with HTTP code: 200
Uncompressing gzipped response for http://eida.gein.noa.gr/fdsnws/station/1/application.wadl
Downloaded http://eida.gein.noa.gr/fdsnws/station/1/application.wadl with HTTP code: 200
HTTP error 404, reason Not Found, while downloading 'http://eida.gein.noa.gr/fdsnws/event/1/application.wadl': b'Error 404: Not Found\n\nThe requested resource does not exist on this server.\n\nUsage details are available from /fdsnws/event/1/\n\nRequest:\n/fdsnws/event/1/application.wadl\n\nRequest Submitted:\n2017-10-23T05:01:48.260069\n\nService Version:\n1.1.0\n'
HTTP error 404, reason Not Found, while downloading 'http://eida.gein.noa.gr/fdsnws/event/1/contributors': b'Error 404: Not Found\n\nThe requested resource does not exist on this server.\n\nUsage details are available from /fdsnws/event/1/\n\nRequest:\n/fdsnws/event/1/contributors\n\nRequest Submitted:\n2017-10-23T05:01:48.261548\n\nService Version:\n1.1.0\n'
HTTP error 404, reason Not Found, while downloading 'http://eida.gein.noa.gr/fdsnws/event/1/catalogs': b'Error 404: Not Found\n\nThe requested resource does not exist on this server.\n\nUsage details are available from /fdsnws/event/1/\n\nRequest:\n/fdsnws/event/1/catalogs\n\nRequest Submitted:\n2017-10-23T05:01:48.26089\n\nService Version:\n1.1.0\n'
Discovered dataselect service
Discovered station service
Storing discovered services in cache.
Downloading http://eida.gein.noa.gr/fdsnws/station/1/query with requesting gzip compression
Sending along the following payload:
----------------------------------------------------------------------
level=station
latitude=30
longitude=14
maxradius=10
HC GVDS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HC KLMT * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HC KNDR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HC KTHR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HC RODP * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL ANKY * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL GVD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL IMMV * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL ITM * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL KEF3 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL KEF4 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL KEF5 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL KTHA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL LXRA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL1 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL2 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL3 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL4 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL5 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL6 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL7 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL8 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL PYL9 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL VLMS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HL VLS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
HP LTHK * * 2017-10-20T00:00:00 2599-12-31T23:59:59
----------------------------------------------------------------------
HTTP error 404, reason Not Found, while downloading 'http://geofon.gfz-potsdam.de/fdsnws/event/1/contributors': b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03]\x8e\xbdn\xc30\x0c\x84w>\x05_\xc0\xb6\xe4\xa8?\xd0\xde\x8e\x1db\xb7\xbb\x1c3\xb5\x80DDI\xca\xc9\xe3G@\x81\x0e\xc5-\x07\xdc\x07\xdc\xf7&amp;\xc2\x82\xc1\x85\x88\x1fl\xf8\xce\xb5\xac\x00\xf3F(\xf4SI\x8d\xd6\xd6\x94\xab\x9c\x08W&amp;\xc5\xd20\xbag5\xe4\x82\xb6eE%\xd9Iz\x80OM\xdf\x8d"K\xf9\xa2\x98\x840\xed\xad\xa6\xe5Bx\x16\xbe\xe2p^\xb5\xdct\xa0\x9d\x8a\r~\x008\xfe\xbeD\xf8?\x9d\xb8\x98\xe4\xa5\x1a\x8b\xfea8\xd5\xe5\x9a\xadIE\x18\x9d\x7f\xe9\xbc\xeb\xc6\xc3\xec\x9e\xa2\xf31\xbc\xf6\x07\xe7\xc6\xe7\x0005\xa3\xdc\x84\xbfH4s\x89\xe0\xfb\x16x\x00\xea\xd1\xf22\xed\x00\x00\x00'
HTTP error 404, reason Not Found, while downloading 'http://geofon.gfz-potsdam.de/fdsnws/event/1/catalogs': b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03]\x8e\xcd\n\xc20\x10\x84\xef\xfb\x14\xfb\x02\xb6I\x1bQr\xd7\xa3\x07\xff\xee\xd1nk\xa0\xcd\xe2nZ}|\x03\x82\x07\x99\xcb\xc0|0\xdfN\x84\x05\x9dq\x1e\x0f\x9cq\xcfs\xea\x00\xce\x0fB\xa1\xe7L\x9a\xa9+My\x96;a\xc7\xa4\x98\nF\xef\xa8\x199a~DE%YH*\x80\x8b\x86\xa1P\x94C\x1c\x15\x83\x10\x86\xa5\xd4p\x1b\t{\xe1\t\xeb\xbe\xd3\xf4\xd2\x9a\x16J\xb9\xb65\xc0\xf1\xfb\xe2\xe1\x7f\xba\x87\x1cF\x1e\xf4\x87\xe0i\xbeM1\x17!\x0f\x8d\xb1\x9b\x955\xab\xa6=\x9b\xb57\xd6\xbbm\xd5\x1agZ\x07p*6\xb1\xc8^I4r\xf2`\xab\x12\xf8\x00\xda\xeae\x17\xe9\x00\x00\x00'
Discovered station service
Discovered dataselect service
Storing discovered services in cache.
Downloading http://geofon.gfz-potsdam.de/fdsnws/station/1/query with requesting gzip compression
Sending along the following payload:
----------------------------------------------------------------------
level=station
latitude=30
longitude=14
maxradius=10
GE GVD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
GE IMMV * * 2017-10-20T00:00:00 2599-12-31T23:59:59
GE KERA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
GE KTHA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
----------------------------------------------------------------------
Downloaded http://webservices.ingv.it/fdsnws/event/1/contributors with HTTP code: 200
Uncompressing gzipped response for http://webservices.ingv.it/fdsnws/dataselect/1/application.wadl
Downloaded http://webservices.ingv.it/fdsnws/dataselect/1/application.wadl with HTTP code: 200
Uncompressing gzipped response for http://webservices.ingv.it/fdsnws/event/1/application.wadl
Downloaded http://webservices.ingv.it/fdsnws/event/1/application.wadl with HTTP code: 200
Uncompressing gzipped response for http://webservices.ingv.it/fdsnws/station/1/application.wadl
Downloaded http://webservices.ingv.it/fdsnws/station/1/application.wadl with HTTP code: 200
Downloaded http://webservices.ingv.it/fdsnws/event/1/catalogs with HTTP code: 200
Discovered dataselect service
Discovered event service
Discovered station service
Storing discovered services in cache.
Downloading http://webservices.ingv.it/fdsnws/station/1/query with requesting gzip compression
Sending along the following payload:
----------------------------------------------------------------------
level=station
latitude=30
longitude=14
maxradius=10
IV AGST * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV AIO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ALJA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ATN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CAGR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CAR1 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CAVT * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CELI * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CET2 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CLTA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CMDO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CORL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CRJA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV CSLB * * 2017-10-20T00:00:00 2099-10-05T00:00:00
IV ECNV * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ECTS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV EMCN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV EMSG * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ENIC * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV EPOZ * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV EPZF * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ERC * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ESLN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ESML * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV EVRN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV FAVR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV GALF * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV GIB * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV GMB * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV GRI * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV GRIS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HAGA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HAVL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HBSP * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HCRL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HLNI * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HMDC * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HPAC * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV HVZN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV IACL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV IFIL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ILLI * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV IST3 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV ISTR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV IVGP * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV IVPL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV JOPP * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV LADO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV LINA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV LPDG * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MARS * * 2017-10-20T09:42:00 2599-12-31T23:59:59
IV MCPD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MCSR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MCT * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MEU * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MFNL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MILZ * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MMGO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MNO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MPAZ * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MPG * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MPNC * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MSCL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MSFR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MSRU * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MTGR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MTTG * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV MUCR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV NOV * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV PETRA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV PIPA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV PLAC * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV PLLN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV PTMD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV RAFF * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV RESU * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV SERS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV SN1 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV SOI * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV SOLUN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV SPS2 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV SSY * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV STR4 * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV TDS * * 2017-10-20T00:00:00 2599-12-31T23:59:59
IV USI * * 2017-10-20T00:00:00 2599-12-31T23:59:59
MN AIO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
MN CEL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
MN CLTB * * 2017-10-20T00:00:00 2599-12-31T23:59:59
MN TIP * * 2017-10-20T00:00:00 2599-12-31T23:59:59
MN VAE * * 2017-10-20T00:00:00 2599-12-31T23:59:59
MN WDD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
----------------------------------------------------------------------
Uncompressing gzipped response for http://eida.gein.noa.gr/fdsnws/station/1/query
Downloaded http://eida.gein.noa.gr/fdsnws/station/1/query with HTTP code: 200
Uncompressing gzipped response for http://service.iris.edu/fdsnws/station/1/application.wadl
Uncompressing gzipped response for http://geofon.gfz-potsdam.de/fdsnws/station/1/query
Downloaded http://geofon.gfz-potsdam.de/fdsnws/station/1/query with HTTP code: 200
Uncompressing gzipped response for http://service.iris.edu/fdsnws/event/1/application.wadl
Downloaded http://service.iris.edu/fdsnws/station/1/application.wadl with HTTP code: 200
Downloaded http://service.iris.edu/fdsnws/event/1/application.wadl with HTTP code: 200
Uncompressing gzipped response for http://webservices.ingv.it/fdsnws/station/1/query
Downloaded http://webservices.ingv.it/fdsnws/station/1/query with HTTP code: 200
Uncompressing gzipped response for http://service.iris.edu/fdsnws/dataselect/1/application.wadl
Downloaded http://service.iris.edu/fdsnws/dataselect/1/application.wadl with HTTP code: 200
Downloaded http://service.iris.edu/fdsnws/event/1/catalogs with HTTP code: 200
Uncompressing gzipped response for http://service.iris.edu/fdsnws/event/1/contributors
Downloaded http://service.iris.edu/fdsnws/event/1/contributors with HTTP code: 200
Discovered station service
Discovered event service
Discovered dataselect service
Storing discovered services in cache.
Downloading http://service.iris.edu/fdsnws/station/1/query with requesting gzip compression
Sending along the following payload:
----------------------------------------------------------------------
level=station
latitude=30
longitude=14
maxradius=10
MN GFA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY AIO * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY CEL * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY CLTB * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY GFA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY GHAR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY GVD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY ITM * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY KARN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY KERA * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY MARJ * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY SKD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY TATN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY TIP * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY VAE * * 2017-10-20T00:00:00 2599-12-31T23:59:59
SY WDD * * 2017-10-20T00:00:00 2599-12-31T23:59:59
TT TAMR * * 2017-10-20T00:00:00 2599-12-31T23:59:59
TT TATN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
TT THTN * * 2017-10-20T00:00:00 2599-12-31T23:59:59
----------------------------------------------------------------------
Uncompressing gzipped response for http://service.iris.edu/fdsnws/station/1/query
Downloaded http://service.iris.edu/fdsnws/station/1/query with HTTP code: 200
Traceback (most recent call last):
File "fdsn_bug.py", line 11, in <module>
latitude=30, longitude=14, maxradius=10)
File "<decorator-gen-63>", line 2, in get_stations
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 78, in _assert_filename_not_in_kwargs
return f(*args, **kwargs)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/federator_routing_client.py", line 110, in get_stations
return super(FederatorRoutingClient, self).get_stations(**kwargs)
File "<decorator-gen-60>", line 2, in get_stations
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 78, in _assert_filename_not_in_kwargs
return f(*args, **kwargs)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 345, in get_stations
return self.get_stations_bulk([bulk], **kwargs)
File "<decorator-gen-64>", line 2, in get_stations_bulk
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 78, in _assert_filename_not_in_kwargs
return f(*args, **kwargs)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/federator_routing_client.py", line 147, in get_stations_bulk
return self._download_stations(split, **kwargs)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 219, in _download_stations
return self._download_parallel(split, data_type="station", **kwargs)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 245, in _download_parallel
results = pool.map(_download_bulk, dl_requests)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/multiprocessing/pool.py", line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/multiprocessing/pool.py", line 644, in get
raise self._value
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/routing/routing_client.py", line 96, in _download_bulk
**credentials)
File "/home/megies/anaconda/envs/1.1.0py3/lib/python3.6/site-packages/obspy/clients/fdsn/client.py", line 229, in __init__
raise ValueError(msg)
ValueError: The FDSN service base URL `http:` is not a valid URL.

# Fixed code
def _split_routing_response(data, service):
    """
    Splits the routing responses per data center for the federator output.

    Returns a dictionary with the keys being the root URLs of the fdsnws
    endpoints and the values the data payloads for that endpoint.

    :param data: The return value from the EIDAWS routing service.
    """
    if service.lower() == "dataselect":
        key = "DATASELECTSERVICE"
    elif service.lower() == "station":
        key = "STATIONSERVICE"
    else:
        raise ValueError("Service must be 'dataselect' or 'station'.")

    split = collections.defaultdict(list)
    current_key = None
    for line in data.splitlines():
        line = line.strip()
        if not line:
            continue
        if "http://" in line:
            if key not in line:
                continue
            current_key = line[len(key) + 1 : line.rfind("/fdsnws")]
            continue
        # Anything before the first data center can be ignored.
        if current_key is None:
            continue
        split[current_key].append(line)

    return {k: "\n".join(v) for k, v in split.items()}