From 248c2f8063426f984967f6f021785aeb986c708f Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 15 Jun 2015 01:28:30 +0300 Subject: [PATCH] Use psutil.boot_time() function if appropriate It now replaced psutil.BOOT_TIME attribute. Fixes #1391 --- powerline/segments/common/sys.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/powerline/segments/common/sys.py b/powerline/segments/common/sys.py index 70d5fe81..f53e2c7d 100644 --- a/powerline/segments/common/sys.py +++ b/powerline/segments/common/sys.py @@ -131,10 +131,12 @@ if os.path.exists('/proc/uptime'): elif 'psutil' in globals(): from time import time - def _get_uptime(): - # psutil.BOOT_TIME is not subject to clock adjustments, but time() is. - # Thus it is a fallback to /proc/uptime reading and not the reverse. - return int(time() - psutil.BOOT_TIME) + if hasattr(psutil, 'boot_time'): + def _get_uptime(): + return int(time() - psutil.boot_time()) + else: + def _get_uptime(): + return int(time() - psutil.BOOT_TIME) else: def _get_uptime(): raise NotImplementedError