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
1=== modified file 'utils/update-software-center-channels'
2--- utils/update-software-center-channels 2012-01-03 11:27:15 +0000
3+++ utils/update-software-center-channels 2012-04-13 12:08:26 +0000
4@@ -5,6 +5,7 @@
5 DBusGMainLoop(set_as_default=True)
6 import logging
7 import sys
8+import xapian
9
10 from gi.repository import GObject
11
12@@ -15,19 +16,19 @@
13 LOG = logging.getLogger("update-software-center-channels")
14
15 def compare_channels_in_db_to_cache(db):
16- # the operation get_origins can take some time (~60s?)
17- cache_origins = set(db._aptcache.get_all_origins())
18- db_origins = set(db.get_origins_from_db())
19- # origins
20- LOG.debug("cache_origins: %s" % cache_origins)
21- LOG.debug("db_origins: %s" % db_origins)
22- # the db_origins will contain origins from the s-c-agent, so
23- # we don't need to rebuild if the db has more origins then
24- # the cache, but we need to rebuild if the cache has origins
25- # that a-x-i does not have
26- if not cache_origins.issubset(db_origins):
27- return True
28- return False
29+ # the operation get_origins can take some time (~60s?)
30+ cache_origins = set(db._aptcache.get_all_origins())
31+ db_origins = set(db.get_origins_from_db())
32+ # origins
33+ LOG.debug("cache_origins: %s" % cache_origins)
34+ LOG.debug("db_origins: %s" % db_origins)
35+ # the db_origins will contain origins from the s-c-agent, so
36+ # we don't need to rebuild if the db has more origins then
37+ # the cache, but we need to rebuild if the cache has origins
38+ # that a-x-i does not have
39+ if not cache_origins.issubset(db_origins):
40+ return True
41+ return False
42
43 def trigger_axi_update_and_wait():
44 def _axi_finished(res):
45@@ -35,11 +36,11 @@
46 context = GObject.main_context_default()
47 main = GObject.MainLoop(context)
48 system_bus = dbus.SystemBus()
49- axi = dbus.Interface(
50- system_bus.get_object("org.debian.AptXapianIndex","/"),
51- "org.debian.AptXapianIndex")
52- axi.connect_to_signal("UpdateFinished", _axi_finished)
53 try:
54+ axi = dbus.Interface(
55+ system_bus.get_object("org.debian.AptXapianIndex","/"),
56+ "org.debian.AptXapianIndex")
57+ axi.connect_to_signal("UpdateFinished", _axi_finished)
58 # first arg is force, second update_only
59 axi.update_async(True, False)
60 main.run()
61@@ -62,9 +63,13 @@
62 logging.basicConfig(level=logging.DEBUG)
63
64 # do it
65- res = check_for_channel_updates_and_trigger_axi()
66- # return "1" means xapian got updated
67- if res:
68- sys.exit(1)
69+ try:
70+ res = check_for_channel_updates_and_trigger_axi()
71+ # return "1" means xapian got updated
72+ if res:
73+ sys.exit(1)
74+ except xapian.DatabaseOpeningError as e:
75+ # this can happen if there is no a-x-i DB yet and we can ignore it
76+ LOG.info("failed to open xapian db: '%s'" % e)
77 # return "0" nothing was done
78 sys.exit(0)

Subscribers

People subscribed via source and target branches