Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/squirrel/tool/commands/update.py: 31%
26 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-04 09:52 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-04 09:52 +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
15logger = logging.getLogger('psq.cli.update')
17headline = 'Update remote sources inventories.'
20def make_subparser(subparsers):
21 return subparsers.add_parser(
22 'update',
23 help=headline,
24 description=headline)
27def setup(parser):
28 parser.add_squirrel_selection_arguments()
29 parser.add_squirrel_query_arguments()
31 parser.add_argument(
32 '--promises',
33 action='store_true',
34 dest='promises',
35 default=False,
36 help='Update waveform promises.')
38 parser.add_argument(
39 '--responses',
40 action='store_true',
41 dest='responses',
42 default=False,
43 help='Update responses.')
46def run(parser, args):
47 d = args.squirrel_query
48 squirrel = args.make_squirrel()
50 tmin = d.get('tmin', model.g_tmin)
51 tmax = d.get('tmax', model.g_tmax)
52 codes = d.get('codes', None)
54 squirrel.update(tmin=tmin, tmax=tmax)
55 if args.promises:
56 squirrel.update_waveform_promises(tmin=tmin, tmax=tmax, codes=codes)
58 if args.responses:
59 squirrel.update_responses()
61 stats = str(squirrel)
62 stats = '\n'.join(' ' + s for s in stats.splitlines())
64 logger.info('Squirrel stats:\n%s' % stats)