]>
git.ipfire.org Git - nitsi.git/blob - nitsi.in
3 from nitsi
.test
import test
4 from nitsi
.logger
import init_logging
8 from nitsi
.recipe
import RecipeExeption
10 from nitsi
.test
import TestException
12 logger
= logging
.getLogger("nitsi")
13 logger
.setLevel(logging
.DEBUG
)
14 # create console handler with a higher log level
15 ch
= logging
.StreamHandler()
16 ch
.setLevel(logging
.DEBUG
)
18 formatter
= logging
.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
19 ch
.setFormatter(formatter
)
20 # add the handlers to the logger
24 parser
= argparse
.ArgumentParser()
26 parser
.add_argument("-d", "--directory", dest
="dir")
28 parser
.add_argument("-v", "--version", help="Display version and exit",
29 action
="store_true", dest
="version")
31 args
= parser
.parse_args()
33 # We just log the version and exit
35 logger
.info("nitsi version: {}".format("@PACKAGE_VERSION@"))
38 # For all other stuff we need logging to a file
39 log_dir
= init_logging(args
.dir)
40 # We now going to log everything to log_dir/genaral.log
41 fh
= logging
.FileHandler("{}/general.log".format(log_dir
))
42 fh
.setLevel(logging
.DEBUG
)
44 logger
.debug("We now logging everything to {}/general.log".format(log_dir
))
48 currenttest
= test(args
.dir, log_dir
)
49 currenttest
.read_settings()
50 currenttest
.virtual_environ_setup()
51 currenttest
.load_recipe()
52 except RecipeExeption
as e
:
57 currenttest
.virtual_environ_start()
58 currenttest
.run_recipe()
59 except TestException
as e
:
62 except BaseException
as e
:
66 currenttest
.virtual_environ_stop()
70 if __name__
== "__main__":