Merge ~pieq/bugit/+git/qabro:python3-port into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: b7786bccf1d31de1c9b726a27d2ccd225f400aa9
Merged at revision: a592920e7037703446b755e1ef99719680625c5f
Proposed branch: ~pieq/bugit/+git/qabro:python3-port
Merge into: bugit:master
Diff against target: 159 lines (+17/-30)
5 files modified
qabro/__init__.py (+5/-14)
qabro/bug_assistant.py (+9/-10)
qabro/ui.py (+2/-4)
setup.py (+1/-1)
snap/snapcraft.yaml (+0/-1)
Reviewer Review Type Date Requested Status
Maciej Kisielewski (community) Approve
Pierre Equoy Needs Resubmitting
Review via email: mp+354221@code.launchpad.net

Description of the change

To test, you can build a snap. Since wadllib was updated on both xenial and bionic, the fix to get binary launchpad attachments to work with Python3 wadllib should be in the repo, so your snap should include it. You can check this by creating a bug with qabro and opening the sosreport tar.xz attachment in the created bug.

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

A few thing I found I think need fixing. See below.

review: Needs Fixing
Revision history for this message
Pierre Equoy (pieq) wrote :

Thanks for the feedback Maciek! I'll take that into account. Please see one comment inline.

Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Re below.

Revision history for this message
Pierre Equoy (pieq) wrote :

I made the modifications you suggested.

Tested by building a snap (`snapcraft cleanbuild`) and submitting a few bug reports with it on Launchpad Staging instance.

review: Needs Resubmitting
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Good stuff. +1.

On some lazy afternoon you may consider fixing PEP8 issues for the code.

review: Approve
Revision history for this message
Pierre Equoy (pieq) wrote :

Thanks! Yes, I need to hook some flake8 to my work process... It's on my todo list :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/qabro/__init__.py b/qabro/__init__.py
2index 53fb41c..358ed45 100644
3--- a/qabro/__init__.py
4+++ b/qabro/__init__.py
5@@ -1,10 +1,8 @@
6-#!usr/bin/env python
7-
8 import logging, os, subprocess, sys
9 from time import sleep
10
11-from bug_assistant import BugAssistant
12-from ui import ReportScreen
13+from qabro.bug_assistant import BugAssistant
14+from qabro.ui import ReportScreen
15
16 def main():
17 if os.geteuid() == 0:
18@@ -16,7 +14,8 @@ def main():
19 sys.exit(("Cannot determine snap name. "
20 "Please install this tool using the snap command."))
21
22- output = subprocess.check_output(['snap', 'list', snap_name])
23+ output = subprocess.check_output(['snap', 'list', snap_name],
24+ universal_newlines=True)
25
26 if 'devmode' not in output:
27 sys.exit("This tool requires --devmode option to run properly.")
28@@ -36,18 +35,10 @@ def start_ui():
29 try:
30 result = ba.file_bug()
31 except Exception as exc:
32+ ui.message.set_text([('error', "Error: "), str(exc)])
33 logging.error(exc)
34- error_msg = ''
35- if hasattr(exc, 'content'):
36- error_msg = exc.content
37- else:
38- error_msg = exc.message
39- ui.message.set_text([('error', "Error: "), error_msg])
40 ui.run()
41 ba.update(ui.report())
42 else:
43 print(result)
44 break
45-
46-if __name__ == '__main__':
47- main()
48diff --git a/qabro/bug_assistant.py b/qabro/bug_assistant.py
49index 6ebf4b6..87cbb62 100644
50--- a/qabro/bug_assistant.py
51+++ b/qabro/bug_assistant.py
52@@ -1,6 +1,3 @@
53-#!/usr/bin/env python
54-from __future__ import print_function, unicode_literals
55-
56 import getpass, os, re, subprocess, sys, tarfile
57 from collections import Counter
58 from httplib2 import ServerNotFoundError
59@@ -227,7 +224,7 @@ class AttachmentAssistant:
60 command = ["sudo", "env", "PATH={}".format(p), "sosreport",
61 "--no-report", "--batch", "--tmp-dir", home_dir,
62 "--config-file", conf_file]
63- output = subprocess.check_output(command)
64+ output = subprocess.check_output(command).decode(sys.stdout.encoding)
65 archive_path = output.splitlines()[-6].strip()
66 print("Report generated: {}".format(archive_path))
67 command = ["sudo", "chown", "{}:{}".format(user, user), archive_path]
68@@ -262,7 +259,7 @@ class AttachmentAssistant:
69 if os.path.exists(classic_path):
70 rootpath = classic_path
71 else:
72- out = subprocess.check_output(["snap", "list"])
73+ out = subprocess.check_output(["snap", "list"]).decode(sys.stdout.encoding)
74 snap_name_list = [e for e in out.split() if 'checkbox' in e]
75 if snap_name_list:
76 snap_name = snap_name_list[0]
77@@ -297,7 +294,7 @@ class AttachmentAssistant:
78 "oops", "esrt", "uefibootpath", "uefirtvariable",
79 "uefirttime", "uefirtmisc", "--acpitests", "--log-level=high"]
80 subprocess.call(command)
81- with open(logfile) as f:
82+ with open(logfile, 'rb') as f:
83 content = f.read()
84 self.attachments['fwts_results.log'] = content
85 else:
86@@ -321,7 +318,7 @@ class AttachmentAssistant:
87 buildstamp = '/etc/buildstamp'
88 if os.path.isfile(buildstamp):
89 standard_info['Image'] = subprocess.check_output(
90- ['tail', '-n', '1', buildstamp])
91+ ['tail', '-n', '1', buildstamp]).decode(sys.stdout.encoding)
92
93 p = os.getenv('PATH')
94
95@@ -336,11 +333,13 @@ class AttachmentAssistant:
96
97 for dmi_value in ['system-manufacturer', 'system-product-name', 'bios-version']:
98 standard_info[dmi_value] = subprocess.check_output(
99- command + [dmi_value]).strip()
100+ command + [dmi_value]).decode(sys.stdout.encoding).strip()
101
102 standard_info['CPU'] = cls.get_cpu_info()
103
104- lspci_output = subprocess.check_output(['lspci']).splitlines()
105+ lspci_output = (subprocess.check_output(['lspci'])
106+ .decode(sys.stdout.encoding)
107+ .splitlines())
108 standard_info['GPU'] = '\n'.join([line for line in lspci_output
109 if 'VGA' in line])
110 return standard_info
111@@ -373,7 +372,7 @@ class AttachmentAssistant:
112 cpu_names[cpu_name] += 1
113
114 cpu_names_str = ['{} ({}x)'.format(cpu_name, count)
115- for cpu_name, count in cpu_names.iteritems()]
116+ for cpu_name, count in cpu_names.items()]
117
118 return '\n'.join(cpu_names_str)
119
120diff --git a/qabro/ui.py b/qabro/ui.py
121index b87ace4..806f78e 100644
122--- a/qabro/ui.py
123+++ b/qabro/ui.py
124@@ -1,11 +1,9 @@
125-#!/usr/bin/env python
126-from __future__ import unicode_literals, print_function
127 from time import sleep
128 import sys
129 import urwid
130
131-from bug_assistant import BugReport
132-from __version__ import __version__ as qversion, __title__ as qtitle
133+from qabro.bug_assistant import BugReport
134+from qabro.__version__ import __version__ as qversion, __title__ as qtitle
135
136 class ReportScreen:
137 palette = [
138diff --git a/setup.py b/setup.py
139index db9e1e5..9ca0a66 100644
140--- a/setup.py
141+++ b/setup.py
142@@ -1,4 +1,4 @@
143-#!/usr/bin/env python
144+#!/usr/bin/env python3
145 import os
146 from codecs import open
147 from setuptools import setup
148diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
149index b7213b9..94d79e9 100644
150--- a/snap/snapcraft.yaml
151+++ b/snap/snapcraft.yaml
152@@ -28,7 +28,6 @@ apps:
153 parts:
154 qabro:
155 plugin: python
156- python-version: python2
157 source: .
158 build-packages:
159 - libffi-dev

Subscribers

People subscribed via source and target branches

to all changes: