forked from ScoDoc/ScoDoc
Ajoute traceback aux dumps envoyés
This commit is contained in:
parent
63f6382397
commit
137d437811
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: UTF-8 -*
|
# -*- coding: UTF-8 -*
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
|
|
||||||
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
@ -69,13 +70,19 @@ def handle_access_denied(exc):
|
|||||||
def internal_server_error(exc):
|
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
|
||||||
|
from app.scodoc import sco_utils as scu
|
||||||
|
|
||||||
return (
|
return (
|
||||||
render_template(
|
render_template(
|
||||||
"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,
|
exc=exc,
|
||||||
|
traceback_str_base64=base64.urlsafe_b64encode(
|
||||||
|
traceback.format_exc().encode(scu.SCO_ENCODING)
|
||||||
|
).decode(scu.SCO_ENCODING),
|
||||||
request_url=request.url,
|
request_url=request.url,
|
||||||
|
scu=scu,
|
||||||
),
|
),
|
||||||
500,
|
500,
|
||||||
)
|
)
|
||||||
|
@ -46,10 +46,12 @@ pg_dump SCORT | psql ANORT
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import os
|
import base64
|
||||||
import fcntl
|
import fcntl
|
||||||
import subprocess
|
import os
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
|
import traceback
|
||||||
|
|
||||||
from flask import g, request
|
from flask import g, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
@ -64,8 +66,14 @@ 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(message: str = "", request_url: str = ""):
|
def sco_dump_and_send_db(
|
||||||
|
message: str = "", request_url: str = "", traceback_str_base64: 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"""
|
||||||
|
breakpoint()
|
||||||
|
traceback_str = base64.urlsafe_b64decode(traceback_str_base64).decode(
|
||||||
|
scu.SCO_ENCODING
|
||||||
|
)
|
||||||
# get current (dept) DB name:
|
# get current (dept) DB name:
|
||||||
cursor = ndb.SimpleQuery("SELECT current_database()", {})
|
cursor = ndb.SimpleQuery("SELECT current_database()", {})
|
||||||
db_name = cursor.fetchone()[0]
|
db_name = cursor.fetchone()[0]
|
||||||
@ -92,7 +100,7 @@ def sco_dump_and_send_db(message: str = "", request_url: str = ""):
|
|||||||
_anonymize_db(ano_db_name)
|
_anonymize_db(ano_db_name)
|
||||||
|
|
||||||
# Send
|
# Send
|
||||||
r = _send_db(ano_db_name, message, request_url)
|
r = _send_db(ano_db_name, message, request_url, traceback_str=traceback_str)
|
||||||
code = r.status_code
|
code = r.status_code
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
@ -152,7 +160,9 @@ def _get_scodoc_serial():
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def _send_db(ano_db_name: str, message: str = "", request_url: str = ""):
|
def _send_db(
|
||||||
|
ano_db_name: str, message: str = "", request_url: str = "", traceback_str: 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:
|
||||||
@ -164,7 +174,7 @@ def _send_db(ano_db_name: str, message: str = "", request_url: str = ""):
|
|||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
f"erreur lors de l'anonymisation de la base {ano_db_name}"
|
f"erreur lors de l'anonymisation de la base {ano_db_name}"
|
||||||
) from e
|
) from e
|
||||||
|
log(f"traceback_str={traceback_str}")
|
||||||
log("uploading anonymized dump...")
|
log("uploading anonymized dump...")
|
||||||
files = {"file": (ano_db_name + ".dump", dump)}
|
files = {"file": (ano_db_name + ".dump", dump)}
|
||||||
try:
|
try:
|
||||||
@ -180,9 +190,11 @@ def _send_db(ano_db_name: str, message: str = "", request_url: str = ""):
|
|||||||
"sent_by": sco_users.user_info(str(current_user))["nomcomplet"],
|
"sent_by": sco_users.user_info(str(current_user))["nomcomplet"],
|
||||||
"sco_version": sco_version.SCOVERSION,
|
"sco_version": sco_version.SCOVERSION,
|
||||||
"sco_fullversion": scu.get_scodoc_version(),
|
"sco_fullversion": scu.get_scodoc_version(),
|
||||||
|
"traceback_str": traceback_str,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except requests.exceptions.ConnectionError as exc:
|
except requests.exceptions.ConnectionError as exc:
|
||||||
|
log("ConnectionError: Impossible de joindre le serveur d'assistance")
|
||||||
raise ScoValueError(
|
raise ScoValueError(
|
||||||
"""
|
"""
|
||||||
Impossible de joindre le serveur d'assistance (scodoc.org).
|
Impossible de joindre le serveur d'assistance (scodoc.org).
|
||||||
|
@ -369,6 +369,8 @@ SCO_USER_MANUAL = "https://scodoc.org/GuideUtilisateur"
|
|||||||
SCO_ANNONCES_WEBSITE = "https://listes.univ-paris13.fr/mailman/listinfo/scodoc-annonces"
|
SCO_ANNONCES_WEBSITE = "https://listes.univ-paris13.fr/mailman/listinfo/scodoc-annonces"
|
||||||
SCO_DEVEL_LIST = "scodoc-devel@listes.univ-paris13.fr"
|
SCO_DEVEL_LIST = "scodoc-devel@listes.univ-paris13.fr"
|
||||||
SCO_USERS_LIST = "notes@listes.univ-paris13.fr"
|
SCO_USERS_LIST = "notes@listes.univ-paris13.fr"
|
||||||
|
SCO_LISTS_URL = "https://scodoc.org/ListesDeDiffusion/"
|
||||||
|
SCO_DISCORD_ASSISTANCE = "https://discord.gg/ybw6ugtFsZ"
|
||||||
|
|
||||||
# Mails avec exceptions (erreurs) anormales envoyés à cette adresse:
|
# Mails avec exceptions (erreurs) anormales envoyés à cette adresse:
|
||||||
# mettre '' pour désactiver completement l'envois de mails d'erreurs.
|
# mettre '' pour désactiver completement l'envois de mails d'erreurs.
|
||||||
|
@ -3,6 +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 app_content %}
|
{% 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
|
||||||
@ -11,14 +12,16 @@
|
|||||||
<p><tt style="font-size:60%">{{date}}</tt></p>
|
<p><tt style="font-size:60%">{{date}}</tt></p>
|
||||||
|
|
||||||
<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 <b>l'assistance sur <a href="{{ scu.SCO_DISCORD_ASSISTANCE
|
||||||
indiquant la version du logiciel.
|
}}">le canal Discord</a></b>.
|
||||||
</p>
|
</p>
|
||||||
{% if 'scodoc_dept' in g %}
|
{% if 'scodoc_dept' in g %}
|
||||||
<p>Pour aider les développeurs à corriger le problème, nous vous suggérons d'envoyer les données
|
<p>Pour aider les développeurs à corriger le problème, nous vous
|
||||||
sur votre configuration:
|
suggérons d'envoyer les données anonymisées sur votre configuration:
|
||||||
<form method="POST" action="{{ url_for( 'scolar.sco_dump_and_send_db', scodoc_dept=g.scodoc_dept ) }}">
|
<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="hidden" name="request_url" value="{{request_url}}">
|
||||||
|
<input type="hidden" name="traceback_str_base64" value="{{traceback_str_base64}}">
|
||||||
<input type="submit" value="Envoyer données assistance">
|
<input type="submit" value="Envoyer données assistance">
|
||||||
<div>Message optionnel: </div>
|
<div>Message optionnel: </div>
|
||||||
<textarea name="message" cols="40" rows="4"></textarea>
|
<textarea name="message" cols="40" rows="4"></textarea>
|
||||||
@ -26,10 +29,15 @@
|
|||||||
</form>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>Pour plus d'informations sur les listes de diffusion <a href="https://scodoc.org/ListesDeDiffusion/">voir
|
<p>Vous pouvez aussi envoyer un mail à la liste "notes"
|
||||||
cette page</a>.
|
<a href="mailto:{{scu.SCO_USERS_LIST}}">{{scu.SCO_USERS_LIST}}</a>
|
||||||
|
</p>
|
||||||
|
<p>Pour plus d'informations sur les listes de diffusion
|
||||||
|
<a href="{{ scu.SCO_LISTS_URL }}">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>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -2282,10 +2282,12 @@ def stat_bac(formsemestre_id):
|
|||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
@scodoc7func
|
@scodoc7func
|
||||||
def sco_dump_and_send_db(message="", request_url=""):
|
def sco_dump_and_send_db(message="", request_url="", traceback_str_base64=""):
|
||||||
"Send anonymized data to supervision"
|
"Send anonymized data to supervision"
|
||||||
|
|
||||||
status_code = sco_dump_db.sco_dump_and_send_db(message, request_url)
|
status_code = sco_dump_db.sco_dump_and_send_db(
|
||||||
|
message, request_url, traceback_str_base64=traceback_str_base64
|
||||||
|
)
|
||||||
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
H = [html_sco_header.sco_header(page_title="Assistance technique")]
|
||||||
if status_code == requests.codes.INSUFFICIENT_STORAGE: # pylint: disable=no-member
|
if status_code == requests.codes.INSUFFICIENT_STORAGE: # pylint: disable=no-member
|
||||||
H.append(
|
H.append(
|
||||||
|
Loading…
Reference in New Issue
Block a user