[fix] 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.
This commit is contained in:
jellium 2016-07-13 16:11:16 +02:00 committed by Jérôme Lebleu
parent f7add32acb
commit 53e19fa32d

View file

@ -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: