mirror of
https://github.com/FAUSheppy/ths-datenlogger
synced 2025-12-06 20:21:35 +01:00
fix: handle retrieval error for weather data
This commit is contained in:
@@ -126,6 +126,12 @@ def processExternalData(datapoints, plotNameKey, fromTime, toTime, dtype, qtText
|
|||||||
# download date if it doesn't exist #
|
# download date if it doesn't exist #
|
||||||
url = CFG("outside_data_url").format(dtype=dtype, fromDate=fromTimeStr, toDate=toTimeStr)
|
url = CFG("outside_data_url").format(dtype=dtype, fromDate=fromTimeStr, toDate=toTimeStr)
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
|
|
||||||
|
# check response code #
|
||||||
|
if r.status_code != 200 or "nicht gefunden" in r.text.lower():
|
||||||
|
qtTextBrowser.append(de.failed_to_retrieve.format("NOT FOUND"))
|
||||||
|
raise ValueError("FAILED TO RETRIEVE DATA")
|
||||||
|
|
||||||
qtTextBrowser.append(de.pg_request.format(url))
|
qtTextBrowser.append(de.pg_request.format(url))
|
||||||
content = r.content.decode('utf-8', "ignore") # ignore bad bytes
|
content = r.content.decode('utf-8', "ignore") # ignore bad bytes
|
||||||
|
|
||||||
|
|||||||
@@ -42,3 +42,5 @@ info_divergence = "INFO: Seitenverhältnisabweichung zu A4: {:.2f}%"
|
|||||||
success = "INFO: Fertig."
|
success = "INFO: Fertig."
|
||||||
testing_input = "Info: Eingabedatei wird geprüft..."
|
testing_input = "Info: Eingabedatei wird geprüft..."
|
||||||
testing_input_suc = "Info: Eingabedatei akzeptiert."
|
testing_input_suc = "Info: Eingabedatei akzeptiert."
|
||||||
|
|
||||||
|
failed_to_retrieve = "ERROR: Kann Wetterarchiv-Daten nicht herunterladen ({})"
|
||||||
|
|||||||
@@ -169,20 +169,21 @@ class WidgetGallery(QDialog):
|
|||||||
|
|
||||||
# workaround for checkboxes changed #
|
# workaround for checkboxes changed #
|
||||||
outsideDataNeeded = self.boxOTemp.isChecked() or self.boxOHumidity.isChecked()
|
outsideDataNeeded = self.boxOTemp.isChecked() or self.boxOHumidity.isChecked()
|
||||||
self.datapoints = input_backend.read_in_file(self.srcFileString,
|
|
||||||
|
# build dates #
|
||||||
|
try:
|
||||||
|
self.datapoints = input_backend.read_in_file(self.srcFileString,
|
||||||
outsideData=outsideDataNeeded,
|
outsideData=outsideDataNeeded,
|
||||||
plotOutsideTemp=self.boxOTemp.isChecked(),
|
plotOutsideTemp=self.boxOTemp.isChecked(),
|
||||||
plotOutsideHum=self.boxOHumidity.isChecked(),
|
plotOutsideHum=self.boxOHumidity.isChecked(),
|
||||||
qtTextBrowser=self.infoTextBox)
|
qtTextBrowser=self.infoTextBox)
|
||||||
|
|
||||||
# build dates #
|
|
||||||
try:
|
|
||||||
startTimeHelper = dt.datetime.strptime(self.startTimeEdit.text(),"%H:%M")
|
startTimeHelper = dt.datetime.strptime(self.startTimeEdit.text(),"%H:%M")
|
||||||
endTimeHelper = dt.datetime.strptime(self.endTimeEdit.text(),"%H:%M")
|
endTimeHelper = dt.datetime.strptime(self.endTimeEdit.text(),"%H:%M")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
errorBox = QMessageBox(self)
|
errorBox = QMessageBox(self)
|
||||||
errorBox.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
|
errorBox.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
|
||||||
errorBox.setText(self.localization.bad_time)
|
errorBox.setText(str(e))
|
||||||
errorBox.setDetailedText(str(e))
|
errorBox.setDetailedText(str(e))
|
||||||
errorBox.show()
|
errorBox.show()
|
||||||
self.buttonGo.setText(self.localization.button_go)
|
self.buttonGo.setText(self.localization.button_go)
|
||||||
|
|||||||
Reference in New Issue
Block a user