mirror of
https://github.com/Doctorado-ML/benchmark.git
synced 2025-08-17 16:35:54 +00:00
Add generate excel fault tolerance with compare
This commit is contained in:
@@ -85,17 +85,33 @@ def excel():
|
|||||||
else:
|
else:
|
||||||
selected_files = request.form["selected-files"]
|
selected_files = request.form["selected-files"]
|
||||||
book = None
|
book = None
|
||||||
for file_name in selected_files:
|
try:
|
||||||
file_name_result = os.path.join(Folders.results, file_name)
|
for file_name in selected_files:
|
||||||
if book is None:
|
file_name_result = os.path.join(Folders.results, file_name)
|
||||||
file_excel = os.path.join(Folders.excel, Files.be_list_excel)
|
if book is None:
|
||||||
book = xlsxwriter.Workbook(file_excel, {"nan_inf_to_errors": True})
|
file_excel = os.path.join(Folders.excel, Files.be_list_excel)
|
||||||
excel = Excel(
|
book = xlsxwriter.Workbook(
|
||||||
file_name=file_name_result,
|
file_excel, {"nan_inf_to_errors": True}
|
||||||
book=book,
|
)
|
||||||
compare=app.config[COMPARE],
|
excel = Excel(
|
||||||
|
file_name=file_name_result,
|
||||||
|
book=book,
|
||||||
|
compare=app.config[COMPARE],
|
||||||
|
)
|
||||||
|
excel.report()
|
||||||
|
except Exception as e:
|
||||||
|
if book is not None:
|
||||||
|
book.close()
|
||||||
|
return (
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"success": False,
|
||||||
|
"error": "Could not create excel file, " + str(e),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
{"ContentType": "application/json"},
|
||||||
)
|
)
|
||||||
excel.report()
|
|
||||||
if book is not None:
|
if book is not None:
|
||||||
book.close()
|
book.close()
|
||||||
Files.open(file_excel, test=app.config[TEST])
|
Files.open(file_excel, test=app.config[TEST])
|
||||||
|
@@ -51,11 +51,15 @@ function excel() {
|
|||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data){
|
success: function(data){
|
||||||
alert("Se ha generado el archivo "+data.file);
|
if (data.success) {
|
||||||
|
alert("Se ha generado el archivo "+data.file);
|
||||||
|
} else {
|
||||||
|
alert(data.error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr, ajaxOptions, thrownError) {
|
error: function (xhr, ajaxOptions, thrownError) {
|
||||||
var mensaje = JSON.parse(xhr.responseText || '{\"mensaje\": \"Error indeterminado\"}');
|
var mensaje = JSON.parse(xhr.responseText || '{\"message\": \"Error indeterminado\"}');
|
||||||
alert(mensaje.mensaje);
|
alert(mensaje.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user