Merge lp:~glatzor/software-center/fix-977020 into lp:software-center

Proposed by Sebastian Heinlein on 2012-04-09
Status: Merged
Merged at revision: 2951
Proposed branch: lp:~glatzor/software-center/fix-977020
Merge into: lp:software-center
Diff against target: 92 lines (+49/-26)
1 file modified
softwarecenter/backend/installbackend_impl/aptd.py (+49/-26)
To merge this branch: bzr merge lp:~glatzor/software-center/fix-977020
Reviewer Review Type Date Requested Status
software-store-developers 2012-04-09 Pending
Review via email: mp+101223@code.launchpad.net

Description of the change

To post a comment you must log in.

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-03-16 20:12:57 +0000
3+++ softwarecenter/backend/installbackend_impl/aptd.py 2012-04-09 07:37:20 +0000
4@@ -245,6 +245,16 @@
5 except Exception as error:
6 self._on_trans_error(error)
7
8+ @inline_callbacks
9+ def fix_incomplete_install(self):
10+ try:
11+ trans = yield self.aptd_client.fix_incomplete_install(defer=True)
12+ self.emit("transaction-started", "", "", trans.tid,
13+ TransactionTypes.REPAIR)
14+ yield self._run_transaction(trans, None, None, None)
15+ except Exception as error:
16+ self._on_trans_error(error)
17+
18 # FIXME: upgrade add-ons here
19 @inline_callbacks
20 def upgrade(self, app, iconname, addons_install=[], addons_remove=[],
21@@ -819,32 +829,45 @@
22
23 # show error
24 if enum == enums.EXIT_FAILED:
25- if trans.error:
26- # Handle invalid packages separately
27- if trans.error.code == enums.ERROR_INVALID_PACKAGE_FILE:
28- action = _("_Ignore and install")
29- res = self._show_transaction_failed_dialog(
30- trans, enum, action)
31- if res == "yes":
32- # Reinject the transaction
33- app, iconname, filename, meta_copy = \
34- self._get_app_and_icon_and_deb_from_trans(trans)
35- self.install(app, iconname, filename, [], [],
36- metadata=meta_copy, force=True)
37- return
38- # on unauthenticated errors, try a "repair" using the
39- # reload functionatlity
40- elif trans.error.code == enums.ERROR_PACKAGE_UNAUTHENTICATED:
41- action = _("Repair")
42- res = self._show_transaction_failed_dialog(
43- trans, enum, action)
44- if res == "yes":
45- app, iconname, filename, meta_copy = \
46- self._get_app_and_icon_and_deb_from_trans(trans)
47- self.reload()
48- self.install(app, iconname, filename, [], [],
49- metadata=meta_copy)
50- return
51+ # Handle invalid packages separately
52+ if (trans.error and
53+ trans.error.code == enums.ERROR_INVALID_PACKAGE_FILE):
54+ action = _("_Ignore and install")
55+ res = self._show_transaction_failed_dialog(
56+ trans, enum, action)
57+ if res == "yes":
58+ # Reinject the transaction
59+ app, iconname, filename, meta_copy = \
60+ self._get_app_and_icon_and_deb_from_trans(trans)
61+ self.install(app, iconname, filename, [], [],
62+ metadata=meta_copy, force=True)
63+ return
64+ # on unauthenticated errors, try a "repair" using the
65+ # reload functionatlity
66+ elif (trans.error and
67+ trans.error.code == enums.ERROR_PACKAGE_UNAUTHENTICATED):
68+ action = _("Repair")
69+ res = self._show_transaction_failed_dialog(
70+ trans, enum, action)
71+ if res == "yes":
72+ app, iconname, filename, meta_copy = \
73+ self._get_app_and_icon_and_deb_from_trans(trans)
74+ self.reload()
75+ self.install(app, iconname, filename, [], [],
76+ metadata=meta_copy)
77+ return
78+ # Finish a cancelled installation before resuming. If the
79+ # user e.g. rebooted during a debconf question apt
80+ # will hang and the user is required to call
81+ # dpkg --configure -a, see LP#659438
82+ elif (trans.error and
83+ trans.error.code == enums.ERROR_INCOMPLETE_INSTALL):
84+ action = _("Repair")
85+ res = self._show_transaction_failed_dialog(trans, enum,
86+ action)
87+ if res == "yes":
88+ self.fix_incomplete_install()
89+ return
90
91 elif (not "sc_add_repo_and_install_ignore_errors" in
92 trans.meta_data):