Merge lp:~osomon/software-center/one_database_per_language into lp:software-center

Proposed by Olivier Tilloy
Status: Rejected
Rejected by: dobey
Proposed branch: lp:~osomon/software-center/one_database_per_language
Merge into: lp:software-center
Diff against target: 498 lines (+95/-65)
19 files modified
.bzrignore (+1/-14)
debian/software-center.postinst (+5/-0)
softwarecenter/app.py (+2/-3)
softwarecenter/db/database.py (+56/-0)
softwarecenter/view/appview.py (+2/-5)
softwarecenter/view/availablepane.py (+2/-3)
softwarecenter/view/channelpane.py (+2/-3)
softwarecenter/view/historypane.py (+2/-4)
softwarecenter/view/installedpane.py (+2/-3)
softwarecenter/view/viewswitcher.py (+2/-4)
test/test_appview.py (+2/-5)
utils/bench.py (+2/-2)
utils/installedapps.py (+2/-2)
utils/query.py (+2/-2)
utils/search_query.py (+2/-3)
utils/stats.py (+2/-2)
utils/topapps.py (+2/-2)
utils/update-software-center (+3/-6)
utils/wildcard_query_parser.py (+2/-2)
To merge this branch: bzr merge lp:~osomon/software-center/one_database_per_language
Reviewer Review Type Date Requested Status
Michael Vogt Needs Fixing
Review via email: mp+23870@code.launchpad.net

Description of the change

This branch intends to fix bug #434601 by implementing the solution proposed by mpt in comment #1: store one database per language code, since the contents of the database is localized. Where the database was previously stored in a "xapian" directory on disk, it is now stored in "xapian.{lang_code}", e.g. "xapian.fr_FR".

Comments on this approach are welcome.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for the patch. It will need similar logic in utils/update-sofware-center when it rebuilds the database. Best is probably to consolidate the name with language added in one place.

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

Right, I overlooked this. I will re-factor the patch to have the database name computed in one place only.

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, this is good now. I wonder how we should deal with the following case though:
1. system locale is en_US and update-software-center creates /var/cache/software-center/xapian.en_US
2. a normal user has de_DE and runs software-center
   - it will not be able to create /var/cache/software-center
   - from looking at the code it does not currently fallback to the existing one

Ideally I guess we would have a dbus service that simply re-builds it in the language we want.

Revision history for this message
Michael Vogt (mvo) wrote :

I pushed a branch with some minor modifications (transition code in postinst) to lp:~mvo/software-center/one_database_per_language/

Revision history for this message
Olivier Tilloy (osomon) wrote :

Indeed there is currently no fallback mechanism. The DBus service solution sounds good to me, but in the short term we can implement a simple fallback mechanism that will pick the first database found in /var/cache/software-center.

749. By Olivier Tilloy

Merged from trunk.

750. By Olivier Tilloy

Merged Michael's changes to the post-installation script.

751. By Olivier Tilloy

When the database path for the current locale doesn't exist
or cannot be created, try to fall back gracefully to an existing database.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I have merged Michael's changes and implemented a mechanism that should ensure we always try to fall back to an existing database when one cannot be created. Comments appreciated!

Revision history for this message
Olivier Tilloy (osomon) wrote :

This branch is too old and doesn’t merge cleanly any longer.

@Michael: do you think the original approach would still work? If so, I could take a stab at refreshing the code to apply to the current code base.

Revision history for this message
Michael Vogt (mvo) wrote :

On Mon, May 23, 2011 at 08:08:27AM -0000, Olivier Tilloy wrote:
> This branch is too old and doesn’t merge cleanly any longer.
>
> @Michael: do you think the original approach would still work? If so, I could take a stab at refreshing the code to apply to the current code base.
> --
> https://code.launchpad.net/~osomon/software-center/one_database_per_language/+merge/23870
> You are reviewing the proposed merge of lp:~osomon/software-center/one_database_per_language into lp:software-center.

I think the general approach is still good and sound, however I would
rather like to see your talents used in the new softwarecener/ui/qml
part of the source ;) Its currently empty, but there is a
lp:~mvo/software-center/refactor-with-qml branch already that
hopefully can move to trunk soonish.

Cheers,
 Michael

Revision history for this message
Olivier Tilloy (osomon) wrote :

> I think the general approach is still good and sound, however I would
> rather like to see your talents used in the new softwarecener/ui/qml
> part of the source ;) Its currently empty, but there is a
> lp:~mvo/software-center/refactor-with-qml branch already that
> hopefully can move to trunk soonish.

Sure, I’m also more interested in playing with the UI!
I only meant to do a bit of cleanup in pending tasks, this one has been pending forever and in view of the recent activity on the related bug report, it looks like it remains an important issue for users.

Revision history for this message
dobey (dobey) wrote :

Setting this to Rejected since it's quite old, and hasn't been commented on in 2 years, or touched in almost 3.

Unmerged revisions

751. By Olivier Tilloy

When the database path for the current locale doesn't exist
or cannot be created, try to fall back gracefully to an existing database.

750. By Olivier Tilloy

Merged Michael's changes to the post-installation script.

749. By Olivier Tilloy

Merged from trunk.

748. By Olivier Tilloy

Use get_database_path everywhere to instantiate the DB.

747. By Olivier Tilloy

Merged from trunk.

746. By Olivier Tilloy

Separate function to compute the database path on disk, depending on the current locale.

745. By Olivier Tilloy

Merged from trunk.

744. By Olivier Tilloy

Handle nicely broken locales: fall back to C.

743. By Olivier Tilloy

Store one database per language code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2009-09-16 16:37:16 +0000
+++ .bzrignore 2010-06-02 15:09:30 +0000
@@ -1,14 +1,1 @@
1data/xapian/flintlock1data/xapian.*
2data/xapian/iamflint
3data/xapian/postlist.baseA
4data/xapian/postlist.baseB
5data/xapian/postlist.DB
6data/xapian/record.baseA
7data/xapian/record.baseB
8data/xapian/record.DB
9data/xapian/termlist.baseA
10data/xapian/termlist.baseB
11data/xapian/termlist.DB
12data/xapian/value.baseA
13data/xapian/value.baseB
14data/xapian/value.DB
152
=== removed directory 'data/xapian'
=== modified file 'debian/software-center.postinst'
--- debian/software-center.postinst 2010-03-11 16:15:42 +0000
+++ debian/software-center.postinst 2010-06-02 15:09:30 +0000
@@ -12,6 +12,11 @@
12 exit 012 exit 0
13fi13fi
1414
15# in 2.1.2 we moved to one db per language so we can remove
16# the old one
17if dpkg --compare-versions "$2" lt-nl "2.1.2"; then
18 rm -rf /var/cache/software-center/xapian
19fi
1520
1621
1722
1823
=== modified file 'softwarecenter/app.py'
--- softwarecenter/app.py 2010-05-28 07:35:33 +0000
+++ softwarecenter/app.py 2010-06-02 15:09:30 +0000
@@ -36,7 +36,7 @@
36from softwarecenter.enums import *36from softwarecenter.enums import *
37from softwarecenter.utils import *37from softwarecenter.utils import *
38from softwarecenter.version import *38from softwarecenter.version import *
39from softwarecenter.db.database import StoreDatabase39from softwarecenter.db.database import get_database_path, StoreDatabase
4040
41import view.dialogs41import view.dialogs
42from view.viewswitcher import ViewSwitcher, ViewSwitcherList42from view.viewswitcher import ViewSwitcher, ViewSwitcherList
@@ -120,8 +120,7 @@
120 self.backend.connect("transaction-stopped", self._on_transaction_stopped)120 self.backend.connect("transaction-stopped", self._on_transaction_stopped)
121 self.backend.connect("channels-changed", self.on_channels_changed)121 self.backend.connect("channels-changed", self.on_channels_changed)
122122
123 # xapian123 pathname = get_database_path(xapian_base_path)
124 pathname = os.path.join(xapian_base_path, "xapian")
125 try:124 try:
126 self.db = StoreDatabase(pathname, self.cache)125 self.db = StoreDatabase(pathname, self.cache)
127 self.db.open()126 self.db.open()
128127
=== modified file 'softwarecenter/db/database.py'
--- softwarecenter/db/database.py 2010-05-18 11:14:59 +0000
+++ softwarecenter/db/database.py 2010-06-02 15:09:30 +0000
@@ -16,9 +16,12 @@
16# this program; if not, write to the Free Software Foundation, Inc.,16# this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
19import errno
20import glob
19import gobject21import gobject
20import locale22import locale
21import logging23import logging
24import os
22import re25import re
23import xapian26import xapian
2427
@@ -28,6 +31,59 @@
28from softwarecenter.enums import *31from softwarecenter.enums import *
29from gettext import gettext as _32from gettext import gettext as _
3033
34
35def _fallback_existing_database(xapian_base_path):
36 # Try to locate an existing database to fall back on.
37 matches = glob.glob(os.path.join(xapian_base_path, "xapian*"))
38 if matches:
39 return matches[0]
40 else:
41 return None
42
43
44def get_database_path(xapian_base_path=XAPIAN_BASE_PATH, create=True):
45 """
46 Return the path to the database for the current locale.
47 If the path doesn't exist yet and the create parameter is True (default),
48 it is created. If creation fails or if the create parameter is False,
49 try to fall back gracefully to an existing database. If that fails, raise
50 an exception.
51 """
52 # Store one database per language code, since the contents of the database
53 # are localized ("xapian.{lang_code}", e.g. "xapian.fr_FR").
54 try:
55 lang_code, encoding = locale.getlocale()
56 except ValueError:
57 lang_code = None
58 if lang_code is None:
59 lang_code = "C"
60 db_name = "xapian.%s" % lang_code
61 pathname = os.path.join(xapian_base_path, db_name)
62 if os.path.exists(pathname):
63 return pathname
64 elif create:
65 try:
66 os.makedirs(pathname)
67 except OSError:
68 # The database cannot be created, most likely because
69 # software-center is being run installed by an unprivileged
70 # user. Try to fall back gracefully to an existing database.
71 pathname = _fallback_existing_database(xapian_base_path)
72 if pathname is not None:
73 return pathname
74 else:
75 raise
76 else:
77 return pathname
78 else:
79 # Try to fall back gracefully to an existing database.
80 fallback = _fallback_existing_database(xapian_base_path)
81 if fallback is not None:
82 return fallback
83 else:
84 raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), pathname)
85
86
31class StoreDatabase(gobject.GObject):87class StoreDatabase(gobject.GObject):
32 """thin abstraction for the xapian database with convenient functions"""88 """thin abstraction for the xapian database with convenient functions"""
3389
3490
=== modified file 'softwarecenter/view/appview.py'
--- softwarecenter/view/appview.py 2010-05-30 16:21:33 +0000
+++ softwarecenter/view/appview.py 2010-06-02 15:09:30 +0000
@@ -39,7 +39,7 @@
39 sys.path.insert(0, ".")39 sys.path.insert(0, ".")
40from softwarecenter.enums import *40from softwarecenter.enums import *
41from softwarecenter.utils import *41from softwarecenter.utils import *
42from softwarecenter.db.database import StoreDatabase, Application42from softwarecenter.db.database import get_database_path, StoreDatabase, Application
43from softwarecenter.backend import get_install_backend43from softwarecenter.backend import get_install_backend
44from softwarecenter.distro import get_distro44from softwarecenter.distro import get_distro
4545
@@ -1464,13 +1464,10 @@
1464if __name__ == "__main__":1464if __name__ == "__main__":
1465 logging.basicConfig(level=logging.DEBUG)1465 logging.basicConfig(level=logging.DEBUG)
14661466
1467 xapian_base_path = XAPIAN_BASE_PATH
1468 pathname = os.path.join(xapian_base_path, "xapian")
1469
1470 # the store1467 # the store
1471 from softwarecenter.apt.aptcache import AptCache1468 from softwarecenter.apt.aptcache import AptCache
1472 cache = AptCache()1469 cache = AptCache()
1473 db = StoreDatabase(pathname, cache)1470 db = StoreDatabase(get_database_path(), cache)
1474 db.open()1471 db.open()
14751472
1476 # additional icons come from app-install-data1473 # additional icons come from app-install-data
14771474
=== modified file 'softwarecenter/view/availablepane.py'
--- softwarecenter/view/availablepane.py 2010-05-30 15:53:11 +0000
+++ softwarecenter/view/availablepane.py 2010-06-02 15:09:30 +0000
@@ -595,8 +595,6 @@
595595
596if __name__ == "__main__":596if __name__ == "__main__":
597 #logging.basicConfig(level=logging.DEBUG)597 #logging.basicConfig(level=logging.DEBUG)
598 xapian_base_path = XAPIAN_BASE_PATH
599 pathname = os.path.join(xapian_base_path, "xapian")
600598
601 if len(sys.argv) > 1:599 if len(sys.argv) > 1:
602 datadir = sys.argv[1]600 datadir = sys.argv[1]
@@ -605,7 +603,8 @@
605 else:603 else:
606 datadir = "/usr/share/software-center"604 datadir = "/usr/share/software-center"
607605
608 db = xapian.Database(pathname)606 from softwarecenter.db.database import get_database_path
607 db = xapian.Database(get_database_path())
609 icons = gtk.icon_theme_get_default()608 icons = gtk.icon_theme_get_default()
610 icons.append_search_path("/usr/share/app-install/icons/")609 icons.append_search_path("/usr/share/app-install/icons/")
611610
612611
=== modified file 'softwarecenter/view/channelpane.py'
--- softwarecenter/view/channelpane.py 2010-05-30 17:11:05 +0000
+++ softwarecenter/view/channelpane.py 2010-06-02 15:09:30 +0000
@@ -219,8 +219,6 @@
219219
220if __name__ == "__main__":220if __name__ == "__main__":
221 #logging.basicConfig(level=logging.DEBUG)221 #logging.basicConfig(level=logging.DEBUG)
222 xapian_base_path = XAPIAN_BASE_PATH
223 pathname = os.path.join(xapian_base_path, "xapian")
224222
225 if len(sys.argv) > 1:223 if len(sys.argv) > 1:
226 datadir = sys.argv[1]224 datadir = sys.argv[1]
@@ -229,7 +227,8 @@
229 else:227 else:
230 datadir = "/usr/share/software-center"228 datadir = "/usr/share/software-center"
231229
232 db = xapian.Database(pathname)230 from softwarecenter.db.database import get_database_path
231 db = xapian.Database(get_database_path())
233 icons = gtk.icon_theme_get_default()232 icons = gtk.icon_theme_get_default()
234 icons.append_search_path("/usr/share/app-install/icons/")233 icons.append_search_path("/usr/share/app-install/icons/")
235 cache = apt.Cache(apt.progress.text.OpProgress())234 cache = apt.Cache(apt.progress.text.OpProgress())
236235
=== modified file 'softwarecenter/view/historypane.py'
--- softwarecenter/view/historypane.py 2010-05-19 16:01:48 +0000
+++ softwarecenter/view/historypane.py 2010-06-02 15:09:30 +0000
@@ -36,7 +36,7 @@
36from softwarecenter.enums import *36from softwarecenter.enums import *
37from softwarecenter.view.widgets.searchentry import SearchEntry37from softwarecenter.view.widgets.searchentry import SearchEntry
38from softwarecenter.apt.aptcache import AptCache38from softwarecenter.apt.aptcache import AptCache
39from softwarecenter.db.database import StoreDatabase39from softwarecenter.db.database import get_database_path, StoreDatabase
4040
4141
42class HistoryPane(gtk.VBox):42class HistoryPane(gtk.VBox):
@@ -287,9 +287,7 @@
287287
288if __name__ == '__main__':288if __name__ == '__main__':
289 cache = AptCache()289 cache = AptCache()
290290 db = StoreDatabase(get_database_path(), cache)
291 db_path = os.path.join(XAPIAN_BASE_PATH, "xapian")
292 db = StoreDatabase(db_path, cache)
293 db.open()291 db.open()
294292
295 icons = gtk.icon_theme_get_default()293 icons = gtk.icon_theme_get_default()
296294
=== modified file 'softwarecenter/view/installedpane.py'
--- softwarecenter/view/installedpane.py 2010-05-31 07:24:21 +0000
+++ softwarecenter/view/installedpane.py 2010-06-02 15:09:30 +0000
@@ -177,8 +177,6 @@
177177
178if __name__ == "__main__":178if __name__ == "__main__":
179 #logging.basicConfig(level=logging.DEBUG)179 #logging.basicConfig(level=logging.DEBUG)
180 xapian_base_path = XAPIAN_BASE_PATH
181 pathname = os.path.join(xapian_base_path, "xapian")
182180
183 if len(sys.argv) > 1:181 if len(sys.argv) > 1:
184 datadir = sys.argv[1]182 datadir = sys.argv[1]
@@ -187,7 +185,8 @@
187 else:185 else:
188 datadir = "/usr/share/software-center"186 datadir = "/usr/share/software-center"
189187
190 db = xapian.Database(pathname)188 from softwarecenter.db.database import get_database_path
189 db = xapian.Database(get_database_path())
191 icons = gtk.icon_theme_get_default()190 icons = gtk.icon_theme_get_default()
192 icons.append_search_path("/usr/share/app-install/icons/")191 icons.append_search_path("/usr/share/app-install/icons/")
193 cache = apt.Cache(apt.progress.text.OpProgress())192 cache = apt.Cache(apt.progress.text.OpProgress())
194193
=== modified file 'softwarecenter/view/viewswitcher.py'
--- softwarecenter/view/viewswitcher.py 2010-05-25 00:48:21 +0000
+++ softwarecenter/view/viewswitcher.py 2010-06-02 15:09:30 +0000
@@ -34,7 +34,7 @@
34from softwarecenter.backend.channel import SoftwareChannel34from softwarecenter.backend.channel import SoftwareChannel
35from softwarecenter.backend import get_install_backend35from softwarecenter.backend import get_install_backend
36from softwarecenter.distro import get_distro36from softwarecenter.distro import get_distro
37from softwarecenter.db.database import StoreDatabase37from softwarecenter.db.database import get_database_path, StoreDatabase
38from softwarecenter.enums import *38from softwarecenter.enums import *
3939
40from widgets.animatedimage import CellRendererAnimatedImage, AnimatedImage40from widgets.animatedimage import CellRendererAnimatedImage, AnimatedImage
@@ -403,10 +403,8 @@
403 scroll = gtk.ScrolledWindow()403 scroll = gtk.ScrolledWindow()
404 icons = gtk.icon_theme_get_default()404 icons = gtk.icon_theme_get_default()
405405
406 xapian_base_path = XAPIAN_BASE_PATH
407 pathname = os.path.join(xapian_base_path, "xapian")
408 cache = apt.Cache(apt.progress.text.OpProgress())406 cache = apt.Cache(apt.progress.text.OpProgress())
409 db = StoreDatabase(pathname, cache)407 db = StoreDatabase(get_database_path(), cache)
410 db.open()408 db.open()
411409
412 view = ViewSwitcher(datadir, db, icons)410 view = ViewSwitcher(datadir, db, icons)
413411
=== modified file 'test/test_appview.py'
--- test/test_appview.py 2010-05-20 18:33:08 +0000
+++ test/test_appview.py 2010-06-02 15:09:30 +0000
@@ -10,9 +10,8 @@
1010
11from softwarecenter import Application11from softwarecenter import Application
12from softwarecenter.apt.aptcache import AptCache12from softwarecenter.apt.aptcache import AptCache
13from softwarecenter.db.database import StoreDatabase13from softwarecenter.db.database import get_database_path, StoreDatabase
14from softwarecenter.view.appview import AppStore14from softwarecenter.view.appview import AppStore
15from softwarecenter.enums import *
1615
17import xapian16import xapian
1817
@@ -30,10 +29,8 @@
30 """ tests the AppStore GtkTreeViewModel """29 """ tests the AppStore GtkTreeViewModel """
3130
32 def setUp(self):31 def setUp(self):
33 xapian_base_path = XAPIAN_BASE_PATH
34 pathname = os.path.join(xapian_base_path, "xapian")
35 self.cache = AptCache()32 self.cache = AptCache()
36 self.db = StoreDatabase(pathname, self.cache)33 self.db = StoreDatabase(get_database_path(), self.cache)
37 self.db.open()34 self.db.open()
38 self.mock_icons = MockIconCache()35 self.mock_icons = MockIconCache()
39 self.mock_filter = MockAppViewFilter()36 self.mock_filter = MockAppViewFilter()
4037
=== modified file 'utils/bench.py'
--- utils/bench.py 2010-05-09 07:13:26 +0000
+++ utils/bench.py 2010-06-02 15:09:30 +0000
@@ -7,6 +7,7 @@
7sys.path.insert(0, "../")7sys.path.insert(0, "../")
8from softwarecenter.enums import *8from softwarecenter.enums import *
9from softwarecenter.utils import *9from softwarecenter.utils import *
10from softwarecenter.db.database import get_database_path
1011
11def run_benchmark(db):12def run_benchmark(db):
12 # test postlist13 # test postlist
@@ -37,8 +38,7 @@
3738
38if __name__ == "__main__":39if __name__ == "__main__":
3940
40 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")41 db = xapian.Database(get_database_path())
41 db = xapian.Database(pathname)
4242
43 print "app db only"43 print "app db only"
44 run_benchmark(db)44 run_benchmark(db)
4545
=== modified file 'utils/installedapps.py'
--- utils/installedapps.py 2010-05-09 07:13:26 +0000
+++ utils/installedapps.py 2010-06-02 15:09:30 +0000
@@ -8,13 +8,13 @@
8sys.path.insert(0, "../")8sys.path.insert(0, "../")
9from softwarecenter.enums import *9from softwarecenter.enums import *
10from softwarecenter.utils import *10from softwarecenter.utils import *
11from softwarecenter.db.database import get_database_path
1112
12if __name__ == "__main__":13if __name__ == "__main__":
1314
14 cache = apt.Cache()15 cache = apt.Cache()
1516
16 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")17 db = xapian.Database(get_database_path())
17 db = xapian.Database(pathname)
1818
19 installed = []19 installed = []
20 for m in db.postlist(""):20 for m in db.postlist(""):
2121
=== modified file 'utils/query.py'
--- utils/query.py 2010-05-09 07:13:26 +0000
+++ utils/query.py 2010-06-02 15:09:30 +0000
@@ -9,6 +9,7 @@
9sys.path.insert(0, "../")9sys.path.insert(0, "../")
10from softwarecenter.enums import *10from softwarecenter.enums import *
11from softwarecenter.utils import *11from softwarecenter.utils import *
12from softwarecenter.db.database import get_database_path
1213
13def parse_query(parser, search_strings, verbose=True):14def parse_query(parser, search_strings, verbose=True):
14 str_to_prefix = { 'section' : 'AE',15 str_to_prefix = { 'section' : 'AE',
@@ -52,8 +53,7 @@
52 help="print found apps/pkgs too")53 help="print found apps/pkgs too")
53 (options, args) = parser.parse_args()54 (options, args) = parser.parse_args()
5455
55 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")56 db = xapian.Database(get_database_path())
56 db = xapian.Database(pathname)
5757
58 axi = xapian.Database("/var/lib/apt-xapian-index/index")58 axi = xapian.Database("/var/lib/apt-xapian-index/index")
59 db.add_database(axi)59 db.add_database(axi)
6060
=== modified file 'utils/search_query.py'
--- utils/search_query.py 2010-05-09 07:13:26 +0000
+++ utils/search_query.py 2010-06-02 15:09:30 +0000
@@ -7,7 +7,6 @@
7from optparse import OptionParser7from optparse import OptionParser
88
9sys.path.insert(0, "../")9sys.path.insert(0, "../")
10from softwarecenter.enums import *
11from softwarecenter.utils import *10from softwarecenter.utils import *
1211
13def run_query(parser, search_terms, verbose):12def run_query(parser, search_terms, verbose):
@@ -37,8 +36,8 @@
37 help="print found apps/pkgs too")36 help="print found apps/pkgs too")
38 (options, args) = parser.parse_args()37 (options, args) = parser.parse_args()
3938
40 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")39 from softwarecenter.db.database import get_database_path
41 db = xapian.Database(pathname)40 db = xapian.Database(get_database_path())
4241
43 axi = xapian.Database("/var/lib/apt-xapian-index/index")42 axi = xapian.Database("/var/lib/apt-xapian-index/index")
44 db.add_database(axi)43 db.add_database(axi)
4544
=== modified file 'utils/stats.py'
--- utils/stats.py 2010-05-09 07:13:26 +0000
+++ utils/stats.py 2010-06-02 15:09:30 +0000
@@ -24,6 +24,7 @@
2424
25sys.path.insert(0, "../")25sys.path.insert(0, "../")
26from softwarecenter.enums import *26from softwarecenter.enums import *
27from softwarecenter.db.database import get_database_path
2728
28if __name__ == "__main__":29if __name__ == "__main__":
2930
@@ -35,8 +36,7 @@
35 app_to_pkg = {}36 app_to_pkg = {}
3637
37 # gather data38 # gather data
38 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")39 db = xapian.Database(get_database_path())
39 db = xapian.Database(pathname)
40 for m in db.postlist(""):40 for m in db.postlist(""):
41 doc = db.get_document(m.docid)41 doc = db.get_document(m.docid)
42 appname = doc.get_data()42 appname = doc.get_data()
4343
=== modified file 'utils/topapps.py'
--- utils/topapps.py 2010-05-09 07:13:26 +0000
+++ utils/topapps.py 2010-06-02 15:09:30 +0000
@@ -8,6 +8,7 @@
8sys.path.insert(0, "../")8sys.path.insert(0, "../")
9from softwarecenter.enums import *9from softwarecenter.enums import *
10from softwarecenter.utils import *10from softwarecenter.utils import *
11from softwarecenter.db.database import get_database_path
1112
12if __name__ == "__main__":13if __name__ == "__main__":
1314
@@ -15,8 +16,7 @@
15 if len(sys.argv) > 1:16 if len(sys.argv) > 1:
16 topn = int(sys.argv[1])17 topn = int(sys.argv[1])
1718
18 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")19 db = xapian.Database(get_database_path())
19 db = xapian.Database(pathname)
2020
21 heap = []21 heap = []
22 for m in db.postlist(""):22 for m in db.postlist(""):
2323
=== modified file 'utils/update-software-center'
--- utils/update-software-center 2010-05-09 07:13:26 +0000
+++ utils/update-software-center 2010-06-02 15:09:30 +0000
@@ -31,6 +31,7 @@
31from optparse import OptionParser31from optparse import OptionParser
3232
33from softwarecenter.enums import *33from softwarecenter.enums import *
34from softwarecenter.db.database import get_database_path
34from softwarecenter.db.update import rebuild_database35from softwarecenter.db.update import rebuild_database
3536
36# dbus may not be available during a upgrade so we 37# dbus may not be available during a upgrade so we
@@ -97,7 +98,7 @@
97 logging.info("no translation information in database needed")98 logging.info("no translation information in database needed")
98 sys.exit(0)99 sys.exit(0)
99 mo_time = os.path.getctime(mofile)100 mo_time = os.path.getctime(mofile)
100 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")101 pathname = get_database_path(create=False)
101 if os.path.exists(pathname):102 if os.path.exists(pathname):
102 db = xapian.Database(pathname)103 db = xapian.Database(pathname)
103 mo_db_time = db.get_metadata("app-install-mo-time")104 mo_db_time = db.get_metadata("app-install-mo-time")
@@ -120,13 +121,9 @@
120121
121 # rebuild and send signal when done122 # rebuild and send signal when done
122 try:123 try:
123 # setup path
124 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
125 if not os.path.exists(pathname):
126 os.makedirs(pathname)
127 # rebuild the database, the default context is run to ensure124 # rebuild the database, the default context is run to ensure
128 # dbus querries are processed125 # dbus querries are processed
129 rebuild_database(pathname)126 rebuild_database(get_database_path())
130 finally:127 finally:
131 # signal that the xapian db is valid again128 # signal that the xapian db is valid again
132 if dbus_controller:129 if dbus_controller:
133130
=== modified file 'utils/wildcard_query_parser.py'
--- utils/wildcard_query_parser.py 2010-05-09 07:13:26 +0000
+++ utils/wildcard_query_parser.py 2010-06-02 15:09:30 +0000
@@ -9,6 +9,7 @@
9sys.path.insert(0, "../")9sys.path.insert(0, "../")
10from softwarecenter.enums import *10from softwarecenter.enums import *
11from softwarecenter.utils import *11from softwarecenter.utils import *
12from softwarecenter.db.database import get_database_path
1213
13if __name__ == "__main__":14if __name__ == "__main__":
1415
@@ -18,8 +19,7 @@
18 help="print found apps/pkgs too")19 help="print found apps/pkgs too")
19 (options, args) = parser.parse_args()20 (options, args) = parser.parse_args()
2021
21 pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")22 db = xapian.Database(get_database_path())
22 db = xapian.Database(pathname)
2323
24 axi = xapian.Database("/var/lib/apt-xapian-index/index")24 axi = xapian.Database("/var/lib/apt-xapian-index/index")
25 db.add_database(axi)25 db.add_database(axi)