Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/apps/pyrocko.py: 0%
49 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6'''
7Pyrocko - package introspection.
8'''
10import sys
11import logging
13logger = logging.getLogger('main')
16def main(args=None):
17 '''
18 CLI entry point for Pyrocko's ``pyrocko`` app.
19 '''
20 logging.basicConfig(
21 level=logging.INFO,
22 format='pyrocko:%(name)-25s - %(levelname)-8s - %(message)s')
24 try:
25 from pyrocko import squirrel
27 class PrintVersion(squirrel.SquirrelCommand):
28 def make_subparser(self, subparsers):
29 return subparsers.add_parser(
30 'version',
31 help='Print version.',
32 description='Print version.')
34 def setup(self, parser):
35 parser.add_argument(
36 '--long',
37 dest='long',
38 action='store_true',
39 help='Print long version string.')
41 def run(self, parser, args):
42 import pyrocko
43 if args.long:
44 print(pyrocko.long_version)
45 else:
46 print(pyrocko.__version__)
48 class PrintDependencies(squirrel.SquirrelCommand):
49 def make_subparser(self, subparsers):
50 return subparsers.add_parser(
51 'dependencies',
52 help='Print versions of available dependencies.',
53 description='Print versions of available dependencies.')
55 def setup(self, parser):
56 pass
58 def run(self, parser, args):
59 from pyrocko import deps
60 deps.print_dependencies()
62 class PrintInfo(squirrel.SquirrelCommand):
63 def make_subparser(self, subparsers):
64 return subparsers.add_parser(
65 'info',
66 help='Print information about Pyrocko installation(s).',
67 description='Print information about Pyrocko '
68 'installation(s).')
70 def setup(self, parser):
71 pass
73 def run(self, parser, args):
74 from pyrocko import deps
75 print()
76 print('Python executable:\n %s' % sys.executable)
77 print()
78 deps.print_installations()
80 squirrel.run(
81 args=args,
82 prog='pyrocko',
83 subcommands=[
84 PrintVersion(),
85 PrintDependencies(),
86 PrintInfo()],
87 description='Tools for seismology.')
89 except ImportError as e:
90 from pyrocko import deps
91 logger.info('\n' + deps.str_dependencies())
92 logger.info('\n' + deps.str_installations())
94 try:
95 deps.require_all('required')
97 except deps.MissingPyrockoDependency as e2:
98 logger.fatal(str(e2))
99 sys.exit(1)
101 logger.fatal(str(e))
102 sys.exit(1)
105if __name__ == '__main__':
106 main()