2016-11-13 15:54:11 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
2016-11-14 04:42:50 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
# création de l'objet logger qui va nous servir à écrire dans les logs
|
|
|
|
logger = logging.getLogger("generate_bilan")
|
|
|
|
# on met le niveau du logger à DEBUG, comme ça il écrit tout
|
2016-11-25 20:57:49 +00:00
|
|
|
logger.setLevel(logging.DEBUG)
|
2016-11-14 04:42:50 +00:00
|
|
|
formatter = logging.Formatter('%(asctime)s :: %(name)s :: %(levelname)s :: %(message)s')
|
|
|
|
steam_handler = logging.StreamHandler()
|
|
|
|
steam_handler.setLevel(logging.DEBUG)
|
|
|
|
steam_handler.setFormatter(formatter)
|
|
|
|
logger.addHandler(steam_handler)
|
|
|
|
|
|
|
|
|
2016-11-13 15:54:11 +00:00
|
|
|
from .generate_bilan import generate_bilan
|
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
from path import Path
|
2016-11-14 04:42:50 +00:00
|
|
|
import sys
|
|
|
|
|
2016-11-13 15:54:11 +00:00
|
|
|
|
|
|
|
# Defaults settings
|
|
|
|
default_template = "tpl_bilan.tex"
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = optparse.OptionParser()
|
|
|
|
parser.add_option("-c",
|
|
|
|
"--classe",
|
|
|
|
action="store",
|
|
|
|
type="string",
|
|
|
|
dest="classe",
|
|
|
|
help="The classe")
|
|
|
|
parser.add_option("-e",
|
|
|
|
"--evaluation",
|
|
|
|
action="store",
|
|
|
|
type="string",
|
|
|
|
dest="ds_name",
|
|
|
|
help="The evaluation name.")
|
|
|
|
parser.add_option("-p",
|
|
|
|
"--path",
|
|
|
|
action="store",
|
|
|
|
type="string",
|
|
|
|
dest="path",
|
|
|
|
default=Path("./"),
|
|
|
|
help="Path where xlsx are stored")
|
|
|
|
parser.add_option("-t",
|
|
|
|
"--template",
|
|
|
|
action="store",
|
|
|
|
type="string",
|
|
|
|
dest="template",
|
|
|
|
default=default_template,
|
|
|
|
help="The template file")
|
2016-11-14 04:42:50 +00:00
|
|
|
parser.add_option("-d",
|
|
|
|
"--debug",
|
|
|
|
action="store_true",
|
|
|
|
dest="debug_level",
|
|
|
|
help="Enable debug")
|
|
|
|
|
2016-11-13 15:54:11 +00:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if not options.classe:
|
2016-11-14 04:42:50 +00:00
|
|
|
logger.error("Need to pass a class with -c. See -h for help")
|
|
|
|
sys.exit()
|
2016-11-13 15:54:11 +00:00
|
|
|
if not options.ds_name:
|
2016-11-14 04:42:50 +00:00
|
|
|
logger.error("Need to pass a evaluation name with -e. See -h for help")
|
|
|
|
sys.exit()
|
|
|
|
if options.debug_level:
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
2016-11-13 15:54:11 +00:00
|
|
|
|
|
|
|
generate_bilan(options.classe,
|
|
|
|
options.ds_name,
|
|
|
|
options.path,
|
|
|
|
options.template)
|
|
|
|
|
2016-11-14 04:42:50 +00:00
|
|
|
logger.info("À fini")
|
|
|
|
|
2016-11-13 15:54:11 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|
|
|
|
# -----------------------------
|
|
|
|
# Reglages pour 'vim'
|
|
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
|
|
|
# cursor: 16 del
|