Add errors handling
This commit is contained in:
parent
844aa68c57
commit
6c159bea46
20
papi/main.py
20
papi/main.py
|
@ -57,6 +57,15 @@ class Notifier:
|
|||
{"changes": changes, "status": [x for x in status]}
|
||||
)
|
||||
|
||||
def error_sonde(idsonde, kind="perte_contact_api"):
|
||||
notifications[idsonde].append(
|
||||
{
|
||||
"changes": ["perte contact api"],
|
||||
"status": ["Le monitoring est inacessible"],
|
||||
}
|
||||
)
|
||||
breakpoint()
|
||||
|
||||
|
||||
Notifier = Notifier()
|
||||
|
||||
|
@ -129,6 +138,17 @@ def list_notification_as_text(request: Request, idsonde: str):
|
|||
)
|
||||
|
||||
|
||||
@app.post("/sonde/{idsonde}/error")
|
||||
def post_sonde_error(
|
||||
idsonde: str, body: dict = Body(...), db: Session = Depends(get_db)
|
||||
):
|
||||
if not (sonde := crud.get_sonde(db, idsonde)):
|
||||
return
|
||||
|
||||
Notifier.error_sonde(idsonde)
|
||||
return
|
||||
|
||||
|
||||
@app.post("/sonde/{idsonde}/")
|
||||
def post_sonde_data(
|
||||
idsonde: str, body: dict = Body(...), db: Session = Depends(get_db)
|
||||
|
|
Loading…
Reference in New Issue