Merge ~pieq/bugit/+git/qabro:fix-1910193-no-pci-bus into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: 78c1933fe61dbf17b0d027e89f22e29ea99ade35
Merged at revision: 44b3acd84a216fba15eb076747034610f45ee309
Proposed branch: ~pieq/bugit/+git/qabro:fix-1910193-no-pci-bus
Merge into: bugit:master
Diff against target: 76 lines (+19/-12)
2 files modified
qabro/bug_assistant.py (+15/-10)
qabro/utils.py (+4/-2)
Reviewer Review Type Date Requested Status
Patrick Liu (community) Approve
Review via email: mp+395821@code.launchpad.net

Description of the change

As explained in lp:1910193, if the device does not have a PCI bus, calling lspci will fail and qabro will fail to launch.

This commit fixes that by checking the returncode from the lspci command.

I tested it on a regular amd64 PC with a proper PCI bus by building a test snap and it works (so it means no regression so far), but I haven't been able to test it on a no-PCI bus device...

To post a comment you must log in.
Revision history for this message
Patrick Liu (patliu) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/qabro/bug_assistant.py b/qabro/bug_assistant.py
2index 7af347c..16bc5d1 100644
3--- a/qabro/bug_assistant.py
4+++ b/qabro/bug_assistant.py
5@@ -1,12 +1,11 @@
6 import getpass
7-from glob import glob
8 import os
9 import re
10 import subprocess
11 import sys
12 import tarfile
13 from collections import Counter
14-
15+from glob import glob
16 from launchpadlib.launchpad import Launchpad
17 from launchpadlib.uris import LPNET_WEB_ROOT, STAGING_WEB_ROOT, QASTAGING_WEB_ROOT
18
19@@ -368,7 +367,7 @@ class AttachmentAssistant:
20 if os.path.isfile(udc):
21 with open(udc) as f:
22 dcd = f.read()
23- manifest = re.search("^([^\s#]+)$", dcd, re.MULTILINE)[0]
24+ manifest = re.search(r"^([^\s#]+)$", dcd, re.MULTILINE)[0]
25 if manifest:
26 standard_info["Manifest"] = manifest
27
28@@ -389,12 +388,18 @@ class AttachmentAssistant:
29
30 standard_info['CPU'] = AttachmentAssistant.get_cpu_info()
31
32- lspci_output = (subprocess.check_output(['lspci', '-nn'])
33- .decode(sys.stdout.encoding)
34- .splitlines())
35- # '03' is the PCI class for display controllers
36- standard_info['GPU'] = '\n'.join([line for line in lspci_output
37- if '[03' in line])
38+ command = ["lspci", "-nn"]
39+ process = subprocess.run(command,
40+ stdout=subprocess.PIPE,
41+ stderr=subprocess.PIPE)
42+ if process.returncode == 0:
43+ lspci_output = process.stdout.decode(sys.stdout.encoding).splitlines()
44+ # '03' is the PCI class for display controllers
45+ standard_info['GPU'] = '\n'.join([line for line in lspci_output
46+ if '[03' in line])
47+ else:
48+ print("Error while running lspci:")
49+ print(process.stderr)
50
51 standard_info["kernel-version"] = (subprocess.check_output(["uname", "-r"])
52 .decode(sys.stdout.encoding)
53@@ -406,7 +411,7 @@ class AttachmentAssistant:
54 """Parse /proc/cpuinfo and return cpu model information."""
55 cpus = []
56 cpuinfo = {}
57- parse_line = re.compile(r'(.*?)\s+:\s+(.*)').match
58+ parse_line = re.compile(r"(.*?)\s+:\s+(.*)").match
59 processor_line = re.compile(r'^(p|P)rocessor')
60 with open('/proc/cpuinfo') as file:
61 for line in file:
62diff --git a/qabro/utils.py b/qabro/utils.py
63index 89845b3..8c3e4e8 100644
64--- a/qabro/utils.py
65+++ b/qabro/utils.py
66@@ -1,7 +1,9 @@
67 #!/usr/bin/env python3
68-import socket, json, pprint
69-
70 import gi
71+import json
72+import pprint
73+import socket
74+
75 gi.require_version('Snapd', '1')
76 from gi.repository import Snapd
77

Subscribers

People subscribed via source and target branches

to all changes: