Merge lp:~brian.curtin/ubuntu-sso-client/py3-unicode-part-2 into lp:ubuntu-sso-client

Proposed by Brian Curtin on 2012-07-25
Status: Merged
Approved by: dobey on 2012-07-31
Approved revision: 988
Merged at revision: 988
Proposed branch: lp:~brian.curtin/ubuntu-sso-client/py3-unicode-part-2
Merge into: lp:ubuntu-sso-client
Prerequisite: lp:~brian.curtin/ubuntu-sso-client/py3-unicode
Diff against target: 594 lines (+106/-78)
13 files modified
ubuntu_sso/qt/__init__.py (+5/-3)
ubuntu_sso/qt/common.py (+10/-7)
ubuntu_sso/qt/current_user_sign_in_page.py (+12/-9)
ubuntu_sso/qt/email_verification_page.py (+3/-2)
ubuntu_sso/qt/forgotten_password_page.py (+4/-3)
ubuntu_sso/qt/loadingoverlay.py (+3/-1)
ubuntu_sso/qt/main/__init__.py (+3/-3)
ubuntu_sso/qt/main/tests/test_main.py (+3/-2)
ubuntu_sso/qt/proxy_dialog.py (+5/-2)
ubuntu_sso/qt/reset_password_page.py (+12/-9)
ubuntu_sso/qt/setup_account_page.py (+31/-25)
ubuntu_sso/qt/tests/__init__.py (+13/-11)
ubuntu_sso/qt/ubuntu_sso_wizard.py (+2/-1)
To merge this branch: bzr merge lp:~brian.curtin/ubuntu-sso-client/py3-unicode-part-2
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve on 2012-07-31
Alejandro J. Cura (community) 2012-07-25 Approve on 2012-07-30
Review via email: mp+116764@code.launchpad.net

Commit Message

The second of three changes to prepare SSO for Python 3 Unicode usage.

Description of the Change

The second of three branches to prepare for Python 3's Unicode usage. This merge proposal mostly contains changes from unicode construction to the compat.text_type wrapper. There are a few StringIO changes, and only a few changes to Unicode literals. It is a follow-up to lp:~brian.curtin/ubuntu-sso-client/py3-unicode

This change covers modules in the following packages:
ubuntu_sso.qt
ubuntu_sso.main

To post a comment you must log in.
Alejandro J. Cura (alecu) wrote :

Code looks fine, and all tests pass.
While trying to test it IRL I get stuck with the progress dialog when creating a new account; but since this currently happens with both trunk and nightlies, it looks like it's not a problem with this code.

review: Approve
Mike McCracken (mikemc) wrote :

Tests pass, but IRL on darwin the captcha fails to work because it needs to use io.BytesIO instead of io.StringIO in ubuntu_sso/qt/setup_account_page.py

With that tweak, everything works for me.

Here's the traceback, for reference:
  File "/Users/mmccrack/Documents/Canonical/Source/ubuntuone-windows-installer/scripts/devsetup/parts/sso-client-py3-unicode/ubuntu_sso/qt/setup_account_page.py", line 333, in on_captcha_generated
    pil_image.save(string_io, format='png')
  File "/Users/mmccrack/Documents/Canonical/Source/ubuntuone-windows-installer/scripts/devsetup/eggs/PIL-1.1.7-py2.7-macosx-10.7-intel.egg/Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "/Users/mmccrack/Documents/Canonical/Source/ubuntuone-windows-installer/scripts/devsetup/eggs/PIL-1.1.7-py2.7-macosx-10.7-intel.egg/PngImagePlugin.py", line 514, in _save
    fp.write(_MAGIC)
exceptions.TypeError: string argument expected, got 'str'

review: Needs Fixing
Mike McCracken (mikemc) wrote :

per discussion in IRC, we'll fix the stringIO thing in a separate branch

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/__init__.py'
2--- ubuntu_sso/qt/__init__.py 2012-06-27 19:03:44 +0000
3+++ ubuntu_sso/qt/__init__.py 2012-07-30 18:07:25 +0000
4@@ -28,6 +28,8 @@
5 # files in the program, then also delete it here.
6 """The Qt graphical interface for the Ubuntu Single Sign On Client."""
7
8+from __future__ import unicode_literals
9+
10 import sys
11 import collections
12
13@@ -38,13 +40,13 @@
14
15 logger = setup_gui_logging('ubuntu_sso.qt')
16
17-LINK_STYLE = (u'<a href="{link_url}">'
18+LINK_STYLE = ('<a href="{link_url}">'
19 '<span style="color:#df2d1f;">{link_text}</span></a>')
20 ERROR_ALL = '__all__'
21-ERROR_STYLE = u'<font color="#df2d1f" style="font-size:small"><b>%s</b></font>'
22+ERROR_STYLE = '<font color="#df2d1f" style="font-size:small"><b>%s</b></font>'
23 ERROR_MESSAGE = 'message'
24 PREFERED_UI_SIZE = {'width': 550, 'height': 525}
25-TITLE_STYLE = u'<span style="font-size:xx-large;font-weight:bold;">%s</span>'
26+TITLE_STYLE = '<span style="font-size:xx-large;font-weight:bold;">%s</span>'
27 WINDOW_TITLE = 'Ubuntu Single Sign On'
28
29 # TODO: There is a pixel discrepancy between Qt on Linux and Windows
30
31=== modified file 'ubuntu_sso/qt/common.py'
32--- ubuntu_sso/qt/common.py 2012-04-09 17:38:24 +0000
33+++ ubuntu_sso/qt/common.py 2012-07-30 18:07:25 +0000
34@@ -30,8 +30,11 @@
35 # files in the program, then also delete it here.
36 """Common functionality used by the UI modules."""
37
38+from __future__ import unicode_literals
39+
40 import re
41
42+from ubuntu_sso.utils import compat
43 from ubuntu_sso.utils.ui import (
44 PASSWORD_DIGIT,
45 PASSWORD_LENGTH,
46@@ -41,14 +44,14 @@
47 )
48
49 # all the text + styles that are used in the gui
50-BAD = u'<img src=":/password_hint_warning.png" /><small> %s </small>'
51-GOOD = u'<img src=":/password_hint_ok.png" /><small> %s </small>'
52-NORMAL = u'<small> %s </small>'
53+BAD = '<img src=":/password_hint_warning.png" /><small> %s </small>'
54+GOOD = '<img src=":/password_hint_ok.png" /><small> %s </small>'
55+NORMAL = '<small> %s </small>'
56
57
58 def password_assistance(line_edit, assistance, icon_type=BAD):
59 """Show help for the password field."""
60- text1 = unicode(line_edit.text())
61+ text1 = compat.text_type(line_edit.text())
62 label_text = ["<b>%s</b>" % PASSWORD_MUST_CONTAIN, ]
63
64 if len(text1) < 8:
65@@ -75,9 +78,9 @@
66 def password_check_match(line_edit, line_edit_confirm, assistance):
67 """Check if passwords match, otherwise show a message."""
68 password_assistance(line_edit, assistance)
69- label_text = unicode(assistance.text())
70- text1 = unicode(line_edit.text())
71- text2 = unicode(line_edit_confirm.text())
72+ label_text = compat.text_type(assistance.text())
73+ text1 = compat.text_type(line_edit.text())
74+ text2 = compat.text_type(line_edit_confirm.text())
75 if text1 != text2:
76 label_text += "<br>" + BAD % PASSWORD_MATCH
77 assistance.setText(label_text)
78
79=== modified file 'ubuntu_sso/qt/current_user_sign_in_page.py'
80--- ubuntu_sso/qt/current_user_sign_in_page.py 2012-06-08 13:33:39 +0000
81+++ ubuntu_sso/qt/current_user_sign_in_page.py 2012-07-30 18:07:25 +0000
82@@ -37,6 +37,7 @@
83 from ubuntu_sso.qt import LINK_STYLE, build_general_error_message
84 from ubuntu_sso.qt.sso_wizard_page import SSOWizardPage
85 from ubuntu_sso.qt.ui.current_user_sign_in_ui import Ui_CurrentUserSignInPage
86+from ubuntu_sso.utils import compat
87 from ubuntu_sso.utils.ui import (
88 CANCEL_BUTTON,
89 EMAIL_LABEL,
90@@ -56,9 +57,9 @@
91 """Wizard Page that lets a current user Sign into Ubuntu Single Sign On."""
92
93 ui_class = Ui_CurrentUserSignInPage
94- userLoggedIn = QtCore.pyqtSignal(unicode)
95+ userLoggedIn = QtCore.pyqtSignal(compat.text_type)
96 passwordForgotten = QtCore.pyqtSignal()
97- userNotValidated = QtCore.pyqtSignal(unicode)
98+ userNotValidated = QtCore.pyqtSignal(compat.text_type)
99
100 @property
101 def _signals(self):
102@@ -76,12 +77,12 @@
103 @property
104 def password(self):
105 """Return the content of the password edit."""
106- return unicode(self.ui.password_edit.text())
107+ return compat.text_type(self.ui.password_edit.text())
108
109 def on_user_not_validated(self, app_name, email):
110 """Show the validate email page."""
111 self.hide_overlay()
112- email = unicode(self.ui.email_edit.text())
113+ email = compat.text_type(self.ui.email_edit.text())
114 self.userNotValidated.emit(email)
115
116 # Invalid names of Qt-inherited methods
117@@ -129,17 +130,19 @@
118
119 def _validate(self):
120 """Perform input validation."""
121- correct_mail = is_correct_email(unicode(self.ui.email_edit.text()))
122- correct_password = len(unicode(self.ui.password_edit.text())) > 0
123+ correct_mail = is_correct_email(
124+ compat.text_type(self.ui.email_edit.text()))
125+ correct_password = len(
126+ compat.text_type(self.ui.password_edit.text())) > 0
127 enabled = correct_mail and correct_password
128 self.ui.sign_in_button.setEnabled(enabled)
129
130 def login(self):
131 """Perform the login using the self.backend."""
132 # grab the data from the view and call the backend
133- email = unicode(self.ui.email_edit.text())
134+ email = compat.text_type(self.ui.email_edit.text())
135 logger.info('CurrentUserSignInPage.login for: %s', email)
136- password = unicode(self.ui.password_edit.text())
137+ password = compat.text_type(self.ui.password_edit.text())
138 args = (self.app_name, email, password)
139 if self.ping_url:
140 f = self.backend.login_and_ping
141@@ -163,7 +166,7 @@
142 """We managed to log in."""
143 logger.info('Logged in for %s', app_name)
144 self.hide_overlay()
145- email = unicode(self.ui.email_edit.text())
146+ email = compat.text_type(self.ui.email_edit.text())
147 logger.debug('About to emit userLoggedIn signal with: (%s).', email)
148 self.userLoggedIn.emit(email)
149
150
151=== modified file 'ubuntu_sso/qt/email_verification_page.py'
152--- ubuntu_sso/qt/email_verification_page.py 2012-04-09 17:38:24 +0000
153+++ ubuntu_sso/qt/email_verification_page.py 2012-07-30 18:07:25 +0000
154@@ -37,6 +37,7 @@
155 from ubuntu_sso.qt import build_general_error_message
156 from ubuntu_sso.qt.sso_wizard_page import SSOWizardPage
157 from ubuntu_sso.qt.ui.email_verification_ui import Ui_EmailVerificationPage
158+from ubuntu_sso.utils import compat
159 from ubuntu_sso.utils.ui import (
160 ERROR_EMAIL_TOKEN,
161 NEXT,
162@@ -53,7 +54,7 @@
163 """Widget used to input the email verification code."""
164
165 ui_class = Ui_EmailVerificationPage
166- registrationSuccess = QtCore.pyqtSignal(unicode)
167+ registrationSuccess = QtCore.pyqtSignal(compat.text_type)
168
169 def __init__(self, *args, **kwargs):
170 self.email = ''
171@@ -115,7 +116,7 @@
172 """Call the next action."""
173 logger.debug('EmailVerificationController.validate_email for: %s',
174 self.email)
175- code = unicode(self.ui.verification_code_edit.text())
176+ code = compat.text_type(self.ui.verification_code_edit.text())
177 args = (self.app_name, self.email, self.password, code)
178 self.hide_error()
179 self.show_overlay()
180
181=== modified file 'ubuntu_sso/qt/forgotten_password_page.py'
182--- ubuntu_sso/qt/forgotten_password_page.py 2012-04-09 17:38:24 +0000
183+++ ubuntu_sso/qt/forgotten_password_page.py 2012-07-30 18:07:25 +0000
184@@ -36,6 +36,7 @@
185 from ubuntu_sso.logger import setup_gui_logging, log_call
186 from ubuntu_sso.qt.sso_wizard_page import SSOWizardEnhancedEditPage
187 from ubuntu_sso.qt.ui.forgotten_password_ui import Ui_ForgottenPasswordPage
188+from ubuntu_sso.utils import compat
189 from ubuntu_sso.utils.ui import (
190 EMAIL_LABEL,
191 FORGOTTEN_PASSWORD_TITLE,
192@@ -53,7 +54,7 @@
193 """Widget used to deal with users that forgot the password."""
194
195 ui_class = Ui_ForgottenPasswordPage
196- passwordResetTokenSent = QtCore.pyqtSignal(unicode)
197+ passwordResetTokenSent = QtCore.pyqtSignal(compat.text_type)
198
199 @property
200 def _signals(self):
201@@ -69,7 +70,7 @@
202 @property
203 def email_address(self):
204 """Return the email address provided by the user."""
205- return unicode(self.ui.email_line_edit.text())
206+ return compat.text_type(self.ui.email_line_edit.text())
207
208 #pylint: disable=C0103
209
210@@ -122,7 +123,7 @@
211
212 def _validate(self):
213 """Validate that we have an email."""
214- email = unicode(self.ui.email_line_edit.text())
215+ email = compat.text_type(self.ui.email_line_edit.text())
216 self.ui.send_button.setEnabled(is_correct_email(email))
217
218 def on_password_reset_token_sent(self, app_name, email):
219
220=== modified file 'ubuntu_sso/qt/loadingoverlay.py'
221--- ubuntu_sso/qt/loadingoverlay.py 2012-06-22 22:34:43 +0000
222+++ ubuntu_sso/qt/loadingoverlay.py 2012-07-30 18:07:25 +0000
223@@ -28,12 +28,14 @@
224 # files in the program, then also delete it here.
225 """Loading animation over a widget."""
226
227+from __future__ import unicode_literals
228+
229 from PyQt4 import QtGui, QtCore
230
231 from ubuntu_sso.qt.ui import loadingoverlay_ui
232 from ubuntu_sso.utils.ui import LOADING_OVERLAY
233
234-LOADING_STYLE = u'<span style="font-size:x-large;">{0}</span>'
235+LOADING_STYLE = '<span style="font-size:x-large;">{0}</span>'
236
237
238 class LoadingOverlay(QtGui.QFrame):
239
240=== modified file 'ubuntu_sso/qt/main/__init__.py'
241--- ubuntu_sso/qt/main/__init__.py 2012-06-13 21:26:02 +0000
242+++ ubuntu_sso/qt/main/__init__.py 2012-07-30 18:07:25 +0000
243@@ -38,7 +38,7 @@
244 from ubuntu_sso.qt.ui import resources_rc
245 # pylint: enable=W0611
246 from ubuntu_sso.qt.ubuntu_sso_wizard import UbuntuSSOClientGUI
247-from ubuntu_sso.utils import PLATFORM_QSS
248+from ubuntu_sso.utils import compat, PLATFORM_QSS
249
250
251 # Invalid name "source", pylint: disable=C0103
252@@ -63,13 +63,13 @@
253 data = []
254 for qss_name in (PLATFORM_QSS, ":/stylesheet.qss"):
255 qss = QtCore.QResource(qss_name)
256- data.append(unicode(qss.data()))
257+ data.append(compat.text_type(qss.data()))
258 app.setStyleSheet('\n'.join(data))
259
260 # Fix the string that contains unicode chars.
261 for key in kwargs:
262 value = kwargs[key]
263- if isinstance(value, str):
264+ if isinstance(value, compat.binary_type):
265 kwargs[key] = value.decode('utf-8')
266
267 # Unused variable 'ui', pylint: disable=W0612
268
269=== modified file 'ubuntu_sso/qt/main/tests/test_main.py'
270--- ubuntu_sso/qt/main/tests/test_main.py 2012-06-13 21:52:42 +0000
271+++ ubuntu_sso/qt/main/tests/test_main.py 2012-07-30 18:07:25 +0000
272@@ -37,6 +37,7 @@
273 from twisted.trial.unittest import TestCase
274
275 from ubuntu_sso.qt import main
276+from ubuntu_sso.utils import compat
277 from ubuntu_sso import tests
278
279
280@@ -205,7 +206,7 @@
281 data = []
282 for qss_name in (main.PLATFORM_QSS, ":/stylesheet.qss"):
283 qss = QtCore.QResource(qss_name)
284- data.append(unicode(qss.data()))
285+ data.append(compat.text_type(qss.data()))
286 self.assertEqual(
287- unicode(main.QtGui.QApplication.instance().styleSheet()),
288+ compat.text_type(main.QtGui.QApplication.instance().styleSheet()),
289 '\n'.join(data))
290
291=== modified file 'ubuntu_sso/qt/proxy_dialog.py'
292--- ubuntu_sso/qt/proxy_dialog.py 2012-06-22 16:12:03 +0000
293+++ ubuntu_sso/qt/proxy_dialog.py 2012-07-30 18:07:25 +0000
294@@ -38,6 +38,7 @@
295 from ubuntu_sso.logger import setup_gui_logging
296 from ubuntu_sso.keyring import Keyring
297 from ubuntu_sso.qt.ui.proxy_credentials_dialog_ui import Ui_ProxyCredsDialog
298+from ubuntu_sso.utils import compat
299 from ubuntu_sso.utils.ui import (
300 CANCEL_BUTTON,
301 PROXY_CREDS_DIALOG_TITLE,
302@@ -109,8 +110,10 @@
303 @defer.inlineCallbacks
304 def _on_save_clicked(self, *args):
305 """Save the new credentials."""
306- username = unicode(self.ui.username_entry.text()).encode('utf8')
307- password = unicode(self.ui.password_entry.text()).encode('utf8')
308+ username = compat.text_type(
309+ self.ui.username_entry.text()).encode('utf8')
310+ password = compat.text_type(
311+ self.ui.password_entry.text()).encode('utf8')
312 creds = dict(username=username, password=password)
313 # pylint: disable=W0703, W0612
314 try:
315
316=== modified file 'ubuntu_sso/qt/reset_password_page.py'
317--- ubuntu_sso/qt/reset_password_page.py 2012-04-09 17:38:24 +0000
318+++ ubuntu_sso/qt/reset_password_page.py 2012-07-30 18:07:25 +0000
319@@ -38,6 +38,7 @@
320 from ubuntu_sso.qt import build_general_error_message, common
321 from ubuntu_sso.qt.sso_wizard_page import SSOWizardEnhancedEditPage
322 from ubuntu_sso.qt.ui.reset_password_ui import Ui_ResetPasswordPage
323+from ubuntu_sso.utils import compat
324 from ubuntu_sso.utils.ui import (
325 is_min_required_password,
326 PASSWORD1_ENTRY,
327@@ -57,7 +58,7 @@
328 """Widget used to allow the user change his password."""
329
330 ui_class = Ui_ResetPasswordPage
331- passwordChanged = pyqtSignal(unicode)
332+ passwordChanged = pyqtSignal(compat.text_type)
333
334 @property
335 def _signals(self):
336@@ -146,9 +147,9 @@
337 def _validate(self):
338 """Enable the submit button if data is valid."""
339 enabled = True
340- code = unicode(self.ui.reset_code_line_edit.text())
341- password = unicode(self.ui.password_line_edit.text())
342- confirm_password = unicode(
343+ code = compat.text_type(self.ui.reset_code_line_edit.text())
344+ password = compat.text_type(self.ui.password_line_edit.text())
345+ confirm_password = compat.text_type(
346 self.ui.confirm_password_line_edit.text())
347 if not is_min_required_password(password):
348 enabled = False
349@@ -175,7 +176,8 @@
350 logger.info('ResetPasswordPage.on_password_changed for %s, email: %s',
351 app_name, email)
352 self.hide_overlay()
353- email = unicode(self.wizard().forgotten.ui.email_line_edit.text())
354+ email = compat.text_type(
355+ self.wizard().forgotten.ui.email_line_edit.text())
356 self.passwordChanged.emit(email)
357
358 def on_password_change_error(self, app_name, error):
359@@ -187,9 +189,10 @@
360 def set_new_password(self):
361 """Request a new password to be set."""
362 self.hide_error()
363- email = unicode(self.wizard().forgotten.ui.email_line_edit.text())
364- code = unicode(self.ui.reset_code_line_edit.text())
365- password = unicode(self.ui.password_line_edit.text())
366+ email = compat.text_type(
367+ self.wizard().forgotten.ui.email_line_edit.text())
368+ code = compat.text_type(self.ui.reset_code_line_edit.text())
369+ password = compat.text_type(self.ui.password_line_edit.text())
370 logger.info('Setting new password for %r and email %r with code %r',
371 self.app_name, email, code)
372 args = (self.app_name, email, code, password)
373@@ -201,4 +204,4 @@
374
375 def is_correct_password_confirmation(self, password):
376 """Return if the password is correct."""
377- return unicode(self.ui.password_line_edit.text()) == password
378+ return compat.text_type(self.ui.password_line_edit.text()) == password
379
380=== modified file 'ubuntu_sso/qt/setup_account_page.py'
381--- ubuntu_sso/qt/setup_account_page.py 2012-07-03 21:30:33 +0000
382+++ ubuntu_sso/qt/setup_account_page.py 2012-07-30 18:07:25 +0000
383@@ -53,6 +53,7 @@
384 )
385 from ubuntu_sso.qt.sso_wizard_page import SSOWizardEnhancedEditPage
386 from ubuntu_sso.qt.ui.setup_account_ui import Ui_SetUpAccountPage
387+from ubuntu_sso.utils import compat
388 from ubuntu_sso.utils.ui import (
389 AGREE_TO_PRIVACY_POLICY,
390 AGREE_TO_TERMS,
391@@ -99,7 +100,7 @@
392 """Customized Setup Account page for SSO."""
393
394 ui_class = Ui_SetUpAccountPage
395- userRegistered = QtCore.pyqtSignal(unicode)
396+ userRegistered = QtCore.pyqtSignal(compat.text_type)
397
398 def __init__(self, *args, **kwargs):
399 self.captcha_file = None
400@@ -127,7 +128,7 @@
401 @property
402 def password(self):
403 """Return the content of the password edit."""
404- return unicode(self.ui.password_edit.text())
405+ return compat.text_type(self.ui.password_edit.text())
406
407 # Invalid name "initializePage"
408 # pylint: disable=C0103
409@@ -263,12 +264,14 @@
410
411 def _enable_setup_button(self):
412 """Only enable the setup button if the form is valid."""
413- name = unicode(self.ui.name_edit.text()).strip()
414- email = unicode(self.ui.email_edit.text())
415- confirm_email = unicode(self.ui.confirm_email_edit.text())
416- password = unicode(self.ui.password_edit.text())
417- confirm_password = unicode(self.ui.confirm_password_edit.text())
418- captcha_solution = unicode(self.ui.captcha_solution_edit.text())
419+ name = compat.text_type(self.ui.name_edit.text()).strip()
420+ email = compat.text_type(self.ui.email_edit.text())
421+ confirm_email = compat.text_type(self.ui.confirm_email_edit.text())
422+ password = compat.text_type(self.ui.password_edit.text())
423+ confirm_password = compat.text_type(
424+ self.ui.confirm_password_edit.text())
425+ captcha_solution = compat.text_type(
426+ self.ui.captcha_solution_edit.text())
427
428 # Check for len(name) > 0 to ensure that a bool is assigned to enabled
429 if not self.terms_checkbox.isVisible():
430@@ -355,18 +358,20 @@
431 def on_user_registered(self, app_name, email):
432 """Execute when the user did register."""
433 self.hide_overlay()
434- email = unicode(self.ui.email_edit.text())
435+ email = compat.text_type(self.ui.email_edit.text())
436 self.userRegistered.emit(email)
437
438 def validate_form(self):
439 """Validate the info of the form and return an error."""
440 logger.debug('SetUpAccountPage.validate_form')
441- name = unicode(self.ui.name_edit.text()).strip()
442- email = unicode(self.ui.email_edit.text())
443- confirm_email = unicode(self.ui.confirm_email_edit.text())
444- password = unicode(self.ui.password_edit.text())
445- confirm_password = unicode(self.ui.confirm_password_edit.text())
446- captcha_solution = unicode(self.ui.captcha_solution_edit.text())
447+ name = compat.text_type(self.ui.name_edit.text()).strip()
448+ email = compat.text_type(self.ui.email_edit.text())
449+ confirm_email = compat.text_type(self.ui.confirm_email_edit.text())
450+ password = compat.text_type(self.ui.password_edit.text())
451+ confirm_password = compat.text_type(
452+ self.ui.confirm_password_edit.text())
453+ captcha_solution = compat.text_type(
454+ self.ui.captcha_solution_edit.text())
455 condition = True
456 messages = []
457 if not name:
458@@ -395,11 +400,12 @@
459 def set_next_validation(self):
460 """Set the validation as the next page."""
461 logger.debug('SetUpAccountPage.set_next_validation')
462- email = unicode(self.ui.email_edit.text())
463- password = unicode(self.ui.password_edit.text())
464- name = unicode(self.ui.name_edit.text())
465+ email = compat.text_type(self.ui.email_edit.text())
466+ password = compat.text_type(self.ui.password_edit.text())
467+ name = compat.text_type(self.ui.name_edit.text())
468 captcha_id = self.captcha_id
469- captcha_solution = unicode(self.ui.captcha_solution_edit.text())
470+ captcha_solution = compat.text_type(
471+ self.ui.captcha_solution_edit.text())
472 # validate the current info of the form, try to perform the action
473 # to register the user, and then move foward
474 if self.validate_form():
475@@ -418,11 +424,11 @@
476
477 def is_correct_email_confirmation(self, email_address):
478 """Return that the email is the same."""
479- return unicode(self.ui.email_edit.text()) == email_address
480+ return compat.text_type(self.ui.email_edit.text()) == email_address
481
482 def is_correct_password_confirmation(self, password):
483 """Return that the passwords are correct."""
484- return unicode(self.ui.password_edit.text()) == password
485+ return compat.text_type(self.ui.password_edit.text()) == password
486
487 def focus_changed(self, old, now):
488 """Check who has the focus to activate password popups if necessary."""
489@@ -441,7 +447,7 @@
490
491 def name_assistance(self):
492 """Show help for the name field."""
493- text = unicode(self.ui.name_edit.text())
494+ text = compat.text_type(self.ui.name_edit.text())
495 if not text.strip():
496 self.set_error_message(self.ui.name_assistance,
497 EMPTY_NAME)
498@@ -452,7 +458,7 @@
499
500 def email_assistance(self):
501 """Show help for the email field."""
502- text = unicode(self.ui.email_edit.text())
503+ text = compat.text_type(self.ui.email_edit.text())
504 if not is_correct_email(text):
505 self.set_error_message(self.ui.email_assistance,
506 INVALID_EMAIL)
507@@ -463,8 +469,8 @@
508
509 def confirm_email_assistance(self):
510 """Show help for the confirm email field."""
511- text1 = unicode(self.ui.email_edit.text())
512- text2 = unicode(self.ui.confirm_email_edit.text())
513+ text1 = compat.text_type(self.ui.email_edit.text())
514+ text2 = compat.text_type(self.ui.confirm_email_edit.text())
515 if text1 != text2:
516 self.set_error_message(self.ui.confirm_email_assistance,
517 EMAIL_MATCH)
518
519=== modified file 'ubuntu_sso/qt/tests/__init__.py'
520--- ubuntu_sso/qt/tests/__init__.py 2012-04-09 17:38:24 +0000
521+++ ubuntu_sso/qt/tests/__init__.py 2012-07-30 18:07:25 +0000
522@@ -42,6 +42,7 @@
523 TC_URL,
524 WINDOW_ID,
525 )
526+from ubuntu_sso.utils import compat
527
528 KWARGS = dict(app_name=APP_NAME, help_text=HELP_TEXT, ping_url=PING_URL,
529 policy_url=POLICY_URL, tc_url=TC_URL, window_id=WINDOW_ID)
530@@ -498,10 +499,10 @@
531 label = QtGui.QLabel()
532 maybe_elide_text(label, expected, max_width)
533
534- self.assertEqual(TITLE_STYLE % unicode(label.text()),
535- unicode(title_label.text()))
536- self.assertEqual(unicode(label.toolTip()),
537- unicode(title_label.toolTip()))
538+ self.assertEqual(TITLE_STYLE % compat.text_type(label.text()),
539+ compat.text_type(title_label.text()))
540+ self.assertEqual(compat.text_type(label.toolTip()),
541+ compat.text_type(title_label.toolTip()))
542 self.assertTrue(title_label.isVisible())
543
544 def assert_subtitle_correct(self, subtitle_label, expected, max_width):
545@@ -509,9 +510,10 @@
546 label = QtGui.QLabel()
547 maybe_elide_text(label, expected, max_width)
548
549- self.assertEqual(unicode(label.text()), unicode(subtitle_label.text()))
550- self.assertEqual(unicode(label.toolTip()),
551- unicode(subtitle_label.toolTip()))
552+ self.assertEqual(compat.text_type(label.text()),
553+ compat.text_type(subtitle_label.text()))
554+ self.assertEqual(compat.text_type(label.toolTip()),
555+ compat.text_type(subtitle_label.toolTip()))
556 self.assertTrue(subtitle_label.isVisible())
557
558 def assert_error_correct(self, error_label, expected, max_width):
559@@ -519,10 +521,10 @@
560 label = QtGui.QLabel()
561 maybe_elide_text(label, expected, max_width)
562
563- self.assertEqual(ERROR_STYLE % unicode(label.text()),
564- unicode(error_label.text()))
565- self.assertEqual(unicode(label.toolTip()),
566- unicode(error_label.toolTip()))
567+ self.assertEqual(ERROR_STYLE % compat.text_type(label.text()),
568+ compat.text_type(error_label.text()))
569+ self.assertEqual(compat.text_type(label.toolTip()),
570+ compat.text_type(error_label.toolTip()))
571 self.assertTrue(error_label.isVisible())
572
573 def get_pixmap_data(self, pixmap):
574
575=== modified file 'ubuntu_sso/qt/ubuntu_sso_wizard.py'
576--- ubuntu_sso/qt/ubuntu_sso_wizard.py 2012-05-25 13:51:31 +0000
577+++ ubuntu_sso/qt/ubuntu_sso_wizard.py 2012-07-30 18:07:25 +0000
578@@ -44,6 +44,7 @@
579 USER_SUCCESS,
580 )
581 from ubuntu_sso.logger import setup_gui_logging
582+from ubuntu_sso.utils import compat
583 from ubuntu_sso.qt import PREFERED_UI_SIZE, WINDOW_TITLE
584 from ubuntu_sso.qt.current_user_sign_in_page import CurrentUserSignInPage
585 from ubuntu_sso.qt.email_verification_page import EmailVerificationPage
586@@ -203,7 +204,7 @@
587 logger.debug('Moving to EmailVerificationPage from: %s',
588 self.currentPage())
589 self._next_id = self.email_verification_page_id
590- self.email_verification.email = unicode(email)
591+ self.email_verification.email = compat.text_type(email)
592 self.email_verification.password = self.currentPage().password
593 self.next()
594 self._next_id = -1

Subscribers

People subscribed via source and target branches