Compare commits
2 commits
master
...
f1b527cf3c
Author | SHA1 | Date | |
---|---|---|---|
Félix Baylac-Jacqué | f1b527cf3c | ||
Félix Baylac-Jacqué | cc5358012e |
|
@ -22,7 +22,9 @@ $ poetry run python test_axione_api.py
|
|||
|
||||
Travailler depuis la VM whitelistée par Axione est peu pratique. C'est pourquoi nous avons ajouté un mode debug permettant de simuler les réponses d'Axione.
|
||||
|
||||
Pour lancer la webapp localement en mode debug, vous pouvez utiliser le script `run-dev-server`:
|
||||
Pour l'activer, il vous faudra mettre la variable d'environnement `DEBUG` a `true`. Vous pouvez également utiliser un fichier de configuration ne se trouvant pas a `/etc/axione-elig-test.ini` à l'aide de la variable d'environnement `CONFIG`.
|
||||
|
||||
Par example:
|
||||
```bash
|
||||
./run-dev-server
|
||||
$ DEBUG=true CONFIG=./elig-test.ini python elig-test.py
|
||||
```
|
||||
|
|
28
dist/elig-test.service
vendored
28
dist/elig-test.service
vendored
|
@ -1,28 +0,0 @@
|
|||
[Unit]
|
||||
After=network.target
|
||||
WantedBy=default.target
|
||||
|
||||
[Service]
|
||||
Environment="PORT=6666"
|
||||
# /etc/ftth-elig/conf.ini
|
||||
ConfigurationDirectory=ftth-elig
|
||||
WorkingDirectory="/srv/www/Axione-FTTH-Test/"
|
||||
ExecStart="./startGunicornService"
|
||||
User=ftthTest
|
||||
Group=ftthTest
|
||||
Restart=on-failure
|
||||
RestartSec=30
|
||||
|
||||
# Sandboxing
|
||||
ProtectSystem=strict
|
||||
ProtectHome=tmpfs
|
||||
PrivateTmp=true
|
||||
PrivateDevices=true
|
||||
PrivateIPC=true
|
||||
ProtectClock=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectKernelLogs=true
|
||||
ProtectControlGroups=true
|
||||
RestrictAddressFamilies=AF_INET
|
||||
RestrictRealtime=true
|
|
@ -19,4 +19,3 @@ if __name__ == "__main__":
|
|||
|
||||
resp = query_axione_pto(cfg, "SPTH-BIEM2-0197")
|
||||
presp = parse_response(resp)
|
||||
print(presp)
|
||||
|
|
19
poetry.lock
generated
19
poetry.lock
generated
|
@ -62,20 +62,6 @@ Werkzeug = ">=2.0"
|
|||
async = ["asgiref (>=3.2)"]
|
||||
dotenv = ["python-dotenv"]
|
||||
|
||||
[[package]]
|
||||
name = "gunicorn"
|
||||
version = "20.1.0"
|
||||
description = "WSGI HTTP Server for UNIX"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
eventlet = ["eventlet (>=0.24.1)"]
|
||||
gevent = ["gevent (>=1.4.0)"]
|
||||
setproctitle = ["setproctitle"]
|
||||
tornado = ["tornado (>=0.2)"]
|
||||
|
||||
[[package]]
|
||||
name = "itsdangerous"
|
||||
version = "2.0.1"
|
||||
|
@ -197,7 +183,7 @@ watchdog = ["watchdog"]
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "2e09ffd1a733b1eebc75fcc481e28791601a142256ce45ad97f71abe520e428c"
|
||||
content-hash = "a0b053d03d5dab404be204f92db3efc73ce6d66ed491318060c5ede1036c4c12"
|
||||
|
||||
[metadata.files]
|
||||
black = [
|
||||
|
@ -216,9 +202,6 @@ flask = [
|
|||
{file = "Flask-2.0.2-py3-none-any.whl", hash = "sha256:cb90f62f1d8e4dc4621f52106613488b5ba826b2e1e10a33eac92f723093ab6a"},
|
||||
{file = "Flask-2.0.2.tar.gz", hash = "sha256:7b2fb8e934ddd50731893bdcdb00fc8c0315916f9fcd50d22c7cc1a95ab634e2"},
|
||||
]
|
||||
gunicorn = [
|
||||
{file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"},
|
||||
]
|
||||
itsdangerous = [
|
||||
{file = "itsdangerous-2.0.1-py3-none-any.whl", hash = "sha256:5174094b9637652bdb841a3029700391451bd092ba3db90600dea710ba28e97c"},
|
||||
{file = "itsdangerous-2.0.1.tar.gz", hash = "sha256:9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0"},
|
||||
|
|
|
@ -7,7 +7,6 @@ authors = ["Félix Baylac-Jacqué <felix@alternativebit.fr>"]
|
|||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
Flask = "^2.0.0"
|
||||
gunicorn = "^20.1.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
mypy = "^0.910"
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
DEBUG=true CONFIG=./elig-test.ini.sample FLASK_APP=webapp poetry run flask run --reload
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export PATH="/usr/bin/:/bin/:/srv/www/Axione-FTTH-Test/.poetry/bin/"
|
||||
poetry install
|
||||
poetry run gunicorn -b "localhost:${PORT}" --timeout 120 'webapp:app'
|
|
@ -1,25 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Aquilenet: Éligibilité FTTH</title>
|
||||
<style>
|
||||
{% include 'style.css' %}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="aquilenet-title">Aquilenet</h1>
|
||||
<div id="container">
|
||||
<h1 id="main-title">Test d'Éligibilité FTTH Aquilenet</h1>
|
||||
<form method="post" action="/result">
|
||||
<label>Numéro de PTO :
|
||||
<input name="pto"/>
|
||||
</label>
|
||||
<button>Tester</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,62 +0,0 @@
|
|||
<!doctype html>
|
||||
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Aquilenet: Éligibilité FTTH</title>
|
||||
<style>
|
||||
{% include 'style.css' %}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="aquilenet-title">Aquilenet</h1>
|
||||
<div id="container">
|
||||
<h1 id="main-title">Test d'Éligibilité FTTH Aquilenet: Résultats</h1>
|
||||
<p>Résultat pour le PTO: {{ pto }}</p>
|
||||
{% for batiment in result %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="100">{{ batiment["referenceBatiment"] }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for etage in batiment["etages"] %}
|
||||
<tr>
|
||||
<td>{{ etage["reference"] }}</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr><td>Nb Lignes Actives</td><td>{{ etage["nbLignesActives"] }}</td></tr>
|
||||
<tr><td>Nb Lignes Existantes</td><td>{{ etage["nbLignesExistantes"] }}</td></tr>
|
||||
<tr><td>Nb Locaux FTTH</td><td>{{ etage["nbLocauxFtth"] }}</td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th colspan="100">Lignes</th></tr>
|
||||
<tr><td>PTO</td><td>PBO</td><td>actif</td><td>commercialisable</td><td>existant</td><td>raccordable</td><td>rompu</td></tr>
|
||||
</thead>
|
||||
{% for ligne in etage["lignes"] %}
|
||||
<tr>
|
||||
<td>{{ ligne["pto"] }}</td>
|
||||
<td>{{ ligne["pbo"] }}</td>
|
||||
<td>{{ ligne["actif"] }}</td>
|
||||
<td>{{ ligne["commercialisable"] }}</td>
|
||||
<td>{{ ligne["existant"] }}</td>
|
||||
<td>{{ ligne["raccordable"] }}</td>
|
||||
<td>{{ ligne["rompu"] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,46 +0,0 @@
|
|||
body {
|
||||
background-color: #1787c2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: 'Titillium Web', sans-serif;
|
||||
}
|
||||
#aquilenet-title {
|
||||
color: white;
|
||||
align-self: center;
|
||||
font-size: 4em;
|
||||
margin-top: .3em;
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
#container {
|
||||
width: 80%;
|
||||
background-color: #ffd38c;
|
||||
align-self: center;
|
||||
padding: 2em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 10em;
|
||||
}
|
||||
|
||||
form {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
#main-title {
|
||||
align-self: center;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
table,td {
|
||||
border: 2px solid #333;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
thead, tfoot {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
td {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
32
webapp.py
32
webapp.py
|
@ -1,32 +0,0 @@
|
|||
import os
|
||||
from flask import Flask, render_template, request, escape
|
||||
|
||||
from axione_api.config import parse_config
|
||||
from axione_api.api import query_axione_pto, parse_response
|
||||
|
||||
def load_config():
|
||||
cfg_path = os.environ.get("CONFIG", "/etc/ftth-elig/conf.ini")
|
||||
print(f'Reading the "{cfg_path}" config file')
|
||||
cfg = parse_config(cfg_path)
|
||||
cfg.debug = True if "DEBUG" in os.environ else False
|
||||
if cfg.debug:
|
||||
print("===================")
|
||||
print("DEBUG_MODE")
|
||||
print("No requests will be performed")
|
||||
print("We'll inject some dummy data instead")
|
||||
print("===================")
|
||||
print("")
|
||||
return cfg
|
||||
|
||||
cfg = load_config()
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/", methods=['GET'])
|
||||
def get_form():
|
||||
return render_template("landing_form.html")
|
||||
|
||||
@app.route("/result", methods=['POST'])
|
||||
def show_result():
|
||||
pto = escape(request.form['pto'])
|
||||
result = parse_response(query_axione_pto(cfg, pto))
|
||||
return render_template("result.html", pto=pto, result=result)
|
Loading…
Reference in a new issue