mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Fix #99 partly - awaiting something better
This commit is contained in:
parent
7135266452
commit
c040956e4d
1 changed files with 13 additions and 1 deletions
|
@ -61,7 +61,19 @@ def monitor_disk(units=None, mountpoint=None, human_readable=False):
|
||||||
|
|
||||||
# Get mounted block devices
|
# Get mounted block devices
|
||||||
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'):
|
for d in output.split('\n'):
|
||||||
m = re.search(r'([a-z]+[0-9]*)[ ]+(\/\S*)', d) # Extract device name (1) and its mountpoint (2)
|
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):
|
if m and (mountpoint is None or m.group(2) == mountpoint):
|
||||||
|
|
Loading…
Add table
Reference in a new issue