-
Notifications
You must be signed in to change notification settings - Fork 1
/
buffer.py
executable file
·50 lines (36 loc) · 1.15 KB
/
buffer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# Nat Morris (c) 2017
import argparse
import logging
import os
import signal
import sys
import yaml
from cctvgifbuffer.service import Service
LOG = logging.getLogger(__name__)
def main():
logging.basicConfig(level=logging.INFO, format='%(levelname)8s [%(asctime)s] %(message)s')
parser = argparse.ArgumentParser(description="CCTV GIF Buffer")
parser.add_argument("-c", "--config", help="Config file", required=True)
parser.add_argument("-v", "--verbose", help="Increase verbosity", action="store_true")
args = parser.parse_args()
# check config exists
cfgpath = args.config.strip()
if os.path.isfile(cfgpath) is False:
LOG.fatal("Specified config file does not exist: %s", cfgpath)
sys.exit(1)
# load the config
with open(cfgpath, 'r') as stream:
try:
config = yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
sys.exit(1)
if type(config) is not dict:
LOG.fatal("Invalid YAML config")
sys.exit(1)
svc = Service(config=config)
svc.start()
sys.exit(0)
if __name__ == "__main__":
main()