Merge lp:~abreu-alexandre/unity-webapps-bbcnews/add-session-migration into lp:unity-webapps-bbcnews

Proposed by Alexandre Abreu
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 52
Merged at revision: 51
Proposed branch: lp:~abreu-alexandre/unity-webapps-bbcnews/add-session-migration
Merge into: lp:unity-webapps-bbcnews
Diff against target: 56 lines (+35/-0)
3 files modified
debian/control (+1/-0)
debian/unity-webapps-bbcnews.migrations (+1/-0)
scripts/update-desktop-file-exec-line.py (+33/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-bbcnews/add-session-migration
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Robert Bruce Park (community) Approve
Review via email: mp+185136@code.launchpad.net

Commit message

add session migration script to upgrade desktop file exec from legacy runner to webbrowser-app

Description of the change

add session migration script to upgrade desktop file exec from legacy runner to webbrowser-app

To post a comment you must log in.
52. By Alexandre Abreu

extract app_id

Revision history for this message
Robert Bruce Park (robru) wrote :

Great, glad to see the APP_ID unified.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-06-18 19:13:08 +0000
3+++ debian/control 2013-09-11 19:06:43 +0000
4@@ -4,6 +4,7 @@
5 Standards-Version: 3.9.4
6 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
7 Build-Depends: debhelper (>= 9),
8+ dh-migrations,
9 unity-webapps-dev (>= 2.4.16),
10 Homepage: http://www.bbc.co.uk/news/
11 # If you aren't a member of ~webapps but need to upload packaging changes,
12
13=== added file 'debian/unity-webapps-bbcnews.migrations'
14--- debian/unity-webapps-bbcnews.migrations 1970-01-01 00:00:00 +0000
15+++ debian/unity-webapps-bbcnews.migrations 2013-09-11 19:06:43 +0000
16@@ -0,0 +1,1 @@
17+scripts/update-desktop-file-exec-line.py
18
19=== added directory 'scripts'
20=== added file 'scripts/update-desktop-file-exec-line.py'
21--- scripts/update-desktop-file-exec-line.py 1970-01-01 00:00:00 +0000
22+++ scripts/update-desktop-file-exec-line.py 2013-09-11 19:06:43 +0000
23@@ -0,0 +1,33 @@
24+#!/usr/bin/python
25+from gi.repository import Gio
26+import os
27+import glib
28+import glob
29+import re
30+
31+APP_ID = 'BBCNewsbbccouk'
32+
33+def get_local_applications_path():
34+ return os.path.join(glib.get_user_data_dir(), 'applications')
35+
36+def update_desktop_file_exec_line():
37+ local_applications_path = get_local_applications_path()
38+ if not os.path.exists(local_applications_path) or not os.path.isdir(local_applications_path):
39+ return
40+
41+ desktop_filename = os.path.join(local_applications_path, '{0}.desktop'.format(APP_ID))
42+ if not os.path.exists(desktop_filename) or not os.path.isfile(desktop_filename):
43+ return
44+
45+ try:
46+ desktop_file_content = open(desktop_filename).read()
47+ if desktop_file_content.find('unity-webapps-runner') != -1:
48+ updated_desktop_file_content = re.sub(r"Exec\s*=\s*unity-webapps-runner\s*-n\s*'([^\s]*)'.*%u",
49+ r"Exec=webbrowser-app --chromeless --webapp='\1' --app-id='{0}'".format(APP_ID),
50+ desktop_file_content)
51+ open(desktop_filename, "w+").write(updated_desktop_file_content)
52+ except Exception, e:
53+ print 'Error while upgrading the desktop file: ', str(e)
54+
55+if __name__ == "__main__":
56+ update_desktop_file_exec_line()

Subscribers

People subscribed via source and target branches

to all changes: