From 51d1cd1926c5696de97f99ca47cbc830c34b49ba Mon Sep 17 00:00:00 2001 From: Martinez Date: Sun, 9 Oct 2016 20:19:11 +0200 Subject: [PATCH] handle systems with no labelled devices --- libexec/render.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libexec/render.py b/libexec/render.py index 8eb3642..c6862b4 100755 --- a/libexec/render.py +++ b/libexec/render.py @@ -547,7 +547,11 @@ class StatsPart(Part): names = [] first_mountpoint = True btrfs_encountered_devices = set() - device_to_label = {os.path.join("/dev", os.path.basename(os.readlink(os.path.join("/dev/disk/by-label", x)))): x for x in os.listdir("/dev/disk/by-label")} + + if os.path.isdir("/dev/disk/by-label"): + device_to_label = {os.path.join("/dev", os.path.basename(os.readlink(os.path.join("/dev/disk/by-label", x)))): x for x in os.listdir("/dev/disk/by-label")} + else: + device_to_label = {} with open("/proc/self/mounts") as f: for line in f: @@ -585,7 +589,7 @@ class StatsPart(Part): continue btrfs_encountered_devices.add(device) - short_name = " "+device_to_label[device][0] + if device in device_to_label: short_name = " "+device_to_label[device][0] btrfs_raw = command(["/sbin/btrfs", "fi", "usage", "-b", dir])