Merge lp:~cr3/checkbox/1047857 into lp:checkbox

Proposed by Marc Tardif
Status: Merged
Merged at revision: 1715
Proposed branch: lp:~cr3/checkbox/1047857
Merge into: lp:checkbox
Diff against target: 309 lines (+2/-281)
3 files modified
debian/changelog (+2/-0)
plugins/apport_prompt.py (+0/-280)
po/POTFILES.in (+0/-1)
To merge this branch: bzr merge lp:~cr3/checkbox/1047857
Reviewer Review Type Date Requested Status
Jeff Marcom (community) Approve
Marc Tardif (community) Needs Resubmitting
Review via email: mp+126709@code.launchpad.net

Commit message

Merged fix to remove apport plugin by cr3 (LP #1047857)

Description of the change

Remembered to update po/POTFILES.in to remove reference to plugins/apport_prompt.py.

To post a comment you must log in.
lp:~cr3/checkbox/1047857 updated
1715. By Marc Tardif

Removed apport_prompt.py from POTFILES.in

Revision history for this message
Marc Tardif (cr3) wrote :

The changes to po/POTFILES.in got lost when creating this merge request again.

review: Needs Resubmitting
Revision history for this message
Jeff Marcom (jeffmarcom) wrote :

Looks okay to me, and no more nagging from apport!!! Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-09-27 09:00:46 +0000
+++ debian/changelog 2012-09-27 16:14:24 +0000
@@ -87,6 +87,8 @@
87 * checkbox/parsers/description.py: Fixed the PURPOSE and STEPS parts87 * checkbox/parsers/description.py: Fixed the PURPOSE and STEPS parts
88 of the description parser to automatically fix bad descriptions.88 of the description parser to automatically fix bad descriptions.
89 * plugins/suites_prompt.py: Fixed tree view in selection window (LP #1056432)89 * plugins/suites_prompt.py: Fixed tree view in selection window (LP #1056432)
90 * plugins/apport_prompt.py: Removed apport plugin that caused crashes
91 when trying to send bug report (LP #1047857)
9092
91 [Sean Feole]93 [Sean Feole]
92 * [FEATURE] scripts/battery_test: measures battery capacity before and after94 * [FEATURE] scripts/battery_test: measures battery capacity before and after
9395
=== removed file 'plugins/apport_prompt.py'
--- plugins/apport_prompt.py 2012-07-27 14:24:06 +0000
+++ plugins/apport_prompt.py 1970-01-01 00:00:00 +0000
@@ -1,280 +0,0 @@
1#
2# This file is part of Checkbox.
3#
4# Copyright 2008 Canonical Ltd.
5#
6# Checkbox is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# Checkbox is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
18#
19import logging
20
21from subprocess import check_output
22
23from gettext import gettext as _
24
25from checkbox.job import FAIL
26from checkbox.plugin import Plugin
27from checkbox.properties import Bool, Path, String
28from checkbox.reactor import StopAllException
29
30
31class DummyUserInterface:
32 pass
33
34try:
35 from apport.ui import UserInterface
36 from apport.crashdb import get_crashdb
37except:
38 UserInterface = DummyUserInterface
39
40
41CATEGORY_TO_PACKAGE = {
42 "SOUND": "alsa-base"}
43
44CATEGORY_TO_SYMPTOM = {
45 "VIDEO": "display",
46 "DISK": "storage"}
47
48
49class ApportOptions:
50
51 def __init__(self, test, device, package, symptom):
52 self.test = test
53 self.device = device
54 self.package = package
55 self.symptom = symptom
56 self.pid = None
57 self.save = False
58 self.tag = '' #Additional tags to add to reports filed
59 #through this tool
60
61
62class ApportUserInterface(UserInterface):
63
64 def __init__(self, interface, options):
65 self.interface = interface
66 self.options = options
67 self.report = None
68 self.report_file = None
69 self.cur_package = None
70
71 # ImportError raised during package upgrade
72 self.crashdb = get_crashdb(None)
73
74 def ui_info_message(self, title, text):
75 self.interface.show_info(text, ["close"])
76
77 def ui_error_message(self, title, text):
78 self.interface.show_progress_stop()
79 self.interface.show_error(text)
80
81 def ui_start_info_collection_progress(self):
82 self.interface.show_progress_start(
83 _("Collecting information about this test.\n"
84 "This might take a few minutes."))
85
86 def ui_pulse_info_collection_progress(self):
87 self.interface.show_progress_pulse()
88
89 def ui_stop_info_collection_progress(self):
90 # tags
91 if "Tags" in self.report:
92 tags = self.report["Tags"].split(" ")
93 else:
94 tags = []
95
96 tags.append("checkbox-bug")
97 if self.options.device:
98 tags.append(self.options.device)
99
100 self.report["Tags"] = " ".join(tags)
101
102 # checkbox
103 test = self.options.test
104 self.report["CheckboxTest"] = test["name"]
105 if test.get("description"):
106 self.report["CheckboxDescription"] = test["description"]
107 if test.get("data"):
108 self.report["CheckboxData"] = test["data"]
109 if test.get("command"):
110 self.report["CheckboxCommand"] = test["command"]
111 if test.get("environ"):
112 self.report["CheckboxEnvironment"] = test["environ"]
113
114 self.interface.show_progress_stop()
115
116 def ui_start_upload_progress(self):
117 self.interface.show_progress_start(
118 _("Collected information is being sent for bug tracking.\n"
119 "This might take a few minutes."))
120
121 def ui_set_upload_progress(self, progress):
122 self.interface.show_progress_pulse()
123
124 def ui_stop_upload_progress(self):
125 self.interface.show_progress_stop()
126
127 def ui_present_report_details(self, *args):
128 return dict(report=1)
129
130 def ui_question_choice(self, text, options, multiple):
131 self.interface.show_progress_stop()
132
133 if multiple:
134 results = self.interface.show_check(text, options)
135 else:
136 results = [self.interface.show_radio(text, options)]
137
138 return [options.index(r) for r in results]
139
140 def ui_question_yesno(self, text):
141 self.interface.show_progress_stop()
142 result = self.interface.show_radio(text, ["Yes", "No"])
143 return result == "Yes"
144
145 def open_url(self, url):
146 self.interface.show_url(url)
147
148
149class ApportPrompt(Plugin):
150
151 # Default configuration filename
152 default_filename = Path(default="/etc/default/apport")
153
154 # Default enabled state
155 default_enabled = Bool(required=False)
156
157 # Default package if none is detected
158 default_package = String(required=False)
159
160 # Filename where Submission ID is cached
161 submission_filename = Path(default="%(checkbox_data)s/submission")
162
163 # Filename where System ID is cached
164 system_filename = Path(default="%(checkbox_data)s/system")
165
166 def register(self, manager):
167 super(ApportPrompt, self).register(manager)
168
169 self._submission_id = None
170 self._system_id = None
171
172 for (rt, rh) in [
173 ("exchange-success", self.exchange_success),
174 ("report-submission_id", self.report_submission_id),
175 ("report-system_id", self.report_system_id)]:
176 self._manager.reactor.call_on(rt, rh)
177
178 if not isinstance(ApportUserInterface, DummyUserInterface):
179 self._manager.reactor.call_on("gather", self.gather)
180 self._manager.reactor.call_on("prompt-test", self.prompt_test, 100)
181
182 def gather(self):
183 if self.default_enabled is None:
184 value = check_output("unset enabled && . %s && echo ${enabled}"
185 % self.default_filename, shell=True, universal_newlines=True)
186 self.default_enabled = value.strip() == "1"
187
188 def prompt_test(self, interface, test):
189 if not self.default_enabled:
190 return
191
192 if test["status"] != FAIL:
193 return
194
195 device = None
196 package = None
197 symptom = None
198
199 # Give lowest priority to required packages
200 for resource in test.get("resources", []):
201 if "version" in resource:
202 package = resource["name"]
203 break
204
205 # Give highest priority to required devices
206 for resource in test.get("resources", []):
207 if "bus" in resource:
208 category = resource["category"]
209 if category in CATEGORY_TO_PACKAGE:
210 package = CATEGORY_TO_PACKAGE[category]
211 break
212
213 if category in CATEGORY_TO_SYMPTOM:
214 symptom = CATEGORY_TO_SYMPTOM[category]
215 break
216
217 # Default to configuration
218 if not package:
219 package = self.default_package
220
221 # Do not report a bug if no package nor symptom is defined
222 if not package and not symptom:
223 return
224
225 if test.get("suite"):
226 failed_test_message = _("Test %(name)s failed.") % {
227 'name': test["name"]}
228 else:
229 failed_test_message = _("Test %s failed.") % test["name"]
230 failed_test_message += "\n" + _("Do you want to report a bug?")
231
232 response = interface.show_info(failed_test_message,
233 ["yes", "no"], "no")
234 if response == "no":
235 return
236
237 # Determine corresponding device
238 for resource in test.get("resources", []):
239 if "bus" in resource:
240 device = resource["category"].lower()
241 break
242
243 try:
244 options = ApportOptions(test, device, package, symptom)
245 apport_interface = ApportUserInterface(interface, options)
246 except ImportError as e:
247 interface.show_error(_("Is a package upgrade in process? Error: %s") % e)
248 return
249
250 try:
251 if symptom and hasattr(apport_interface, "run_symptom"):
252 apport_interface.run_symptom()
253 else:
254 apport_interface.run_report_bug()
255 except SystemExit as e:
256 # In case of error, show_error already have been called
257 raise StopAllException
258
259 def exchange_success(self, response):
260 for message, filename in [
261 (self._submission_id, self.submission_filename),
262 (self._system_id, self.system_filename)]:
263 try:
264 file = open(filename, "w")
265 try:
266 file.write(message)
267 finally:
268 file.close()
269 except IOError as e:
270 logging.info("Failed to write to file '%s': %d %s",
271 filename, e.errno, e.strerror)
272
273 def report_submission_id(self, submission_id):
274 self._submission_id = submission_id
275
276 def report_system_id(self, system_id):
277 self._system_id = system_id
278
279
280factory = ApportPrompt
2810
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2012-09-19 22:09:38 +0000
+++ po/POTFILES.in 2012-09-27 16:14:24 +0000
@@ -53,7 +53,6 @@
53checkbox_urwid/urwid_interface.py53checkbox_urwid/urwid_interface.py
54checkbox_gtk/gtk_interface.py54checkbox_gtk/gtk_interface.py
55checkbox/user_interface.py55checkbox/user_interface.py
56plugins/apport_prompt.py
57plugins/final_prompt.py56plugins/final_prompt.py
58plugins/gather_prompt.py57plugins/gather_prompt.py
59plugins/intro_prompt.py58plugins/intro_prompt.py

Subscribers

People subscribed via source and target branches