From fd990eb4fde0e206ca7898681395e6b966c81f83 Mon Sep 17 00:00:00 2001 From: Alex Boag-Munroe Date: Thu, 26 Sep 2019 23:22:25 +0100 Subject: [PATCH] Don't crash when ZFS version info is unavailable Catch the FileNotFoundError and stub the zfs version for the script to not crash. --- bumblebee/modules/zpool.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/zpool.py b/bumblebee/modules/zpool.py index 5b6092a..b8569df 100644 --- a/bumblebee/modules/zpool.py +++ b/bumblebee/modules/zpool.py @@ -65,8 +65,13 @@ class Module(bumblebee.engine.Module): def _update_widgets(self, widgets): # zpool list -H: List all zpools, use script mode (no headers and tabs as separators). - with open('/sys/module/zfs/version', 'r') as zfs_mod_version: - zfs_version = zfs_mod_version.readline().rstrip().split('-')[0] + try: + with open('/sys/module/zfs/version', 'r') as zfs_mod_version: + zfs_version = zfs_mod_version.readline().rstrip().split('-')[0] + except FileNotFoundError: + # ZFS isn't installed or the module isn't loaded, stub the version + zfs_version = "0.0.0" + raw_zpools = execute(('sudo ' if self._usesudo else '') + 'zpool list -H').split('\n') for widget in widgets: