TamasBakai | d38feb6 | 2019-02-28 09:06:19 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
TamasBakai | d38feb6 | 2019-02-28 09:06:19 +0000 | [diff] [blame] | 2 | import sys |
Bartek Grzybowski | 1f76234 | 2020-05-05 08:54:37 -0700 | [diff] [blame] | 3 | import logging |
Bartek Grzybowski | c85faa4 | 2020-05-11 05:38:08 -0700 | [diff] [blame] | 4 | from MassPnfSim import MassPnfSim, get_parser |
TamasBakai | d38feb6 | 2019-02-28 09:06:19 +0000 | [diff] [blame] | 5 | |
Bartek Grzybowski | 8feb3f5 | 2020-05-08 06:26:02 -0700 | [diff] [blame] | 6 | if __name__ == '__main__': |
| 7 | parser = get_parser() |
| 8 | args = parser.parse_args() |
Bartek Grzybowski | feb93cd | 2020-05-11 04:51:37 -0700 | [diff] [blame] | 9 | log_lvl = getattr(logging, args.verbose.upper()) |
Bartek Grzybowski | 6a09dd6 | 2020-05-08 04:39:22 -0700 | [diff] [blame] | 10 | |
Bartek Grzybowski | c85faa4 | 2020-05-11 05:38:08 -0700 | [diff] [blame] | 11 | if sys.stdout.isatty(): |
| 12 | logging.basicConfig(level=logging.INFO, format='\033[92m[%(levelname)s]\033[0m %(message)s') |
| 13 | else: |
| 14 | logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(message)s') |
| 15 | |
Bartek Grzybowski | 8feb3f5 | 2020-05-08 06:26:02 -0700 | [diff] [blame] | 16 | logger = logging.getLogger(__name__) |
Bartek Grzybowski | feb93cd | 2020-05-11 04:51:37 -0700 | [diff] [blame] | 17 | logger.setLevel(log_lvl) |
| 18 | MassPnfSim.log_lvl = log_lvl |
TamasBakai | d38feb6 | 2019-02-28 09:06:19 +0000 | [diff] [blame] | 19 | |
Bartek Grzybowski | feb93cd | 2020-05-11 04:51:37 -0700 | [diff] [blame] | 20 | if args.subcommand is not None: |
Bartek Grzybowski | 950cbad | 2020-05-11 06:00:00 -0700 | [diff] [blame^] | 21 | sim_routine = getattr(MassPnfSim(args), args.subcommand) |
| 22 | sim_routine() |
Bartek Grzybowski | feb93cd | 2020-05-11 04:51:37 -0700 | [diff] [blame] | 23 | else: |
Bartek Grzybowski | 8feb3f5 | 2020-05-08 06:26:02 -0700 | [diff] [blame] | 24 | parser.print_usage() |