88 lines
2.3 KiB
Python
88 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
# encoding: utf-8
|
|
|
|
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
|
|
logger.setLevel(logging.WARNING)
|
|
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)
|
|
|
|
|
|
from .generate_bilan import generate_bilan
|
|
import optparse
|
|
import os
|
|
from path import Path
|
|
import sys
|
|
|
|
|
|
# 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")
|
|
parser.add_option("-d",
|
|
"--debug",
|
|
action="store_true",
|
|
dest="debug_level",
|
|
help="Enable debug")
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
if not options.classe:
|
|
logger.error("Need to pass a class with -c. See -h for help")
|
|
sys.exit()
|
|
if not options.ds_name:
|
|
logger.error("Need to pass a evaluation name with -e. See -h for help")
|
|
sys.exit()
|
|
if options.debug_level:
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
generate_bilan(options.classe,
|
|
options.ds_name,
|
|
options.path,
|
|
options.template)
|
|
|
|
logger.info("À fini")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
# -----------------------------
|
|
# Reglages pour 'vim'
|
|
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
|
# cursor: 16 del
|