# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
'localhost': 'http://localhost:8080', 'kinherd': 'http://kinherd.org:8080'}
return util.time_to_str(t, format='%Y-%m-%dT%H:%M:%S')
Exception.__init__(self) self._url = url
def __str__(self): return 'No results for request %s' % self._url
Exception.__init__(self) self._url = url
def __str__(self): return 'Request entity too large: %s' % self._url
logger.debug('Accessing URL %s' % url)
if post: logger.debug('POST data: \n%s' % post) req = requests.Request( 'POST', url=url, params=kwargs, data=post) else: req = requests.Request( 'GET', url=url, params=kwargs)
ses = requests.Session()
prep = ses.prepare_request(req) prep.headers['Accept'] = '*/*'
resp = ses.send(prep, stream=True) resp.raise_for_status()
if resp.status_code == 204: raise EmptyResult(url) return resp.raw
return url % dict( site=g_site_abbr.get(site, site), service=service, majorversion=majorversion, method=method)
url = fillurl(url, site, 'static', majorversion) return _request(url, **kwargs)
return '/'.join(args)
status_callback=None, entries_wanted=None):
return util._download( url, path, force=force, method=method, status_callback=status_callback, entries_wanted=entries_wanted, recursive=True)
store_id=None, force=False, quiet=False):
url = fillurl(url, site, 'static', majorversion)
stores_url = ujoin(url, 'stores')
tlast = [time.time()]
if not quiet: def status_callback(d): i = d['nread_bytes_all_files'] n = d['ntotal_bytes_all_files'] tnow = time.time() if n != 0 and ((tnow - tlast[0]) > 5 or i == n): print('%s / %s [%.1f%%]' % ( util.human_bytesize(i), util.human_bytesize(n), i*100.0/n))
tlast[0] = tnow else: def status_callback(d): pass
wanted = ['config', 'extra/', 'index', 'phases/', 'traces/']
try: if store_id is None: print(static( url=stores_url+'/', format='text').read().decode('utf-8'))
else: store_url = ujoin(stores_url, store_id) stotal = rget( store_url, store_id, force=force, method='calcsize', entries_wanted=wanted)
rget( store_url, store_id, force=force, stats=[0, stotal], status_callback=status_callback, entries_wanted=wanted)
except Exception as e: raise DownloadError('download failed. Original error was: %s, %s' % ( type(e).__name__, e))
import shutil shutil.rmtree(store_id)
request=None):
url = fillurl(url, site, 'seismosizer', majorversion)
from pyrocko.gf import meta
return meta.load(stream=_request(url, post={'request': request.dump()})) |