basic log
This commit is contained in:
parent
5ba03e8e40
commit
ae5a529602
@ -1,10 +1,25 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# 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
|
from .generate_bilan import generate_bilan
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
from path import Path
|
from path import Path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# Defaults settings
|
# Defaults settings
|
||||||
default_template = "tpl_bilan.tex"
|
default_template = "tpl_bilan.tex"
|
||||||
@ -38,18 +53,31 @@ def main():
|
|||||||
dest="template",
|
dest="template",
|
||||||
default=default_template,
|
default=default_template,
|
||||||
help="The template file")
|
help="The template file")
|
||||||
|
parser.add_option("-d",
|
||||||
|
"--debug",
|
||||||
|
action="store_true",
|
||||||
|
dest="debug_level",
|
||||||
|
help="Enable debug")
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if not options.classe:
|
if not options.classe:
|
||||||
raise ValueError("Need to pass a class with -c. See -h for help")
|
logger.error("Need to pass a class with -c. See -h for help")
|
||||||
|
sys.exit()
|
||||||
if not options.ds_name:
|
if not options.ds_name:
|
||||||
raise ValueError("Need to pass a evaluation name with -e. See -h for help")
|
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,
|
generate_bilan(options.classe,
|
||||||
options.ds_name,
|
options.ds_name,
|
||||||
options.path,
|
options.path,
|
||||||
options.template)
|
options.template)
|
||||||
|
|
||||||
|
logger.info("À fini")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@ import numpy as np
|
|||||||
import xlrd
|
import xlrd
|
||||||
from path import Path
|
from path import Path
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger("generate_bilan")
|
||||||
|
|
||||||
notStudent = ["Trimestre", "Nom", "Date", "Exercice", "Question", "Competence", "Domaine", "Commentaire", "Bareme", "Niveau"]
|
notStudent = ["Trimestre", "Nom", "Date", "Exercice", "Question", "Competence", "Domaine", "Commentaire", "Bareme", "Niveau"]
|
||||||
|
|
||||||
def extract_students(df, notStudent = notStudent):
|
def extract_students(df, notStudent = notStudent):
|
||||||
@ -92,7 +95,7 @@ def feed_bilan(target, datas, template = "tpl_bilan.tex"):
|
|||||||
|
|
||||||
with open(target, "w") as f:
|
with open(target, "w") as f:
|
||||||
f.write(bilan.render(**datas))
|
f.write(bilan.render(**datas))
|
||||||
print("{} est construit! Ya plus qu'à compiler!".format(target))
|
logger.info("{} est construit! Ya plus qu'à compiler!".format(target))
|
||||||
|
|
||||||
def generate_bilan(classe, ds_name, path = Path('./'), template = "tpl_bilan.tex"):
|
def generate_bilan(classe, ds_name, path = Path('./'), template = "tpl_bilan.tex"):
|
||||||
""" Generate the bilan of a evaluation for a class
|
""" Generate the bilan of a evaluation for a class
|
||||||
@ -104,9 +107,11 @@ def generate_bilan(classe, ds_name, path = Path('./'), template = "tpl_bilan.tex
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
ws = get_class_ws(classe, path)
|
ws = get_class_ws(classe, path)
|
||||||
|
logger.info("Worksheets of {} imported".format(classe))
|
||||||
|
|
||||||
flat_df = extract_flat_marks(ws)
|
flat_df = extract_flat_marks(ws)
|
||||||
quest_df, exo_df, eval_df = digest_flat_df(flat_df)
|
quest_df, exo_df, eval_df = digest_flat_df(flat_df)
|
||||||
|
logger.info("Worksheets parsed")
|
||||||
|
|
||||||
quest_df = select_ds(ds_name, quest_df)
|
quest_df = select_ds(ds_name, quest_df)
|
||||||
exo_df = select_ds(ds_name, exo_df)
|
exo_df = select_ds(ds_name, exo_df)
|
||||||
|
Loading…
Reference in New Issue
Block a user