From c040956e4d116e56c5e6222d7c4c6218d6921c63 Mon Sep 17 00:00:00 2001 From: Jerome Lebleu Date: Fri, 14 Mar 2014 18:36:20 +0100 Subject: [PATCH] Fix #99 partly - awaiting something better --- yunohost_monitor.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/yunohost_monitor.py b/yunohost_monitor.py index 9875ae77..3256d26f 100644 --- a/yunohost_monitor.py +++ b/yunohost_monitor.py @@ -61,7 +61,19 @@ def monitor_disk(units=None, mountpoint=None, human_readable=False): # Get mounted block devices devices = {} - output = subprocess.check_output('lsblk -o NAME,MOUNTPOINT -l -n'.split()) + try: + output = subprocess.check_output('lsblk -o NAME,MOUNTPOINT -l -n'.split()) + except subprocess.CalledProcessError: + output = '' + + # Try to find at least root partition + if not output: + for p in psutil.disk_partitions(all=True): + if p.mountpoint == '/': + output = '%s /' % p.device.replace('/dev/', '') + break + + # Format results for d in output.split('\n'): m = re.search(r'([a-z]+[0-9]*)[ ]+(\/\S*)', d) # Extract device name (1) and its mountpoint (2) if m and (mountpoint is None or m.group(2) == mountpoint):