Don't crash when ZFS version info is unavailable
Catch the FileNotFoundError and stub the zfs version for the script to not crash.
This commit is contained in:
parent
3a2fcb1abf
commit
fd990eb4fd
1 changed files with 7 additions and 2 deletions
|
@ -65,8 +65,13 @@ class Module(bumblebee.engine.Module):
|
||||||
|
|
||||||
def _update_widgets(self, widgets):
|
def _update_widgets(self, widgets):
|
||||||
# zpool list -H: List all zpools, use script mode (no headers and tabs as separators).
|
# zpool list -H: List all zpools, use script mode (no headers and tabs as separators).
|
||||||
|
try:
|
||||||
with open('/sys/module/zfs/version', 'r') as zfs_mod_version:
|
with open('/sys/module/zfs/version', 'r') as zfs_mod_version:
|
||||||
zfs_version = zfs_mod_version.readline().rstrip().split('-')[0]
|
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')
|
raw_zpools = execute(('sudo ' if self._usesudo else '') + 'zpool list -H').split('\n')
|
||||||
|
|
||||||
for widget in widgets:
|
for widget in widgets:
|
||||||
|
|
Loading…
Reference in a new issue