fix: no fallar con usuario sin tickets
This commit is contained in:
parent
2d9ce9f97c
commit
ebed934246
18
app.py
18
app.py
|
|
@ -238,17 +238,23 @@ def api_datos():
|
|||
def api_regenerar():
|
||||
usuario = session["usuario"]
|
||||
try:
|
||||
subprocess.run(
|
||||
r1 = subprocess.run(
|
||||
[sys.executable, str(BASE_DIR / "autocompra7.py"), "--usuario", usuario],
|
||||
cwd=str(BASE_DIR), check=True, capture_output=True, timeout=120
|
||||
cwd=str(BASE_DIR), capture_output=True, text=True, timeout=120
|
||||
)
|
||||
subprocess.run(
|
||||
if r1.returncode != 0:
|
||||
return jsonify({"ok": False, "mensaje": "Error en pipeline",
|
||||
"detalle": r1.stderr or r1.stdout}), 500
|
||||
|
||||
r2 = subprocess.run(
|
||||
[sys.executable, str(BASE_DIR / "generar_lista.py"), "--usuario", usuario],
|
||||
cwd=str(BASE_DIR), check=True, capture_output=True, timeout=30
|
||||
cwd=str(BASE_DIR), capture_output=True, text=True, timeout=30
|
||||
)
|
||||
if r2.returncode != 0:
|
||||
return jsonify({"ok": False, "mensaje": "Error generando lista",
|
||||
"detalle": r2.stderr or r2.stdout}), 500
|
||||
|
||||
return jsonify({"ok": True, "mensaje": "Pipeline ejecutado correctamente"})
|
||||
except subprocess.CalledProcessError as e:
|
||||
return jsonify({"ok": False, "mensaje": str(e)}), 500
|
||||
except subprocess.TimeoutExpired:
|
||||
return jsonify({"ok": False, "mensaje": "Timeout al ejecutar el pipeline"}), 500
|
||||
|
||||
|
|
|
|||
|
|
@ -247,8 +247,16 @@
|
|||
try {
|
||||
const res = await fetch('/api/regenerar', { method: 'POST' });
|
||||
const data = await res.json();
|
||||
estado.textContent = data.mensaje;
|
||||
if (data.ok) setTimeout(() => location.reload(), 1500);
|
||||
if (data.ok) {
|
||||
estado.textContent = '✅ ' + data.mensaje;
|
||||
setTimeout(() => location.reload(), 1500);
|
||||
} else {
|
||||
estado.style.color = '#f97316';
|
||||
estado.textContent = '❌ ' + data.mensaje;
|
||||
if (data.detalle) {
|
||||
estado.innerHTML += '<pre style="font-size:.7rem;white-space:pre-wrap;margin-top:.3rem;color:#f97316;">' + data.detalle + '</pre>';
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
estado.textContent = 'Error de conexion';
|
||||
} finally {
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue