1
0
forked from ScoDoc/ScoDoc

code cleaning

This commit is contained in:
Emmanuel Viennet 2022-09-30 09:37:20 +02:00
parent c6c7187c34
commit 9527240ea8
3 changed files with 11 additions and 11 deletions

View File

@ -420,7 +420,6 @@ WHERE A.ETUDID = %(etudid)s
def list_abs_date(etudid, beg_date=None, end_date=None):
"""Liste des absences et justifs entre deux dates (inclues)."""
print("On rentre")
cnx = ndb.GetDBConnexion()
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)

View File

@ -39,13 +39,14 @@ import re
import shutil
from pathlib import Path
from flask import abort, current_app, url_for
from flask import current_app, url_for
from PIL import Image as PILImage
from werkzeug.utils import secure_filename
from app import Departement, ScoValueError
from app import log
from app.models import Departement
from app.scodoc import sco_utils as scu
from app.scodoc.sco_exceptions import ScoValueError
from PIL import Image as PILImage
GLOBAL = "_" # category for server level logos
@ -323,13 +324,13 @@ def guess_image_type(stream) -> str:
def make_logo_local(logoname, dept_name):
depts = Departement.query.filter_by(acronym=dept_name).all()
if len(depts) == 0:
print(f"no dept {dept_name} found. aborting")
log(f"no dept {dept_name} found. aborting")
return
if len(depts) > 1:
print(f"several depts {dept_name} found. aborting")
log(f"several depts {dept_name} found. aborting")
return
dept = depts[0]
print(f"Move logo {logoname}' from global to {dept.acronym}")
log(f"Move logo {logoname}' from global to {dept.acronym}")
old_path_wild = f"/opt/scodoc-data/config/logos/logo_{logoname}.*"
new_dir = f"/opt/scodoc-data/config/logos/logos_{dept.id}"
logos = glob.glob(old_path_wild)
@ -338,15 +339,15 @@ def make_logo_local(logoname, dept_name):
filename = os.path.split(logo)[1]
new_name = os.path.sep.join([new_dir, filename])
if os.path.exists(new_name):
print("local version of global logo already exists. aborting")
log("local version of global logo already exists. aborting")
return
# create new__dir if necessary
if not os.path.exists(new_dir):
print(f"- create {new_dir} directory")
log(f"- create {new_dir} directory")
os.mkdir(new_dir)
# move global logo (all suffixes) to local dir note: pre existent file (logo_XXX.*) in local dir does not
# prevent operation if there is no conflict with moved files
# At this point everything is ok so we can do files manipulation
for logo in logos:
shutil.move(logo, new_dir)
# print(f"moved {n_moves}/{n} etuds")
# log(f"moved {n_moves}/{n} etuds")

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.3.47"
SCOVERSION = "9.3.48"
SCONAME = "ScoDoc"