forked from ScoDoc/installmgr
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
59b7f8bef2 | |||
b1f907aaaa | |||
297c0a8308 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -176,4 +176,6 @@ copy
|
||||
|
||||
incoming_dumps/
|
||||
upload-dump-*
|
||||
counter
|
||||
counter
|
||||
# Le .env contient le token et ne DOIT PAS être sous git
|
||||
.env
|
||||
|
@ -12,20 +12,21 @@ bp = Blueprint("routes", __name__)
|
||||
# --------------------------------------------------------------
|
||||
DIR = "/opt/installmgr/"
|
||||
REPOSIT_DIR = "/opt/installmgr/incoming_dumps"
|
||||
MAX_REPOSIT_SIZE = 300 * 20 * 1024 # kB (here, max 300 dumps of 20MB)
|
||||
MAX_REPOSIT_SIZE = 2000 * 20 * 1024 # kB (here, max 2000 dumps of 20MB)
|
||||
|
||||
ALERT_MAIL_FROM = "root@scodoc.org"
|
||||
ALERT_MAIL_TO = "emmanuel.viennet@gmail.com"
|
||||
ALERT_MAIL_TO = "viennet"
|
||||
|
||||
LOG_FILENAME = os.path.join(DIR, "upload-dump-errors.log")
|
||||
UPLOAD_LOG_FILENAME = os.path.join(DIR, "upload-dump-log.json")
|
||||
DEBUG = False # if false, don't publish error messages
|
||||
|
||||
# Les paquets publiés:
|
||||
DEBIAN_PACKAGES_EXP = "/srv/packages/pool/main/s/scodoc9/scodoc9_*.deb"
|
||||
#DEBIAN_PACKAGES_EXP = "/srv/packages/pool/main/s/scodoc9/scodoc9_*.deb"
|
||||
DEBIAN_PACKAGES_EXP = "/srv/bookworm/pool/main/s/scodoc9/scodoc9_*.deb"
|
||||
RELEASE_LOG_FILE = "/home/viennet/scodoc-releases.log"
|
||||
|
||||
GITEA_URL = "https://scodoc.org/git"
|
||||
GITEA_URL = "https://git.scodoc.org/"
|
||||
GITEA_REPO = "ScoDoc/ScoDoc"
|
||||
GITEA_LABEL_ID = None
|
||||
|
||||
@ -188,29 +189,27 @@ def report():
|
||||
)
|
||||
|
||||
if response.status_code != 201:
|
||||
log.write("gitea error\n")
|
||||
log.write(f"gitea error: status code={response.status_code}\n")
|
||||
try:
|
||||
log.write("sending notification to {}\n".format(ALERT_MAIL_TO))
|
||||
email.send_email(
|
||||
"[report] Gitea error !",
|
||||
ALERT_MAIL_FROM,
|
||||
[ALERT_MAIL_TO],
|
||||
"Error "
|
||||
+ response.status_code
|
||||
+ " while creating the gitea ticket :\n"
|
||||
+ response.text
|
||||
+ "\n\nTicket info : "
|
||||
+ ticket.get("title")
|
||||
+ "\n"
|
||||
+ ticket_body
|
||||
+ "\n- Utilisateur : "
|
||||
+ user.get("name", "Nom inconnu")
|
||||
+ " <"
|
||||
+ user.get("email", "Adresse email inconnue")
|
||||
+ ">",
|
||||
f"""Error {response.status_code}
|
||||
while creating the gitea ticket :
|
||||
{response.text}
|
||||
|
||||
Ticket info : {ticket.get("title")}
|
||||
|
||||
{ticket_body}
|
||||
|
||||
Utilisateur : {user.get("name", "Nom inconnu")} <{user.get("email", "Adresse email inconnue")}>
|
||||
"""
|
||||
)
|
||||
except:
|
||||
log.write("exception while sending email !\n")
|
||||
except Exception as exc:
|
||||
log.write("exception while sending email (1) !\n")
|
||||
log.write(f"{type(exc).__name__}, Exception message: {exc}\n")
|
||||
log.close()
|
||||
return (
|
||||
jsonify(
|
||||
@ -222,26 +221,20 @@ def report():
|
||||
)
|
||||
|
||||
try:
|
||||
log.write("sending notification to {}\n".format(ALERT_MAIL_TO))
|
||||
log.write(f"sending notification to {ALERT_MAIL_TO}\n")
|
||||
email.send_email(
|
||||
"[report] Ticket # "
|
||||
+ response.json()["id"]
|
||||
+ " créé avec succès ! : "
|
||||
+ ticket.get("title"),
|
||||
f"""[report] Ticket #{response.json()["id"]} créé: {ticket.get("title")}""",
|
||||
ALERT_MAIL_FROM,
|
||||
[ALERT_MAIL_TO],
|
||||
"Nouveau ticket utilisateur :\n"
|
||||
+ meta
|
||||
+ "\n- Lien du ticket : "
|
||||
+ response.json()["url"]
|
||||
+ "\n- Utilisateur : "
|
||||
+ user.get("name", "Nom inconnu")
|
||||
+ " <"
|
||||
+ user.get("email", "Adresse email inconnue")
|
||||
+ ">",
|
||||
f"""Nouveau ticket utilisateur :
|
||||
{meta}
|
||||
Lien du ticket : {response.json()["html_url"]}
|
||||
Utilisateur : {user.get("name", "Nom inconnu")} <{user.get("email", "Adresse email inconnue")}>
|
||||
"""
|
||||
)
|
||||
except:
|
||||
log.write("exception while sending email !\n")
|
||||
except Exception as exc:
|
||||
log.write("exception while sending email (2) !\n")
|
||||
log.write(f"{type(exc).__name__}, Exception message: {exc}\n")
|
||||
log.close()
|
||||
|
||||
return (
|
||||
@ -251,7 +244,7 @@ def report():
|
||||
+ response.json()["html_url"]
|
||||
+ "'>"
|
||||
+ response.json()["html_url"]
|
||||
+ "</a>. Vous êtes susceptible d'être contacté(e) par email à l'adresse liée à votre compte ScoDoc si des informations supplémentatires sont nécéssaires."
|
||||
+ "</a>. Vous êtes susceptible d'être contacté(e) par email à l'adresse liée à votre compte ScoDoc si des informations supplémentaires sont nécessaires."
|
||||
}
|
||||
),
|
||||
201,
|
||||
@ -262,12 +255,13 @@ def report():
|
||||
def upload_scodoc9():
|
||||
"""Réception d'un fichier de dump"""
|
||||
log = open(LOG_FILENAME, "a")
|
||||
log.write("haallo\n")
|
||||
log.write("upload_scodoc9\n")
|
||||
now = datetime.datetime.now()
|
||||
fulltime = now.isoformat()
|
||||
# client addr:
|
||||
remote_addr = request.environ.get("HTTP_X_REAL_IP", request.remote_addr)
|
||||
log.write(f"{fulltime} request from {remote_addr}\n")
|
||||
log.write(f"{request.form}")
|
||||
log.flush()
|
||||
# Avec seulement alphanum et tiret:
|
||||
clean_deptname = re.sub(r"[^A-Za-z-]", "", request.form["dept_name"])
|
||||
@ -287,7 +281,7 @@ def upload_scodoc9():
|
||||
try:
|
||||
remote_host = socket.gethostbyaddr(remote_addr)[0]
|
||||
except:
|
||||
log.write("reverse DNS lookup failed for {}".format(remote_addr))
|
||||
log.write(f"reverse DNS lookup failed for {remote_addr}")
|
||||
remote_host = ""
|
||||
|
||||
the_file = request.files["file"]
|
||||
@ -300,6 +294,7 @@ def upload_scodoc9():
|
||||
"sent_by": request.form["sent_by"],
|
||||
"sco_version": request.form.get("sco_version", ""), # release
|
||||
"sco_subversion": request.form.get("sco_subversion", ""),
|
||||
"traceback_str": request.form.get("traceback_str", ""),
|
||||
"dump_filename": fulltime + "_" + clean_deptname + ".gz",
|
||||
"dump_size": len(data),
|
||||
"message": request.form.get("message", ""),
|
||||
|
Loading…
x
Reference in New Issue
Block a user