Merge lp:~chipaca/ubuntu-push/fix-click-hook-wrt-legacy-apps into lp:ubuntu-push/automatic

Proposed by John Lenton
Status: Merged
Approved by: John Lenton
Approved revision: 343
Merged at revision: 342
Proposed branch: lp:~chipaca/ubuntu-push/fix-click-hook-wrt-legacy-apps
Merge into: lp:ubuntu-push/automatic
Diff against target: 50 lines (+16/-10)
1 file modified
scripts/click-hook (+16/-10)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/fix-click-hook-wrt-legacy-apps
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Review via email: mp+238418@code.launchpad.net

Commit message

Fix the click hook wrt legacy apps.

Description of the change

Fix the click hook wrt legacy apps.

To post a comment you must log in.
342. By John Lenton

oops, use the second element now that we know the first one is empty :)

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

Looks good.

review: Approve
343. By John Lenton

tweak the click hook a bit

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

still +1 ;-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/click-hook'
2--- scripts/click-hook 2014-08-04 15:37:01 +0000
3+++ scripts/click-hook 2014-10-15 11:56:55 +0000
4@@ -1,4 +1,5 @@
5 #!/usr/bin/python3
6+# -*- python -*-
7 """Collect helpers hook data into a single json file"""
8
9 import argparse
10@@ -24,25 +25,30 @@
11
12
13 def cleanup_settings():
14+ settings = Gio.Settings.new('com.ubuntu.notifications.hub')
15+ blacklist = settings.get_value('blacklist').unpack()
16+ if not blacklist:
17+ return
18+
19 clickdb = Click.DB.new()
20 clickdb.read()
21
22- pkgnames = []
23+ pkgnames = set()
24 for package in clickdb.get_packages(False):
25- pkgnames.append(package.get_property('package'))
26+ pkgnames.add(package.get_property('package'))
27
28- settings = Gio.Settings.new('com.ubuntu.notifications.hub')
29 goodapps = GLib.VariantBuilder.new(GLib.VariantType.new("a(ss)"))
30
31- for appname in settings.get_value('blacklist').unpack():
32- if appname[0] in pkgnames:
33+ dirty = False
34+
35+ for appname in blacklist:
36+ if appname[0] not in pkgnames and Gio.DesktopAppInfo.new(appname[1] + ".desktop") is None:
37+ dirty = True
38+ else:
39 goodapps.add_value(tup2variant(appname))
40- elif (appname[0] == appname[1]):
41- appinfo = Gio.DesktopAppInfo.new(appname[0] + ".desktop")
42- if not appinfo is None:
43- goodapps.add_value(tup2variant(appname))
44
45- settings.set_value('blacklist', goodapps.end())
46+ if dirty:
47+ settings.set_value('blacklist', goodapps.end())
48
49
50 def collect_helpers(helpers_data_path, helpers_data_path_tmp, hooks_path):

Subscribers

People subscribed via source and target branches