Merge lp:~townsend/libertine/puritine-favorite-libertine-scope into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 274
Merged at revision: 273
Proposed branch: lp:~townsend/libertine/puritine-favorite-libertine-scope
Merge into: lp:libertine
Diff against target: 102 lines (+66/-18)
1 file modified
tools/update-puritine-containers (+66/-18)
To merge this branch: bzr merge lp:~townsend/libertine/puritine-favorite-libertine-scope
Reviewer Review Type Date Requested Status
Larry Price Approve
Libertine CI Bot continuous-integration Approve
Review via email: mp+300393@code.launchpad.net

Commit message

Add functionality to "favorite" the Libertine scope upon first installation of the Puritine click package.

To post a comment you must log in.
274. By Christopher Townsend

Remove extra line.

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:274
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/56/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/184
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=default/144
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/144
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=default/144
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=vivid+overlay,testname=default/144
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/144
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=yakkety,testname=default/144
    None: https://jenkins.canonical.com/libertine/job/lp-generic-update-mp/143/console
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/187
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=vivid+overlay/172
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=xenial+overlay/172
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-1-sourcepkg/release=yakkety/172
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/165
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=vivid+overlay/165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/165
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/165
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=yakkety/165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/165
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=vivid+overlay/165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/165
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/165
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=yakkety/165/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/56/rebuild

review: Approve (continuous-integration)
Revision history for this message
Larry Price (larryprice) wrote :

verified works

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/update-puritine-containers'
2--- tools/update-puritine-containers 2016-06-10 20:34:33 +0000
3+++ tools/update-puritine-containers 2016-07-18 21:00:41 +0000
4@@ -23,10 +23,20 @@
5 import shutil
6 import subprocess
7
8+from gi.repository import GLib, Gio
9+
10 puritine_hook_dir = os.path.join(os.environ['HOME'], '.cache', 'libertine', 'puritine')
11 puritine_symlink_farm_file = os.path.join(puritine_hook_dir, 'PuritineSymlinkFarm.json')
12 puritine_click_config_file = os.path.join('libertine-config', 'libertine', 'ContainersConfig.json')
13
14+def symlink_farm_entries_count():
15+ if (puritine_symlink_farm_list and
16+ puritine_symlink_farm_list['customContainers']):
17+ return len(puritine_symlink_farm_list['customContainers'])
18+
19+ return 0
20+
21+
22 def puritine_symlink_exists(symlink):
23 for file in os.listdir(puritine_hook_dir):
24 if file == symlink:
25@@ -117,21 +127,59 @@
26 return puritine_symlink_farm_list
27
28
29-puritine_symlink_farm_list = {}
30-
31-if not os.path.exists(puritine_hook_dir):
32- os.makedirs(puritine_hook_dir)
33-
34-if (os.path.exists(puritine_symlink_farm_file) and
35- os.path.getsize(puritine_symlink_farm_file) != 0):
36- with open(puritine_symlink_farm_file, 'r') as fd:
37- puritine_symlink_farm_list = json.load(fd)
38-
39-puritine_symlink_farm_list = find_new_or_updated_puritine_symlinks(puritine_symlink_farm_list)
40-
41-if puritine_symlink_farm_list:
42- puritine_symlink_farm_list = find_removed_puritine_symlinks(puritine_symlink_farm_list)
43-
44-with open(puritine_symlink_farm_file, 'w') as fd:
45- json.dump(puritine_symlink_farm_list, fd, sort_keys=True, indent=4)
46- fd.write('\n')
47+def favorite_libertine_scope():
48+ libertine_scope_value = 'scope://libertine-scope.ubuntu_libertine-scope'
49+ click_scope_value = 'scope://clickscope'
50+ schema = 'com.canonical.Unity.Dash'
51+ schema_key = 'favorite-scopes'
52+
53+ settings = Gio.Settings.new(schema)
54+
55+ favorites = settings.get_value(schema_key)
56+
57+ array = favorites.dup_strv()
58+
59+ if not libertine_scope_value in array:
60+ array.insert(array.index(click_scope_value) + 1, libertine_scope_value)
61+ new_favorites = GLib.Variant.new_strv(array)
62+ settings.set_value(schema_key, new_favorites)
63+ del new_favorites
64+
65+ del array
66+ del favorites
67+ del settings
68+
69+
70+if __name__ == '__main__':
71+ puritine_symlink_farm_list = {}
72+
73+ with open(os.path.join('/', 'run', 'user', str(os.getuid()), 'dbus-session'), 'r') as fd:
74+ dbus_session_str = fd.read()
75+
76+ os.environ['DBUS_SESSION_BUS_ADDRESS'] = dbus_session_str.partition('DBUS_SESSION_BUS_ADDRESS=')[2].rstrip('\n')
77+
78+ if not os.path.exists(puritine_hook_dir):
79+ os.makedirs(puritine_hook_dir)
80+
81+ if (os.path.exists(puritine_symlink_farm_file) and
82+ os.path.getsize(puritine_symlink_farm_file) != 0):
83+ with open(puritine_symlink_farm_file, 'r') as fd:
84+ puritine_symlink_farm_list = json.load(fd)
85+
86+ count_at_start = symlink_farm_entries_count()
87+
88+ puritine_symlink_farm_list = find_new_or_updated_puritine_symlinks(puritine_symlink_farm_list)
89+
90+ if puritine_symlink_farm_list:
91+ puritine_symlink_farm_list = find_removed_puritine_symlinks(puritine_symlink_farm_list)
92+
93+ count_at_finish = symlink_farm_entries_count()
94+
95+ with open(puritine_symlink_farm_file, 'w') as fd:
96+ json.dump(puritine_symlink_farm_list, fd, sort_keys=True, indent=4)
97+ fd.write('\n')
98+
99+ if count_at_start == 0 and count_at_finish > 0:
100+ favorite_libertine_scope()
101+
102+ libertine.utils.refresh_libertine_scope()

Subscribers

People subscribed via source and target branches