1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

dist/tools/usb-serial/ttys.py: improve error handling

Do not throw an exception when called with `--most-recent` but no
matching serial was found.
This commit is contained in:
Marian Buschsieweke 2022-08-29 16:37:28 +02:00
parent 0a872aaba2
commit dc6e8e51d7
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -213,11 +213,14 @@ def print_ttys(args):
ttys.append(tty)
if args.most_recent:
most_recent = ttys[0]
for tty in ttys:
if tty["ctime"] > most_recent["ctime"]:
most_recent = tty
ttys = [most_recent]
if len(ttys) > 0:
most_recent = ttys[0]
for tty in ttys:
if tty["ctime"] > most_recent["ctime"]:
most_recent = tty
ttys = [most_recent]
else:
ttys = []
print_results(args, ttys)