Merge lp:~nataliabidart/ubuntu-sso-client/install-ui-files-properly into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 850
Merged at revision: 851
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/install-ui-files-properly
Merge into: lp:ubuntu-sso-client
Diff against target: 206 lines (+68/-34)
5 files modified
.bzrignore (+3/-1)
run-tests (+1/-0)
setup.py (+12/-4)
ubuntu_sso/constants.py.in (+27/-0)
ubuntu_sso/utils/ui.py (+25/-29)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/install-ui-files-properly
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+91754@code.launchpad.net

Commit message

- Install ui files consitently between Gtk and Qt (part of LP: #927994).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-02-01 19:19:32 +0000
3+++ .bzrignore 2012-02-07 01:58:19 +0000
4@@ -1,7 +1,9 @@
5 _trial_temp
6 data/*.service
7+MANIFEST
8 build/
9 dist/
10-MANIFEST
11 po/ubuntu-sso-client.pot
12+ubuntu_sso/constants.py
13 ubuntu_sso/qt/ui/*_ui.py
14+ubuntu_sso/qt/ui/*_rc.py
15
16=== modified file 'run-tests'
17--- run-tests 2012-02-03 19:07:37 +0000
18+++ run-tests 2012-02-07 01:58:19 +0000
19@@ -40,6 +40,7 @@
20 }
21 unset GTK_MODULES
22
23+XVFB_CMDLINE=""
24 XVFB=$(which xvfb-run)
25 if [ $XVFB ]; then
26 XVFB_CMDLINE="$XVFB -a"
27
28=== modified file 'setup.py'
29--- setup.py 2012-02-01 20:20:45 +0000
30+++ setup.py 2012-02-07 01:58:19 +0000
31@@ -40,15 +40,16 @@
32
33 POT_FILE = 'po/ubuntu-sso-client.pot'
34 SERVICE_FILE = 'data/com.ubuntu.sso.service'
35+CONSTANTS = 'ubuntu_sso/constants.py'
36
37-CLEANFILES = [SERVICE_FILE, POT_FILE, 'MANIFEST']
38+CLEANFILES = [SERVICE_FILE, POT_FILE, CONSTANTS, 'MANIFEST']
39 QT_UI_DIR = os.path.join('ubuntu_sso', 'qt', 'ui')
40
41
42 def replace_prefix(prefix):
43 """Replace every '@prefix@' with prefix within 'filename' content."""
44- # replace .service file
45- for filename in (SERVICE_FILE,):
46+ # replace .service file, DATA_DIR constant
47+ for filename in (SERVICE_FILE, CONSTANTS):
48 with open(filename + '.in') as in_file:
49 content = in_file.read()
50 with open(filename, 'w') as out_file:
51@@ -327,6 +328,7 @@
52 def run(self, *args):
53 """Dummy."""
54
55+
56 if sys.platform == 'win32':
57 cmdclass['build_i18n'] = dummy_build_i18n
58
59@@ -364,7 +366,6 @@
60 'bin/ubuntu-sso-login-gtk',
61 'bin/ubuntu-sso-login-qt']),
62 ('share/dbus-1/services', ['data/com.ubuntu.sso.service']),
63- ('share/ubuntu-sso-client/data/gtk', ['data/gtk/ui.glade']),
64 ]
65 extra = {}
66
67@@ -382,15 +383,22 @@
68 data_files=data_files,
69 packages=[
70 'ubuntu_sso',
71+ 'ubuntu_sso.tests',
72 'ubuntu_sso.gtk',
73 'ubuntu_sso.keyring',
74+ 'ubuntu_sso.keyring.tests',
75 'ubuntu_sso.main',
76+ 'ubuntu_sso.main.tests',
77 'ubuntu_sso.networkstate',
78+ 'ubuntu_sso.networkstate.tests',
79 'ubuntu_sso.qt',
80 'ubuntu_sso.qt.ui',
81 'ubuntu_sso.utils',
82+ 'ubuntu_sso.utils.tests',
83 'ubuntu_sso.utils.webclient',
84+ 'ubuntu_sso.utils.webclient.tests',
85 'ubuntu_sso.xdg_base_directory',
86+ 'ubuntu_sso.xdg_base_directory.tests',
87 ],
88 cmdclass=cmdclass,
89 **extra)
90
91=== added file 'ubuntu_sso/constants.py.in'
92--- ubuntu_sso/constants.py.in 1970-01-01 00:00:00 +0000
93+++ ubuntu_sso/constants.py.in 2012-02-07 01:58:19 +0000
94@@ -0,0 +1,27 @@
95+# -*- coding: utf-8 -*-
96+#
97+# Copyright 2012 Canonical Ltd.
98+#
99+# This program is free software: you can redistribute it and/or modify it
100+# under the terms of the GNU General Public License version 3, as published
101+# by the Free Software Foundation.
102+#
103+# This program is distributed in the hope that it will be useful, but
104+# WITHOUT ANY WARRANTY; without even the implied warranties of
105+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
106+# PURPOSE. See the GNU General Public License for more details.
107+#
108+# You should have received a copy of the GNU General Public License along
109+# with this program. If not, see <http://www.gnu.org/licenses/>.
110+
111+"""Some generated constants.
112+
113+DO NO EDIT! This is a generated file. It will be built at installation time.
114+
115+"""
116+
117+import os
118+
119+
120+PROJECT_NAME = 'ubuntu-sso-client'
121+PROJECT_DIR = os.path.join('@prefix@', 'share', PROJECT_NAME)
122
123=== modified file 'ubuntu_sso/utils/ui.py'
124--- ubuntu_sso/utils/ui.py 2012-01-04 16:02:05 +0000
125+++ ubuntu_sso/utils/ui.py 2012-02-07 01:58:19 +0000
126@@ -1,9 +1,6 @@
127 # -*- coding: utf-8 -*-
128 #
129-# Author: Natalia Bidart <natalia.bidart@canonical.com>
130-# Author: Manuel de la Pena <manuel@canonical.com>
131-#
132-# Copyright 2011 Canonical Ltd.
133+# Copyright 2011-2012 Canonical Ltd.
134 #
135 # This program is free software: you can redistribute it and/or modify it
136 # under the terms of the GNU General Public License version 3, as published
137@@ -23,7 +20,6 @@
138 import gettext
139
140 from ubuntu_sso.logger import setup_logging
141-from ubuntu_sso import xdg_base_directory
142
143 logger = setup_logging('ubuntu_sso.utils.ui')
144
145@@ -105,37 +101,37 @@
146 YES_TO_TC = _('I agree with the %(app_name)s terms and conditions')
147 YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')
148
149-
150-def get_data_dir():
151- """Build absolute path to the 'data' directory."""
152+DATA_SUFFIX = 'data'
153+
154+
155+def get_project_dir():
156+ """Return the absolute path to this project's data/ dir.
157+
158+ Support symlinks, and priorize local (relative) data/ dir.
159+ """
160 module = os.path.dirname(__file__)
161- result = os.path.abspath(os.path.join(module, os.pardir,
162- os.pardir, 'data'))
163- logger.debug('get_data_file: trying to load from %r (exists? %s)',
164- result, os.path.exists(result))
165+ result = os.path.abspath(os.path.join(module, os.path.pardir,
166+ os.path.pardir, DATA_SUFFIX))
167+ logger.debug('get_project_dir: trying use data dir at %r (exists? %s)',
168+ result, os.path.exists(result))
169 if os.path.exists(result):
170- logger.info('get_data_file: returning data dir located at %r.', result)
171+ logger.info('get_project_dir: returning dir located at %r.', result)
172 return result
173
174- # no local data dir, looking within system data dirs
175- data_dirs = xdg_base_directory.xdg_data_dirs
176- for path in data_dirs:
177- result = os.path.join(path, 'ubuntu-sso-client', 'data')
178- result = os.path.abspath(result)
179- logger.debug('get_data_file: trying to load from %r (exists? %s)',
180- result, os.path.exists(result))
181- if os.path.exists(result):
182- logger.info('get_data_file: data dir located at %r.', result)
183- return result
184- else:
185- msg = 'get_data_file: can not build a valid data path. Giving up.' \
186- '__file__ is %r, data_dirs are %r'
187- logger.error(msg, __file__, data_dirs)
188+ # otherwise, try to load PROJECT_DIR from installation path
189+ try:
190+ # pylint: disable=F0401, E0611, W0404
191+ from ubuntu_sso.constants import PROJECT_DIR
192+ return PROJECT_DIR
193+ except ImportError:
194+ msg = 'get_project_dir: can not build a valid path. Giving up. ' \
195+ '__file__ is %r, constants module not available.'
196+ logger.error(msg, __file__)
197
198
199 def get_data_file(*args):
200- """Build absolute path to the path within the 'data' directory."""
201- return os.path.join(get_data_dir(), *args)
202+ """Return the absolute path to 'args' within project data dir."""
203+ return os.path.join(get_project_dir(), *args)
204
205
206 def get_password_strength(password):

Subscribers

People subscribed via source and target branches