diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index 06b0f60ee..c0b1e4736 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -701,7 +701,6 @@ class TF: labels = descr.get( "labels", descr.get("allowed_values", ["oui", "non"]) ) - # XXX open('/tmp/log', 'w').write('%s labels=%s, val=%s\ndescr=%s\n'%(field, labels, self.values[field], descr)) R.append(labels[int(self.values[field])]) if int(self.values[field]): R.append('' % field) diff --git a/config/anonymize_db.py b/config/anonymize_db.py index dd3911ff5..9492764fd 100755 --- a/config/anonymize_db.py +++ b/config/anonymize_db.py @@ -34,11 +34,15 @@ Runned as "www-data" with scodoc and postgresql up. E. Viennet, Jan 2019 """ -import sys, os, traceback, psycopg2 +import os +import psycopg2 +import sys +import traceback + def log(msg): sys.stdout.flush() - sys.stderr.write(msg+'\n') + sys.stderr.write(msg + "\n") sys.stderr.flush() @@ -61,85 +65,84 @@ anonymize_null = "NULL" # car c'est la clé avec SCOUSERS) # ANONYMIZED_FIELDS = { - 'identite.nom' : anonymize_name, - 'identite.prenom' : anonymize_name, - 'identite.date_naissance' : anonymize_date, - 'identite.lieu_naissance' : anonymize_question_str, - 'identite.nationalite' : anonymize_question_str, - 'identite.foto' : anonymize_null, - 'identite.code_nip' : anonymize_null, - 'identite.code_ine' : anonymize_null, - 'identite.nom_usuel' : anonymize_null, + "identite.nom": anonymize_name, + "identite.prenom": anonymize_name, + "identite.date_naissance": anonymize_date, + "identite.lieu_naissance": anonymize_question_str, + "identite.nationalite": anonymize_question_str, + "identite.foto": anonymize_null, + "identite.code_nip": anonymize_null, + "identite.code_ine": anonymize_null, + "identite.nom_usuel": anonymize_null, + "adresse.email": "'ano@nyme.fr'", + "adresse.emailperso": anonymize_null, + "adresse.domicile": anonymize_null, + "adresse.telephone": anonymize_null, + "adresse.telephonemobile": anonymize_null, + "adresse.fax": anonymize_null, + "billet_absence.description": anonymize_null, + "etud_annotations.comment": anonymize_name, + "entreprises.nom": anonymize_name, + "entreprises.adresse": anonymize_null, + "entreprises.ville": anonymize_null, + "entreprises.codepostal": anonymize_null, + "entreprises.pays": anonymize_null, + "entreprises.contact_origine": anonymize_null, + "entreprises.secteur": anonymize_null, + "entreprises.note": anonymize_null, + "entreprises.privee": anonymize_null, + "entreprises.localisation": anonymize_null, + "entreprise_correspondant.nom": anonymize_name, + "entreprise_correspondant.prenom": anonymize_name, + "entreprise_correspondant.phone1": anonymize_null, + "entreprise_correspondant.phone2": anonymize_null, + "entreprise_correspondant.mobile": anonymize_null, + "entreprise_correspondant.mail1": anonymize_null, + "entreprise_correspondant.mail2": anonymize_null, + "entreprise_correspondant.note": anonymize_null, + "entreprise_correspondant.fax": anonymize_null, + "entreprise_contact.description": anonymize_null, + "entreprise_contact.enseignant": anonymize_null, + "notes_appreciations.comment": anonymize_name, +} - 'adresse.email' : "'ano@nyme.fr'", - 'adresse.emailperso' : anonymize_null, - 'adresse.domicile' : anonymize_null, - 'adresse.telephone' : anonymize_null, - 'adresse.telephonemobile' : anonymize_null, - 'adresse.fax' : anonymize_null, - - 'billet_absence.description' : anonymize_null, - 'etud_annotations.comment' : anonymize_name, - - 'entreprises.nom' : anonymize_name, - 'entreprises.adresse' : anonymize_null, - 'entreprises.ville' : anonymize_null, - 'entreprises.codepostal' : anonymize_null, - 'entreprises.pays' : anonymize_null, - 'entreprises.contact_origine' : anonymize_null, - 'entreprises.secteur' : anonymize_null, - 'entreprises.note' : anonymize_null, - 'entreprises.privee' : anonymize_null, - 'entreprises.localisation' : anonymize_null, - - 'entreprise_correspondant.nom' : anonymize_name, - 'entreprise_correspondant.prenom' : anonymize_name, - 'entreprise_correspondant.phone1' : anonymize_null, - 'entreprise_correspondant.phone2' : anonymize_null, - 'entreprise_correspondant.mobile' : anonymize_null, - 'entreprise_correspondant.mail1' : anonymize_null, - 'entreprise_correspondant.mail2' : anonymize_null, - 'entreprise_correspondant.note' : anonymize_null, - 'entreprise_correspondant.fax' : anonymize_null, - - 'entreprise_contact.description' : anonymize_null, - 'entreprise_contact.enseignant' : anonymize_null, - - 'notes_appreciations.comment' : anonymize_name, - } def anonymize_column(cursor, tablecolumn): """Anonymise une colonne tablecolumn est de la forme nom_de_table.nom_de_colonne, par exemple "identite.nom" key_name est le nom de la colonne (clé) à utiliser pour certains remplacements - (cette clé doit être anonyme et unique). Par exemple, un nom propre pourrait être + (cette clé doit être anonyme et unique). Par exemple, un nom propre pourrait être remplacé par nom_valeur_de_la_clé. - """ - table, column = tablecolumn.split('.') - anonymization = ANONYMIZED_FIELDS[ tablecolumn ] - log('processing {}'.format(tablecolumn)) - cursor.execute("UPDATE {table} SET {column} = {value};".format( - table=table, - column=column, - value=anonymization(column, key_name) if callable(anonymization) else anonymization - )) + """ + table, column = tablecolumn.split(".") + anonymization = ANONYMIZED_FIELDS[tablecolumn] + log("processing {}".format(tablecolumn)) + cursor.execute( + "UPDATE {table} SET {column} = {value};".format( + table=table, + column=column, + value=anonymization(column, key_name) + if callable(anonymization) + else anonymization, + ) + ) + def anonymize_db(cursor): - """Traite, une à une, les colonnes indiquées dans ANONYMIZED_FIELDS - """ + """Traite, une à une, les colonnes indiquées dans ANONYMIZED_FIELDS""" for tablecolumn in ANONYMIZED_FIELDS: anonymize_column(cursor, tablecolumn) dbname = sys.argv[1] -log('\nAnonymizing database %s' % dbname) -cnx_string = 'dbname=' + dbname +log("\nAnonymizing database %s" % dbname) +cnx_string = "dbname=" + dbname try: - cnx = psycopg2.connect( cnx_string ) + cnx = psycopg2.connect(cnx_string) except: log("\n*** Error: can't connect to database %s ***\n" % dbname) - log('connexion string was "%s"' % cnx_string) + log('connexion string was "%s"' % cnx_string) traceback.print_exc() cnx.set_session(autocommit=False) diff --git a/config/fix_bug70_db.py b/config/fix_bug70_db.py index 4c0d64033..b55f7507d 100644 --- a/config/fix_bug70_db.py +++ b/config/fix_bug70_db.py @@ -1,6 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- +# Script pour ScoDoc7 (python2), obsolete """Fix bug #70 Utiliser comme: diff --git a/config/postupgrade.py b/config/postupgrade.py old mode 100644 new mode 100755 diff --git a/config/scodoc_config.py b/config/scodoc_config.py index 32d3fa216..436185454 100644 --- a/config/scodoc_config.py +++ b/config/scodoc_config.py @@ -7,46 +7,53 @@ # La plupart des réglages sont stoqués en base de donnée et accessibles via le web # (pages de paramètres ou préférences). -# Les valeurs indiquées ici sont les valeurs initiales que prendront -# les paramètres lors de la création d'un nouveau département, +# Les valeurs indiquées ici sont les valeurs initiales que prendront +# les paramètres lors de la création d'un nouveau département, # elles ne sont plus utilisées ensuite. -# Nota: il y a aussi des réglages dans sco_utils.py, mais ils nécessitent +# Nota: il y a aussi des réglages dans sco_utils.py, mais ils nécessitent # souvent de comprendre le code qui les utilise pour ne pas faire d'erreur: attention. -class CFG : +class CFG: pass + CONFIG = CFG() -CONFIG.always_require_ine = 0 # set to 1 if you want to require INE +CONFIG.always_require_ine = 0 # set to 1 if you want to require INE # The base URL, use only if you are behind a proxy # eg "https://scodoc.example.net/ScoDoc" -CONFIG.ABSOLUTE_URL = "" +CONFIG.ABSOLUTE_URL = "" # # ------------- Documents PDF ------------- # -CONFIG.SCOLAR_FONT = 'Helvetica' +CONFIG.SCOLAR_FONT = "Helvetica" CONFIG.SCOLAR_FONT_SIZE = 10 CONFIG.SCOLAR_FONT_SIZE_FOOT = 6 # Pour pieds de pages Procès verbaux: # (markup leger reportlab supporté, par ex. blah blah) -CONFIG.INSTITUTION_NAME="Institut Universitaire de Technologie - Université Paris 13" -CONFIG.INSTITUTION_ADDRESS="Web www.iutv.univ-paris13.fr - 99 avenue Jean-Baptiste Clément - F 93430 Villetaneuse" +CONFIG.INSTITUTION_NAME = ( + "Institut Universitaire de Technologie - Université Georges Perec" +) +CONFIG.INSTITUTION_ADDRESS = ( + "Web www.sor.bonne.top - 11, rue Simon Crubelier - 75017 Paris" +) -CONFIG.INSTITUTION_CITY="Villetaneuse" +CONFIG.INSTITUTION_CITY = "Paris" # Taille du l'image logo: largeur/hauteur (ne pas oublier le . !!!) -CONFIG.LOGO_FOOTER_ASPECT = 326/96. # W/H XXX provisoire: utilisera PIL pour connaitre la taille de l'image -CONFIG.LOGO_FOOTER_HEIGHT = 10 # taille dans le document en millimetres +CONFIG.LOGO_FOOTER_ASPECT = ( + 326 / 96.0 +) # W/H XXX provisoire: utilisera PIL pour connaitre la taille de l'image +CONFIG.LOGO_FOOTER_HEIGHT = 10 # taille dans le document en millimetres -CONFIG.LOGO_HEADER_ASPECT = 549 / 346. # XXX logo IUTV -CONFIG.LOGO_HEADER_HEIGHT = 28 # taille verticale dans le document en millimetres +CONFIG.LOGO_HEADER_ASPECT = 549 / 346.0 # XXX logo IUTV +CONFIG.LOGO_HEADER_HEIGHT = 28 # taille verticale dans le document en millimetres # Pied de page PDF : un format Python, %(xxx)s est remplacé par la variable xxx. # Les variables définies sont: @@ -56,12 +63,11 @@ CONFIG.LOGO_HEADER_HEIGHT = 28 # taille verticale dans le document en millimetre # Year : Year with century as a decimal number. # hour : Hour (24-hour clock) as a decimal number [00,23]. # minute: Minute as a decimal number [00,59]. -# +# # server_url: URL du serveur ScoDoc # scodoc_name: le nom du logiciel (ScoDoc actuellement, voir VERSION.py) - -CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s" +CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s" # @@ -80,7 +86,9 @@ CONFIG.compute_bonus = bonus_iutv # # - règle "LMD": capitalisation uniquement des UE avec moy. > 10 -CONFIG.CAPITALIZE_ALL_UES = True # si vrai, capitalise toutes les UE des semestres validés (règle "LMD"). +CONFIG.CAPITALIZE_ALL_UES = ( + True # si vrai, capitalise toutes les UE des semestres validés (règle "LMD"). +) # @@ -91,10 +99,10 @@ CONFIG.CAPITALIZE_ALL_UES = True # si vrai, capitalise toutes les UE des semestr # ----------------------------------------------------- # Nom (chemin complet) d'un fichier .html à inclure juste après le # le des pages ScoDoc -CONFIG.CUSTOM_HTML_HEADER = '' +CONFIG.CUSTOM_HTML_HEADER = "" # Fichier html a inclure en fin des pages (juste avant le ) -CONFIG.CUSTOM_HTML_FOOTER = '' +CONFIG.CUSTOM_HTML_FOOTER = "" # Fichier .html à inclure dans la pages connexion/déconnexion (accueil) # si on veut que ce soit différent (par défaut la même chose) @@ -110,22 +118,25 @@ CONFIG.CUSTOM_HTML_FOOTER_CNX = CONFIG.CUSTOM_HTML_FOOTER # Fichier de correspondance codelycee -> noms # (chemin relatif au repertoire d'install des sources) -CONFIG.ETABL_FILENAME = 'config/etablissements.csv' +CONFIG.ETABL_FILENAME = "config/etablissements.csv" # ---------------------------------------------------- -CONFIG.ALLOW_NULL_PRENOM = False # True for UCAC (étudiants camerounais sans prénoms) +CONFIG.ALLOW_NULL_PRENOM = False # True for UCAC (étudiants camerounais sans prénoms) -CONFIG.ETUD_MAX_FILE_SIZE = 10*1024*1024 # taille max des fichiers archive etudiants (en octets) +CONFIG.ETUD_MAX_FILE_SIZE = ( + 10 * 1024 * 1024 +) # taille max des fichiers archive etudiants (en octets) -CONFIG.PUBLISH_PORTAL_PHOTO_URL = False # si pas de photo et portail, publie l'url (était vrai jusqu'en oct 2016) +CONFIG.PUBLISH_PORTAL_PHOTO_URL = ( + False # si pas de photo et portail, publie l'url (était vrai jusqu'en oct 2016) +) -CONFIG.MIN_PASSWORD_LENGTH = 0 # si > 0: longueur minimale requise des nouveaux mots de passe (le test cracklib.FascistCheck s'appliquera dans tous les cas) +CONFIG.MIN_PASSWORD_LENGTH = 0 # si > 0: longueur minimale requise des nouveaux mots de passe (le test cracklib.FascistCheck s'appliquera dans tous les cas) # ---------------------------------------------------- # Ce dictionnaire est fusionné à celui de sco_codes_parcours # pour définir les codes jury et explications associées CONFIG.CODES_EXPL = { # AJ : 'Ajourné (échec)', - - } +} diff --git a/config/scodocutils.py b/config/scodocutils.py index 5141d0003..b099380fb 100755 --- a/config/scodocutils.py +++ b/config/scodocutils.py @@ -5,7 +5,10 @@ """ -import sys, os, psycopg2, glob, subprocess, traceback, time +import glob +import os +import sys +import traceback sys.path.append("..") @@ -17,6 +20,7 @@ os.environ["INSTANCE_HOME"] = "/opt/scodoc" def log(msg): + "write msg on stderr, add newline and flush" sys.stdout.flush() sys.stderr.write(msg + "\n") sys.stderr.flush()