# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
except ImportError: from urllib import urlencode
HTTPError, urlopen) urlopen)
'geofon': 'https://geofon.gfz-potsdam.de', 'iris': 'http://service.iris.edu', 'orfeus': 'http://www.orfeus-eu.org', 'bgr': 'http://eida.bgr.de', 'geonet': 'http://service.geonet.org.nz', 'knmi': 'http://rdsa.knmi.nl', 'ncedc': 'http://service.ncedc.org', 'scedc': 'http://service.scedc.caltech.edu', 'usgs': 'http://earthquake.usgs.gov', 'koeri': 'http://eida-service.koeri.boun.edu.tr', 'ethz': 'http://eida.ethz.ch', 'icgc': 'http://ws.icgc.cat', 'ipgp': 'http://eida.ipgp.fr', 'ingv': 'http://webservices.ingv.it', 'isc': 'http://www.isc.ac.uk', 'lmu': 'http://erde.geophysik.uni-muenchen.de', 'noa': 'http://eida.gein.noa.gr', 'resif': 'http://ws.resif.fr', 'usp': 'http://seisrequest.iag.usp.br', 'niep': 'http://eida-sc3.infp.ro' }
else: g_timeout = config.config().fdsn_timeout
realm = dict(re_realm_from_auth_header.findall( headers['WWW-Authenticate'])).get('realm', None)
if realm is None: raise CannotGetRealmFromAuthHeader('headers=%s' % str(headers))
return realm
DownloadError.__init__(self) self._url = url
def __str__(self): return 'No results for request %s' % self._url
DownloadError.__init__(self) self._url = url
def __str__(self): return 'Request entity too large: %s' % self._url
allow_TLSv1=False, **kwargs):
'timeout': timeout }
url_args['context'] = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
post = post.encode('utf8')
except TypeError: del url_args['context'] # context not avail before 3.4.3
raise EmptyResult(url)
except HTTPError as e: if e.code == 413: raise RequestEntityTooLarge(url)
elif e.code == 401: headers = getattr(e, 'headers', e.hdrs)
realm = get_realm_from_auth_header(headers)
if itry == 1 and user is not None: auth_handler = HTTPDigestAuthHandler() auth_handler.add_password( realm=realm, uri=url, user=user, passwd=passwd or '')
opener = build_opener(auth_handler) continue else: logger.error( 'authentication failed for realm "%s" when ' 'accessing url "%s"' % (realm, url))
raise DownloadError('Original error was: %s' % str(e))
else: logger.error( 'error content returned by server:\n%s' % e.read())
raise DownloadError('Original error was: %s' % str(e))
break
site=g_site_abbr.get(site, site), service=service, majorversion=majorversion, method=method)
endafter'''.split():
params['location'] = '--'
channel_prio=[['BHZ', 'HHZ'], ['BH1', 'BHN', 'HH1', 'HHN'], ['BH2', 'BHE', 'HH2', 'HHE']]):
selection = [] for station in stations: wanted = [] for group in channel_prio: gchannels = [] for channel in station.get_channels(): if channel.name in group: gchannels.append(channel) if gchannels: gchannels.sort(key=lambda a: group.index(a.name)) wanted.append(gchannels[0])
if wanted: for channel in wanted: selection.append((station.network, station.station, station.location, channel.name, tmin, tmax))
return selection
selection=None, **kwargs):
location = '--'
sdatetime(tmin), sdatetime(tmax))))
stream=_request(url, **params)) else: raise InvalidRequest('if format="text" shall be parsed, ' 'level="channel" is required')
else: raise InvalidRequest('format must be "xml" or "text"') else: return _request(url, **params)
token, url=g_url, site=g_default_site, majorversion=1):
url = fillurl(url, site, 'dataselect', majorversion, method='auth')
f = _request(url, post=token) s = f.read().decode() try: user, passwd = s.strip().split(':') except ValueError: raise CannotGetCredentialsFromAuthRequest('data="%s"' % s)
return user, passwd
user=None, passwd=None, token=None, **kwargs):
method = 'queryauth' else:
user, passwd = get_auth_credentials( token, url=url, site=site, majorversion=majorversion)
location = '--'
sdatetime(tmin), sdatetime(tmax))))
timeout=params.get('timeout', g_timeout)) else:
user=None, passwd=None, token=None, **kwargs):
'''Query FDSN web service for events
On success, will return a list of events in QuakeML format.
Check the documentation of FDSN for allowed arguments: https://www.fdsn.org/webservices '''
'starttime', 'endtime', 'minlatitude', 'maxlatitude', 'minlongitude', 'maxlongitude', 'latitude', 'longitude', 'minradius', 'maxradius', 'mindepth', 'maxdepth', 'minmagnitude', 'maxmagnitude', 'magnitudetype', 'eventtype', 'includeallorigins', 'includeallmagnitudes', 'includearrivals', 'eventid'}
raise ValueError('invalid argument: %s' % k)
method = 'queryauth' else:
user, passwd = get_auth_credentials( token, url=url, site=site, majorversion=majorversion)
|