Merge lp:~didrocks/software-center/fix-running-standalone-pane into lp:software-center

Proposed by Didier Roche-Tolomelli
Status: Merged
Merged at revision: 940
Proposed branch: lp:~didrocks/software-center/fix-running-standalone-pane
Merge into: lp:software-center
Diff against target: 166 lines (+90/-17)
2 files modified
softwarecenter/view/availablepane.py (+50/-12)
softwarecenter/view/installedpane.py (+40/-5)
To merge this branch: bzr merge lp:~didrocks/software-center/fix-running-standalone-pane
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+30866@code.launchpad.net

Description of the change

Fix running standalone availablepane and installedpane.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/view/availablepane.py'
2--- softwarecenter/view/availablepane.py 2010-07-19 15:00:15 +0000
3+++ softwarecenter/view/availablepane.py 2010-07-24 22:30:57 +0000
4@@ -132,8 +132,10 @@
5 gtk.Label(self.NAV_BUTTON_ID_SUBCAT))
6
7 # add nav history back/forward buttons
8- self.navhistory_back_action.set_sensitive(False)
9- self.navhistory_forward_action.set_sensitive(False)
10+ if self.navhistory_back_action:
11+ self.navhistory_back_action.set_sensitive(False)
12+ if self.navhistory_forward_action:
13+ self.navhistory_forward_action.set_sensitive(False)
14 # note: this is hacky, would be much nicer to make the custom self/right
15 # buttons in BackForwardButton to be gtk.Activatable/gtk.Widgets, then wire in the
16 # actions using e.g. self.navhistory_back_action.connect_proxy(self.back_forward.left),
17@@ -144,10 +146,11 @@
18 self.top_hbox.pack_start(self.back_forward, expand=False, padding=self.PADDING)
19 # nav buttons first in the panel
20 self.top_hbox.reorder_child(self.back_forward, 0)
21- self.nav_history = NavigationHistory(self,
22- self.back_forward,
23- self.navhistory_back_action,
24- self.navhistory_forward_action)
25+ if self.navhistory_back_action and self.navhistory_forward_action:
26+ self.nav_history = NavigationHistory(self,
27+ self.back_forward,
28+ self.navhistory_back_action,
29+ self.navhistory_forward_action)
30
31 # app list
32 self.notebook.append_page(self.scroll_app_list,
33@@ -646,9 +649,11 @@
34 pass
35
36 if __name__ == "__main__":
37+
38+ from softwarecenter.apt.apthistory import get_apt_history
39+ from softwarecenter.db.database import StoreDatabase
40+
41 #logging.basicConfig(level=logging.DEBUG)
42- xapian_base_path = XAPIAN_BASE_PATH
43- pathname = os.path.join(xapian_base_path, "xapian")
44
45 if len(sys.argv) > 1:
46 datadir = sys.argv[1]
47@@ -657,14 +662,47 @@
48 else:
49 datadir = "/usr/share/software-center"
50
51- db = xapian.Database(pathname)
52+ # additional icons come from app-install-data
53 icons = gtk.icon_theme_get_default()
54- icons.append_search_path("/usr/share/app-install/icons/")
55-
56+ icons.append_search_path(ICON_PATH)
57+ icons.append_search_path(os.path.join(datadir,"icons"))
58+ icons.append_search_path(os.path.join(datadir,"emblems"))
59+ # HACK: make it more friendly for local installs (for mpt)
60+ icons.append_search_path(datadir+"/icons/32x32/status")
61+ gtk.window_set_default_icon_name("softwarecenter")
62+ import apt
63 cache = apt.Cache(apt.progress.text.OpProgress())
64 cache.ready = True
65
66- w = AvailablePane(cache, db, icons, datadir)
67+ #apt history
68+ history = get_apt_history()
69+ # xapian
70+ xapian_base_path = XAPIAN_BASE_PATH
71+ pathname = os.path.join(xapian_base_path, "xapian")
72+ try:
73+ db = StoreDatabase(pathname, cache)
74+ db.open()
75+ except xapian.DatabaseOpeningError:
76+ # Couldn't use that folder as a database
77+ # This may be because we are in a bzr checkout and that
78+ # folder is empty. If the folder is empty, and we can find the
79+ # script that does population, populate a database in it.
80+ if os.path.isdir(pathname) and not os.listdir(pathname):
81+ from softwarecenter.db.update import rebuild_database
82+ logging.info("building local database")
83+ rebuild_database(pathname)
84+ db = StoreDatabase(pathname, cache)
85+ db.open()
86+ except xapian.DatabaseCorruptError, e:
87+ logging.exception("xapian open failed")
88+ view.dialogs.error(None,
89+ _("Sorry, can not open the software database"),
90+ _("Please re-install the 'software-center' "
91+ "package."))
92+ # FIXME: force rebuild by providing a dbus service for this
93+ sys.exit(1)
94+
95+ w = AvailablePane(cache, history, db, 'Ubuntu', icons, datadir, None, None)
96 w.show()
97
98 win = gtk.Window()
99
100=== modified file 'softwarecenter/view/installedpane.py'
101--- softwarecenter/view/installedpane.py 2010-07-08 00:21:25 +0000
102+++ softwarecenter/view/installedpane.py 2010-07-24 22:30:57 +0000
103@@ -176,9 +176,11 @@
104 return False
105
106 if __name__ == "__main__":
107+
108+ from softwarecenter.apt.apthistory import get_apt_history
109+ from softwarecenter.db.database import StoreDatabase
110+
111 #logging.basicConfig(level=logging.DEBUG)
112- xapian_base_path = XAPIAN_BASE_PATH
113- pathname = os.path.join(xapian_base_path, "xapian")
114
115 if len(sys.argv) > 1:
116 datadir = sys.argv[1]
117@@ -187,13 +189,46 @@
118 else:
119 datadir = "/usr/share/software-center"
120
121- db = xapian.Database(pathname)
122+ # additional icons come from app-install-data
123 icons = gtk.icon_theme_get_default()
124- icons.append_search_path("/usr/share/app-install/icons/")
125+ icons.append_search_path(ICON_PATH)
126+ icons.append_search_path(os.path.join(datadir,"icons"))
127+ icons.append_search_path(os.path.join(datadir,"emblems"))
128+ # HACK: make it more friendly for local installs (for mpt)
129+ icons.append_search_path(datadir+"/icons/32x32/status")
130+ gtk.window_set_default_icon_name("softwarecenter")
131 cache = apt.Cache(apt.progress.text.OpProgress())
132 cache.ready = True
133
134- w = InstalledPane(cache, db, icons, datadir)
135+ #apt history
136+ history = get_apt_history()
137+ # xapian
138+ xapian_base_path = XAPIAN_BASE_PATH
139+ pathname = os.path.join(xapian_base_path, "xapian")
140+ try:
141+ db = StoreDatabase(pathname, cache)
142+ db.open()
143+ except xapian.DatabaseOpeningError:
144+ # Couldn't use that folder as a database
145+ # This may be because we are in a bzr checkout and that
146+ # folder is empty. If the folder is empty, and we can find the
147+ # script that does population, populate a database in it.
148+ if os.path.isdir(pathname) and not os.listdir(pathname):
149+ from softwarecenter.db.update import rebuild_database
150+ logging.info("building local database")
151+ rebuild_database(pathname)
152+ db = StoreDatabase(pathname, cache)
153+ db.open()
154+ except xapian.DatabaseCorruptError, e:
155+ logging.exception("xapian open failed")
156+ view.dialogs.error(None,
157+ _("Sorry, can not open the software database"),
158+ _("Please re-install the 'software-center' "
159+ "package."))
160+ # FIXME: force rebuild by providing a dbus service for this
161+ sys.exit(1)
162+
163+ w = InstalledPane(cache, history, db, 'Ubuntu', icons, datadir)
164 w.show()
165
166 win = gtk.Window()