forked from ScoDoc/ScoDoc
Archives: utilise dept_id et non acronyme
This commit is contained in:
parent
45352d9248
commit
bd2e0ccde5
@ -29,19 +29,19 @@
|
||||
|
||||
|
||||
Archives are plain files, stored in
|
||||
<SCODOC_VAR_DIR>/archives/<deptid>
|
||||
(where <SCODOC_VAR_DIR> is usually /opt/scodoc-data, and <deptid> a departement id)
|
||||
<SCODOC_VAR_DIR>/archives/<dept_id>
|
||||
(where <SCODOC_VAR_DIR> is usually /opt/scodoc-data, and <dept_id> a departement id (int))
|
||||
|
||||
Les PV de jurys et documents associés sont stockées dans un sous-repertoire de la forme
|
||||
<archivedir>/<dept>/<formsemestre_id>/<YYYY-MM-DD-HH-MM-SS>
|
||||
(formsemestre_id est ici FormSemestre.id)
|
||||
|
||||
Les documents liés à l'étudiant sont dans
|
||||
<archivedir>/docetuds/<dept>/<etudid>/<YYYY-MM-DD-HH-MM-SS>
|
||||
<archivedir>/docetuds/<dept_id>/<etudid>/<YYYY-MM-DD-HH-MM-SS>
|
||||
(etudid est ici Identite.id)
|
||||
|
||||
Les maquettes Apogée pour l'export des notes sont dans
|
||||
<archivedir>/apo_csv/<dept>/<annee_scolaire>-<sem_id>/<YYYY-MM-DD-HH-MM-SS>/<code_etape>.csv
|
||||
<archivedir>/apo_csv/<dept_id>/<annee_scolaire>-<sem_id>/<YYYY-MM-DD-HH-MM-SS>/<code_etape>.csv
|
||||
|
||||
Un répertoire d'archive contient des fichiers quelconques, et un fichier texte nommé _description.txt
|
||||
qui est une description (humaine, format libre) de l'archive.
|
||||
@ -61,6 +61,7 @@ from flask import g
|
||||
import app.scodoc.sco_utils as scu
|
||||
from config import Config
|
||||
from app import log
|
||||
from app.models import Departement
|
||||
from app.scodoc.TrivialFormulator import TrivialFormulator
|
||||
from app.scodoc.sco_exceptions import (
|
||||
AccessDenied,
|
||||
@ -109,7 +110,8 @@ class BaseArchiver(object):
|
||||
If directory does not yet exist, create it.
|
||||
"""
|
||||
self.initialize()
|
||||
dept_dir = os.path.join(self.root, g.scodoc_dept)
|
||||
dept = Departement.query.filter_by(acronym=g.scodoc_dept).first()
|
||||
dept_dir = os.path.join(self.root, str(dept.id))
|
||||
try:
|
||||
scu.GSL.acquire()
|
||||
if not os.path.isdir(dept_dir):
|
||||
@ -128,7 +130,8 @@ class BaseArchiver(object):
|
||||
:return: list of archive oids
|
||||
"""
|
||||
self.initialize()
|
||||
base = os.path.join(self.root, g.scodoc_dept) + os.path.sep
|
||||
dept = Departement.query.filter_by(acronym=g.scodoc_dept).first()
|
||||
base = os.path.join(self.root, str(dept.id)) + os.path.sep
|
||||
dirs = glob.glob(base + "*")
|
||||
return [os.path.split(x)[1] for x in dirs]
|
||||
|
||||
|
@ -32,11 +32,11 @@
|
||||
Voir sco_apogee_csv.py pour la structure du fichier Apogée.
|
||||
|
||||
Stockage: utilise sco_archive.py
|
||||
=> /opt/scodoc/var/scodoc/archives/apo_csv/RT/2016-1/2016-07-03-16-12-19/V3ASR.csv
|
||||
=> /opt/scodoc/var/scodoc/archives/apo_csv/<dept_id>/2016-1/2016-07-03-16-12-19/V3ASR.csv
|
||||
pour une maquette de l'année scolaire 2016, semestre 1, etape V3ASR
|
||||
|
||||
ou bien (à partir de ScoDoc 1678) :
|
||||
/opt/scodoc/var/scodoc/archives/apo_csv/RT/2016-1/2016-07-03-16-12-19/V3ASR!111.csv
|
||||
/opt/scodoc/var/scodoc/archives/apo_csv/<dept_id>/2016-1/2016-07-03-16-12-19/V3ASR!111.csv
|
||||
pour une maquette de l'étape V3ASR version VDI 111.
|
||||
|
||||
La version VDI sera ignorée sauf si elle est indiquée dans l'étape du semestre.
|
||||
|
@ -341,7 +341,7 @@ def find_new_dir():
|
||||
|
||||
def copy_portal_photo_to_fs(etud):
|
||||
"""Copy the photo from portal (distant website) to local fs.
|
||||
Returns rel. path or None if copy failed, with a diagnotic message
|
||||
Returns rel. path or None if copy failed, with a diagnostic message
|
||||
"""
|
||||
sco_etud.format_etud_ident(etud)
|
||||
url = photo_portal_url(etud)
|
||||
@ -353,8 +353,9 @@ def copy_portal_photo_to_fs(etud):
|
||||
log("copy_portal_photo_to_fs: getting %s" % url)
|
||||
r = requests.get(url, timeout=portal_timeout)
|
||||
except:
|
||||
log("download failed: exception:\n%s" % traceback.format_exc())
|
||||
log("called from:\n" + "".join(traceback.format_stack()))
|
||||
# log("download failed: exception:\n%s" % traceback.format_exc())
|
||||
# log("called from:\n" + "".join(traceback.format_stack()))
|
||||
log("copy_portal_photo_to_fs: error.")
|
||||
return None, "%s: erreur chargement de %s" % (etud["nomprenom"], url)
|
||||
if r.status_code != 200:
|
||||
log("download failed")
|
||||
|
@ -4,6 +4,7 @@
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from app.models import Departement
|
||||
from app.models.formsemestre import FormSemestre
|
||||
@ -25,7 +26,8 @@ def migrate_scodoc7_dept_archive(dept_name=""):
|
||||
migrate_docetuds(dept)
|
||||
|
||||
# ApoCSVArchiver:
|
||||
# /opt/scodoc-data/archives/apo_csv/<dept>/ ne bouge pas
|
||||
# /opt/scodoc-data/archives/apo_csv/<dept>/ -> apo_csv/<dept_id>/
|
||||
migrate_apo_csv(dept)
|
||||
|
||||
|
||||
def migrate_sem_archives(dept):
|
||||
@ -35,7 +37,7 @@ def migrate_sem_archives(dept):
|
||||
for sem in FormSemestre.query.filter_by(dept_id=dept.id):
|
||||
n += 1
|
||||
arch_dir7 = f"/opt/scodoc-data/archives/{dept.acronym}/{sem.scodoc7_id}"
|
||||
arch_dir9 = f"/opt/scodoc-data/archives/{dept.acronym}/{sem.id}"
|
||||
arch_dir9 = f"/opt/scodoc-data/archives/{dept.id}/{sem.id}"
|
||||
if os.path.exists(arch_dir7):
|
||||
n_moves += 1
|
||||
if not os.path.exists(arch_dir9):
|
||||
@ -58,7 +60,7 @@ def migrate_docetuds(dept):
|
||||
arch_dir7 = (
|
||||
f"/opt/scodoc-data/archives/docetuds/{dept.acronym}/{etud.scodoc7_id}"
|
||||
)
|
||||
arch_dir9 = f"/opt/scodoc-data/archives/docetuds/{dept.acronym}/{etud.id}"
|
||||
arch_dir9 = f"/opt/scodoc-data/archives/docetuds/{dept.id}/{etud.id}"
|
||||
if os.path.exists(arch_dir7):
|
||||
n_moves += 1
|
||||
if not os.path.exists(arch_dir9):
|
||||
@ -70,3 +72,25 @@ def migrate_docetuds(dept):
|
||||
# print(f"\tmoving {arch}")
|
||||
shutil.move(arch, arch_dir9)
|
||||
# print(f"moved {n_moves}/{n} etuds")
|
||||
|
||||
|
||||
def migrate_apo_csv(dept):
|
||||
"/opt/scodoc-data/archives/apo_csv/<dept>/ -> .../apo_csv/<dept_id>/"
|
||||
arch_dir7 = f"/opt/scodoc-data/archives/apo_csv/{dept.acronym}"
|
||||
arch_dir7_upper = f"/opt/scodoc-data/archives/apo_csv/{dept.acronym.upper()}"
|
||||
arch_dir9 = f"/opt/scodoc-data/archives/apo_csv/{dept.id}"
|
||||
if os.path.exists(arch_dir7):
|
||||
if os.path.exists(arch_dir9):
|
||||
print(
|
||||
f"Warning: {arch_dir9} exist ! not moving {arch_dir7}", file=sys.stderr
|
||||
)
|
||||
else:
|
||||
shutil.move(arch_dir7, arch_dir9)
|
||||
elif os.path.exists(arch_dir7_upper):
|
||||
if os.path.exists(arch_dir9):
|
||||
print(
|
||||
f"Warning: {arch_dir9} exist ! not moving {arch_dir7_upper}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
shutil.move(arch_dir7_upper, arch_dir9)
|
||||
|
Loading…
Reference in New Issue
Block a user