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 2024-10-02 07:18 +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 

14from pyrocko import progress 

15 

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

17 

18headline = 'Update remote sources inventories.' 

19 

20 

21def make_subparser(subparsers): 

22 return subparsers.add_parser( 

23 'update', 

24 help=headline, 

25 description=headline) 

26 

27 

28def setup(parser): 

29 parser.add_squirrel_selection_arguments() 

30 parser.add_squirrel_query_arguments() 

31 

32 parser.add_argument( 

33 '--promises', 

34 action='store_true', 

35 dest='promises', 

36 default=False, 

37 help='Update waveform promises.') 

38 

39 parser.add_argument( 

40 '--responses', 

41 action='store_true', 

42 dest='responses', 

43 default=False, 

44 help='Update responses.') 

45 

46 

47def run(parser, args): 

48 with progress.view(): 

49 d = args.squirrel_query 

50 squirrel = args.make_squirrel() 

51 

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

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

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

55 

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

57 if args.promises: 

58 squirrel.update_waveform_promises( 

59 tmin=tmin, tmax=tmax, codes=codes) 

60 

61 if args.responses: 

62 squirrel.update_responses( 

63 tmin=tmin, tmax=tmax, codes=codes) 

64 

65 stats = str(squirrel) 

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

67 

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