~mvo/software-center/size-calculation-via-aptdaemon-5.2

« back to all changes in this revision

Viewing changes to softwarecenter/db/pkginfo_impl/aptcache.py

  • Committer: Michael Vogt
  • Date: 2012-06-25 09:15:26 UTC
  • Revision ID: michael.vogt@ubuntu.com-20120625091526-m5u8fxhk48t0dr8f
softwarecenter/db/pkginfo_impl/aptcache.py: make it truely async

Show diffs side-by-side

added added

removed removed

Lines of Context:
577
577
            "query-total-size-on-install-done", trans.download, trans.space)
578
578
 
579
579
    def _on_trans_simulate_error(self, error):
580
 
        LOG.exception("simulate failed", error)
 
580
        LOG.exception("simulate failed")
 
581
 
 
582
    def _on_trans_commit_packages_ready(self, trans):
 
583
        trans.connect("space-changed", self._on_total_size_calculation_done)
 
584
        try:
 
585
            trans.simulate(reply_handler=lambda: True,
 
586
                           error_handler=self._on_trans_simulate_error)
 
587
        except:
 
588
            LOG.exception("simulate failed for '%s'" % pkgname)
581
589
 
582
590
    def query_total_size_on_install(self, pkgname,
583
591
                                    addons_install=[], addons_remove=[],
593
601
        install = [pkgname] + addons_install
594
602
        remove = addons_remove
595
603
        reinstall = purge = upgrade = downgrade = []
596
 
        trans = self.aptd_client.commit_packages(
597
 
            install, reinstall, remove, purge, upgrade, downgrade)
598
 
 
599
 
        trans.connect("space-changed", self._on_total_size_calculation_done)
600
 
 
601
 
        # simulate it async
 
604
 
 
605
        # do this async
602
606
        try:
603
 
            trans.simulate(reply_handler=lambda: True,
604
 
                           error_handler=self._on_trans_simulate_error)
 
607
            self.aptd_client.commit_packages(
 
608
                install, reinstall, remove, purge, upgrade, downgrade,
 
609
                # wait
 
610
                False,
 
611
                # reply and error handlers
 
612
                self._on_trans_commit_packages_ready,
 
613
                self._on_trans_simulate_error)
605
614
        except:
606
 
            LOG.exception("simulate failed for '%s'" % pkgname)
 
615
            LOG.exception(
 
616
                "getting commit_packages trans failed for '%s'" % pkgname)
607
617
 
608
618
    def get_all_deps_upgrading(self, pkg):
609
619
        # note: this seems not to be used anywhere