Merge ~pieq/bugit/+git/qabro:master into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: c3a9e17629c3988a7aad7b3d572a2351e5bf8326
Merged at revision: 6e11a700ae15d56fb301aa5bbbd085970637f35a
Proposed branch: ~pieq/bugit/+git/qabro:master
Merge into: bugit:master
Diff against target: 235 lines (+90/-22)
5 files modified
qabro/__init__.py (+15/-2)
qabro/__version__.py (+6/-0)
qabro/ui.py (+52/-10)
setup.py (+16/-9)
snap/snapcraft.yaml (+1/-1)
Reviewer Review Type Date Requested Status
Pierre Equoy Approve
Review via email: mp+347345@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pierre Equoy (pieq) wrote :

Self-approve

review: Approve

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 ad140a0..fd63106 100644
3--- a/qabro/__init__.py
4+++ b/qabro/__init__.py
5@@ -1,6 +1,6 @@
6 #!usr/bin/env python
7
8-import os, sys
9+import logging, os, sys
10 from time import sleep
11
12 from bug_assistant import BugAssistant
13@@ -8,6 +8,10 @@ from ui import ReportScreen
14
15 def main():
16 if os.getenv('SUDO_USER'):
17+ logging.basicConfig(filename='qabro.log',
18+ format='%(asctime)s - %(levelname)s - %(message)s',
19+ level=logging.ERROR
20+ )
21 start_ui()
22 else:
23 sys.exit("Please run this tool using sudo!")
24@@ -20,9 +24,18 @@ def start_ui():
25 try:
26 result = ba.file_bug()
27 except Exception as exc:
28- ui.message.set_text([('error', "Error: "), exc.message])
29+ logging.error(exc)
30+ error_msg = ''
31+ if hasattr(exc, 'content'):
32+ error_msg = exc.content
33+ else:
34+ error_msg = exc.message
35+ ui.message.set_text([('error', "Error: "), error_msg])
36 ui.run()
37 ba.update(ui.report())
38 else:
39 print(result)
40 break
41+
42+if __name__ == '__main__':
43+ main()
44diff --git a/qabro/__version__.py b/qabro/__version__.py
45new file mode 100644
46index 0000000..e83815e
47--- /dev/null
48+++ b/qabro/__version__.py
49@@ -0,0 +1,6 @@
50+__title__ = 'qabro'
51+__version__ = '0.4'
52+__description__ = 'Report bug information with attachments in Launchpad'
53+__author__ = 'Pierre Equoy'
54+__author_email__ = 'pierre.equoy@canonical.com'
55+__url__ = 'https://launchpad.net/qabro'
56diff --git a/qabro/ui.py b/qabro/ui.py
57index 80d0477..cdf2ec5 100644
58--- a/qabro/ui.py
59+++ b/qabro/ui.py
60@@ -5,6 +5,7 @@ import sys
61 import urwid
62
63 from bug_assistant import BugReport
64+from __version__ import __version__ as qversion, __title__ as qtitle
65
66 class ReportScreen:
67 palette = [
68@@ -18,18 +19,37 @@ class ReportScreen:
69 ]
70
71 footer_text = [
72- "Bug Report ",
73+ qtitle + ' v' + qversion + ' ',
74 ('key', "Alt-Enter"), " Submit ",
75 ('key', "Esc"), " Quit",
76 ]
77
78- statuses = ('New', 'Incomplete', 'Opinion', 'Confirmed')
79+ statuses = ('New', 'Confirmed')
80 importances = ('Undecided',
81 'Wishlist',
82 'Low',
83 'Medium',
84 'High',
85 'Critical')
86+ bug_types = { "Audio": "hwe-audio",
87+ "Bluetooth": "hwe-bluetooth",
88+ "Camera": "oem-camera",
89+ "External storage": "oem-storage",
90+ "Touchpad": "hwe-touchpad",
91+ "Touchscreen": "oem-touchscreen",
92+ "Install": "hwe-installer",
93+ "Media Card": "hwe-media",
94+ "Networking (ethernet)": "hwe-networking-ethernet",
95+ "Networking (wifi)": "hwe-networking-wifi",
96+ "Networking (modem)": "hwe-networking-modem",
97+ "Power management": "hwe-suspend-resume",
98+ "Checkbox": "checkbox test-case",
99+ "Video": "hwe-graphics",
100+ "Hotkeys": "hwe-hotkeys",
101+ "Firmware": "hwe-firmware",
102+ "Missing driver": "hwe-needs-driver",
103+ "Performance": "oem-performance",
104+ "Other problem": "oem-other"}
105
106 default_description = ("Summary:\n\n"
107 "Steps to reproduce:\n\n"
108@@ -51,12 +71,14 @@ class ReportScreen:
109 self._importance = []
110 for i in self.importances:
111 rb = urwid.RadioButton(self._importance, i, 'first True', None)
112- self._assignee = urwid.LineBox(urwid.Edit(), 'Assigned To')
113+ self._bug_type = []
114+ for i in sorted(self.bug_types):
115+ rb = urwid.RadioButton(self._bug_type, i, state=False, on_state_change=self.add_tag)
116+ self._assignee = urwid.LineBox(urwid.Edit(), 'Assigned To (Launchpad ID)')
117 self._tags = urwid.LineBox(urwid.Edit(), 'Tags')
118- self.cb_checkbox = urwid.CheckBox('Attach most recent Checkbox session (if any)')
119- self._options = urwid.LineBox(self.cb_checkbox, 'Options')
120 status_list = urwid.LineBox(urwid.Pile(self._status), 'Status')
121 importance_list = urwid.LineBox(urwid.Pile(self._importance), 'Importance')
122+ bug_types_list = urwid.LineBox(urwid.Pile(self._bug_type), 'Bug Type')
123 self.message = urwid.Text('')
124 self.footer = urwid.AttrMap(urwid.Text(self.footer_text), 'foot')
125 self.pile = urwid.Pile([self.message,
126@@ -68,13 +90,28 @@ class ReportScreen:
127 importance_list,
128 self._assignee,
129 self._tags,
130- self._options])
131+ bug_types_list])
132 self.view = urwid.Frame(urwid.Filler(self.pile, 'top'), footer=self.footer)
133
134+ def add_tag(self, rb, state):
135+ if state:
136+ # for the selected radio button
137+ tag = self.bug_types[rb.label]
138+ self._tags.base_widget.edit_text += ' ' + tag
139+ else:
140+ # for the previously selected radio button
141+ tag = self.bug_types[rb.label]
142+ self._tags.base_widget.edit_text = self._tags.base_widget.edit_text.replace(tag, '')
143+ # clean up the list of tags to remove unwanted white spaces
144+ self._tags.base_widget.edit_text = " ".join(self._tags.base_widget.edit_text.split())
145+
146 def run(self):
147 """Run the urwid MainLoop."""
148- self.loop = urwid.MainLoop(
149- self.view, self.palette, unhandled_input=self.unhandled_input)
150+ self.loop = urwid.MainLoop(self.view,
151+ self.palette,
152+ handle_mouse=False,
153+ unhandled_input=self.unhandled_input
154+ )
155 self.loop.run()
156
157 def unhandled_input(self, key):
158@@ -83,15 +120,20 @@ class ReportScreen:
159 sys.exit(0)
160 if key == 'meta enter':
161 raise urwid.ExitMainLoop()
162+ if key == 'page down':
163+ self.loop.process_input(['down' for _ in range(5)])
164+ if key == 'page up':
165+ self.loop.process_input(['up' for _ in range(5)])
166
167 def report(self):
168- options = {'include_checkbox_session': self.cb_checkbox.state}
169+ tags = self._tags.base_widget.text
170+ options = {'include_checkbox_session': 'checkbox' in tags}
171 return BugReport(title=self._title.base_widget.text,
172 description=self._description.base_widget.text,
173 project=self._project.base_widget.text,
174 series=self._series.base_widget.text,
175 assignee=self._assignee.base_widget.text,
176- tags=self._tags.base_widget.text,
177+ tags=tags,
178 status=[rb.label for rb in self._status if rb.state][0],
179 importance=[rb.label for rb in self._importance if rb.state][0],
180 options=options
181diff --git a/setup.py b/setup.py
182index 865cee9..db9e1e5 100644
183--- a/setup.py
184+++ b/setup.py
185@@ -1,23 +1,30 @@
186 #!/usr/bin/env python
187-
188+import os
189+from codecs import open
190 from setuptools import setup
191
192-package_name = 'qabro'
193+packages = ['qabro']
194+
195+here = os.path.abspath(os.path.dirname(__file__))
196+
197+about = {}
198+with open(os.path.join(here, 'qabro', '__version__.py'), 'r', 'utf-8') as f:
199+ exec(f.read(), about)
200
201 setup(
202- name=package_name,
203- version='0.2',
204- description="Report bug information with attachments in Launchpad",
205+ name=about['__title__'],
206+ version=about['__version__'],
207+ description=about['__description__'],
208 long_description="""
209 qabro is a tool to report bugs against Launchpad projects and
210 automatically attach relevent information to them (log files).
211 """,
212- packages=[package_name],
213+ packages=packages,
214 entry_points={
215 'console_scripts': ['qabro = qabro.__init__:main']
216 },
217- author="Pierre Equoy",
218- author_email="pierre.equoy@canonical.com",
219- url='https://launchpad.net/qabro',
220+ author=about['__author__'],
221+ author_email=about['__author_email__'],
222+ url=about['__url__'],
223 license='License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
224 )
225diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
226index cecdaa0..5e8e93e 100644
227--- a/snap/snapcraft.yaml
228+++ b/snap/snapcraft.yaml
229@@ -1,5 +1,5 @@
230 name: qabro
231-version: '0.3'
232+version: '0.4'
233 summary: QA OEM bug reporting tool
234 description: |
235 Tool to generate a Launchpad bug report and attach useful logs (using

Subscribers

People subscribed via source and target branches

to all changes: