From 5f8f1637abe660509a2036a2061e894ba1f78be8 Mon Sep 17 00:00:00 2001 From: Jerome Lebleu Date: Thu, 5 Dec 2013 14:32:36 +0100 Subject: [PATCH] Fix regex for block devices retrieving and clean up in yunohost_monitor.py --- yunohost_monitor.py | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/yunohost_monitor.py b/yunohost_monitor.py index 1648264b..d23390cb 100644 --- a/yunohost_monitor.py +++ b/yunohost_monitor.py @@ -55,13 +55,15 @@ def monitor_disk(units=None, mountpoint=None, human_readable=False): devices = {} output = subprocess.check_output('lsblk -o NAME,MOUNTPOINT -l -n'.split()) 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): (dn, dm) = (m.group(1), m.group(2)) devices[dn] = dm result[dn] = {} if len(units) > 1 else [] result_dname = dn if mountpoint is not None else None if len(devices) == 0: + if mountpoint is None: + raise YunoHostError(1, _("No mounted block device found")) raise YunoHostError(1, _("Unknown mountpoint '%s'") % mountpoint) # Retrieve monitoring for unit(s) @@ -216,33 +218,6 @@ def monitor_system(units=None, human_readable=False): return result -def monitor_process(enable=None, disable=None, start=None, stop=None, check=False, info=False): - """ - Check Process - - Keyword argument: - info -- Process info - disable -- Disable process - enable -- Enable process - start -- Start process - check -- Check process - stop -- Stop process - - """ - if enable: - return process_enable(enable) - elif disable: - return process_disable(disable) - elif start: - return process_start(start) - elif stop: - return process_stop(stop) - elif check: - return process_check(check) - elif info: - return json.loads(s.getProcessCount()) - - def _get_glances_api(): """ Retrieve Glances API running on the local server