From f0d5e29439e1f336fe21f537daa40a2f5783ed5b Mon Sep 17 00:00:00 2001
From: Lyanis Souidi
Date: Mon, 13 May 2024 15:46:20 +0200
Subject: [PATCH 1/3] Ajout PyCharm dans .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index 9a2e411..87df45d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -169,5 +169,7 @@ Thumbs.db
.vscode/
*.code-workspace
+# PyCharm
+.idea/
copy
From 9b67f77be78379d723de90a531a2c005e564ef83 Mon Sep 17 00:00:00 2001
From: Lyanis Souidi
Date: Mon, 13 May 2024 15:48:40 +0200
Subject: [PATCH 2/3] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20README?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 80 ++++++++++++++++++++++++++++---------------------------
1 file changed, 41 insertions(+), 39 deletions(-)
diff --git a/README.md b/README.md
index c89adcd..80343ca 100644
--- a/README.md
+++ b/README.md
@@ -17,55 +17,57 @@ Mini-app Flask remplaçant les CGI scripts de `scodoc.iutv`.
## Installation
1. Créer un utilisateur
-
- adduser installmgr
+```bash
+adduser installmgr
+```
2. Cloner le dépot
-
- cd /opt
- git clone https://scodoc.org/git/viennet/installmgr.git
- chown -R installmgr installmgr
+```bash
+git clone https://scodoc.org/git/ScoDoc/installmgr.git /opt/installmgr
+chown -R installmgr:installmgr /opt/installmgr
+```
3. Créer l'environnement
-
- su - installmgr
- cd /opt/installmgr
- python3 -m venv venv
- source venv/bin/activate
- pip install wheel
- pip install -r requirements.txt
+```bash
+su - installmgr
+cd /opt/installmgr
+python3 -m venv venv
+source venv/bin/activate
+pip install wheel
+pip install -r requirements.txt
+```
4. Créer les répertoires
-
- mkdir incoming_dumps
- # et éventuellement:
- echo 1000 > counter
+```bash
+mkdir incoming_dumps
+# et éventuellement:
+echo 1000 > counter
+```
5. Configurer nginx
-
- location /scodoc-installmgr {
- # forward application requests to the gunicorn server
- proxy_pass http://localhost:8010;
- proxy_redirect off;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto https;
- proxy_connect_timeout 120;
- client_max_body_size 100m;
- }
-
-
+```nginx
+location /scodoc-installmgr {
+ # forward application requests to the gunicorn server
+ proxy_pass http://localhost:8010;
+ proxy_redirect off;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto https;
+ proxy_connect_timeout 120;
+ client_max_body_size 100m;
+}
+```
6. Installer le service
-
- cp etc/installmgr.service /etc/systemd/system/
- systemctl daemon-reload
- systemctl start installmgr
-
+```bash
+cp etc/installmgr.service /etc/systemd/system/
+systemctl daemon-reload
+systemctl start installmgr
+```
7. Tester
Depuis un client extérieur,
-
- http https://scodoc.org/scodoc-installmgr/last_stable_version
-
+```bash
+http https://scodoc.org/scodoc-installmgr/last_stable_version
+```
From b07f5975536288abfb5377ab087a3a19226c3927 Mon Sep 17 00:00:00 2001
From: Lyanis Souidi
Date: Thu, 23 May 2024 00:08:46 +0200
Subject: [PATCH 3/3] =?UTF-8?q?Ajout=20d'une=20route=20pour=20la=20cr?=
=?UTF-8?q?=C3=A9ation=20de=20tickets?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Ajout de la route /report qui permet de créer un ticket git depuis un formulaire dans ScoDoc
- Modification de la route /upload-dump pour qu'elle retourne du json + ajout d'un champ dump_id dans la réponse
---
.env | 1 +
.gitignore | 4 +
app/routes.py | 186 ++++++++++++++++++++++++++++++++++++++++++++++-
requirements.txt | 3 +-
4 files changed, 188 insertions(+), 6 deletions(-)
create mode 100644 .env
diff --git a/.env b/.env
new file mode 100644
index 0000000..b0428ea
--- /dev/null
+++ b/.env
@@ -0,0 +1 @@
+GITEA_TOKEN=
diff --git a/.gitignore b/.gitignore
index 87df45d..123fb2e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -173,3 +173,7 @@ Thumbs.db
.idea/
copy
+
+incoming_dumps/
+upload-dump-*
+counter
\ No newline at end of file
diff --git a/app/routes.py b/app/routes.py
index ee7acb7..6cd392f 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -1,8 +1,11 @@
-import json, datetime, fcntl, glob, os, re, socket, subprocess, time
+import json, datetime, fcntl, glob, os, re, socket, subprocess, time, requests
from flask import jsonify, request, abort
from flask import Blueprint
from app import email
+from dotenv import load_dotenv
+
+load_dotenv()
bp = Blueprint("routes", __name__)
@@ -22,6 +25,10 @@ DEBUG = False # if false, don't publish error messages
DEBIAN_PACKAGES_EXP = "/srv/packages/pool/main/s/scodoc9/scodoc9_*.deb"
RELEASE_LOG_FILE = "/home/viennet/scodoc-releases.log"
+GITEA_URL = "https://scodoc.org/git"
+GITEA_REPO = "ScoDoc/ScoDoc"
+GITEA_LABEL_ID = None
+
@bp.route("/scodoc-installmgr/check_version/