| Conditions | 5 |
| Total Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | #!/usr/bin/env python |
||
| 16 | def main(): |
||
| 17 | |||
| 18 | logging.basicConfig(level=logging.INFO, format='%(levelname)8s [%(asctime)s] %(message)s') |
||
| 19 | |||
| 20 | parser = argparse.ArgumentParser(description="CCTV GIF Buffer") |
||
| 21 | parser.add_argument("-c", "--config", help="Config file", required=True) |
||
| 22 | parser.add_argument("-v", "--verbose", help="Increase verbosity", action="store_true") |
||
| 23 | args = parser.parse_args() |
||
| 24 | |||
| 25 | # check config exists |
||
| 26 | cfgpath = args.config.strip() |
||
| 27 | if os.path.isfile(cfgpath) is False: |
||
| 28 | LOG.fatal("Specified config file does not exist: %s", cfgpath) |
||
| 29 | sys.exit(1) |
||
| 30 | |||
| 31 | # load the config |
||
| 32 | with open(cfgpath, 'r') as stream: |
||
| 33 | try: |
||
| 34 | config = yaml.load(stream) |
||
| 35 | except yaml.YAMLError as exc: |
||
| 36 | print(exc) |
||
| 37 | sys.exit(1) |
||
| 38 | |||
| 39 | if type(config) is not dict: |
||
| 40 | LOG.fatal("Invalid YAML config") |
||
| 41 | sys.exit(1) |
||
| 42 | |||
| 43 | svc = Service(config=config) |
||
| 44 | svc.start() |
||
| 45 | |||
| 46 | sys.exit(0) |
||
| 47 | |||
| 51 |