Add an uptime section to qute:version

This commit is contained in:
Jay Kamat 2017-11-13 21:17:44 -05:00
parent 408ceefad1
commit ae48fa68a8
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5

View File

@ -29,6 +29,7 @@ import importlib
import collections
import enum
import pkg_resources
import datetime
import attr
from PyQt5.QtCore import PYQT_VERSION_STR, QLibraryInfo
@ -324,6 +325,12 @@ def _backend():
assert objects.backend == webengine, objects.backend
return 'QtWebEngine (Chromium {})'.format(_chromium_version())
def _uptime() -> datetime.timedelta:
launch_time = QApplication.instance().launch_time
time_delta = datetime.datetime.now() - launch_time
# Round off microseconds
time_delta -= datetime.timedelta(microseconds=time_delta.microseconds)
return time_delta
def version():
"""Return a string with various version informations."""
@ -388,6 +395,11 @@ def version():
for name, path in sorted(_path_info().items()):
lines += ['{}: {}'.format(name, path)]
lines += [
'',
'Uptime: {}'.format(str(_uptime()))
]
return '\n'.join(lines)