mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 11:28:14 +00:00
Allow firmware update by version or latest from releases.json
This commit is contained in:
parent
a20f976721
commit
6475f98b1e
17
trezorctl
17
trezorctl
@ -203,9 +203,6 @@ class Commands(object):
|
||||
return ret
|
||||
|
||||
def firmware_update(self, args):
|
||||
if not args.file and not args.url:
|
||||
raise Exception("Must provide firmware filename or URL")
|
||||
|
||||
if args.file:
|
||||
fp = open(args.file, 'r')
|
||||
elif args.url:
|
||||
@ -213,6 +210,19 @@ class Commands(object):
|
||||
resp = urllib.urlretrieve(args.url)
|
||||
fp = open(resp[0], 'r')
|
||||
urllib.urlcleanup() # We still keep file pointer open
|
||||
else:
|
||||
resp = urllib.urlopen("https://mytrezor.com/data/firmware/releases.json")
|
||||
releases = json.load(resp)
|
||||
version = lambda r: r['version']
|
||||
version_string = lambda r: ".".join(map(str, version(r)))
|
||||
if args.version:
|
||||
release = next((r for r in releases if version_string(r) == args.version))
|
||||
else:
|
||||
release = max(releases, key=version)
|
||||
print "No file, url, or version given. Fetching latest version: %s" % version_string(release)
|
||||
print "Firmware fingerprint: %s" % release['fingerprint']
|
||||
args.url = release['url']
|
||||
return self.firmware_update(args)
|
||||
|
||||
if fp.read(8) == '54525a52':
|
||||
print "Converting firmware to binary"
|
||||
@ -358,6 +368,7 @@ class Commands(object):
|
||||
firmware_update.arguments = (
|
||||
(('-f', '--file'), {'type': str}),
|
||||
(('-u', '--url'), {'type': str}),
|
||||
(('-n', '--version'), {'type': str}),
|
||||
)
|
||||
|
||||
def list_usb():
|
||||
|
Loading…
Reference in New Issue
Block a user