From c47570773f079a6ab1827917b687a3f5323d77a1 Mon Sep 17 00:00:00 2001 From: petersulyok Date: Sun, 3 Mar 2024 22:00:26 +0100 Subject: [PATCH] Fix: the demo won't stop if a disk does not have temperate (e.g. USB pendrive). --- src/diskinfo/demo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/diskinfo/demo.py b/src/diskinfo/demo.py index 9a8fc79..2e4416c 100644 --- a/src/diskinfo/demo.py +++ b/src/diskinfo/demo.py @@ -43,8 +43,13 @@ def disklist_demo(): disks = di.get_disk_list(sorting=True) for d in disks: s, u = d.get_size_in_hrf() + temp = d.get_temperature(sudo=True) + if temp: + temp_str = f"{temp:.1f} C" + else: + temp_str = "" table.add_row(d.get_name(), d.get_type_str(), d.get_model(), d.get_path(), - f"{d.get_temperature(sudo=True):.1f} C", d.get_serial_number(), d.get_firmware(), + temp_str, d.get_serial_number(), d.get_firmware(), f"{s:.1f} {u}") group = Group(panel, table) rprint(Panel(group, title="diskinfo demo: disks", title_align="left", border_style="gray30", expand=False))