Form. assistance dans exception handler
This commit is contained in:
parent
c0a8f6f7d6
commit
6a525eb1a1
@ -62,7 +62,7 @@ def handle_access_denied(exc):
|
|||||||
return render_template("error_access_denied.html", exc=exc), 403
|
return render_template("error_access_denied.html", exc=exc), 403
|
||||||
|
|
||||||
|
|
||||||
def internal_server_error(e):
|
def internal_server_error(exc):
|
||||||
"""Bugs scodoc, erreurs 500"""
|
"""Bugs scodoc, erreurs 500"""
|
||||||
# note that we set the 500 status explicitly
|
# note that we set the 500 status explicitly
|
||||||
return (
|
return (
|
||||||
@ -70,6 +70,8 @@ def internal_server_error(e):
|
|||||||
"error_500.html",
|
"error_500.html",
|
||||||
SCOVERSION=sco_version.SCOVERSION,
|
SCOVERSION=sco_version.SCOVERSION,
|
||||||
date=datetime.datetime.now().isoformat(),
|
date=datetime.datetime.now().isoformat(),
|
||||||
|
exc=exc,
|
||||||
|
request_url=request.url,
|
||||||
),
|
),
|
||||||
500,
|
500,
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,7 @@ import fcntl
|
|||||||
import subprocess
|
import subprocess
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from flask import flash
|
from flask import flash, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
|
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
@ -66,7 +66,7 @@ from app.scodoc.sco_exceptions import ScoValueError
|
|||||||
SCO_DUMP_LOCK = "/tmp/scodump.lock"
|
SCO_DUMP_LOCK = "/tmp/scodump.lock"
|
||||||
|
|
||||||
|
|
||||||
def sco_dump_and_send_db():
|
def sco_dump_and_send_db(message: str = "", request_url: str = ""):
|
||||||
"""Dump base de données et l'envoie anonymisée pour debug"""
|
"""Dump base de données et l'envoie anonymisée pour debug"""
|
||||||
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
||||||
# get currect (dept) DB name:
|
# get currect (dept) DB name:
|
||||||
@ -95,7 +95,7 @@ def sco_dump_and_send_db():
|
|||||||
_anonymize_db(ano_db_name)
|
_anonymize_db(ano_db_name)
|
||||||
|
|
||||||
# Send
|
# Send
|
||||||
r = _send_db(ano_db_name)
|
r = _send_db(ano_db_name, message, request_url)
|
||||||
if (
|
if (
|
||||||
r.status_code
|
r.status_code
|
||||||
== requests.codes.INSUFFICIENT_STORAGE # pylint: disable=no-member
|
== requests.codes.INSUFFICIENT_STORAGE # pylint: disable=no-member
|
||||||
@ -175,7 +175,7 @@ def _get_scodoc_serial():
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def _send_db(ano_db_name):
|
def _send_db(ano_db_name: str, message: str = "", request_url: str = ""):
|
||||||
"""Dump this (anonymized) database and send it to tech support"""
|
"""Dump this (anonymized) database and send it to tech support"""
|
||||||
log(f"dumping anonymized database {ano_db_name}")
|
log(f"dumping anonymized database {ano_db_name}")
|
||||||
try:
|
try:
|
||||||
@ -184,7 +184,9 @@ def _send_db(ano_db_name):
|
|||||||
)
|
)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
log(f"sco_dump_and_send_db: exception in anonymisation: {e}")
|
log(f"sco_dump_and_send_db: exception in anonymisation: {e}")
|
||||||
raise ScoValueError(f"erreur lors de l'anonymisation de la base {ano_db_name}")
|
raise ScoValueError(
|
||||||
|
f"erreur lors de l'anonymisation de la base {ano_db_name}"
|
||||||
|
) from e
|
||||||
|
|
||||||
log("uploading anonymized dump...")
|
log("uploading anonymized dump...")
|
||||||
files = {"file": (ano_db_name + ".dump", dump)}
|
files = {"file": (ano_db_name + ".dump", dump)}
|
||||||
@ -194,6 +196,8 @@ def _send_db(ano_db_name):
|
|||||||
files=files,
|
files=files,
|
||||||
data={
|
data={
|
||||||
"dept_name": sco_preferences.get_preference("DeptName"),
|
"dept_name": sco_preferences.get_preference("DeptName"),
|
||||||
|
"message": message or "",
|
||||||
|
"request_url": request_url or request.url,
|
||||||
"serial": _get_scodoc_serial(),
|
"serial": _get_scodoc_serial(),
|
||||||
"sco_user": str(current_user),
|
"sco_user": str(current_user),
|
||||||
"sent_by": sco_users.user_info(str(current_user))["nomcomplet"],
|
"sent_by": sco_users.user_info(str(current_user))["nomcomplet"],
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{% import 'bootstrap/wtf.html' as wtf %}
|
{% import 'bootstrap/wtf.html' as wtf %}
|
||||||
|
|
||||||
{% block title %}Une erreur est survenue !{% endblock %}
|
{% block title %}Une erreur est survenue !{% endblock %}
|
||||||
{% block body %}
|
{% block app_content %}
|
||||||
<h1>Une erreur est survenue !</h1>
|
<h1>Une erreur est survenue !</h1>
|
||||||
<p>Oups...</tt> <span style="color:red;"><b>ScoDoc version
|
<p>Oups...</tt> <span style="color:red;"><b>ScoDoc version
|
||||||
<span style="font-size: 120%;">{{SCOVERSION}}</span></b></span>
|
<span style="font-size: 120%;">{{SCOVERSION}}</span></b></span>
|
||||||
@ -12,10 +12,22 @@
|
|||||||
|
|
||||||
<p> Si le problème persiste, contacter l'administrateur de votre site,
|
<p> Si le problème persiste, contacter l'administrateur de votre site,
|
||||||
ou écrire la liste "notes" <a href="mailto:notes@listes.univ-paris13.fr">notes@listes.univ-paris13.fr</a> en
|
ou écrire la liste "notes" <a href="mailto:notes@listes.univ-paris13.fr">notes@listes.univ-paris13.fr</a> en
|
||||||
indiquant la version du logiciel
|
indiquant la version du logiciel.
|
||||||
<br />
|
</p>
|
||||||
(plus d'informations sur les listes de diffusion <a href="https://scodoc.org/ListesDeDiffusion/">voir
|
{% if 'scodoc_dept' in g %}
|
||||||
cette page</a>).
|
<p>Pour aider les développeurs à corriger le problème, nous vous suggérons d'envoyer les données
|
||||||
|
sur votre configuration:
|
||||||
|
<form method="POST" action="{{ url_for( 'scolar.sco_dump_and_send_db', scodoc_dept=g.scodoc_dept ) }}">
|
||||||
|
<input type="hidden" name="request_url" value="{{request_url}}">
|
||||||
|
<input type="submit" value="Envoyer données assistance">
|
||||||
|
<div>Message optionnel: </div>
|
||||||
|
<textarea name="message" cols="40" rows="4"></textarea>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
<p>Pour plus d'informations sur les listes de diffusion <a href="https://scodoc.org/ListesDeDiffusion/">voir
|
||||||
|
cette page</a>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><a href="{{ url_for('scodoc.index') }}">retour à la page d'accueil</a></p>
|
<p><a href="{{ url_for('scodoc.index') }}">retour à la page d'accueil</a></p>
|
||||||
|
@ -2190,7 +2190,11 @@ def stat_bac(formsemestre_id):
|
|||||||
return Bacs
|
return Bacs
|
||||||
|
|
||||||
|
|
||||||
# --- Dump
|
# --- Dump (assistance)
|
||||||
sco_publish(
|
@bp.route("/sco_dump_and_send_db", methods=["GET", "POST"])
|
||||||
"/sco_dump_and_send_db", sco_dump_db.sco_dump_and_send_db, Permission.ScoView
|
@scodoc
|
||||||
)
|
@permission_required(Permission.ScoView)
|
||||||
|
@scodoc7func
|
||||||
|
def sco_dump_and_send_db(message="", request_url=""):
|
||||||
|
"Send anonymized data to supervision"
|
||||||
|
return sco_dump_db.sco_dump_and_send_db(message, request_url)
|
||||||
|
Loading…
Reference in New Issue
Block a user