Add parsed distribution to version info

Fixes #2369
This commit is contained in:
Florian Bruhin 2017-05-20 23:22:56 +02:00
parent fe145b66c1
commit aa8e6c8d17
2 changed files with 37 additions and 15 deletions

View File

@ -349,6 +349,14 @@ def version():
lines += [ lines += [
'Platform: {}, {}'.format(platform.platform(), 'Platform: {}, {}'.format(platform.platform(),
platform.architecture()[0]), platform.architecture()[0]),
]
dist = distribution()
if dist is not None:
lines += [
'Linux distribution: {} ({})'.format(dist.pretty, dist.parsed.name)
]
lines += [
'Frozen: {}'.format(hasattr(sys, 'frozen')), 'Frozen: {}'.format(hasattr(sys, 'frozen')),
"Imported from {}".format(importpath), "Imported from {}".format(importpath),
"Qt library executable path: {}, data path: {}".format( "Qt library executable path: {}, data path: {}".format(
@ -356,7 +364,9 @@ def version():
QLibraryInfo.location(QLibraryInfo.DataPath) QLibraryInfo.location(QLibraryInfo.DataPath)
) )
] ]
lines += _os_info()
if not dist or dist.parsed == Distribution.unknown:
lines += _os_info()
lines += [ lines += [
'', '',

View File

@ -809,16 +809,18 @@ def test_chromium_version_unpatched(qapp):
assert version._chromium_version() not in ['', 'unknown', 'unavailable'] assert version._chromium_version() not in ['', 'unknown', 'unavailable']
@pytest.mark.parametrize(['git_commit', 'frozen', 'style', 'with_webkit'], [ @pytest.mark.parametrize(['git_commit', 'frozen', 'style', 'with_webkit',
(True, False, True, True), # normal 'known_distribution'], [
(False, False, True, True), # no git commit (True, False, True, True, True), # normal
(True, True, True, True), # frozen (False, False, True, True, True), # no git commit
(True, True, False, True), # no style (True, True, True, True, True), # frozen
(True, False, True, False), # no webkit (True, True, False, True, True), # no style
(True, False, True, 'ng'), # QtWebKit-NG (True, False, True, False, True), # no webkit
(True, False, True, 'ng', True), # QtWebKit-NG
(True, False, True, True, False), # unknown Linux distribution
]) ])
def test_version_output(git_commit, frozen, style, with_webkit, stubs, def test_version_output(git_commit, frozen, style, with_webkit,
monkeypatch): known_distribution, stubs, monkeypatch):
"""Test version.version().""" """Test version.version()."""
class FakeWebEngineProfile: class FakeWebEngineProfile:
def httpUserAgent(self): def httpUserAgent(self):
@ -843,7 +845,7 @@ def test_version_output(git_commit, frozen, style, with_webkit, stubs,
'_path_info': lambda: {'PATH DESC': 'PATH NAME'}, '_path_info': lambda: {'PATH DESC': 'PATH NAME'},
'QApplication': (stubs.FakeQApplication(style='STYLE') if style else 'QApplication': (stubs.FakeQApplication(style='STYLE') if style else
stubs.FakeQApplication(instance=None)), stubs.FakeQApplication(instance=None)),
'QLibraryInfo.location': (lambda _loc: 'QT PATH') 'QLibraryInfo.location': (lambda _loc: 'QT PATH'),
} }
substitutions = { substitutions = {
@ -870,6 +872,18 @@ def test_version_output(git_commit, frozen, style, with_webkit, stubs,
patches['QWebEngineProfile'] = FakeWebEngineProfile patches['QWebEngineProfile'] = FakeWebEngineProfile
substitutions['backend'] = 'QtWebEngine (Chromium CHROMIUMVERSION)' substitutions['backend'] = 'QtWebEngine (Chromium CHROMIUMVERSION)'
if known_distribution:
patches['distribution'] = lambda: version.DistributionInfo(
parsed=version.Distribution.arch, version=None,
pretty='LINUX DISTRIBUTION', id='arch')
substitutions['linuxdist'] = ('\nLinux distribution: '
'LINUX DISTRIBUTION (arch)')
substitutions['osinfo'] = ''
else:
patches['distribution'] = lambda: None
substitutions['linuxdist'] = ''
substitutions['osinfo'] = 'OS INFO 1\nOS INFO 2\n'
for attr, val in patches.items(): for attr, val in patches.items():
monkeypatch.setattr('qutebrowser.utils.version.' + attr, val) monkeypatch.setattr('qutebrowser.utils.version.' + attr, val)
@ -891,13 +905,11 @@ def test_version_output(git_commit, frozen, style, with_webkit, stubs,
pdf.js: PDFJS VERSION pdf.js: PDFJS VERSION
SSL: SSL VERSION SSL: SSL VERSION
{style} {style}
Platform: PLATFORM, ARCHITECTURE Platform: PLATFORM, ARCHITECTURE{linuxdist}
Frozen: {frozen} Frozen: {frozen}
Imported from {import_path} Imported from {import_path}
Qt library executable path: QT PATH, data path: QT PATH Qt library executable path: QT PATH, data path: QT PATH
OS INFO 1 {osinfo}
OS INFO 2
Paths: Paths:
PATH DESC: PATH NAME PATH DESC: PATH NAME
""".lstrip('\n')) """.lstrip('\n'))