Merge lp:~jamesh/software-center/scan-scopes into lp:software-center

Proposed by James Henstridge
Status: Merged
Approved by: dobey
Approved revision: 3304
Merged at revision: 3305
Proposed branch: lp:~jamesh/software-center/scan-scopes
Merge into: lp:software-center
Diff against target: 120 lines (+53/-6)
4 files modified
data/software-center.menu.in (+4/-1)
softwarecenter/db/update.py (+20/-2)
tests/data/desktop/music-banshee.scope (+17/-0)
tests/test_database.py (+12/-3)
To merge this branch: bzr merge lp:~jamesh/software-center/scan-scopes
Reviewer Review Type Date Requested Status
dobey Approve
Review via email: mp+158014@code.launchpad.net

Commit message

Include unity-scope-* packages in the list of dash search plugins.

Description of the change

We want Unity scopes to appear in the software center. The archive indexer has been updated to extract scope files from packages in the archive. We would also like information from these files included in the Xapian index Software Center creates from this data.

This branch adds such support.

Since we aren't including the new Unity stack in 13.04 it doesn't need to hit that deadline, but it'd be nice to know whether the approach seems sound.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

On 10 April 2013 09:23, James Henstridge <email address hidden> wrote:
> @@ -1019,13 +1031,16 @@
> if not datadir:
> datadir = softwarecenter.paths.APP_INSTALL_DESKTOP_PATH
> context = GLib.main_context_default()
> - for desktopf in glob(datadir + "/*.desktop"):
> + for desktopf in glob(datadir + "/*.desktop") + glob(datadir + "/*.scope"):

Right, so scope files are in the same place as the .desktop files. I
will make sure app-install-data has them in the matching above place.
I didn't know at the time if we will use
/usr/share/app-install/desktop or /usr/share/app-install/scopes.

Regards,

Dmitrijs.

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

On Wed, Apr 10, 2013 at 08:22:24AM -0000, James Henstridge wrote:
> James Henstridge has proposed merging lp:~jamesh/software-center/scan-scopes into lp:software-center.
>
> Requested reviews:
> software-store-developers (software-store-developers)
>
> For more details, see:
> https://code.launchpad.net/~jamesh/software-center/scan-scopes/+merge/158014
>
> We want Unity scopes to appear in the software center. The archive indexer has been updated to extract scope files from packages in the archive. We would also like information from these files included in the Xapian index Software Center creates from this data.
>
> This branch adds such support.
[..]

Thanks James, this looks fine.

Approved from me.

Revision history for this message
dobey (dobey) :
review: Approve
3304. By James Henstridge

Force scope files to have Type=Scope so they don't get mistaken for
other desktop entry types via [Scope]/Type.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/software-center.menu.in'
2--- data/software-center.menu.in 2012-08-21 11:58:06 +0000
3+++ data/software-center.menu.in 2013-05-02 21:39:26 +0000
4@@ -538,7 +538,10 @@
5 <SCIcon>preferences-other</SCIcon>
6 <Include>
7 <And>
8- <SCPkgnameWildcard>unity-lens-*</SCPkgnameWildcard>
9+ <Or>
10+ <SCPkgnameWildcard>unity-lens-*</SCPkgnameWildcard>
11+ <SCPkgnameWildcard>unity-scope-*</SCPkgnameWildcard>
12+ </Or>
13 </And>
14 </Include>
15 </Menu>
16
17=== modified file 'softwarecenter/db/update.py'
18--- softwarecenter/db/update.py 2013-02-07 16:10:44 +0000
19+++ softwarecenter/db/update.py 2013-05-02 21:39:26 +0000
20@@ -933,6 +933,21 @@
21 def desktopf(self):
22 return self._filename
23
24+class ScopeConfigParser(DesktopConfigParser):
25+ """Thin wrapper to handle Scope files."""
26+
27+ SCOPE = "Scope"
28+
29+ def _get_option_desktop(self, key):
30+ # Mark scopes as Type=Scope.
31+ if key.lower() == 'type':
32+ return 'Scope'
33+ value = super(ScopeConfigParser, self)._get_option_desktop(key)
34+ if value is not None:
35+ return value
36+ # Fall back to values from the SCOPE section.
37+ if self.has_option(self.SCOPE, key):
38+ return self.get(self.SCOPE, key)
39
40 def ascii_upper(key):
41 """Translate an ASCII string to uppercase
42@@ -1019,13 +1034,16 @@
43 if not datadir:
44 datadir = softwarecenter.paths.APP_INSTALL_DESKTOP_PATH
45 context = GLib.main_context_default()
46- for desktopf in glob(datadir + "/*.desktop"):
47+ for desktopf in glob(datadir + "/*.desktop") + glob(datadir + "/*.scope"):
48 LOG.debug("processing %r", desktopf)
49 # process events
50 while context.pending():
51 context.iteration()
52 try:
53- parser = DesktopConfigParser()
54+ if desktopf.endswith('.scope'):
55+ parser = ScopeConfigParser()
56+ else:
57+ parser = DesktopConfigParser()
58 parser.read(desktopf)
59 parser.index_app_info(db, cache)
60 except Exception as e:
61
62=== added file 'tests/data/desktop/music-banshee.scope'
63--- tests/data/desktop/music-banshee.scope 1970-01-01 00:00:00 +0000
64+++ tests/data/desktop/music-banshee.scope 2013-05-02 21:39:26 +0000
65@@ -0,0 +1,17 @@
66+[Scope]
67+DBusName=com.canonical.Unity.Scope.Music
68+DBusPath=/com/canonical/unity/scope/banshee
69+Icon=/usr/share/unity/6/lens-nav-music.svg
70+Name=Music (Banshee)
71+Description=Find artists, albums, and your favorite tracks
72+SearchHint=Search Music Collection
73+Shortcut=m
74+Type=music
75+
76+[Desktop Entry]
77+X-AppInstall-Package=unity-lens-music
78+X-AppInstall-Popcon=1000
79+X-AppInstallSection=main
80+
81+X-Ubuntu-Gettext-Domain=unity-lens-music
82+
83
84=== modified file 'tests/test_database.py'
85--- tests/test_database.py 2013-02-06 23:14:37 +0000
86+++ tests/test_database.py 2013-05-02 21:39:26 +0000
87@@ -102,6 +102,17 @@
88 for it in db.postlist("AAUbuntu Software Zentrum"):
89 i+=1
90
91+ def test_update_includes_scope_files(self):
92+ datadir = os.path.join(DATA_DIR, "desktop")
93+ db = get_test_db_from_app_install_data(datadir)
94+ for it in db.postlist("APMunity_lens_music"):
95+ doc = db.get_document(it.docid)
96+ self.assertEqual(
97+ doc.get_value(XapianValues.APPNAME), "Music (Banshee)")
98+ break
99+ else:
100+ self.fail("Did not find scope file in Xapian database")
101+
102 def test_regression_index_terms(self):
103 """ this tests for a regression that we had in the term indexer
104 that would index hundrets of size 1 terms due to a bug
105@@ -230,7 +241,7 @@
106 self.assertTrue(res)
107 db = StoreDatabase(TEST_DB, self.cache)
108 db.open(use_axi=False, use_agent=False)
109- self.assertEqual(len(db), 5)
110+ self.assertEqual(len(db), 6)
111 # test details
112 app = Application("Ubuntu Software Center Test", "software-center")
113 details = app.get_details(db)
114@@ -940,6 +951,4 @@
115
116
117 if __name__ == "__main__":
118- #import logging
119- #logging.basicConfig(level=logging.DEBUG)
120 unittest.main()