2021-01-13 23:39:19 +00:00
|
|
|
import os
|
2019-10-04 13:22:39 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
from device.t1 import TrezorOne
|
2020-09-03 09:11:21 +00:00
|
|
|
from device.tt import TrezorT
|
2019-10-04 13:22:39 +00:00
|
|
|
|
|
|
|
|
2020-09-03 09:11:21 +00:00
|
|
|
def main(model: str, file: str = None):
|
2019-10-04 13:22:39 +00:00
|
|
|
t1 = TrezorOne(
|
2021-01-13 23:39:19 +00:00
|
|
|
os.environ["T1_UHUB_LOCATION"],
|
|
|
|
os.environ["T1_ARDUINO_SERIAL"],
|
|
|
|
os.environ["T1_UHUB_PORT"],
|
2019-10-04 13:22:39 +00:00
|
|
|
)
|
2021-01-13 23:39:19 +00:00
|
|
|
tt = TrezorT(os.environ["TT_UHUB_LOCATION"], os.environ["TT_UHUB_PORT"])
|
2020-09-03 09:11:21 +00:00
|
|
|
|
|
|
|
if model == "t1":
|
2021-01-21 23:18:34 +00:00
|
|
|
tt.power_off()
|
|
|
|
path = t1.update_firmware(file)
|
2020-09-03 09:11:21 +00:00
|
|
|
elif model == "tt":
|
2021-01-21 23:18:34 +00:00
|
|
|
t1.power_off()
|
|
|
|
path = tt.update_firmware(file)
|
2020-09-03 09:11:21 +00:00
|
|
|
else:
|
|
|
|
raise ValueError("Unknown Trezor model.")
|
2019-10-04 13:22:39 +00:00
|
|
|
|
2021-01-21 23:18:34 +00:00
|
|
|
print(path)
|
|
|
|
|
2019-10-04 13:22:39 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-09-03 09:11:21 +00:00
|
|
|
model = sys.argv[1]
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
main(model, file=sys.argv[2])
|
|
|
|
else:
|
|
|
|
main(model)
|