do not abort on value error in dbf (warning only)

This commit is contained in:
Yannik Schmidt
2021-03-18 20:54:31 +01:00
parent db09dae115
commit 69ed98e64b
2 changed files with 18 additions and 4 deletions

View File

@@ -211,7 +211,7 @@ def read_in_file(path, backend=None, outsideData=False, plotOutsideTemp=True,
elif backend != None: elif backend != None:
backend(path) backend(path)
elif path.endswith(".DBF") or path.endswith(".dbf"): elif path.endswith(".DBF") or path.endswith(".dbf"):
dbfread(path,datapoints,pt,ph,pd) dbfread(path,datapoints,pt,ph,pd, qtTextBrowser)
elif path.endswith(".xls") or path.endswith(".XLS"): elif path.endswith(".xls") or path.endswith(".XLS"):
csvread(path,datapoints,pt,ph,pd,qtTextBrowser) csvread(path,datapoints,pt,ph,pd,qtTextBrowser)
elif path.endswith(".txt"): elif path.endswith(".txt"):
@@ -233,8 +233,20 @@ def read_in_file(path, backend=None, outsideData=False, plotOutsideTemp=True,
return datapoints return datapoints
def dbfread(path,datapoints,pt,ph,pd): def dbfread(path, datapoints, pt, ph, pd, qtTextBrowser):
for record in DBF(path): print("lol")
dbfIterator = iter(DBF(path))
print("lol2")
while True:
record = None
try:
record = next(dbfIterator)
except ValueError as e:
qtTextBrowser.append("Warning: Fehlerhafter Eintrag wird übersprungen")
continue
except StopIteration:
break
parse_line(datapoints, record, 'DATETIME', parse_line(datapoints, record, 'DATETIME',
[ ('TEMPCELS',pt), ('HUMIDITY',ph), ('DEWCELS',pd) ], [ ('TEMPCELS',pt), ('HUMIDITY',ph), ('DEWCELS',pd) ],
timeutils.time_from_dbf) timeutils.time_from_dbf)

View File

@@ -16,6 +16,7 @@ import datetime as dt
import input_backend import input_backend
import plot import plot
import traceback
import config_parse as cp import config_parse as cp
class WidgetGallery(QDialog): class WidgetGallery(QDialog):
@@ -242,9 +243,10 @@ class WidgetGallery(QDialog):
qtTextBrowser=self.infoTextBox) qtTextBrowser=self.infoTextBox)
except Exception as e: except Exception as e:
errorBox = QMessageBox(self) errorBox = QMessageBox(self)
errorBox.setStyleSheet("QLabel{min-width: 700px;}");
errorBox.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose) errorBox.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
errorBox.setText(self.localization.error_read_in) errorBox.setText(self.localization.error_read_in)
errorBox.setDetailedText(str(e)) errorBox.setDetailedText(traceback.format_exc())
errorBox.show() errorBox.show()
return return