Add an uptime section to qute:version
This commit is contained in:
parent
408ceefad1
commit
ae48fa68a8
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user