Merge ~kissiel/plainbox-provider-resource:fix-1731660-bad-driver-reported into plainbox-provider-resource:master

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Maciej Kisielewski
Approved revision: 98bc8d27a9f0f886c8474e96f18e226ad3f40a3e
Merged at revision: e8a34665f827381289fdb33bcd67c168f0f4e093
Proposed branch: ~kissiel/plainbox-provider-resource:fix-1731660-bad-driver-reported
Merge into: plainbox-provider-resource:master
Diff against target: 34 lines (+10/-5)
1 file modified
bin/graphics_card_resource (+10/-5)
Reviewer Review Type Date Requested Status
Sheila Miguez (community) Approve
Checkbox Developers Pending
Review via email: mp+333582@code.launchpad.net

Description of the change

override the driver name to amdgpu-pro only for vendor == amd

previously, if the system had vulkan-amdgpu-pro pkg installed, the script
reported 'amdgpu-pro' as the driver for all the GPUs.

Now it's amdgpu-pro is reported only for GPUs from vendor 4098 - AMD.
This is still not perfect, as theretically there might be multiple amd pus
in the system, not all of them amdgpu-pro, but it still makes it closer to the truth and right for the typical intel+radeon configuration.

This patch also rearranges the logic for the dpkg-query call.
if not `some commands run` intuitively should mean "if the command failed"
which in the case of subprocess.call(...) is casted to boolean, therefore
`if not subprocess.call(...)` means success. I added explicit comparison to 0.

Fixes: LP:1731660

To post a comment you must log in.
Revision history for this message
Sheila Miguez (codersquid) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/graphics_card_resource b/bin/graphics_card_resource
2index 6c18672..19daf11 100755
3--- a/bin/graphics_card_resource
4+++ b/bin/graphics_card_resource
5@@ -2,8 +2,9 @@
6 #
7 # This file is part of Checkbox.
8 #
9-# Copyright 2015 Canonical Ltd.
10+# Copyright 2015-2017 Canonical Ltd.
11 # Authors: Daniel Manrique <daniel.manrique@canonical.com>
12+# Authors: Maciej Kisielewski <maciej.kisielewski@canonical.com>
13 #
14 # Checkbox is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License version 3,
16@@ -124,10 +125,14 @@ def main():
17 try:
18 for index, record in enumerate(video_devices, 1):
19 record['index'] = index
20- if not subprocess.call(['dpkg-query', '-W', 'vulkan-amdgpu-pro'],
21- stderr=subprocess.STDOUT,
22- stdout=subprocess.DEVNULL):
23- record['driver'] = 'amdgpu-pro'
24+ if record['vendor_id'] == '4098': # vendor == amd/ati
25+ if subprocess.call(
26+ ['dpkg-query', '-W', 'vulkan-amdgpu-pro'],
27+ stderr=subprocess.STDOUT,
28+ stdout=subprocess.DEVNULL) == 0:
29+ # dpkg-query did not report error, so
30+ # vulkan-amdgpu-pro is installed
31+ record['driver'] = 'amdgpu-pro'
32 if 'product' not in record:
33 # Fake a product name with the product_id
34 try:

Subscribers

People subscribed via source and target branches