forked from ScoDoc/ScoDoc
PE: Fix moys (thx @jmpulille). Ajoute log au zip.
This commit is contained in:
parent
6761f5a620
commit
9c15cbe647
@ -6,18 +6,37 @@
|
|||||||
"""Affichages, debug
|
"""Affichages, debug
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from flask import g
|
||||||
from app import log
|
from app import log
|
||||||
|
|
||||||
PE_DEBUG = 0
|
PE_DEBUG = False
|
||||||
|
|
||||||
if not PE_DEBUG:
|
|
||||||
# log to notes.log
|
|
||||||
def pe_print(*a, **kw):
|
|
||||||
# kw is ignored. log always add a newline
|
|
||||||
log(" ".join(a))
|
|
||||||
|
|
||||||
else:
|
# On stocke les logs PE dans g.scodoc_pe_log
|
||||||
pe_print = print # print function
|
# pour ne pas modifier les nombreux appels à pe_print.
|
||||||
|
def pe_start_log() -> list[str]:
|
||||||
|
"Initialize log"
|
||||||
|
g.scodoc_pe_log = []
|
||||||
|
return g.scodoc_pe_log
|
||||||
|
|
||||||
|
|
||||||
|
def pe_print(*a):
|
||||||
|
"Log (or print in PE_DEBUG mode) and store in g"
|
||||||
|
lines = getattr(g, "scodoc_pe_log")
|
||||||
|
if lines is None:
|
||||||
|
lines = pe_start_log()
|
||||||
|
msg = " ".join(a)
|
||||||
|
lines.append(msg)
|
||||||
|
if PE_DEBUG:
|
||||||
|
print(msg)
|
||||||
|
else:
|
||||||
|
log(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def pe_get_log() -> str:
|
||||||
|
"Renvoie une chaîne avec tous les messages loggués"
|
||||||
|
return "\n".join(getattr(g, "scodoc_pe_log", []))
|
||||||
|
|
||||||
|
|
||||||
# Affichage dans le tableur pe en cas d'absence de notes
|
# Affichage dans le tableur pe en cas d'absence de notes
|
||||||
SANS_NOTE = "-"
|
SANS_NOTE = "-"
|
||||||
|
@ -44,6 +44,7 @@ Created on Fri Sep 9 09:15:05 2016
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -70,13 +71,17 @@ class JuryPE(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, diplome):
|
def __init__(self, diplome):
|
||||||
|
pe_affichage.pe_start_log()
|
||||||
self.diplome = diplome
|
self.diplome = diplome
|
||||||
"L'année du diplome"
|
"L'année du diplome"
|
||||||
|
|
||||||
self.nom_export_zip = f"Jury_PE_{self.diplome}"
|
self.nom_export_zip = f"Jury_PE_{self.diplome}"
|
||||||
"Nom du zip où ranger les fichiers générés"
|
"Nom du zip où ranger les fichiers générés"
|
||||||
|
|
||||||
# Chargement des étudiants à prendre en compte Sydans le jury
|
pe_affichage.pe_print(
|
||||||
|
f"Données de poursuite d'étude générées le {time.strftime('%d/%m/%Y à %H:%M')}\n"
|
||||||
|
)
|
||||||
|
# Chargement des étudiants à prendre en compte dans le jury
|
||||||
pe_affichage.pe_print(
|
pe_affichage.pe_print(
|
||||||
f"""*** Recherche et chargement des étudiants diplômés en {
|
f"""*** Recherche et chargement des étudiants diplômés en {
|
||||||
self.diplome}"""
|
self.diplome}"""
|
||||||
@ -96,6 +101,8 @@ class JuryPE(object):
|
|||||||
self._gen_xls_interclassements_rcss(zipfile)
|
self._gen_xls_interclassements_rcss(zipfile)
|
||||||
self._gen_xls_synthese_jury_par_tag(zipfile)
|
self._gen_xls_synthese_jury_par_tag(zipfile)
|
||||||
self._gen_xls_synthese_par_etudiant(zipfile)
|
self._gen_xls_synthese_par_etudiant(zipfile)
|
||||||
|
# et le log
|
||||||
|
self._add_log_to_zip(zipfile)
|
||||||
|
|
||||||
# Fin !!!! Tada :)
|
# Fin !!!! Tada :)
|
||||||
|
|
||||||
@ -251,6 +258,11 @@ class JuryPE(object):
|
|||||||
zipfile, f"synthese_jury_{self.diplome}_par_etudiant.xlsx", output.read()
|
zipfile, f"synthese_jury_{self.diplome}_par_etudiant.xlsx", output.read()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _add_log_to_zip(self, zipfile):
|
||||||
|
"""Add a text file with the log messages"""
|
||||||
|
log_data = pe_affichage.pe_get_log()
|
||||||
|
self.add_file_to_zip(zipfile, "pe_log.txt", log_data)
|
||||||
|
|
||||||
def add_file_to_zip(self, zipfile: ZipFile, filename: str, data, path=""):
|
def add_file_to_zip(self, zipfile: ZipFile, filename: str, data, path=""):
|
||||||
"""Add a file to given zip
|
"""Add a file to given zip
|
||||||
All files under NOM_EXPORT_ZIP/
|
All files under NOM_EXPORT_ZIP/
|
||||||
@ -397,7 +409,7 @@ class JuryPE(object):
|
|||||||
|
|
||||||
# Les moys
|
# Les moys
|
||||||
champ = (descr, NOM_STAT_GROUPE, "moy")
|
champ = (descr, NOM_STAT_GROUPE, "moy")
|
||||||
moys = moy_traj.get_max()
|
moys = moy_traj.get_moy()
|
||||||
donnees.loc[etudids_communs, champ] = moys.loc[etudids_communs]
|
donnees.loc[etudids_communs, champ] = moys.loc[etudids_communs]
|
||||||
|
|
||||||
# Ajoute les données d'interclassement
|
# Ajoute les données d'interclassement
|
||||||
|
@ -102,11 +102,3 @@ def pe_view_sem_recap(formsemestre_id: int):
|
|||||||
download_name=scu.sanitize_filename(jury.nom_export_zip + ".zip"),
|
download_name=scu.sanitize_filename(jury.nom_export_zip + ".zip"),
|
||||||
as_attachment=True,
|
as_attachment=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
return render_template(
|
|
||||||
"pe/pe_view_sem_recap.j2",
|
|
||||||
annee_diplome=annee_diplome,
|
|
||||||
formsemestre=formsemestre,
|
|
||||||
sco=ScoData(formsemestre=formsemestre),
|
|
||||||
cosemestres=cosemestres,
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user