ci: check model before flashing

pull/1488/head
Martin Milata 3 years ago
parent 17494b2276
commit 3213557f72

@ -20,10 +20,11 @@ class Device:
return run(full_cmd, shell=True, check=True, **kwargs) return run(full_cmd, shell=True, check=True, **kwargs)
def check_model(self, model=None): def check_model(self, model=None):
res = self.run_trezorctl("list", capture_output=True, text=True).stdout res = self.run_trezorctl("list", capture_output=True, text=True)
self.log(res) self.log(res.stdout)
self.log(res.stderr)
self.run_trezorctl("get-features | grep version") self.run_trezorctl("get-features | grep version")
lines = res.splitlines() lines = res.stdout.splitlines()
if len(lines) != 1: if len(lines) != 1:
raise RuntimeError("{} trezors connected".format(len(lines))) raise RuntimeError("{} trezors connected".format(len(lines)))
if model and model not in lines[0]: if model and model not in lines[0]:

@ -27,9 +27,9 @@ class TrezorOne(Device):
self.wait(3) self.wait(3)
self._enter_bootloader() self._enter_bootloader()
self.run_trezorctl("list")
self.wait(3) self.wait(3)
self.check_model("Trezor 1 bootloader")
self.run_trezorctl(trezorctlcmd) self.run_trezorctl(trezorctlcmd)
self.wait(3) self.wait(3)
self.touch("right", "click") self.touch("right", "click")

@ -3,18 +3,18 @@ from .device import Device
class TrezorT(Device): class TrezorT(Device):
def update_firmware(self, file=None): def update_firmware(self, file=None):
# reset to enter bootloader again
self.power_off()
self.power_on()
self.run_trezorctl("list")
if not file: if not file:
raise ValueError( raise ValueError(
"Uploading production firmware will replace the bootloader, it is not allowed!" "Uploading production firmware will replace the bootloader, it is not allowed!"
) )
# reset to enter bootloader again
self.power_off()
self.power_on()
self.wait(5) self.wait(5)
self.check_model("Trezor T bootloader")
self.run_trezorctl("device wipe --bootloader || true") self.run_trezorctl("device wipe --bootloader || true")
self.wait(5) self.wait(5)
self.power_off() self.power_off()

Loading…
Cancel
Save