Merge lp:~osomon/software-center/one_database_per_language into lp:software-center
- one_database_per_language
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Vogt | Needs Fixing | ||
Review via email: mp+23870@code.launchpad.net |
Commit message
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.
Comments on this approach are welcome.
Olivier Tilloy (osomon) wrote : | # |
Right, I overlooked this. I will re-factor the patch to have the database name computed in one place only.
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-
2. a normal user has de_DE and runs software-center
- it will not be able to create /var/cache/
- 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.
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/
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/
- 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.
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!
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.
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:/
> 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/
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
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/
> 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.
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
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2009-09-16 16:37:16 +0000 | |||
3 | +++ .bzrignore 2010-06-02 15:09:30 +0000 | |||
4 | @@ -1,14 +1,1 @@ | |||
19 | 1 | data/xapian/flintlock | 1 | data/xapian.* |
6 | 2 | data/xapian/iamflint | ||
7 | 3 | data/xapian/postlist.baseA | ||
8 | 4 | data/xapian/postlist.baseB | ||
9 | 5 | data/xapian/postlist.DB | ||
10 | 6 | data/xapian/record.baseA | ||
11 | 7 | data/xapian/record.baseB | ||
12 | 8 | data/xapian/record.DB | ||
13 | 9 | data/xapian/termlist.baseA | ||
14 | 10 | data/xapian/termlist.baseB | ||
15 | 11 | data/xapian/termlist.DB | ||
16 | 12 | data/xapian/value.baseA | ||
17 | 13 | data/xapian/value.baseB | ||
18 | 14 | data/xapian/value.DB | ||
20 | 15 | 2 | ||
21 | === removed directory 'data/xapian' | |||
22 | === modified file 'debian/software-center.postinst' | |||
23 | --- debian/software-center.postinst 2010-03-11 16:15:42 +0000 | |||
24 | +++ debian/software-center.postinst 2010-06-02 15:09:30 +0000 | |||
25 | @@ -12,6 +12,11 @@ | |||
26 | 12 | exit 0 | 12 | exit 0 |
27 | 13 | fi | 13 | fi |
28 | 14 | 14 | ||
29 | 15 | # in 2.1.2 we moved to one db per language so we can remove | ||
30 | 16 | # the old one | ||
31 | 17 | if dpkg --compare-versions "$2" lt-nl "2.1.2"; then | ||
32 | 18 | rm -rf /var/cache/software-center/xapian | ||
33 | 19 | fi | ||
34 | 15 | 20 | ||
35 | 16 | 21 | ||
36 | 17 | 22 | ||
37 | 18 | 23 | ||
38 | === modified file 'softwarecenter/app.py' | |||
39 | --- softwarecenter/app.py 2010-05-28 07:35:33 +0000 | |||
40 | +++ softwarecenter/app.py 2010-06-02 15:09:30 +0000 | |||
41 | @@ -36,7 +36,7 @@ | |||
42 | 36 | from softwarecenter.enums import * | 36 | from softwarecenter.enums import * |
43 | 37 | from softwarecenter.utils import * | 37 | from softwarecenter.utils import * |
44 | 38 | from softwarecenter.version import * | 38 | from softwarecenter.version import * |
46 | 39 | from softwarecenter.db.database import StoreDatabase | 39 | from softwarecenter.db.database import get_database_path, StoreDatabase |
47 | 40 | 40 | ||
48 | 41 | import view.dialogs | 41 | import view.dialogs |
49 | 42 | from view.viewswitcher import ViewSwitcher, ViewSwitcherList | 42 | from view.viewswitcher import ViewSwitcher, ViewSwitcherList |
50 | @@ -120,8 +120,7 @@ | |||
51 | 120 | self.backend.connect("transaction-stopped", self._on_transaction_stopped) | 120 | self.backend.connect("transaction-stopped", self._on_transaction_stopped) |
52 | 121 | self.backend.connect("channels-changed", self.on_channels_changed) | 121 | self.backend.connect("channels-changed", self.on_channels_changed) |
53 | 122 | 122 | ||
56 | 123 | # xapian | 123 | pathname = get_database_path(xapian_base_path) |
55 | 124 | pathname = os.path.join(xapian_base_path, "xapian") | ||
57 | 125 | try: | 124 | try: |
58 | 126 | self.db = StoreDatabase(pathname, self.cache) | 125 | self.db = StoreDatabase(pathname, self.cache) |
59 | 127 | self.db.open() | 126 | self.db.open() |
60 | 128 | 127 | ||
61 | === modified file 'softwarecenter/db/database.py' | |||
62 | --- softwarecenter/db/database.py 2010-05-18 11:14:59 +0000 | |||
63 | +++ softwarecenter/db/database.py 2010-06-02 15:09:30 +0000 | |||
64 | @@ -16,9 +16,12 @@ | |||
65 | 16 | # this program; if not, write to the Free Software Foundation, Inc., | 16 | # this program; if not, write to the Free Software Foundation, Inc., |
66 | 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
67 | 18 | 18 | ||
68 | 19 | import errno | ||
69 | 20 | import glob | ||
70 | 19 | import gobject | 21 | import gobject |
71 | 20 | import locale | 22 | import locale |
72 | 21 | import logging | 23 | import logging |
73 | 24 | import os | ||
74 | 22 | import re | 25 | import re |
75 | 23 | import xapian | 26 | import xapian |
76 | 24 | 27 | ||
77 | @@ -28,6 +31,59 @@ | |||
78 | 28 | from softwarecenter.enums import * | 31 | from softwarecenter.enums import * |
79 | 29 | from gettext import gettext as _ | 32 | from gettext import gettext as _ |
80 | 30 | 33 | ||
81 | 34 | |||
82 | 35 | def _fallback_existing_database(xapian_base_path): | ||
83 | 36 | # Try to locate an existing database to fall back on. | ||
84 | 37 | matches = glob.glob(os.path.join(xapian_base_path, "xapian*")) | ||
85 | 38 | if matches: | ||
86 | 39 | return matches[0] | ||
87 | 40 | else: | ||
88 | 41 | return None | ||
89 | 42 | |||
90 | 43 | |||
91 | 44 | def get_database_path(xapian_base_path=XAPIAN_BASE_PATH, create=True): | ||
92 | 45 | """ | ||
93 | 46 | Return the path to the database for the current locale. | ||
94 | 47 | If the path doesn't exist yet and the create parameter is True (default), | ||
95 | 48 | it is created. If creation fails or if the create parameter is False, | ||
96 | 49 | try to fall back gracefully to an existing database. If that fails, raise | ||
97 | 50 | an exception. | ||
98 | 51 | """ | ||
99 | 52 | # Store one database per language code, since the contents of the database | ||
100 | 53 | # are localized ("xapian.{lang_code}", e.g. "xapian.fr_FR"). | ||
101 | 54 | try: | ||
102 | 55 | lang_code, encoding = locale.getlocale() | ||
103 | 56 | except ValueError: | ||
104 | 57 | lang_code = None | ||
105 | 58 | if lang_code is None: | ||
106 | 59 | lang_code = "C" | ||
107 | 60 | db_name = "xapian.%s" % lang_code | ||
108 | 61 | pathname = os.path.join(xapian_base_path, db_name) | ||
109 | 62 | if os.path.exists(pathname): | ||
110 | 63 | return pathname | ||
111 | 64 | elif create: | ||
112 | 65 | try: | ||
113 | 66 | os.makedirs(pathname) | ||
114 | 67 | except OSError: | ||
115 | 68 | # The database cannot be created, most likely because | ||
116 | 69 | # software-center is being run installed by an unprivileged | ||
117 | 70 | # user. Try to fall back gracefully to an existing database. | ||
118 | 71 | pathname = _fallback_existing_database(xapian_base_path) | ||
119 | 72 | if pathname is not None: | ||
120 | 73 | return pathname | ||
121 | 74 | else: | ||
122 | 75 | raise | ||
123 | 76 | else: | ||
124 | 77 | return pathname | ||
125 | 78 | else: | ||
126 | 79 | # Try to fall back gracefully to an existing database. | ||
127 | 80 | fallback = _fallback_existing_database(xapian_base_path) | ||
128 | 81 | if fallback is not None: | ||
129 | 82 | return fallback | ||
130 | 83 | else: | ||
131 | 84 | raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), pathname) | ||
132 | 85 | |||
133 | 86 | |||
134 | 31 | class StoreDatabase(gobject.GObject): | 87 | class StoreDatabase(gobject.GObject): |
135 | 32 | """thin abstraction for the xapian database with convenient functions""" | 88 | """thin abstraction for the xapian database with convenient functions""" |
136 | 33 | 89 | ||
137 | 34 | 90 | ||
138 | === modified file 'softwarecenter/view/appview.py' | |||
139 | --- softwarecenter/view/appview.py 2010-05-30 16:21:33 +0000 | |||
140 | +++ softwarecenter/view/appview.py 2010-06-02 15:09:30 +0000 | |||
141 | @@ -39,7 +39,7 @@ | |||
142 | 39 | sys.path.insert(0, ".") | 39 | sys.path.insert(0, ".") |
143 | 40 | from softwarecenter.enums import * | 40 | from softwarecenter.enums import * |
144 | 41 | from softwarecenter.utils import * | 41 | from softwarecenter.utils import * |
146 | 42 | from softwarecenter.db.database import StoreDatabase, Application | 42 | from softwarecenter.db.database import get_database_path, StoreDatabase, Application |
147 | 43 | from softwarecenter.backend import get_install_backend | 43 | from softwarecenter.backend import get_install_backend |
148 | 44 | from softwarecenter.distro import get_distro | 44 | from softwarecenter.distro import get_distro |
149 | 45 | 45 | ||
150 | @@ -1464,13 +1464,10 @@ | |||
151 | 1464 | if __name__ == "__main__": | 1464 | if __name__ == "__main__": |
152 | 1465 | logging.basicConfig(level=logging.DEBUG) | 1465 | logging.basicConfig(level=logging.DEBUG) |
153 | 1466 | 1466 | ||
154 | 1467 | xapian_base_path = XAPIAN_BASE_PATH | ||
155 | 1468 | pathname = os.path.join(xapian_base_path, "xapian") | ||
156 | 1469 | |||
157 | 1470 | # the store | 1467 | # the store |
158 | 1471 | from softwarecenter.apt.aptcache import AptCache | 1468 | from softwarecenter.apt.aptcache import AptCache |
159 | 1472 | cache = AptCache() | 1469 | cache = AptCache() |
161 | 1473 | db = StoreDatabase(pathname, cache) | 1470 | db = StoreDatabase(get_database_path(), cache) |
162 | 1474 | db.open() | 1471 | db.open() |
163 | 1475 | 1472 | ||
164 | 1476 | # additional icons come from app-install-data | 1473 | # additional icons come from app-install-data |
165 | 1477 | 1474 | ||
166 | === modified file 'softwarecenter/view/availablepane.py' | |||
167 | --- softwarecenter/view/availablepane.py 2010-05-30 15:53:11 +0000 | |||
168 | +++ softwarecenter/view/availablepane.py 2010-06-02 15:09:30 +0000 | |||
169 | @@ -595,8 +595,6 @@ | |||
170 | 595 | 595 | ||
171 | 596 | if __name__ == "__main__": | 596 | if __name__ == "__main__": |
172 | 597 | #logging.basicConfig(level=logging.DEBUG) | 597 | #logging.basicConfig(level=logging.DEBUG) |
173 | 598 | xapian_base_path = XAPIAN_BASE_PATH | ||
174 | 599 | pathname = os.path.join(xapian_base_path, "xapian") | ||
175 | 600 | 598 | ||
176 | 601 | if len(sys.argv) > 1: | 599 | if len(sys.argv) > 1: |
177 | 602 | datadir = sys.argv[1] | 600 | datadir = sys.argv[1] |
178 | @@ -605,7 +603,8 @@ | |||
179 | 605 | else: | 603 | else: |
180 | 606 | datadir = "/usr/share/software-center" | 604 | datadir = "/usr/share/software-center" |
181 | 607 | 605 | ||
183 | 608 | db = xapian.Database(pathname) | 606 | from softwarecenter.db.database import get_database_path |
184 | 607 | db = xapian.Database(get_database_path()) | ||
185 | 609 | icons = gtk.icon_theme_get_default() | 608 | icons = gtk.icon_theme_get_default() |
186 | 610 | icons.append_search_path("/usr/share/app-install/icons/") | 609 | icons.append_search_path("/usr/share/app-install/icons/") |
187 | 611 | 610 | ||
188 | 612 | 611 | ||
189 | === modified file 'softwarecenter/view/channelpane.py' | |||
190 | --- softwarecenter/view/channelpane.py 2010-05-30 17:11:05 +0000 | |||
191 | +++ softwarecenter/view/channelpane.py 2010-06-02 15:09:30 +0000 | |||
192 | @@ -219,8 +219,6 @@ | |||
193 | 219 | 219 | ||
194 | 220 | if __name__ == "__main__": | 220 | if __name__ == "__main__": |
195 | 221 | #logging.basicConfig(level=logging.DEBUG) | 221 | #logging.basicConfig(level=logging.DEBUG) |
196 | 222 | xapian_base_path = XAPIAN_BASE_PATH | ||
197 | 223 | pathname = os.path.join(xapian_base_path, "xapian") | ||
198 | 224 | 222 | ||
199 | 225 | if len(sys.argv) > 1: | 223 | if len(sys.argv) > 1: |
200 | 226 | datadir = sys.argv[1] | 224 | datadir = sys.argv[1] |
201 | @@ -229,7 +227,8 @@ | |||
202 | 229 | else: | 227 | else: |
203 | 230 | datadir = "/usr/share/software-center" | 228 | datadir = "/usr/share/software-center" |
204 | 231 | 229 | ||
206 | 232 | db = xapian.Database(pathname) | 230 | from softwarecenter.db.database import get_database_path |
207 | 231 | db = xapian.Database(get_database_path()) | ||
208 | 233 | icons = gtk.icon_theme_get_default() | 232 | icons = gtk.icon_theme_get_default() |
209 | 234 | icons.append_search_path("/usr/share/app-install/icons/") | 233 | icons.append_search_path("/usr/share/app-install/icons/") |
210 | 235 | cache = apt.Cache(apt.progress.text.OpProgress()) | 234 | cache = apt.Cache(apt.progress.text.OpProgress()) |
211 | 236 | 235 | ||
212 | === modified file 'softwarecenter/view/historypane.py' | |||
213 | --- softwarecenter/view/historypane.py 2010-05-19 16:01:48 +0000 | |||
214 | +++ softwarecenter/view/historypane.py 2010-06-02 15:09:30 +0000 | |||
215 | @@ -36,7 +36,7 @@ | |||
216 | 36 | from softwarecenter.enums import * | 36 | from softwarecenter.enums import * |
217 | 37 | from softwarecenter.view.widgets.searchentry import SearchEntry | 37 | from softwarecenter.view.widgets.searchentry import SearchEntry |
218 | 38 | from softwarecenter.apt.aptcache import AptCache | 38 | from softwarecenter.apt.aptcache import AptCache |
220 | 39 | from softwarecenter.db.database import StoreDatabase | 39 | from softwarecenter.db.database import get_database_path, StoreDatabase |
221 | 40 | 40 | ||
222 | 41 | 41 | ||
223 | 42 | class HistoryPane(gtk.VBox): | 42 | class HistoryPane(gtk.VBox): |
224 | @@ -287,9 +287,7 @@ | |||
225 | 287 | 287 | ||
226 | 288 | if __name__ == '__main__': | 288 | if __name__ == '__main__': |
227 | 289 | cache = AptCache() | 289 | cache = AptCache() |
231 | 290 | 290 | db = StoreDatabase(get_database_path(), cache) | |
229 | 291 | db_path = os.path.join(XAPIAN_BASE_PATH, "xapian") | ||
230 | 292 | db = StoreDatabase(db_path, cache) | ||
232 | 293 | db.open() | 291 | db.open() |
233 | 294 | 292 | ||
234 | 295 | icons = gtk.icon_theme_get_default() | 293 | icons = gtk.icon_theme_get_default() |
235 | 296 | 294 | ||
236 | === modified file 'softwarecenter/view/installedpane.py' | |||
237 | --- softwarecenter/view/installedpane.py 2010-05-31 07:24:21 +0000 | |||
238 | +++ softwarecenter/view/installedpane.py 2010-06-02 15:09:30 +0000 | |||
239 | @@ -177,8 +177,6 @@ | |||
240 | 177 | 177 | ||
241 | 178 | if __name__ == "__main__": | 178 | if __name__ == "__main__": |
242 | 179 | #logging.basicConfig(level=logging.DEBUG) | 179 | #logging.basicConfig(level=logging.DEBUG) |
243 | 180 | xapian_base_path = XAPIAN_BASE_PATH | ||
244 | 181 | pathname = os.path.join(xapian_base_path, "xapian") | ||
245 | 182 | 180 | ||
246 | 183 | if len(sys.argv) > 1: | 181 | if len(sys.argv) > 1: |
247 | 184 | datadir = sys.argv[1] | 182 | datadir = sys.argv[1] |
248 | @@ -187,7 +185,8 @@ | |||
249 | 187 | else: | 185 | else: |
250 | 188 | datadir = "/usr/share/software-center" | 186 | datadir = "/usr/share/software-center" |
251 | 189 | 187 | ||
253 | 190 | db = xapian.Database(pathname) | 188 | from softwarecenter.db.database import get_database_path |
254 | 189 | db = xapian.Database(get_database_path()) | ||
255 | 191 | icons = gtk.icon_theme_get_default() | 190 | icons = gtk.icon_theme_get_default() |
256 | 192 | icons.append_search_path("/usr/share/app-install/icons/") | 191 | icons.append_search_path("/usr/share/app-install/icons/") |
257 | 193 | cache = apt.Cache(apt.progress.text.OpProgress()) | 192 | cache = apt.Cache(apt.progress.text.OpProgress()) |
258 | 194 | 193 | ||
259 | === modified file 'softwarecenter/view/viewswitcher.py' | |||
260 | --- softwarecenter/view/viewswitcher.py 2010-05-25 00:48:21 +0000 | |||
261 | +++ softwarecenter/view/viewswitcher.py 2010-06-02 15:09:30 +0000 | |||
262 | @@ -34,7 +34,7 @@ | |||
263 | 34 | from softwarecenter.backend.channel import SoftwareChannel | 34 | from softwarecenter.backend.channel import SoftwareChannel |
264 | 35 | from softwarecenter.backend import get_install_backend | 35 | from softwarecenter.backend import get_install_backend |
265 | 36 | from softwarecenter.distro import get_distro | 36 | from softwarecenter.distro import get_distro |
267 | 37 | from softwarecenter.db.database import StoreDatabase | 37 | from softwarecenter.db.database import get_database_path, StoreDatabase |
268 | 38 | from softwarecenter.enums import * | 38 | from softwarecenter.enums import * |
269 | 39 | 39 | ||
270 | 40 | from widgets.animatedimage import CellRendererAnimatedImage, AnimatedImage | 40 | from widgets.animatedimage import CellRendererAnimatedImage, AnimatedImage |
271 | @@ -403,10 +403,8 @@ | |||
272 | 403 | scroll = gtk.ScrolledWindow() | 403 | scroll = gtk.ScrolledWindow() |
273 | 404 | icons = gtk.icon_theme_get_default() | 404 | icons = gtk.icon_theme_get_default() |
274 | 405 | 405 | ||
275 | 406 | xapian_base_path = XAPIAN_BASE_PATH | ||
276 | 407 | pathname = os.path.join(xapian_base_path, "xapian") | ||
277 | 408 | cache = apt.Cache(apt.progress.text.OpProgress()) | 406 | cache = apt.Cache(apt.progress.text.OpProgress()) |
279 | 409 | db = StoreDatabase(pathname, cache) | 407 | db = StoreDatabase(get_database_path(), cache) |
280 | 410 | db.open() | 408 | db.open() |
281 | 411 | 409 | ||
282 | 412 | view = ViewSwitcher(datadir, db, icons) | 410 | view = ViewSwitcher(datadir, db, icons) |
283 | 413 | 411 | ||
284 | === modified file 'test/test_appview.py' | |||
285 | --- test/test_appview.py 2010-05-20 18:33:08 +0000 | |||
286 | +++ test/test_appview.py 2010-06-02 15:09:30 +0000 | |||
287 | @@ -10,9 +10,8 @@ | |||
288 | 10 | 10 | ||
289 | 11 | from softwarecenter import Application | 11 | from softwarecenter import Application |
290 | 12 | from softwarecenter.apt.aptcache import AptCache | 12 | from softwarecenter.apt.aptcache import AptCache |
292 | 13 | from softwarecenter.db.database import StoreDatabase | 13 | from softwarecenter.db.database import get_database_path, StoreDatabase |
293 | 14 | from softwarecenter.view.appview import AppStore | 14 | from softwarecenter.view.appview import AppStore |
294 | 15 | from softwarecenter.enums import * | ||
295 | 16 | 15 | ||
296 | 17 | import xapian | 16 | import xapian |
297 | 18 | 17 | ||
298 | @@ -30,10 +29,8 @@ | |||
299 | 30 | """ tests the AppStore GtkTreeViewModel """ | 29 | """ tests the AppStore GtkTreeViewModel """ |
300 | 31 | 30 | ||
301 | 32 | def setUp(self): | 31 | def setUp(self): |
302 | 33 | xapian_base_path = XAPIAN_BASE_PATH | ||
303 | 34 | pathname = os.path.join(xapian_base_path, "xapian") | ||
304 | 35 | self.cache = AptCache() | 32 | self.cache = AptCache() |
306 | 36 | self.db = StoreDatabase(pathname, self.cache) | 33 | self.db = StoreDatabase(get_database_path(), self.cache) |
307 | 37 | self.db.open() | 34 | self.db.open() |
308 | 38 | self.mock_icons = MockIconCache() | 35 | self.mock_icons = MockIconCache() |
309 | 39 | self.mock_filter = MockAppViewFilter() | 36 | self.mock_filter = MockAppViewFilter() |
310 | 40 | 37 | ||
311 | === modified file 'utils/bench.py' | |||
312 | --- utils/bench.py 2010-05-09 07:13:26 +0000 | |||
313 | +++ utils/bench.py 2010-06-02 15:09:30 +0000 | |||
314 | @@ -7,6 +7,7 @@ | |||
315 | 7 | sys.path.insert(0, "../") | 7 | sys.path.insert(0, "../") |
316 | 8 | from softwarecenter.enums import * | 8 | from softwarecenter.enums import * |
317 | 9 | from softwarecenter.utils import * | 9 | from softwarecenter.utils import * |
318 | 10 | from softwarecenter.db.database import get_database_path | ||
319 | 10 | 11 | ||
320 | 11 | def run_benchmark(db): | 12 | def run_benchmark(db): |
321 | 12 | # test postlist | 13 | # test postlist |
322 | @@ -37,8 +38,7 @@ | |||
323 | 37 | 38 | ||
324 | 38 | if __name__ == "__main__": | 39 | if __name__ == "__main__": |
325 | 39 | 40 | ||
328 | 40 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 41 | db = xapian.Database(get_database_path()) |
327 | 41 | db = xapian.Database(pathname) | ||
329 | 42 | 42 | ||
330 | 43 | print "app db only" | 43 | print "app db only" |
331 | 44 | run_benchmark(db) | 44 | run_benchmark(db) |
332 | 45 | 45 | ||
333 | === modified file 'utils/installedapps.py' | |||
334 | --- utils/installedapps.py 2010-05-09 07:13:26 +0000 | |||
335 | +++ utils/installedapps.py 2010-06-02 15:09:30 +0000 | |||
336 | @@ -8,13 +8,13 @@ | |||
337 | 8 | sys.path.insert(0, "../") | 8 | sys.path.insert(0, "../") |
338 | 9 | from softwarecenter.enums import * | 9 | from softwarecenter.enums import * |
339 | 10 | from softwarecenter.utils import * | 10 | from softwarecenter.utils import * |
340 | 11 | from softwarecenter.db.database import get_database_path | ||
341 | 11 | 12 | ||
342 | 12 | if __name__ == "__main__": | 13 | if __name__ == "__main__": |
343 | 13 | 14 | ||
344 | 14 | cache = apt.Cache() | 15 | cache = apt.Cache() |
345 | 15 | 16 | ||
348 | 16 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 17 | db = xapian.Database(get_database_path()) |
347 | 17 | db = xapian.Database(pathname) | ||
349 | 18 | 18 | ||
350 | 19 | installed = [] | 19 | installed = [] |
351 | 20 | for m in db.postlist(""): | 20 | for m in db.postlist(""): |
352 | 21 | 21 | ||
353 | === modified file 'utils/query.py' | |||
354 | --- utils/query.py 2010-05-09 07:13:26 +0000 | |||
355 | +++ utils/query.py 2010-06-02 15:09:30 +0000 | |||
356 | @@ -9,6 +9,7 @@ | |||
357 | 9 | sys.path.insert(0, "../") | 9 | sys.path.insert(0, "../") |
358 | 10 | from softwarecenter.enums import * | 10 | from softwarecenter.enums import * |
359 | 11 | from softwarecenter.utils import * | 11 | from softwarecenter.utils import * |
360 | 12 | from softwarecenter.db.database import get_database_path | ||
361 | 12 | 13 | ||
362 | 13 | def parse_query(parser, search_strings, verbose=True): | 14 | def parse_query(parser, search_strings, verbose=True): |
363 | 14 | str_to_prefix = { 'section' : 'AE', | 15 | str_to_prefix = { 'section' : 'AE', |
364 | @@ -52,8 +53,7 @@ | |||
365 | 52 | help="print found apps/pkgs too") | 53 | help="print found apps/pkgs too") |
366 | 53 | (options, args) = parser.parse_args() | 54 | (options, args) = parser.parse_args() |
367 | 54 | 55 | ||
370 | 55 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 56 | db = xapian.Database(get_database_path()) |
369 | 56 | db = xapian.Database(pathname) | ||
371 | 57 | 57 | ||
372 | 58 | axi = xapian.Database("/var/lib/apt-xapian-index/index") | 58 | axi = xapian.Database("/var/lib/apt-xapian-index/index") |
373 | 59 | db.add_database(axi) | 59 | db.add_database(axi) |
374 | 60 | 60 | ||
375 | === modified file 'utils/search_query.py' | |||
376 | --- utils/search_query.py 2010-05-09 07:13:26 +0000 | |||
377 | +++ utils/search_query.py 2010-06-02 15:09:30 +0000 | |||
378 | @@ -7,7 +7,6 @@ | |||
379 | 7 | from optparse import OptionParser | 7 | from optparse import OptionParser |
380 | 8 | 8 | ||
381 | 9 | sys.path.insert(0, "../") | 9 | sys.path.insert(0, "../") |
382 | 10 | from softwarecenter.enums import * | ||
383 | 11 | from softwarecenter.utils import * | 10 | from softwarecenter.utils import * |
384 | 12 | 11 | ||
385 | 13 | def run_query(parser, search_terms, verbose): | 12 | def run_query(parser, search_terms, verbose): |
386 | @@ -37,8 +36,8 @@ | |||
387 | 37 | help="print found apps/pkgs too") | 36 | help="print found apps/pkgs too") |
388 | 38 | (options, args) = parser.parse_args() | 37 | (options, args) = parser.parse_args() |
389 | 39 | 38 | ||
392 | 40 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 39 | from softwarecenter.db.database import get_database_path |
393 | 41 | db = xapian.Database(pathname) | 40 | db = xapian.Database(get_database_path()) |
394 | 42 | 41 | ||
395 | 43 | axi = xapian.Database("/var/lib/apt-xapian-index/index") | 42 | axi = xapian.Database("/var/lib/apt-xapian-index/index") |
396 | 44 | db.add_database(axi) | 43 | db.add_database(axi) |
397 | 45 | 44 | ||
398 | === modified file 'utils/stats.py' | |||
399 | --- utils/stats.py 2010-05-09 07:13:26 +0000 | |||
400 | +++ utils/stats.py 2010-06-02 15:09:30 +0000 | |||
401 | @@ -24,6 +24,7 @@ | |||
402 | 24 | 24 | ||
403 | 25 | sys.path.insert(0, "../") | 25 | sys.path.insert(0, "../") |
404 | 26 | from softwarecenter.enums import * | 26 | from softwarecenter.enums import * |
405 | 27 | from softwarecenter.db.database import get_database_path | ||
406 | 27 | 28 | ||
407 | 28 | if __name__ == "__main__": | 29 | if __name__ == "__main__": |
408 | 29 | 30 | ||
409 | @@ -35,8 +36,7 @@ | |||
410 | 35 | app_to_pkg = {} | 36 | app_to_pkg = {} |
411 | 36 | 37 | ||
412 | 37 | # gather data | 38 | # gather data |
415 | 38 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 39 | db = xapian.Database(get_database_path()) |
414 | 39 | db = xapian.Database(pathname) | ||
416 | 40 | for m in db.postlist(""): | 40 | for m in db.postlist(""): |
417 | 41 | doc = db.get_document(m.docid) | 41 | doc = db.get_document(m.docid) |
418 | 42 | appname = doc.get_data() | 42 | appname = doc.get_data() |
419 | 43 | 43 | ||
420 | === modified file 'utils/topapps.py' | |||
421 | --- utils/topapps.py 2010-05-09 07:13:26 +0000 | |||
422 | +++ utils/topapps.py 2010-06-02 15:09:30 +0000 | |||
423 | @@ -8,6 +8,7 @@ | |||
424 | 8 | sys.path.insert(0, "../") | 8 | sys.path.insert(0, "../") |
425 | 9 | from softwarecenter.enums import * | 9 | from softwarecenter.enums import * |
426 | 10 | from softwarecenter.utils import * | 10 | from softwarecenter.utils import * |
427 | 11 | from softwarecenter.db.database import get_database_path | ||
428 | 11 | 12 | ||
429 | 12 | if __name__ == "__main__": | 13 | if __name__ == "__main__": |
430 | 13 | 14 | ||
431 | @@ -15,8 +16,7 @@ | |||
432 | 15 | if len(sys.argv) > 1: | 16 | if len(sys.argv) > 1: |
433 | 16 | topn = int(sys.argv[1]) | 17 | topn = int(sys.argv[1]) |
434 | 17 | 18 | ||
437 | 18 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 19 | db = xapian.Database(get_database_path()) |
436 | 19 | db = xapian.Database(pathname) | ||
438 | 20 | 20 | ||
439 | 21 | heap = [] | 21 | heap = [] |
440 | 22 | for m in db.postlist(""): | 22 | for m in db.postlist(""): |
441 | 23 | 23 | ||
442 | === modified file 'utils/update-software-center' | |||
443 | --- utils/update-software-center 2010-05-09 07:13:26 +0000 | |||
444 | +++ utils/update-software-center 2010-06-02 15:09:30 +0000 | |||
445 | @@ -31,6 +31,7 @@ | |||
446 | 31 | from optparse import OptionParser | 31 | from optparse import OptionParser |
447 | 32 | 32 | ||
448 | 33 | from softwarecenter.enums import * | 33 | from softwarecenter.enums import * |
449 | 34 | from softwarecenter.db.database import get_database_path | ||
450 | 34 | from softwarecenter.db.update import rebuild_database | 35 | from softwarecenter.db.update import rebuild_database |
451 | 35 | 36 | ||
452 | 36 | # dbus may not be available during a upgrade so we | 37 | # dbus may not be available during a upgrade so we |
453 | @@ -97,7 +98,7 @@ | |||
454 | 97 | logging.info("no translation information in database needed") | 98 | logging.info("no translation information in database needed") |
455 | 98 | sys.exit(0) | 99 | sys.exit(0) |
456 | 99 | mo_time = os.path.getctime(mofile) | 100 | mo_time = os.path.getctime(mofile) |
458 | 100 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 101 | pathname = get_database_path(create=False) |
459 | 101 | if os.path.exists(pathname): | 102 | if os.path.exists(pathname): |
460 | 102 | db = xapian.Database(pathname) | 103 | db = xapian.Database(pathname) |
461 | 103 | mo_db_time = db.get_metadata("app-install-mo-time") | 104 | mo_db_time = db.get_metadata("app-install-mo-time") |
462 | @@ -120,13 +121,9 @@ | |||
463 | 120 | 121 | ||
464 | 121 | # rebuild and send signal when done | 122 | # rebuild and send signal when done |
465 | 122 | try: | 123 | try: |
466 | 123 | # setup path | ||
467 | 124 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | ||
468 | 125 | if not os.path.exists(pathname): | ||
469 | 126 | os.makedirs(pathname) | ||
470 | 127 | # rebuild the database, the default context is run to ensure | 124 | # rebuild the database, the default context is run to ensure |
471 | 128 | # dbus querries are processed | 125 | # dbus querries are processed |
473 | 129 | rebuild_database(pathname) | 126 | rebuild_database(get_database_path()) |
474 | 130 | finally: | 127 | finally: |
475 | 131 | # signal that the xapian db is valid again | 128 | # signal that the xapian db is valid again |
476 | 132 | if dbus_controller: | 129 | if dbus_controller: |
477 | 133 | 130 | ||
478 | === modified file 'utils/wildcard_query_parser.py' | |||
479 | --- utils/wildcard_query_parser.py 2010-05-09 07:13:26 +0000 | |||
480 | +++ utils/wildcard_query_parser.py 2010-06-02 15:09:30 +0000 | |||
481 | @@ -9,6 +9,7 @@ | |||
482 | 9 | sys.path.insert(0, "../") | 9 | sys.path.insert(0, "../") |
483 | 10 | from softwarecenter.enums import * | 10 | from softwarecenter.enums import * |
484 | 11 | from softwarecenter.utils import * | 11 | from softwarecenter.utils import * |
485 | 12 | from softwarecenter.db.database import get_database_path | ||
486 | 12 | 13 | ||
487 | 13 | if __name__ == "__main__": | 14 | if __name__ == "__main__": |
488 | 14 | 15 | ||
489 | @@ -18,8 +19,7 @@ | |||
490 | 18 | help="print found apps/pkgs too") | 19 | help="print found apps/pkgs too") |
491 | 19 | (options, args) = parser.parse_args() | 20 | (options, args) = parser.parse_args() |
492 | 20 | 21 | ||
495 | 21 | pathname = os.path.join(XAPIAN_BASE_PATH, "xapian") | 22 | db = xapian.Database(get_database_path()) |
494 | 22 | db = xapian.Database(pathname) | ||
496 | 23 | 23 | ||
497 | 24 | axi = xapian.Database("/var/lib/apt-xapian-index/index") | 24 | axi = xapian.Database("/var/lib/apt-xapian-index/index") |
498 | 25 | db.add_database(axi) | 25 | db.add_database(axi) |
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.