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 9d64174b60..665b7fe5d6 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 e894f4d08a..ebe5c52a82 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 d93ca57452..a318f93eec 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 82c33cf790..4944f6e406 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 6f91ec1220..0000000000 --- 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 bfd7c9e25e..0c5b6a6532 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 f6af848b50..e9fdaf0250 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 3259e20fb2..70fe390df4 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 779efdf61f..286c7cd9bd 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 2dc94ea973..5be8e2d986 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 84c9465547..a0fffc6737 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 23cc49044a..69f6518bb2 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 c83e654ef7..213a4a3eff 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 25858300c1..f116a42b14 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 deab4e1593..2fce3c3937 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 c9333eeaf8..108bb055ef 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 c1ce03ef62..2c346123ce 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 8a50a39834..ce24edde29 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 5a1bfa2709..bea049a596 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 01acbbcf94..5198872bdc 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 a655b7cf91..fd21a70c82 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 a8f88b793c..296239ead0 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 088bc09620..46d3e7b7a3 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 fc3cda44c6..9329db687d 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 c107fb33b7..4ccfb74819 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 9ae16999fd..ae821068fc 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 dceeee6517..3937847329 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 6e128e23e0..8def024964 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 db9d4a5eb7..befe5e33ed 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 5de623e6ed..7c666d16de 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 4f662a9d8f..6b9e7d4379 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 f3ebed08cc..3b4ce2540d 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 66a8fe8c48..e19e7e1781 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 3f28bec7dc..4f97bcbbdf 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 514d262a18..3345eb1087 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 6d1bb22a3f..dbb6e87767 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 365ebc4d91..c653c007d0 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 4ab2e05d47..45a555d895 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 34495ac80a..32cf27c0a3 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 e0636b491d..73f3c27eeb 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 e18ad01176..2194a00f1f 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 eadc20dcc8..3360b847b7 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 b165f6f949..df2285616f 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 578e85de78..ca3c4294e8 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 8f2c3a0889..627a2844d0 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 c31d0bfc15..1e2862e371 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 00d80655b5..47ffd83f66 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 989830e07e..aec10d82dc 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 f9b688b481..e224d32614 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 3a46257c3f..68f5ecd3c9 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 90f89db9a3..9efaabce2c 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 26fb6205ac..a8f540dbdd 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 ebb6ca0b61..13cbeef6c0 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 dd4f6029b3..7d82744a64 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 46b1d614b9..42d2fff0cc 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 22d50fae3d..cf73fc7056 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 109c1ddf50..00dc64927e 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 0d478f0189..2fb5c732c5 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 3d3799c8a8..1f49646326 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 579ac82549..b63b2afc3d 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 d3a9675e34..4f9e9a0b79 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 fe827683a6..e79b35312a 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 3ecc5a6788..b8c4eafae1 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 d7bc9c8ba5..c49c584494 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 02bacda949..86579f8c67 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 b0a02ab7a2..2bf2fa1e93 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 e7890a8470..ea7aac90be 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 929f55615d..b6d3abc267 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 b324d61ec0..db54f84cf2 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 ba97b86120..246c959332 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 455278d5d1..24019712b1 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 1a9dbd4c08..b77bf61d03 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 5c9f562617..ff1d69d261 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 cfb7869deb..cab38a63c0 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 6cbaab2cd0..f7eee67311 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 1a54104488..fcbfb4a767 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 9feec9206a..f0dee786a7 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 33c712f0f6..b5568b61c7 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 e60fdfacd1..0c7c57a415 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 4e97aa2c85..5c12673c6e 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 81df91bc11..7d817cc30f 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 1d150fe201..44ca12817e 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 a7329be335..aed798d608 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 2468cb9df6..cd5bddde3a 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 3ef84dae1f..c2a3d89fde 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 0000000000..59e9410359 --- /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 +}