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: |
| 21 | sim = MassPnfSim(args) |
| 22 | if args.subcommand == 'bootstrap' : |
| 23 | sim.bootstrap() |
| 24 | if args.subcommand == 'clean': |
| 25 | sim.clean() |
| 26 | if args.subcommand == 'start': |
| 27 | sim.start() |
| 28 | if args.subcommand == 'status': |
| 29 | sim.status() |
| 30 | if args.subcommand == 'stop': |
| 31 | sim.stop() |
| 32 | if args.subcommand == 'trigger': |
| 33 | sim.trigger() |
| 34 | if args.subcommand == 'trigger-custom': |
| 35 | sim.trigger_custom() |
| 36 | else: |
Bartek Grzybowski | 8feb3f5 | 2020-05-08 06:26:02 -0700 | [diff] [blame] | 37 | parser.print_usage() |