Catch FileNotFoundError when updating custom firmware

In case there is a bug there, we won't crash the thread.
This commit is contained in:
Ghostkeeper 2018-03-14 14:23:40 +01:00
parent 0655ef0bc5
commit 877d061a1b
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -127,9 +127,11 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
if self._connection_state != ConnectionState.closed:
self.close()
hex_file = intelHex.readHex(self._firmware_location)
if len(hex_file) == 0:
Logger.log("e", "Unable to read provided hex file. Could not update firmware")
try:
hex_file = intelHex.readHex(self._firmware_location)
assert len(hex_file) > 0
except (FileNotFoundError, AssertionError):
Logger.log("e", "Unable to read provided hex file. Could not update firmware.")
self.setFirmwareUpdateState(FirmwareUpdateState.firmware_not_found_error)
return