Add --version command
[nitsi.git] / nitsi.in
CommitLineData
1ed8ca9f 1#!/usr/bin/python3
f72f2f70 2
2fa4467d 3from nitsi.test import test
1ed8ca9f
JS
4import logging
5
6logger = logging.getLogger("nitsi")
7logger.setLevel(logging.DEBUG)
8# create file handler which logs even debug messages
9fh = logging.FileHandler('nitsi.log')
10fh.setLevel(logging.DEBUG)
11# create console handler with a higher log level
12ch = logging.StreamHandler()
13ch.setLevel(logging.DEBUG)
14
15formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
16fh.setFormatter(formatter)
17ch.setFormatter(formatter)
18# add the handlers to the logger
19logger.addHandler(fh)
20logger.addHandler(ch)
f72f2f70
JS
21
22if __name__ == "__main__":
23 import argparse
24
25 parser = argparse.ArgumentParser()
26
27 parser.add_argument("-d", "--directory", dest="dir")
28
4cba2549
JS
29 parser.add_argument("-v" "--version", help="Display version and exit",
30 action="store_true", dest="version")
31
f72f2f70
JS
32 args = parser.parse_args()
33
4cba2549
JS
34 if args.version:
35 logger.info("nitsi version: {}".format("@PACKAGE_VERSION@"))
36 else:
37 currenttest = test(args.dir)
38 currenttest.read_settings()
39 currenttest.virtual_environ_setup()
40 currenttest.load_recipe()
41 try:
42 currenttest.virtual_environ_start()
43 currenttest.run_recipe()
44 except BaseException as e:
45 print(e)
46 finally:
47 currenttest.virtual_environ_stop()