Merge pull request #1393 from ZyX-I/fix-1391

Use psutil.boot_time() function if appropriate
This commit is contained in:
Nikolai Aleksandrovich Pavlov 2015-06-15 01:36:04 +03:00
commit 0dc5c391fb
1 changed files with 6 additions and 4 deletions

View File

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