From 74b935ec1dd21fcca828cdb8caa848860d64baed Mon Sep 17 00:00:00 2001 From: jellium Date: Wed, 13 Jul 2016 16:11:16 +0200 Subject: [PATCH] Replace deprecated psutil.BOOT_TIME attribute The `psutil.BOOT_TIME` attribute appears to be deprecated, and returns an `AttributeError` when called. Even though the psutil documentation states that old attributes should be callable, one should use `psutil.boot_time()` function instead. In some version of psutil (e.g. 2.1.1), both appear callable. In old versions (e.g. 1.2.1), `psutil.BOOT_TIME` is but `psutil.boot_time()` is not. In the newest version (4.3.0), only the latter can be called. This bug would introduce an Internal Server Error (Error 500) when accessing the Monitor tool in the YunoHost admin panel. --- src/yunohost/monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/monitor.py b/src/yunohost/monitor.py index 9dfae8573..d0fe224e9 100644 --- a/src/yunohost/monitor.py +++ b/src/yunohost/monitor.py @@ -283,7 +283,7 @@ def monitor_system(units=None, human_readable=False): elif u == 'process': result[u] = json.loads(glances.getProcessCount()) elif u == 'uptime': - result[u] = (str(datetime.now() - datetime.fromtimestamp(psutil.BOOT_TIME)).split('.')[0]) + result[u] = (str(datetime.now() - datetime.fromtimestamp(psutil.boot_time())).split('.')[0]) elif u == 'infos': result[u] = json.loads(glances.getSystem()) else: