2019-10-04 13:22:39 +00:00
|
|
|
import configparser
|
|
|
|
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
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read_file(open("hardware.cfg"))
|
|
|
|
t1 = TrezorOne(
|
2020-09-03 09:11:21 +00:00
|
|
|
config["t1"]["uhub_location"],
|
2020-09-25 11:59:16 +00:00
|
|
|
config["t1"]["arduino_serial"],
|
2020-09-03 09:11:21 +00:00
|
|
|
config["t1"]["port"],
|
2019-10-04 13:22:39 +00:00
|
|
|
)
|
2020-09-03 09:11:21 +00:00
|
|
|
tt = TrezorT(config["tt"]["uhub_location"], config["tt"]["port"])
|
|
|
|
|
|
|
|
if model == "t1":
|
|
|
|
t1.update_firmware(file)
|
|
|
|
elif model == "tt":
|
|
|
|
tt.update_firmware(file)
|
|
|
|
else:
|
|
|
|
raise ValueError("Unknown Trezor model.")
|
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)
|