Merge lp:~mvo/software-center/recoverable-errors-lp1051829 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3235
Proposed branch: lp:~mvo/software-center/recoverable-errors-lp1051829
Merge into: lp:software-center
Diff against target: 102 lines (+32/-8)
2 files modified
softwarecenter/backend/installbackend_impl/aptd.py (+19/-6)
tests/test_aptd.py (+13/-2)
To merge this branch: bzr merge lp:~mvo/software-center/recoverable-errors-lp1051829
Reviewer Review Type Date Requested Status
Evan Pending
software-store-developers Pending
Review via email: mp+129121@code.launchpad.net

Description of the change

This branch adds a custom DuplicateSignature to help erorrs.ubuntu.com
sort the various types of transaction faiures into different buckets so
that its easier to idenitify common problem types.

It also skips dpkg errors as those are recorded seperately (and are
usually not easily recoverable anyway).

To post a comment you must log in.
Revision history for this message
Evan (ev) wrote :

This will require a change to lp:daisy, which I'll make now.

Revision history for this message
Evan (ev) wrote :

The change is in lp:daisy r172, but we're waiting for it to be deployed in RT 56667.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/backend/installbackend_impl/aptd.py'
2--- softwarecenter/backend/installbackend_impl/aptd.py 2012-10-08 08:04:43 +0000
3+++ softwarecenter/backend/installbackend_impl/aptd.py 2012-10-11 08:58:21 +0000
4@@ -1008,6 +1008,10 @@
5 if pkgname and pkgname in self.pending_transactions:
6 del self.pending_transactions[pkgname]
7
8+ # calculate a dupes_signature here to have different buckets
9+ # on errors.ubuntu.com for the different crash types
10+ dupes_signature = "software-center:trans-failed:%s" % trans.error_code
11+
12 self.emit("transaction-stopped", result)
13 if isinstance(error, dbus.DBusException):
14 # ignore errors that the user knows about already (like
15@@ -1025,21 +1029,27 @@
16 "the authentication service is not available. "
17 "(%s") % error
18 # send to apport for reporting
19- self._call_apport_recoverable_error(text, error)
20+ self._call_apport_recoverable_error(
21+ text, error, dupes_signature)
22 # ... and display as a dialog
23 self.ui.error(None, summary, text)
24 return
25
26 # lintian errors are ignored and not send to apport_recoverable_error
27- if trans.error_code == enums.ERROR_INVALID_PACKAGE_FILE:
28+ # and dpkg errors as well as they will already be recorded seperately
29+ # by apt itself
30+ if trans.error_code in (enums.ERROR_INVALID_PACKAGE_FILE,
31+ enums.ERROR_PACKAGE_MANAGER_FAILED):
32 return
33
34 # show a apport recoverable error dialog to the user as we want
35 # to know about these issues
36 self._call_apport_recoverable_error(
37- _("There was an error submitting the transaction"), error)
38+ _("There was an error submitting the transaction"),
39+ error,
40+ dupes_signature)
41
42- def _call_apport_recoverable_error(self, text, error):
43+ def _call_apport_recoverable_error(self, text, error, dupes_signature):
44 """Call apports recoverable_problem dialog """
45
46 # ensure we have a proper expection string in the report
47@@ -1048,10 +1058,13 @@
48
49 # mvo: I don't think we need to send "Package\0software-center",
50 # apport should figure this out itself
51- data = "DialogBody\0%(text)s\0Traceback\0%(error)s" % {
52+ data = ("DialogBody\0%(text)s\0"
53+ "Traceback\0%(error)s\0"
54+ "DuplicateSignature\0%(dupes_signature)s" % {
55 'text': text,
56 'error': error,
57- }
58+ 'dupes_signature': dupes_signature,
59+ })
60 # This will be quick as it just writes the report file. Then
61 # the report gets picked up asynchronously by a inotify watch
62 # and displayed to the user in a seperate process.
63
64=== modified file 'tests/test_aptd.py'
65--- tests/test_aptd.py 2012-10-05 08:39:29 +0000
66+++ tests/test_aptd.py 2012-10-11 08:58:21 +0000
67@@ -159,7 +159,8 @@
68 mock_popen_instance.communicate.return_value = ("stdout", "stderr")
69 mock_popen_instance.returncode = 0
70 mock_popen.return_value = mock_popen_instance
71- self.aptd._call_apport_recoverable_error("msg", "traceback-error")
72+ self.aptd._call_apport_recoverable_error(
73+ "msg", "traceback-error", "custom:dupes:signature")
74 mock_popen.assert_called_with(
75 [APPORT_RECOVERABLE_ERROR], stdin=subprocess.PIPE,
76 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
77@@ -167,7 +168,10 @@
78 args, kwargs = mock_popen_instance.communicate.call_args
79 self.assertEqual(
80 kwargs["input"].split("\0"),
81- [ 'DialogBody', 'msg','Traceback', 'traceback-error'])
82+ [ 'DialogBody', 'msg',
83+ 'Traceback', 'traceback-error',
84+ 'DuplicateSignature', 'custom:dupes:signature',
85+ ])
86
87 def test_ignore_bad_packages(self):
88 mock_trans = Mock(aptdaemon.client.AptTransaction)
89@@ -176,6 +180,13 @@
90 self.aptd._on_trans_error("some error", mock_trans)
91 self.assertFalse(m.called)
92
93+ def test_ignore_dpkg_errors(self):
94+ mock_trans = Mock(aptdaemon.client.AptTransaction)
95+ mock_trans.error_code = aptdaemon.enums.ERROR_PACKAGE_MANAGER_FAILED
96+ with patch.object(self.aptd, "_call_apport_recoverable_error") as m:
97+ self.aptd._on_trans_error("some error", mock_trans)
98+ self.assertFalse(m.called)
99+
100
101 if __name__ == "__main__":
102 logging.basicConfig(level=logging.INFO)

Subscribers

People subscribed via source and target branches