wrap in try/except

pull/1931/head
dgtlmoon 1 year ago
parent 73c0bd1839
commit 160901a32c

@ -137,6 +137,7 @@ class import_distill_io_json(Importer):
flash("{} Imported from Distill.io in {:.2f}s, {} Skipped.".format(len(self.new_uuids), time.time() - now, len(self.remaining_data)))
class import_xlsx_wachete(Importer):
def run(self,
@ -157,8 +158,9 @@ class import_xlsx_wachete(Importer):
# @todo correct except
flash("Unable to read export XLSX file, something wrong with the file?", 'error')
return
for row in wb.active.iter_rows(min_row=2):
row_id = 2
for row in wb.active.iter_rows(min_row=row_id):
try:
extras = {}
data = {}
for cell in row:
@ -202,10 +204,16 @@ class import_xlsx_wachete(Importer):
# Straight into the queue.
self.new_uuids.append(new_uuid)
good += 1
except Exception as e:
print(e)
flash(f"Error processing row number {row_id}, check all cell data types are correct")
else:
row_id += 1
flash(
"{} imported from Wachete .xlsx in {:.2f}s".format(len(self.new_uuids), time.time() - now))
class import_xlsx_custom(Importer):
def run(self,
@ -230,7 +238,8 @@ class import_xlsx_custom(Importer):
# @todo cehck atleast 2 rows, same in other method
from .forms import validate_url
try:
row_i = 1
for row in wb.active.iter_rows():
url = None
tags = None
@ -278,6 +287,11 @@ class import_xlsx_custom(Importer):
# Straight into the queue.
self.new_uuids.append(new_uuid)
good += 1
except Exception as e:
print(e)
flash(f"Error processing row number {row_i}, check all cell data types are correct")
else:
row_i += 1
flash(
"{} imported from custom .xlsx in {:.2f}s".format(len(self.new_uuids), time.time() - now))

Loading…
Cancel
Save