Merge lp:~mvo/software-center/lp976169 into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2972
Proposed branch: lp:~mvo/software-center/lp976169
Merge into: lp:software-center
Diff against target: 78 lines (+26/-21)
1 file modified
utils/update-software-center-channels (+26/-21)
To merge this branch: bzr merge lp:~mvo/software-center/lp976169
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+101900@code.launchpad.net

Description of the change

This branch fixes two crashes when apt-xapian-index is not installed or was installed and got removed.

- do not crash if apt-xapian-index is not installed (LP: #976337)
- ignore xapian.DatabaseOpeningError here (happens when there is no a-x-i so we don't care)

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

Very nice, thank you, mvo!

Revision history for this message
Gary Lasker (gary-lasker) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'utils/update-software-center-channels'
--- utils/update-software-center-channels 2012-01-03 11:27:15 +0000
+++ utils/update-software-center-channels 2012-04-13 12:08:26 +0000
@@ -5,6 +5,7 @@
5DBusGMainLoop(set_as_default=True)5DBusGMainLoop(set_as_default=True)
6import logging6import logging
7import sys7import sys
8import xapian
89
9from gi.repository import GObject10from gi.repository import GObject
1011
@@ -15,19 +16,19 @@
15LOG = logging.getLogger("update-software-center-channels")16LOG = logging.getLogger("update-software-center-channels")
1617
17def compare_channels_in_db_to_cache(db):18def compare_channels_in_db_to_cache(db):
18 # the operation get_origins can take some time (~60s?)19 # the operation get_origins can take some time (~60s?)
19 cache_origins = set(db._aptcache.get_all_origins())20 cache_origins = set(db._aptcache.get_all_origins())
20 db_origins = set(db.get_origins_from_db())21 db_origins = set(db.get_origins_from_db())
21 # origins22 # origins
22 LOG.debug("cache_origins: %s" % cache_origins)23 LOG.debug("cache_origins: %s" % cache_origins)
23 LOG.debug("db_origins: %s" % db_origins)24 LOG.debug("db_origins: %s" % db_origins)
24 # the db_origins will contain origins from the s-c-agent, so25 # the db_origins will contain origins from the s-c-agent, so
25 # we don't need to rebuild if the db has more origins then26 # we don't need to rebuild if the db has more origins then
26 # the cache, but we need to rebuild if the cache has origins27 # the cache, but we need to rebuild if the cache has origins
27 # that a-x-i does not have28 # that a-x-i does not have
28 if not cache_origins.issubset(db_origins):29 if not cache_origins.issubset(db_origins):
29 return True30 return True
30 return False31 return False
3132
32def trigger_axi_update_and_wait():33def trigger_axi_update_and_wait():
33 def _axi_finished(res):34 def _axi_finished(res):
@@ -35,11 +36,11 @@
35 context = GObject.main_context_default()36 context = GObject.main_context_default()
36 main = GObject.MainLoop(context)37 main = GObject.MainLoop(context)
37 system_bus = dbus.SystemBus()38 system_bus = dbus.SystemBus()
38 axi = dbus.Interface(
39 system_bus.get_object("org.debian.AptXapianIndex","/"),
40 "org.debian.AptXapianIndex")
41 axi.connect_to_signal("UpdateFinished", _axi_finished)
42 try:39 try:
40 axi = dbus.Interface(
41 system_bus.get_object("org.debian.AptXapianIndex","/"),
42 "org.debian.AptXapianIndex")
43 axi.connect_to_signal("UpdateFinished", _axi_finished)
43 # first arg is force, second update_only44 # first arg is force, second update_only
44 axi.update_async(True, False)45 axi.update_async(True, False)
45 main.run()46 main.run()
@@ -62,9 +63,13 @@
62 logging.basicConfig(level=logging.DEBUG)63 logging.basicConfig(level=logging.DEBUG)
6364
64 # do it65 # do it
65 res = check_for_channel_updates_and_trigger_axi()66 try:
66 # return "1" means xapian got updated67 res = check_for_channel_updates_and_trigger_axi()
67 if res:68 # return "1" means xapian got updated
68 sys.exit(1)69 if res:
70 sys.exit(1)
71 except xapian.DatabaseOpeningError as e:
72 # this can happen if there is no a-x-i DB yet and we can ignore it
73 LOG.info("failed to open xapian db: '%s'" % e)
69 # return "0" nothing was done74 # return "0" nothing was done
70 sys.exit(0)75 sys.exit(0)

Subscribers

People subscribed via source and target branches