Merge lp:~mvo/software-center/fix-chroot-lp1040311 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3132
Proposed branch: lp:~mvo/software-center/fix-chroot-lp1040311
Merge into: lp:software-center
Diff against target: 41 lines (+12/-1)
2 files modified
softwarecenter/db/pkginfo_impl/aptcache.py (+6/-1)
tests/test_pkginfo.py (+6/-0)
To merge this branch: bzr merge lp:~mvo/software-center/fix-chroot-lp1040311
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+121827@code.launchpad.net

Description of the change

Fix crash if there is no system dbus, this can happen e.g. when running
inside a chroot environment.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

A unit test and a bug fix, perfect! Thanks, mvo.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/pkginfo_impl/aptcache.py'
2--- softwarecenter/db/pkginfo_impl/aptcache.py 2012-08-20 09:56:39 +0000
3+++ softwarecenter/db/pkginfo_impl/aptcache.py 2012-08-29 11:44:19 +0000
4@@ -139,7 +139,12 @@
5 # this is fast, so ok
6 self._language_packages = self._read_language_pkgs()
7 # query the totalize on install using aptdaemon
8- self.aptd_client = AptClient()
9+ try:
10+ self.aptd_client = AptClient()
11+ except Exception as e:
12+ self.aptd_client = None
13+ logging.error("Can not get aptdaemon client: '%s', on "
14+ "size information will be available " % e)
15 self._aptd_trans = None
16
17 @staticmethod
18
19=== modified file 'tests/test_pkginfo.py'
20--- tests/test_pkginfo.py 2012-08-20 09:55:18 +0000
21+++ tests/test_pkginfo.py 2012-08-29 11:44:19 +0000
22@@ -11,6 +11,7 @@
23 )
24 setup_test_env()
25
26+import softwarecenter
27 from softwarecenter.db.pkginfo import get_pkg_info
28 from softwarecenter.utils import ExecutionTime
29
30@@ -83,6 +84,11 @@
31 to_install = args[0]
32 self.assertTrue(to_install[0].endswith("/%s" % archive_suite))
33
34+ @patch("softwarecenter.db.pkginfo_impl.aptcache.AptClient")
35+ def test_aptd_client_unavailable(self, mock_apt_client):
36+ mock_apt_client.side_effect = Exception("fake")
37+ cache = softwarecenter.db.pkginfo_impl.aptcache.AptCache()
38+ self.assertEqual(cache.aptd_client, None)
39
40 if __name__ == "__main__":
41 unittest.main()

Subscribers

People subscribed via source and target branches