From aee02d911e8766b9803020e9ffb30627f124165f Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 29 Aug 2021 19:57:32 +0200 Subject: [PATCH] reorganized logging. --- app/__init__.py | 82 +++++++++++++++++---- app/scodoc/TrivialFormulator.py | 2 +- app/scodoc/gen_tables.py | 2 +- app/scodoc/html_sco_header.py | 2 +- app/scodoc/notes_log.py | 77 ------------------- app/scodoc/notes_table.py | 2 +- app/scodoc/notesdb.py | 2 +- app/scodoc/pe_avislatex.py | 2 +- app/scodoc/pe_semestretag.py | 2 +- app/scodoc/pe_tools.py | 2 +- app/scodoc/sco_abs.py | 2 +- app/scodoc/sco_abs_notification.py | 2 +- app/scodoc/sco_abs_views.py | 2 +- app/scodoc/sco_apogee_compare.py | 2 +- app/scodoc/sco_apogee_csv.py | 2 +- app/scodoc/sco_archives.py | 26 ++++++- app/scodoc/sco_bulletins.py | 2 +- app/scodoc/sco_bulletins_example.py | 2 +- app/scodoc/sco_bulletins_generator.py | 3 +- app/scodoc/sco_bulletins_legacy.py | 2 +- app/scodoc/sco_bulletins_pdf.py | 2 +- app/scodoc/sco_bulletins_standard.py | 2 +- app/scodoc/sco_bulletins_ucac.py | 6 +- app/scodoc/sco_bulletins_xml.py | 2 +- app/scodoc/sco_cache.py | 2 +- app/scodoc/sco_compute_moy.py | 2 +- app/scodoc/sco_config_load.py | 2 +- app/scodoc/sco_debouche.py | 2 +- app/scodoc/sco_dump_db.py | 2 +- app/scodoc/sco_edit_formation.py | 2 +- app/scodoc/sco_edit_matiere.py | 2 +- app/scodoc/sco_edit_module.py | 2 +- app/scodoc/sco_edit_ue.py | 2 +- app/scodoc/sco_edt_cal.py | 2 +- app/scodoc/sco_etape_apogee_view.py | 2 +- app/scodoc/sco_etape_bilan.py | 2 +- app/scodoc/sco_etud.py | 2 +- app/scodoc/sco_evaluations.py | 1 - app/scodoc/sco_excel.py | 2 +- app/scodoc/sco_export_results.py | 2 +- app/scodoc/sco_formations.py | 2 +- app/scodoc/sco_formsemestre.py | 2 +- app/scodoc/sco_formsemestre_edit.py | 6 +- app/scodoc/sco_formsemestre_exterieurs.py | 2 +- app/scodoc/sco_formsemestre_inscriptions.py | 2 +- app/scodoc/sco_formsemestre_status.py | 2 +- app/scodoc/sco_formsemestre_validation.py | 2 +- app/scodoc/sco_groups.py | 2 +- app/scodoc/sco_import_etuds.py | 2 +- app/scodoc/sco_import_users.py | 2 +- app/scodoc/sco_inscr_passage.py | 2 +- app/scodoc/sco_liste_notes.py | 2 +- app/scodoc/sco_modalites.py | 2 +- app/scodoc/sco_moduleimpl.py | 2 +- app/scodoc/sco_moduleimpl_inscriptions.py | 2 +- app/scodoc/sco_news.py | 2 +- app/scodoc/sco_page_etud.py | 2 +- app/scodoc/sco_parcours_dut.py | 2 +- app/scodoc/sco_pdf.py | 2 +- app/scodoc/sco_photos.py | 2 +- app/scodoc/sco_placement.py | 2 +- app/scodoc/sco_portal_apogee.py | 2 +- app/scodoc/sco_preferences.py | 2 +- app/scodoc/sco_pvjury.py | 2 +- app/scodoc/sco_recapcomplet.py | 2 +- app/scodoc/sco_report.py | 2 +- app/scodoc/sco_saisie_notes.py | 2 +- app/scodoc/sco_semset.py | 2 +- app/scodoc/sco_synchro_etuds.py | 2 +- app/scodoc/sco_tag_module.py | 2 +- app/scodoc/sco_trombino.py | 2 +- app/scodoc/sco_trombino_tours.py | 2 +- app/scodoc/sco_ue_external.py | 2 +- app/scodoc/sco_up_to_date.py | 2 +- app/scodoc/sco_users.py | 2 +- app/scodoc/sco_utils.py | 6 +- app/views/absences.py | 2 +- app/views/entreprises.py | 2 +- app/views/notes.py | 4 +- app/views/scodoc.py | 16 ++++ app/views/scolar.py | 5 +- app/views/users.py | 2 +- config.py | 2 +- tests/unit/sco_fake_gen.py | 2 +- tools/debian/postinst | 4 + tools/etc/scodoc-logrotate | 9 +++ 86 files changed, 204 insertions(+), 187 deletions(-) delete mode 100644 app/scodoc/notes_log.py create mode 100644 tools/etc/scodoc-logrotate diff --git a/app/__init__.py b/app/__init__.py index 9d64174b..665b7fe5 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -2,10 +2,13 @@ # pylint: disable=invalid-name import os +import socket import sys +import time +import traceback import logging -from logging.handlers import SMTPHandler, TimedRotatingFileHandler +from logging.handlers import SMTPHandler, WatchedFileHandler from flask import request from flask import Flask @@ -51,9 +54,6 @@ def create_app(config_class=DevConfig): app.logger.setLevel(logging.DEBUG) app.config.from_object(config_class) - app.logger.info( - f"create_app({config_class.__name__}, {config_class.SQLALCHEMY_DATABASE_URI})" - ) db.init_app(app) migrate.init_app(app, db) login.init_app(app) @@ -88,7 +88,11 @@ def create_app(config_class=DevConfig): absences_bp, url_prefix="/ScoDoc//Scolarite/Absences" ) + # Config logs pour PRODUCTION if not app.debug and not app.testing: + # On supprime le logguer par défaut qui va vers stderr et pollue le slogs systemes + # nb: pas trouvé plus élégant + app.logger.handlers.pop() if app.config["MAIL_SERVER"]: auth = None if app.config["MAIL_USERNAME"] or app.config["MAIL_PASSWORD"]: @@ -96,24 +100,25 @@ def create_app(config_class=DevConfig): secure = None if app.config["MAIL_USE_TLS"]: secure = () + host_name = socket.gethostname() mail_handler = SMTPHandler( mailhost=(app.config["MAIL_SERVER"], app.config["MAIL_PORT"]), fromaddr="no-reply@" + app.config["MAIL_SERVER"], - toaddrs=[app.config["ADMINS"]], - subject="ScoDoc Failure", + toaddrs=["exception@scodoc.org"], + subject="ScoDoc Exception from " + host_name, credentials=auth, secure=secure, ) mail_handler.setLevel(logging.ERROR) app.logger.addHandler(mail_handler) + + # Config logs pour DEV et PRODUCTION if not app.testing: # Configuration des logs (actifs aussi en mode development) - if not os.path.exists("logs"): - os.mkdir("logs") - file_handler = TimedRotatingFileHandler( - "/opt/scodoc-data/log/scodoc.log", - when="W6", # Sunday - backupCount=53, # 1 an de logs + # usually /opt/scodoc-data/log/scodoc.log: + # rotated by logrotate + file_handler = WatchedFileHandler( + app.config["SCODOC_LOG_FILE"], encoding="utf-8" ) file_handler.setFormatter( logging.Formatter( @@ -123,9 +128,25 @@ def create_app(config_class=DevConfig): file_handler.setLevel(logging.INFO) app.logger.addHandler(file_handler) - app.logger.setLevel(logging.INFO) + # app.logger.setLevel(logging.INFO) app.logger.info(f"{sco_version.SCONAME} {sco_version.SCOVERSION} startup") + app.logger.info( + f"create_app({config_class.__name__}, {config_class.SQLALCHEMY_DATABASE_URI})" + ) + # ---- INITIALISATION SPECIFIQUES A SCODOC + from app.scodoc import sco_bulletins_generator + from app.scodoc.sco_bulletins_example import BulletinGeneratorExample + from app.scodoc.sco_bulletins_legacy import BulletinGeneratorLegacy + from app.scodoc.sco_bulletins_standard import BulletinGeneratorStandard + from app.scodoc.sco_bulletins_ucac import BulletinGeneratorUCAC + sco_bulletins_generator.register_bulletin_class(BulletinGeneratorExample) + sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy) + sco_bulletins_generator.register_bulletin_class(BulletinGeneratorStandard) + sco_bulletins_generator.register_bulletin_class(BulletinGeneratorUCAC) + app.logger.info( + f"registered bulletin classes {[ k for k in sco_bulletins_generator.BULLETIN_CLASSES ]}" + ) return app @@ -230,6 +251,41 @@ def clear_scodoc_cache(): sco_preferences.clear_base_preferences() +# --------- Logging +def log(msg: str): + """log a message. + If Flask app, use configured logger, else stderr.""" + try: + dept = getattr(g, "scodoc_dept", "") + msg = f" ({dept}) {msg}" + except RuntimeError: + # Flask Working outside of application context. + pass + + if current_app: + current_app.logger.info(msg) + else: + sys.stdout.flush() + sys.stderr.write( + "[%s] scodoc: %s\n" % (time.strftime("%a %b %d %H:%M:%S %Y"), msg) + ) + sys.stderr.flush() + + +# Debug: log call stack +def log_call_stack(): + log("Call stack:\n" + "\n".join(x.strip() for x in traceback.format_stack()[:-1])) + + +# Alarms by email: +def send_scodoc_alarm(subject, txt): + from app.scodoc import sco_preferences + from app import email + + sender = sco_preferences.get_preference("email_from_addr") + email.send_email(subject, sender, ["exception@scodoc.org"], txt) + + from app.models import Departement from app.scodoc import notesdb as ndb, sco_preferences from app.scodoc import sco_cache diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index e894f4d0..ebe5c52a 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -487,7 +487,7 @@ class TF(object): lem.append("") for i in range(len(labels)): if input_type == "checkbox": - # from app.scodoc.notes_log import log # debug only + # from app.scodoc.sco_utils import log # debug only # log('checkbox: values[%s] = "%s"' % (field,repr(values[field]) )) # log("descr['allowed_values'][%s] = '%s'" % (i, repr(descr['allowed_values'][i]))) if ( diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index d93ca574..a318f93e 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -59,7 +59,7 @@ from app.scodoc import sco_excel from app.scodoc import sco_pdf from app.scodoc import sco_xml from app.scodoc.sco_pdf import SU -from app.scodoc.notes_log import log +from app import log def mark_paras(L, tags): diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py index 82c33cf7..4944f6e4 100644 --- a/app/scodoc/html_sco_header.py +++ b/app/scodoc/html_sco_header.py @@ -35,7 +35,7 @@ from flask import request from flask_login import current_user import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sidebar import sco_version diff --git a/app/scodoc/notes_log.py b/app/scodoc/notes_log.py deleted file mode 100644 index 6f91ec12..00000000 --- a/app/scodoc/notes_log.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- mode: python -*- -# -*- coding: utf-8 -*- - -import os -import time -import traceback - -from flask import g, current_app - -from app import email - -"""Simple & stupid file logguer, used only to debug - (logging to SQL is done in scolog) -""" - -LOG_FILENAME = "notes.log" # empty to disable logging -DEFAULT_LOG_DIR = ( - "/opt/scodoc-data/log" # clients should call set_log_directory to change this -) - -ALARM_DESTINATION = "emmanuel@scodoc.org" - - -class _logguer(object): - def __init__(self): - self.file = None - self.directory = None - self.set_log_directory(DEFAULT_LOG_DIR) - - def set_log_directory(self, directory): - if self.directory != directory and self.file: - # changing directory when a log is already open: close it - self.file.close() - self.file = None - self.directory = directory - - def _open(self): - if LOG_FILENAME: - path = os.path.join(self.directory, LOG_FILENAME) - self.file = open(path, "a") - self("new _logguer (%s)" % path) - else: - self.file = None # logging disabled - - def __call__(self, msg): - if not self.file: - self._open() - if self.file: - try: - dept = getattr(g, "scodoc_dept", "") - except RuntimeError: - # Flask Working outside of application context. - dept = "" - if dept: - dept = " (%s)" % dept - msg = dept + " " + msg - self.file.write("[%s]%s\n" % (time.strftime("%a %b %d %H:%M:%S %Y"), msg)) - if current_app: - current_app.logger.info(msg) - - self.file.flush() - - -log = _logguer() - - -# Alarms by email: -def sendAlarm(subject, txt): - from app.scodoc import sco_preferences - - sender = sco_preferences.get_preference("email_from_addr") - email.send_email(subject, sender, [ALARM_DESTINATION], txt) - - -# Debug: log call stack -def logCallStack(): - log("Call stack:\n" + "\n".join(x.strip() for x in traceback.format_stack()[:-1])) diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index bfd7c9e2..0c5b6a65 100644 --- a/app/scodoc/notes_table.py +++ b/app/scodoc/notes_table.py @@ -37,7 +37,7 @@ from flask import g, url_for import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_formulas import NoteVector from app.scodoc.sco_exceptions import ( AccessDenied, diff --git a/app/scodoc/notesdb.py b/app/scodoc/notesdb.py index f6af848b..e9fdaf02 100644 --- a/app/scodoc/notesdb.py +++ b/app/scodoc/notesdb.py @@ -11,7 +11,7 @@ from flask import g, current_app import app import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoException, ScoValueError, NoteProcessError import datetime diff --git a/app/scodoc/pe_avislatex.py b/app/scodoc/pe_avislatex.py index 3259e20f..70fe390d 100644 --- a/app/scodoc/pe_avislatex.py +++ b/app/scodoc/pe_avislatex.py @@ -39,7 +39,7 @@ from app.scodoc import pe_tools import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.gen_tables import GenTable, SeqGenTable from app.scodoc import sco_preferences from app.scodoc import sco_etud diff --git a/app/scodoc/pe_semestretag.py b/app/scodoc/pe_semestretag.py index 779efdf6..286c7cd9 100644 --- a/app/scodoc/pe_semestretag.py +++ b/app/scodoc/pe_semestretag.py @@ -36,7 +36,7 @@ Created on Fri Sep 9 09:15:05 2016 @author: barasc """ -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_codes_parcours from app.scodoc import sco_cache from app.scodoc import sco_tag_module diff --git a/app/scodoc/pe_tools.py b/app/scodoc/pe_tools.py index 2dc94ea9..5be8e2d9 100644 --- a/app/scodoc/pe_tools.py +++ b/app/scodoc/pe_tools.py @@ -43,7 +43,7 @@ import re import unicodedata import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log import six PE_DEBUG = 0 diff --git a/app/scodoc/sco_abs.py b/app/scodoc/sco_abs.py index 84c94655..a0fffc67 100644 --- a/app/scodoc/sco_abs.py +++ b/app/scodoc/sco_abs.py @@ -36,7 +36,7 @@ import time import types from app.scodoc import notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc.sco_exceptions import ScoValueError, ScoInvalidDateError from app.scodoc import sco_abs_notification diff --git a/app/scodoc/sco_abs_notification.py b/app/scodoc/sco_abs_notification.py index 23cc4904..69f6518b 100644 --- a/app/scodoc/sco_abs_notification.py +++ b/app/scodoc/sco_abs_notification.py @@ -38,7 +38,7 @@ from flask_mail import Message import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc import sco_etud from app.scodoc import sco_formsemestre diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index c83e654e..213a4a3e 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -46,7 +46,7 @@ from app.scodoc import sco_groups from app.scodoc import sco_moduleimpl from app.scodoc import sco_photos from app.scodoc import sco_preferences -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError diff --git a/app/scodoc/sco_apogee_compare.py b/app/scodoc/sco_apogee_compare.py index 25858300..f116a42b 100644 --- a/app/scodoc/sco_apogee_compare.py +++ b/app/scodoc/sco_apogee_compare.py @@ -44,7 +44,7 @@ Pour chaque étudiant commun: """ -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_apogee_csv from app.scodoc.gen_tables import GenTable from app.scodoc.sco_exceptions import ScoValueError diff --git a/app/scodoc/sco_apogee_csv.py b/app/scodoc/sco_apogee_csv.py index deab4e15..2fce3c39 100644 --- a/app/scodoc/sco_apogee_csv.py +++ b/app/scodoc/sco_apogee_csv.py @@ -96,7 +96,7 @@ from chardet import detect as chardet_detect import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError, FormatError from app.scodoc.gen_tables import GenTable from app.scodoc.sco_vdi import ApoEtapeVDI diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index c9333eea..108bb055 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -59,7 +59,7 @@ from flask import g import app.scodoc.sco_utils as scu from config import Config -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc.sco_exceptions import ( AccessDenied, @@ -77,9 +77,17 @@ from app.scodoc import sco_pvpdf class BaseArchiver(object): def __init__(self, archive_type=""): + self.archive_type = archive_type + self.initialized = False + self.root = None + + def initialize(self): + if self.initialized: + return dirs = [Config.SCODOC_VAR_DIR, "archives"] - if archive_type: - dirs.append(archive_type) + if self.archive_type: + dirs.append(self.archive_type) + self.root = os.path.join(*dirs) log("initialized archiver, path=" + self.root) path = dirs[0] @@ -92,12 +100,14 @@ class BaseArchiver(object): os.mkdir(path) finally: scu.GSL.release() + self.initialized = True def get_obj_dir(self, oid): """ :return: path to directory of archives for this object (eg formsemestre_id or etudid). If directory does not yet exist, create it. """ + self.initialize() dept_dir = os.path.join(self.root, g.scodoc_dept) try: scu.GSL.acquire() @@ -116,6 +126,7 @@ class BaseArchiver(object): """ :return: list of archive oids """ + self.initialize() base = os.path.join(self.root, g.scodoc_dept) + os.path.sep dirs = glob.glob(base + "*") return [os.path.split(x)[1] for x in dirs] @@ -124,6 +135,7 @@ class BaseArchiver(object): """Returns :return: list of archive identifiers for this object (paths to non empty dirs) """ + self.initialize() base = self.get_obj_dir(oid) + os.path.sep dirs = glob.glob( base @@ -136,6 +148,7 @@ class BaseArchiver(object): def delete_archive(self, archive_id): """Delete (forever) this archive""" + self.initialize() try: scu.GSL.acquire() shutil.rmtree(archive_id, ignore_errors=True) @@ -149,6 +162,7 @@ class BaseArchiver(object): def list_archive(self, archive_id: str) -> str: """Return list of filenames (without path) in archive""" + self.initialize() try: scu.GSL.acquire() files = os.listdir(archive_id) @@ -169,6 +183,7 @@ class BaseArchiver(object): def get_id_from_name(self, oid, archive_name): """returns archive id (check that name is valid)""" + self.initialize() if not self.is_valid_archive_name(archive_name): raise ValueError("invalid archive name") archive_id = os.path.join(self.get_obj_dir(oid), archive_name) @@ -182,6 +197,7 @@ class BaseArchiver(object): def get_archive_description(self, archive_id): """Return description of archive""" + self.initialize() return open(os.path.join(archive_id, "_description.txt")).read() def create_obj_archive(self, oid: int, description: str): @@ -205,6 +221,7 @@ class BaseArchiver(object): Filename may be modified (sanitized): return used filename The file is created or replaced. """ + self.initialize() filename = scu.sanitize_filename(filename) log("storing %s (%d bytes) in %s" % (filename, len(data), archive_id)) try: @@ -219,6 +236,7 @@ class BaseArchiver(object): def get(self, archive_id: str, filename: str): """Retreive data""" + self.initialize() if not scu.is_valid_filename(filename): log('Archiver.get: invalid filename "%s"' % filename) raise ValueError("invalid filename") @@ -401,7 +419,7 @@ def formsemestre_archive(REQUEST, formsemestre_id, group_ids=[]): les documents résultant de ce semestre: PV de jury, lettres individuelles, tableaux récapitulatifs.

Les documents archivés sont enregistrés et non modifiables, on peut les retrouver ultérieurement. -

On peut archiver plusieurs versions des documents +

On peut archiver plusieurs versions des documents (avant et après le jury par exemple).

""", diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index c1ce03ef..2c346123 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -46,7 +46,7 @@ from flask_mail import Message import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import AccessDenied from app.scodoc import html_sco_header diff --git a/app/scodoc/sco_bulletins_example.py b/app/scodoc/sco_bulletins_example.py index 8a50a398..ce24edde 100644 --- a/app/scodoc/sco_bulletins_example.py +++ b/app/scodoc/sco_bulletins_example.py @@ -67,4 +67,4 @@ class BulletinGeneratorExample(sco_bulletins_standard.BulletinGeneratorStandard) # Déclarer votre classe à ScoDoc: -sco_bulletins_generator.register_bulletin_class(BulletinGeneratorExample) +# sco_bulletins_generator.register_bulletin_class(BulletinGeneratorExample) diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index 5a1bfa27..bea049a5 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -54,7 +54,7 @@ from reportlab.platypus import Table, TableStyle, Image, KeepInFrame from app.scodoc import sco_utils as scu from app.scodoc.sco_exceptions import NoteProcessError -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_formsemestre from app.scodoc import sco_pdf from app.scodoc.sco_pdf import PDFLOCK @@ -65,7 +65,6 @@ BULLETIN_CLASSES = collections.OrderedDict() def register_bulletin_class(klass): - log("registering bulletin class '%s'" % klass.__name__) BULLETIN_CLASSES[klass.__name__] = klass diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index 01acbbcf..5198872b 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -378,7 +378,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): return [] -sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy) +# sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy) class BulTableStyle(object): diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index a655b7cf..fd21a70c 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -61,7 +61,7 @@ from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate from flask import g, url_for import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_cache from app.scodoc import sco_formsemestre from app.scodoc import sco_pdf diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index a8f88b79..296239ea 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -673,4 +673,4 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): return nbeval -sco_bulletins_generator.register_bulletin_class(BulletinGeneratorStandard) +# sco_bulletins_generator.register_bulletin_class(BulletinGeneratorStandard) diff --git a/app/scodoc/sco_bulletins_ucac.py b/app/scodoc/sco_bulletins_ucac.py index 088bc096..46d3e7b7 100644 --- a/app/scodoc/sco_bulletins_ucac.py +++ b/app/scodoc/sco_bulletins_ucac.py @@ -300,8 +300,4 @@ class BulletinGeneratorUCAC(sco_bulletins_standard.BulletinGeneratorStandard): return colkeys, P, pdf_style, colWidths -sco_bulletins_generator.register_bulletin_class(BulletinGeneratorUCAC) - - -def bulletin_table_ucac(I, version=None): - """""" +# sco_bulletins_generator.register_bulletin_class(BulletinGeneratorUCAC) diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index fc3cda44..9329db68 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -46,7 +46,7 @@ from xml.etree.ElementTree import Element import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_abs from app.scodoc import sco_codes_parcours from app.scodoc import sco_cache diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index c107fb33..4ccfb748 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -61,7 +61,7 @@ from flask import g from app.scodoc import notesdb as ndb from app.scodoc import sco_utils as scu -from app.scodoc.notes_log import log +from app import log CACHE = None # set in app.__init__.py diff --git a/app/scodoc/sco_compute_moy.py b/app/scodoc/sco_compute_moy.py index 9ae16999..ae821068 100644 --- a/app/scodoc/sco_compute_moy.py +++ b/app/scodoc/sco_compute_moy.py @@ -41,7 +41,7 @@ from app.scodoc.sco_utils import ( EVALUATION_SESSION2, ) from app.scodoc.sco_exceptions import ScoException -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_abs from app.scodoc import sco_edit_module from app.scodoc import sco_evaluations diff --git a/app/scodoc/sco_config_load.py b/app/scodoc/sco_config_load.py index dceeee65..39378473 100644 --- a/app/scodoc/sco_config_load.py +++ b/app/scodoc/sco_config_load.py @@ -6,7 +6,7 @@ import os import sys -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_config # scodoc_local defines a CONFIG object diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py index 6e128e23..8def0249 100644 --- a/app/scodoc/sco_debouche.py +++ b/app/scodoc/sco_debouche.py @@ -33,7 +33,7 @@ from flask import url_for, g import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import AccessDenied from app.scodoc.scolog import logdb from app.scodoc.gen_tables import GenTable diff --git a/app/scodoc/sco_dump_db.py b/app/scodoc/sco_dump_db.py index db9d4a5e..befe5e33 100644 --- a/app/scodoc/sco_dump_db.py +++ b/app/scodoc/sco_dump_db.py @@ -54,7 +54,7 @@ import requests import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_preferences from app.scodoc import sco_users diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py index 5de623e6..7c666d16 100644 --- a/app/scodoc/sco_edit_formation.py +++ b/app/scodoc/sco_edit_formation.py @@ -33,7 +33,7 @@ from flask import g, url_for import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py index 4f662a9d..6b9e7d43 100644 --- a/app/scodoc/sco_edit_matiere.py +++ b/app/scodoc/sco_edit_matiere.py @@ -33,7 +33,7 @@ from flask import g, url_for import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError from app.scodoc import html_sco_header diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index f3ebed08..3b4ce254 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -33,7 +33,7 @@ from flask import url_for, g import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import ScoValueError, ScoLockedFormError, ScoGenError diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index 66a8fe8c..e19e7e17 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -34,7 +34,7 @@ from flask_login import current_user import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator, TF from app.scodoc.gen_tables import GenTable from app.scodoc.sco_permissions import Permission diff --git a/app/scodoc/sco_edt_cal.py b/app/scodoc/sco_edt_cal.py index 3f28bec7..4f97bcbb 100644 --- a/app/scodoc/sco_edt_cal.py +++ b/app/scodoc/sco_edt_cal.py @@ -39,7 +39,7 @@ import icalendar import pprint import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_formsemestre from app.scodoc import sco_groups diff --git a/app/scodoc/sco_etape_apogee_view.py b/app/scodoc/sco_etape_apogee_view.py index 514d262a..3345eb10 100644 --- a/app/scodoc/sco_etape_apogee_view.py +++ b/app/scodoc/sco_etape_apogee_view.py @@ -35,7 +35,7 @@ import flask from flask import url_for, g import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import notes_table from app.scodoc import sco_apogee_csv diff --git a/app/scodoc/sco_etape_bilan.py b/app/scodoc/sco_etape_bilan.py index 6d1bb22a..dbb6e877 100644 --- a/app/scodoc/sco_etape_bilan.py +++ b/app/scodoc/sco_etape_bilan.py @@ -95,7 +95,7 @@ import json from flask import url_for, g from app.scodoc.sco_portal_apogee import get_inscrits_etape -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_utils import annee_scolaire_debut from app.scodoc.gen_tables import GenTable diff --git a/app/scodoc/sco_etud.py b/app/scodoc/sco_etud.py index 365ebc4d..c653c007 100644 --- a/app/scodoc/sco_etud.py +++ b/app/scodoc/sco_etud.py @@ -45,7 +45,7 @@ from app.scodoc.sco_utils import SCO_ENCODING import app.scodoc.notesdb as ndb from app.scodoc.sco_exceptions import ScoGenError, ScoValueError -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc import safehtml from app.scodoc import sco_preferences diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 4ab2e05d..45a555d8 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -39,7 +39,6 @@ from flask import g from flask_login import current_user from flask import request -from app.scodoc.notes_log import log, logCallStack import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb from app.scodoc.sco_exceptions import AccessDenied, ScoValueError diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 34495ac8..32cf27c0 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -44,7 +44,7 @@ from openpyxl.comments import Comment import app.scodoc.sco_utils as scu from app.scodoc import notesdb from app.scodoc import sco_preferences -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError diff --git a/app/scodoc/sco_export_results.py b/app/scodoc/sco_export_results.py index e0636b49..73f3c27e 100644 --- a/app/scodoc/sco_export_results.py +++ b/app/scodoc/sco_export_results.py @@ -31,7 +31,7 @@ from flask import url_for, g import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_bac from app.scodoc import sco_codes_parcours diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index e18ad011..2194a00f 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -36,7 +36,7 @@ from flask import g, url_for import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_codes_parcours from app.scodoc import sco_edit_matiere from app.scodoc import sco_edit_module diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index eadc20dc..3360b847 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -40,7 +40,7 @@ from app.scodoc import sco_formations from app.scodoc import sco_preferences from app.scodoc import sco_users from app.scodoc.gen_tables import GenTable -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_codes_parcours import NO_SEMESTRE_ID from app.scodoc.sco_vdi import ApoEtapeVDI import app.scodoc.notesdb as ndb diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index b165f6f9..df228561 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -36,7 +36,7 @@ import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu from app.scodoc import sco_cache from app.scodoc import sco_groups -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator, TF from app.scodoc.sco_exceptions import AccessDenied, ScoValueError from app.scodoc.sco_permissions import Permission @@ -78,7 +78,7 @@ def formsemestre_createwithmodules(REQUEST=None): """

Mise en place d'un semestre de formation

""", ] r = do_formsemestre_createwithmodules(REQUEST=REQUEST) - if isinstance(r, six.string_types): + if isinstance(r, str): H.append(r) else: return r # response redirect @@ -106,7 +106,7 @@ def formsemestre_editwithmodules(REQUEST, formsemestre_id): ) else: r = do_formsemestre_createwithmodules(REQUEST=REQUEST, edit=1) - if isinstance(r, six.string_types): + if isinstance(r, str): H.append(r) else: return r # response redirect diff --git a/app/scodoc/sco_formsemestre_exterieurs.py b/app/scodoc/sco_formsemestre_exterieurs.py index 578e85de..ca3c4294 100644 --- a/app/scodoc/sco_formsemestre_exterieurs.py +++ b/app/scodoc/sco_formsemestre_exterieurs.py @@ -39,7 +39,7 @@ from flask_login import current_user import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.sco_utils import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message from app.scodoc import html_sco_header from app.scodoc import sco_cache diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 8f2c3a08..627a2844 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -33,7 +33,7 @@ import flask from flask import url_for, g import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_permissions import Permission diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index c31d0bfc..1e2862e3 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -34,7 +34,7 @@ from flask import request from flask import url_for from flask_login import current_user -from app.scodoc.notes_log import log +from app import log import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb from app.scodoc.sco_permissions import Permission diff --git a/app/scodoc/sco_formsemestre_validation.py b/app/scodoc/sco_formsemestre_validation.py index 00d80655..47ffd83f 100644 --- a/app/scodoc/sco_formsemestre_validation.py +++ b/app/scodoc/sco_formsemestre_validation.py @@ -34,7 +34,7 @@ from flask import url_for, g import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message from app.scodoc.sco_exceptions import ScoValueError diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 989830e0..aec10d82 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -47,7 +47,7 @@ from flask import url_for import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc import html_sco_header from app.scodoc import sco_codes_parcours diff --git a/app/scodoc/sco_import_etuds.py b/app/scodoc/sco_import_etuds.py index f9b688b4..e224d326 100644 --- a/app/scodoc/sco_import_etuds.py +++ b/app/scodoc/sco_import_etuds.py @@ -39,7 +39,7 @@ from flask import g, url_for import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_excel import COLORS from app.scodoc.sco_formsemestre_inscriptions import ( do_formsemestre_inscription_with_modules, diff --git a/app/scodoc/sco_import_users.py b/app/scodoc/sco_import_users.py index 3a46257c..68f5ecd3 100644 --- a/app/scodoc/sco_import_users.py +++ b/app/scodoc/sco_import_users.py @@ -36,7 +36,7 @@ from email.header import Header from app import db, Departement import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import AccessDenied, ScoValueError, ScoException from app.scodoc import sco_excel from app.scodoc import sco_preferences diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index 90f89db9..9efaabce 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -35,7 +35,7 @@ from flask import url_for, g import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.gen_tables import GenTable from app.scodoc import html_sco_header from app.scodoc import sco_codes_parcours diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index 26fb6205..a8f540db 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -35,7 +35,7 @@ from flask import url_for, g import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc import htmlutils from app.scodoc import html_sco_header diff --git a/app/scodoc/sco_modalites.py b/app/scodoc/sco_modalites.py index ebb6ca0b..13cbeef6 100644 --- a/app/scodoc/sco_modalites.py +++ b/app/scodoc/sco_modalites.py @@ -35,7 +35,7 @@ Elle n'est pas utilisée pour les parcours, ni pour rien d'autre """ import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log def list_formsemestres_modalites(sems): diff --git a/app/scodoc/sco_moduleimpl.py b/app/scodoc/sco_moduleimpl.py index dd4f6029..7d82744a 100644 --- a/app/scodoc/sco_moduleimpl.py +++ b/app/scodoc/sco_moduleimpl.py @@ -34,7 +34,7 @@ import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import ScoValueError, AccessDenied -from app.scodoc.notes_log import log +from app import log from app.scodoc import scolog from app.scodoc import sco_formsemestre from app.scodoc import sco_cache diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index 46b1d614..42d2fff0 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -34,7 +34,7 @@ from flask import url_for, g import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc import html_sco_header from app.scodoc import htmlutils diff --git a/app/scodoc/sco_news.py b/app/scodoc/sco_news.py index 22d50fae..cf73fc70 100644 --- a/app/scodoc/sco_news.py +++ b/app/scodoc/sco_news.py @@ -38,7 +38,7 @@ from flask_login import current_user import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_formsemestre from app.scodoc import sco_moduleimpl from app.scodoc import sco_preferences diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index 109c1ddf..00dc6492 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -34,7 +34,7 @@ from flask import url_for, g import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import htmlutils from app.scodoc import sco_archives_etud diff --git a/app/scodoc/sco_parcours_dut.py b/app/scodoc/sco_parcours_dut.py index 0d478f01..2fb5c732 100644 --- a/app/scodoc/sco_parcours_dut.py +++ b/app/scodoc/sco_parcours_dut.py @@ -30,7 +30,7 @@ import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc import sco_cache from app.scodoc import sco_formsemestre diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py index 3d3799c8..1f496463 100755 --- a/app/scodoc/sco_pdf.py +++ b/app/scodoc/sco_pdf.py @@ -64,7 +64,7 @@ from app.scodoc.sco_utils import ( SCODOC_LOGOS_DIR, LOGOS_IMAGES_ALLOWED_TYPES, ) -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoGenError import sco_version diff --git a/app/scodoc/sco_photos.py b/app/scodoc/sco_photos.py index 579ac825..b63b2afc 100644 --- a/app/scodoc/sco_photos.py +++ b/app/scodoc/sco_photos.py @@ -61,7 +61,7 @@ from config import Config from app.scodoc import sco_etud from app.scodoc import sco_portal_apogee from app.scodoc import sco_preferences -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index d3a9675e..4f9e9a0b 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -39,7 +39,7 @@ import flask from app.scodoc.sco_exceptions import ScoValueError import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_edit_module from app.scodoc import sco_evaluations diff --git a/app/scodoc/sco_portal_apogee.py b/app/scodoc/sco_portal_apogee.py index fe827683..e79b3531 100644 --- a/app/scodoc/sco_portal_apogee.py +++ b/app/scodoc/sco_portal_apogee.py @@ -36,7 +36,7 @@ import xml.sax.saxutils import xml.dom.minidom import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError from app.scodoc import sco_preferences import six diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 3ecc5a67..b8c4eafa 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -115,7 +115,7 @@ from flask import g from app.models import Departement from app.scodoc import sco_cache -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError, ScoException from app.scodoc.TrivialFormulator import TrivialFormulator import app.scodoc.notesdb as ndb diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index d7bc9c8b..c49c5844 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -56,7 +56,7 @@ from flask import url_for, g import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_codes_parcours from app.scodoc import sco_cache diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index 02bacda9..86579f8c 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -32,7 +32,7 @@ import datetime from xml.etree import ElementTree import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_bac from app.scodoc import sco_bulletins_json diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py index b0a02ab7..2bf2fa1e 100644 --- a/app/scodoc/sco_report.py +++ b/app/scodoc/sco_report.py @@ -56,7 +56,7 @@ from app.scodoc import sco_pdf from app.scodoc import sco_preferences import sco_version from app.scodoc.gen_tables import GenTable -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_codes_parcours import code_semestre_validant from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_pdf import SU diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py index e7890a84..ea7aac90 100644 --- a/app/scodoc/sco_saisie_notes.py +++ b/app/scodoc/sco_saisie_notes.py @@ -40,7 +40,7 @@ from flask_login import current_user import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ( AccessDenied, InvalidNoteValue, diff --git a/app/scodoc/sco_semset.py b/app/scodoc/sco_semset.py index 929f5561..b6d3abc2 100644 --- a/app/scodoc/sco_semset.py +++ b/app/scodoc/sco_semset.py @@ -50,7 +50,7 @@ from app.scodoc import sco_formsemestre_status from app.scodoc import sco_portal_apogee from app.scodoc import sco_preferences from app.scodoc.gen_tables import GenTable -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_etape_bilan import EtapeBilan from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_vdi import ApoEtapeVDI diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index b324d61e..db54f84c 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -46,7 +46,7 @@ from app.scodoc import sco_news from app.scodoc import sco_excel from app.scodoc import sco_portal_apogee from app.scodoc import sco_etud -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_permissions import Permission diff --git a/app/scodoc/sco_tag_module.py b/app/scodoc/sco_tag_module.py index ba97b861..246c9593 100644 --- a/app/scodoc/sco_tag_module.py +++ b/app/scodoc/sco_tag_module.py @@ -39,7 +39,7 @@ from flask import g, url_for import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_cache from app.scodoc import sco_edit_module from app.scodoc import sco_etud diff --git a/app/scodoc/sco_trombino.py b/app/scodoc/sco_trombino.py index 455278d5..24019712 100644 --- a/app/scodoc/sco_trombino.py +++ b/app/scodoc/sco_trombino.py @@ -46,7 +46,7 @@ from PIL import Image as PILImage import flask from flask import url_for, g -from app.scodoc.notes_log import log +from app import log import app.scodoc.sco_utils as scu from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc.sco_exceptions import ScoValueError diff --git a/app/scodoc/sco_trombino_tours.py b/app/scodoc/sco_trombino_tours.py index 1a9dbd4c..b77bf61d 100644 --- a/app/scodoc/sco_trombino_tours.py +++ b/app/scodoc/sco_trombino_tours.py @@ -37,7 +37,7 @@ from reportlab.lib import pagesizes from reportlab.lib.pagesizes import A4, A3 import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import sco_abs from app.scodoc import sco_groups from app.scodoc import sco_groups_view diff --git a/app/scodoc/sco_ue_external.py b/app/scodoc/sco_ue_external.py index 5c9f5626..ff1d69d2 100644 --- a/app/scodoc/sco_ue_external.py +++ b/app/scodoc/sco_ue_external.py @@ -58,7 +58,7 @@ from flask_login import current_user import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc import html_sco_header from app.scodoc import sco_codes_parcours from app.scodoc import sco_edit_matiere diff --git a/app/scodoc/sco_up_to_date.py b/app/scodoc/sco_up_to_date.py index cfb7869d..cab38a63 100644 --- a/app/scodoc/sco_up_to_date.py +++ b/app/scodoc/sco_up_to_date.py @@ -32,7 +32,7 @@ import datetime import app.scodoc.sco_utils as scu -from app.scodoc.notes_log import log +from app import log # Appel renvoyant la subversion "stable" # La notion de "stable" est juste là pour éviter d'afficher trop frequemment diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py index 6cbaab2c..f7eee673 100644 --- a/app/scodoc/sco_users.py +++ b/app/scodoc/sco_users.py @@ -45,7 +45,7 @@ from app.scodoc import sco_etud from app.scodoc import sco_excel from app.scodoc import sco_preferences from app.scodoc.gen_tables import GenTable -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb import app.scodoc.sco_utils as scu diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 1a541044..fcbfb4a7 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -43,13 +43,14 @@ import six import six.moves._thread import sys import time +import traceback import types import unicodedata import six.moves.urllib.parse, six.moves.urllib.error import six.moves.urllib.error, six.moves.urllib.parse from xml.etree import ElementTree -STRING_TYPES = six.string_types +from flask import g, current_app from PIL import Image as PILImage @@ -57,7 +58,6 @@ from flask import g, url_for, request from config import Config -from app.scodoc.notes_log import log from app.scodoc.sco_vdi import ApoEtapeVDI from app.scodoc.sco_xml import quote_xml_attr from app.scodoc.sco_codes_parcours import NOTES_TOLERANCE, CODES_EXPL @@ -794,7 +794,7 @@ def return_text_if_published(val, REQUEST): sauf quand elles sont appellées depuis python. La présence de l'argument REQUEST indique la publication. """ - if REQUEST and not isinstance(val, STRING_TYPES): + if REQUEST and not isinstance(val, str): return sendJSON(REQUEST, val) return val diff --git a/app/views/absences.py b/app/views/absences.py index 9feec920..f0dee786 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -75,7 +75,7 @@ from app.views import absences_bp as bp # --------------- from app.scodoc import sco_utils as scu from app.scodoc import notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import ScoValueError, ScoInvalidDateError diff --git a/app/views/entreprises.py b/app/views/entreprises.py index 33c712f0..b5568b61 100644 --- a/app/views/entreprises.py +++ b/app/views/entreprises.py @@ -42,7 +42,7 @@ import calendar # A REVOIR # from sco_permissions import ScoEntrepriseView, ScoEntrepriseChange -# from app.scodoc.notes_log import log +# from app import log # from scolog import logdb # from sco_utils import SCO_ENCODING # import app.scodoc.sco_utils as scu diff --git a/app/views/notes.py b/app/views/notes.py index e60fdfac..0c7c57a4 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -60,7 +60,7 @@ from app.views import notes_bp as bp from app.scodoc import sco_utils as scu from app.scodoc import notesdb as ndb -from app.scodoc.notes_log import log, sendAlarm +from app import log, send_scodoc_alarm from app.scodoc import scolog from app.scodoc.scolog import logdb @@ -2514,7 +2514,7 @@ def check_formsemestre_integrity(formsemestre_id, REQUEST=None): ) ) if diag: - sendAlarm( + send_scodoc_alarm( "Notes: formation incoherente dans semestre %s !" % formsemestre_id, "\n".join(diag), ) diff --git a/app/views/scodoc.py b/app/views/scodoc.py index 4e97aa2c..5c12673c 100644 --- a/app/views/scodoc.py +++ b/app/views/scodoc.py @@ -62,3 +62,19 @@ def index(): def table_etud_in_accessible_depts(): """recherche étudiants sur plusieurs départements""" return sco_find_etud.table_etud_in_accessible_depts(expnom=request.form["expnom"]) + + +# essais +@bp.route("/testlog") +def testlog(): + import time + from flask import current_app + from app import log + + log(f"testlog called: handlers={current_app.logger.handlers}") + current_app.logger.debug(f"testlog message DEBUG") + current_app.logger.info(f"testlog message INFO") + current_app.logger.warning(f"testlog message WARNING") + current_app.logger.error(f"testlog message ERROR") + current_app.logger.critical(f"testlog message CRITICAL") + return "testlog completed at " + str(time.time()) diff --git a/app/views/scolar.py b/app/views/scolar.py index 81df91bc..7d817cc3 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -57,7 +57,7 @@ from app.views import scolar_bp as bp import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb -from app.scodoc.notes_log import log +from app import log from app.scodoc.scolog import logdb from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import ( @@ -119,9 +119,6 @@ def sco_publish(route, function, permission, methods=["GET"]): ) -log.set_log_directory(Config.SCODOC_VAR_DIR + "/log") -log("ScoDoc restarting...") - # -------------------------------------------------------------------- # # SCOLARITE (/ScoDoc//Scolarite/...) diff --git a/app/views/users.py b/app/views/users.py index 1d150fe2..44ca1281 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -61,7 +61,7 @@ from app.scodoc import html_sco_header, sco_import_users, sco_excel from app.scodoc import sco_users from app.scodoc import sco_utils as scu from app.scodoc import sco_xml -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import AccessDenied, ScoValueError from app.scodoc.sco_permissions_check import can_handle_passwd from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message diff --git a/config.py b/config.py index a7329be3..aed798d6 100755 --- a/config.py +++ b/config.py @@ -29,7 +29,7 @@ class Config: BOOTSTRAP_SERVE_LOCAL = os.environ.get("BOOTSTRAP_SERVE_LOCAL") SCODOC_DIR = os.environ.get("SCODOC_DIR", "/opt/scodoc") SCODOC_VAR_DIR = os.environ.get("SCODOC_VAR_DIR", "/opt/scodoc-data") - + SCODOC_LOG_FILE = os.path.join(SCODOC_VAR_DIR, "log", "scodoc.log") # For legacy ScoDoc7 installs: postgresql user SCODOC7_SQL_USER = os.environ.get("SCODOC7_SQL_USER", "www-data") DEFAULT_SQL_PORT = os.environ.get("DEFAULT_SQL_PORT", "5432") diff --git a/tests/unit/sco_fake_gen.py b/tests/unit/sco_fake_gen.py index 2468cb9d..cd5bddde 100644 --- a/tests/unit/sco_fake_gen.py +++ b/tests/unit/sco_fake_gen.py @@ -34,7 +34,7 @@ from app.scodoc import sco_moduleimpl from app.scodoc import sco_saisie_notes from app.scodoc import sco_synchro_etuds from app.scodoc import sco_utils as scu -from app.scodoc.notes_log import log +from app import log from app.scodoc.sco_exceptions import ScoValueError random.seed(12345) # tests reproductibles diff --git a/tools/debian/postinst b/tools/debian/postinst index 3ef84dae..c2a3d89f 100644 --- a/tools/debian/postinst +++ b/tools/debian/postinst @@ -103,6 +103,10 @@ then su -c "(cd $SCODOC_DIR && source venv/bin/activate && flask db upgrade)" "$SCODOC_USER" fi +# ------------ LOGROTATE +cp "$SCODOC_DIR"/tools/etc/scodoc-logrotate /etc/logrotate.d/scodoc +chmod 644 /etc/logrotate.d/scodoc + # ------------ CONFIG SERVICE SCODOC echo echo "Installation du service systemd scodoc9..." diff --git a/tools/etc/scodoc-logrotate b/tools/etc/scodoc-logrotate new file mode 100644 index 00000000..59e94103 --- /dev/null +++ b/tools/etc/scodoc-logrotate @@ -0,0 +1,9 @@ +/opt/scodoc-datalog/scodoc.log { + weekly + missingok + rotate 64 + compress + notifempty + dateext + create 0644 scodoc scodoc +}