Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/squirrel/tool/commands/update.py: 32%
28 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-11-27 09:36 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-11-27 09:36 +0000
1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6'''
7Implementation of :app:`squirrel update`.
8'''
10import logging
12# from pyrocko.squirrel.error import SquirrelError
13from pyrocko.squirrel import model
14from pyrocko import progress
16logger = logging.getLogger('psq.cli.update')
18headline = 'Update remote sources inventories.'
21def make_subparser(subparsers):
22 return subparsers.add_parser(
23 'update',
24 help=headline,
25 description=headline)
28def setup(parser):
29 parser.add_squirrel_selection_arguments()
30 parser.add_squirrel_query_arguments()
32 parser.add_argument(
33 '--promises',
34 action='store_true',
35 dest='promises',
36 default=False,
37 help='Update waveform promises.')
39 parser.add_argument(
40 '--responses',
41 action='store_true',
42 dest='responses',
43 default=False,
44 help='Update responses.')
47def run(parser, args):
48 with progress.view():
49 d = args.squirrel_query
50 squirrel = args.make_squirrel()
52 tmin = d.get('tmin', model.g_tmin)
53 tmax = d.get('tmax', model.g_tmax)
54 codes = d.get('codes', None)
56 squirrel.update(tmin=tmin, tmax=tmax)
57 if args.promises:
58 squirrel.update_waveform_promises(
59 tmin=tmin, tmax=tmax, codes=codes)
61 if args.responses:
62 squirrel.update_responses(
63 tmin=tmin, tmax=tmax, codes=codes)
65 stats = str(squirrel)
66 stats = '\n'.join(' ' + s for s in stats.splitlines())
68 logger.info('Squirrel stats:\n%s' % stats)