]>
git.ipfire.org Git - people/jschlag/nitsi.git/blob - nitsi.in
6 from nitsi
.logger
import init_logging
7 from nitsi
.recipe
import RecipeExeption
8 from nitsi
.test
import TestException
, test
10 logger
= logging
.getLogger("nitsi")
11 logger
.setLevel(logging
.DEBUG
)
12 # create console handler with a higher log level
13 ch
= logging
.StreamHandler()
14 ch
.setLevel(logging
.DEBUG
)
16 formatter
= logging
.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
17 ch
.setFormatter(formatter
)
18 # add the handlers to the logger
22 parser
= argparse
.ArgumentParser()
24 parser
.add_argument("-d", "--directory", dest
="dir")
26 parser
.add_argument("-v", "--version", help="Display version and exit",
27 action
="store_true", dest
="version")
29 args
= parser
.parse_args()
31 # We just log the version and exit
33 logger
.info("nitsi version: {}".format("@PACKAGE_VERSION@"))
36 # For all other stuff we need logging to a file
37 log_dir
= init_logging(args
.dir)
38 # We now going to log everything to log_dir/genaral.log
39 fh
= logging
.FileHandler("{}/general.log".format(log_dir
))
40 fh
.setLevel(logging
.DEBUG
)
42 logger
.debug("We now logging everything to {}/general.log".format(log_dir
))
46 currenttest
= test(args
.dir, log_dir
)
47 currenttest
.read_settings()
48 currenttest
.virtual_environ_setup()
49 currenttest
.load_recipe()
50 except RecipeExeption
as e
:
55 currenttest
.virtual_environ_start()
56 currenttest
.run_recipe()
57 except TestException
as e
:
60 except BaseException
as e
:
64 currenttest
.virtual_environ_stop()
68 if __name__
== "__main__":
70 logger
.debug("Return value of main is: {}".format(return_value
))