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-06 06:59 +0000

1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6''' 

7Implementation of :app:`squirrel update`. 

8''' 

9 

10import logging 

11 

12# from pyrocko.squirrel.error import SquirrelError 

13from pyrocko.squirrel import model 

14 

15logger = logging.getLogger('psq.cli.update') 

16 

17headline = 'Update remote sources inventories.' 

18 

19 

20def make_subparser(subparsers): 

21 return subparsers.add_parser( 

22 'update', 

23 help=headline, 

24 description=headline) 

25 

26 

27def setup(parser): 

28 parser.add_squirrel_selection_arguments() 

29 parser.add_squirrel_query_arguments() 

30 

31 parser.add_argument( 

32 '--promises', 

33 action='store_true', 

34 dest='promises', 

35 default=False, 

36 help='Update waveform promises.') 

37 

38 parser.add_argument( 

39 '--responses', 

40 action='store_true', 

41 dest='responses', 

42 default=False, 

43 help='Update responses.') 

44 

45 

46def run(parser, args): 

47 d = args.squirrel_query 

48 squirrel = args.make_squirrel() 

49 

50 tmin = d.get('tmin', model.g_tmin) 

51 tmax = d.get('tmax', model.g_tmax) 

52 codes = d.get('codes', None) 

53 

54 squirrel.update(tmin=tmin, tmax=tmax) 

55 if args.promises: 

56 squirrel.update_waveform_promises(tmin=tmin, tmax=tmax, codes=codes) 

57 

58 if args.responses: 

59 squirrel.update_responses() 

60 

61 stats = str(squirrel) 

62 stats = '\n'.join(' ' + s for s in stats.splitlines()) 

63 

64 logger.info('Squirrel stats:\n%s' % stats)