mirror of
https://github.com/Doctorado-ML/benchmark.git
synced 2025-08-15 15:35:52 +00:00
Add generate excel fault tolerance with compare
This commit is contained in:
@@ -85,17 +85,33 @@ def excel():
|
||||
else:
|
||||
selected_files = request.form["selected-files"]
|
||||
book = None
|
||||
for file_name in selected_files:
|
||||
file_name_result = os.path.join(Folders.results, file_name)
|
||||
if book is None:
|
||||
file_excel = os.path.join(Folders.excel, Files.be_list_excel)
|
||||
book = xlsxwriter.Workbook(file_excel, {"nan_inf_to_errors": True})
|
||||
excel = Excel(
|
||||
file_name=file_name_result,
|
||||
book=book,
|
||||
compare=app.config[COMPARE],
|
||||
try:
|
||||
for file_name in selected_files:
|
||||
file_name_result = os.path.join(Folders.results, file_name)
|
||||
if book is None:
|
||||
file_excel = os.path.join(Folders.excel, Files.be_list_excel)
|
||||
book = xlsxwriter.Workbook(
|
||||
file_excel, {"nan_inf_to_errors": True}
|
||||
)
|
||||
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:
|
||||
book.close()
|
||||
Files.open(file_excel, test=app.config[TEST])
|
||||
|
@@ -51,11 +51,15 @@ function excel() {
|
||||
contentType: "application/json",
|
||||
dataType: 'json',
|
||||
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) {
|
||||
var mensaje = JSON.parse(xhr.responseText || '{\"mensaje\": \"Error indeterminado\"}');
|
||||
alert(mensaje.mensaje);
|
||||
var mensaje = JSON.parse(xhr.responseText || '{\"message\": \"Error indeterminado\"}');
|
||||
alert(mensaje.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user