~mvo/software-center/lp970342

« back to all changes in this revision

Viewing changes to softwarecenter/backend/installbackend_impl/aptd.py

  • Committer: Michael Vogt
  • Date: 2012-04-10 14:19:18 UTC
  • mfrom: (2941.4.2 fix-977020)
  • Revision ID: michael.vogt@ubuntu.com-20120410141918-m3dcmp24a8diieiu
mergedĀ lp:~glatzor/software-center/fix-977020

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
        except Exception as error:
246
246
            self._on_trans_error(error)
247
247
 
 
248
    @inline_callbacks
 
249
    def fix_incomplete_install(self):
 
250
        try:
 
251
            trans = yield self.aptd_client.fix_incomplete_install(defer=True)
 
252
            self.emit("transaction-started", "", "", trans.tid,
 
253
                      TransactionTypes.REPAIR)
 
254
            yield self._run_transaction(trans, None, None, None)
 
255
        except Exception as error:
 
256
            self._on_trans_error(error)
 
257
 
248
258
    # FIXME: upgrade add-ons here
249
259
    @inline_callbacks
250
260
    def upgrade(self, app, iconname, addons_install=[], addons_remove=[],
819
829
 
820
830
        # show error
821
831
        if enum == enums.EXIT_FAILED:
822
 
            if trans.error:
823
 
                # Handle invalid packages separately
824
 
                if trans.error.code == enums.ERROR_INVALID_PACKAGE_FILE:
825
 
                    action = _("_Ignore and install")
826
 
                    res = self._show_transaction_failed_dialog(
827
 
                        trans, enum, action)
828
 
                    if res == "yes":
829
 
                        # Reinject the transaction
830
 
                        app, iconname, filename, meta_copy = \
831
 
                            self._get_app_and_icon_and_deb_from_trans(trans)
832
 
                        self.install(app, iconname, filename, [], [],
833
 
                                     metadata=meta_copy, force=True)
834
 
                        return
835
 
                # on unauthenticated errors, try a "repair" using the
836
 
                # reload functionatlity
837
 
                elif trans.error.code == enums.ERROR_PACKAGE_UNAUTHENTICATED:
838
 
                    action = _("Repair")
839
 
                    res = self._show_transaction_failed_dialog(
840
 
                        trans, enum, action)
841
 
                    if res == "yes":
842
 
                        app, iconname, filename, meta_copy = \
843
 
                            self._get_app_and_icon_and_deb_from_trans(trans)
844
 
                        self.reload()
845
 
                        self.install(app, iconname, filename, [], [],
846
 
                                     metadata=meta_copy)
847
 
                        return
 
832
            # Handle invalid packages separately
 
833
            if (trans.error and
 
834
                trans.error.code == enums.ERROR_INVALID_PACKAGE_FILE):
 
835
                action = _("_Ignore and install")
 
836
                res = self._show_transaction_failed_dialog(
 
837
                    trans, enum, action)
 
838
                if res == "yes":
 
839
                    # Reinject the transaction
 
840
                    app, iconname, filename, meta_copy = \
 
841
                        self._get_app_and_icon_and_deb_from_trans(trans)
 
842
                    self.install(app, iconname, filename, [], [],
 
843
                                 metadata=meta_copy, force=True)
 
844
                    return
 
845
            # on unauthenticated errors, try a "repair" using the
 
846
            # reload functionatlity
 
847
            elif (trans.error and
 
848
                  trans.error.code == enums.ERROR_PACKAGE_UNAUTHENTICATED):
 
849
                action = _("Repair")
 
850
                res = self._show_transaction_failed_dialog(
 
851
                    trans, enum, action)
 
852
                if res == "yes":
 
853
                    app, iconname, filename, meta_copy = \
 
854
                        self._get_app_and_icon_and_deb_from_trans(trans)
 
855
                    self.reload()
 
856
                    self.install(app, iconname, filename, [], [],
 
857
                                 metadata=meta_copy)
 
858
                    return
 
859
            # Finish a cancelled installation before resuming. If the 
 
860
            # user e.g. rebooted during a debconf question apt
 
861
            # will hang and the user is required to call
 
862
            # dpkg --configure -a, see LP#659438
 
863
            elif (trans.error and
 
864
                  trans.error.code == enums.ERROR_INCOMPLETE_INSTALL):
 
865
                action = _("Repair")
 
866
                res = self._show_transaction_failed_dialog(trans, enum,
 
867
                                                           action)
 
868
                if res == "yes":
 
869
                    self.fix_incomplete_install()
 
870
                    return
848
871
 
849
872
            elif (not "sc_add_repo_and_install_ignore_errors" in
850
 
                trans.meta_data):
 
873
                  trans.meta_data):
851
874
                self._show_transaction_failed_dialog(trans, enum)
852
875
 
853
876
        # send finished signal, use "" here instead of None, because