Merge lp:~cjwatson/canonical-identity-provider/py3-print into lp:canonical-identity-provider/release

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: no longer in the source branch.
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~cjwatson/canonical-identity-provider/py3-print
Merge into: lp:canonical-identity-provider/release
Diff against target: 406 lines (+69/-44)
17 files modified
Makefile.db (+3/-3)
acceptance/devices.py (+3/-1)
acceptance/helpers.py (+5/-3)
acceptance/tests/edit/scripts/illegitimate_passwords.py (+4/-2)
acceptance/tests/edit/scripts/valid_change_password.py (+3/-1)
django_project/paths.py (+4/-2)
docs/resources/email.txt (+1/-1)
doctests/openidhelpers.py (+10/-8)
doctests/runner.py (+4/-1)
doctests/stories/api-authentications.txt (+1/-1)
scripts/generate-random-accounts (+6/-4)
src/identityprovider/management/commands/create_test_team.py (+3/-1)
src/identityprovider/management/commands/readonly.py (+3/-1)
src/identityprovider/management/commands/runserver_plus.py (+9/-7)
src/identityprovider/models/captcha.py (+1/-1)
src/mockservice/api-authentications.txt (+5/-5)
src/mockservice/sso_mockserver/mockserver.py (+4/-2)
To merge this branch: bzr merge lp:~cjwatson/canonical-identity-provider/py3-print
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+336641@code.launchpad.net

Commit message

Use Python 3-style print functions.

Description of the change

A tiny step, but might as well.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

LGTM! THanks!

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.db'
2--- Makefile.db 2016-01-05 19:58:16 +0000
3+++ Makefile.db 2018-01-26 00:49:48 +0000
4@@ -1,7 +1,7 @@
5 SHELL_ENV = DJANGO_SETTINGS_MODULE=$(DJANGO_SETTINGS_MODULE) PYTHONPATH=$(PYTHONPATH)
6-PGNAME = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['NAME']")
7-PGHOST = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['HOST']")
8-PGUSER = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print settings.DATABASES['default']['USER']")
9+PGNAME = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print(settings.DATABASES['default']['NAME'])")
10+PGHOST = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print(settings.DATABASES['default']['HOST'])")
11+PGUSER = $(shell $(SHELL_ENV) $(PYTHON) -c "from django.conf import settings; print(settings.DATABASES['default']['USER'])")
12 DATA_DIR = $(PGHOST)/data
13 LOG_FILE = $(PGHOST)/postgresql.log
14 CONF_FILE = $(PGHOST)/postgresql.conf
15
16=== modified file 'acceptance/devices.py'
17--- acceptance/devices.py 2013-08-01 22:31:12 +0000
18+++ acceptance/devices.py 2018-01-26 00:49:48 +0000
19@@ -1,3 +1,5 @@
20+from __future__ import print_function
21+
22 import re
23 from base64 import b32decode
24 from urlparse import urlparse, parse_qs
25@@ -149,7 +151,7 @@
26 go_to(urls.DEVICES)
27 # Fetch the name of the device we will be deleting
28 name = get_elements_by_css('#device-list td.name')[0].text
29- print 'Deleting a device:', name
30+ print('Deleting a device:', name)
31 # Click on the delete button
32 click_delete_button()
33
34
35=== modified file 'acceptance/helpers.py'
36--- acceptance/helpers.py 2016-04-08 14:07:27 +0000
37+++ acceptance/helpers.py 2018-01-26 00:49:48 +0000
38@@ -1,3 +1,5 @@
39+from __future__ import print_function
40+
41 from urllib import quote
42
43 import u1testutils.sso.sst.pages
44@@ -102,19 +104,19 @@
45 def skip_unless_staging_or_production():
46 """Skip a test if not running against staging or production."""
47 if not (is_staging() or is_production()):
48- print "This test can only be run against staging or production."
49+ print("This test can only be run against staging or production.")
50 skip()
51
52
53 def skip_production():
54 if is_production():
55- print 'This test should not run against production.'
56+ print('This test should not run against production.')
57 skip()
58
59
60 def production_only():
61 if not is_production():
62- print 'This is a test only for Production.'
63+ print('This is a test only for Production.')
64 skip()
65
66
67
68=== modified file 'acceptance/tests/edit/scripts/illegitimate_passwords.py'
69--- acceptance/tests/edit/scripts/illegitimate_passwords.py 2016-04-07 16:03:13 +0000
70+++ acceptance/tests/edit/scripts/illegitimate_passwords.py 2018-01-26 00:49:48 +0000
71@@ -3,6 +3,8 @@
72 # rules:
73 # Password must be at least 8 characters long.
74
75+from __future__ import print_function
76+
77 from sst.actions import (
78 assert_element,
79 assert_text,
80@@ -27,7 +29,7 @@
81
82 wait_for(assert_element, **edit_account_anchor)
83
84-print 'password: %s\nconfirm: %s' % (password, passwordconfirm)
85+print('password: %s\nconfirm: %s' % (password, passwordconfirm))
86
87 write_textfield('id_password', password)
88 write_textfield('id_passwordconfirm', passwordconfirm)
89@@ -43,5 +45,5 @@
90 elif error == 'good':
91 fails(get_elements, css_class='error')
92 else:
93- print 'Unknown error type "%s"' % error
94+ print('Unknown error type "%s"' % error)
95 assert False
96
97=== modified file 'acceptance/tests/edit/scripts/valid_change_password.py'
98--- acceptance/tests/edit/scripts/valid_change_password.py 2013-06-28 15:28:46 +0000
99+++ acceptance/tests/edit/scripts/valid_change_password.py 2018-01-26 00:49:48 +0000
100@@ -3,6 +3,8 @@
101 # rules:
102 # Password must be at least 8 characters long.
103
104+from __future__ import print_function
105+
106 from django.conf import settings
107 from sst.actions import (
108 assert_element,
109@@ -23,7 +25,7 @@
110 helpers.login(
111 settings.SSO_TEST_ACCOUNT_EMAIL, settings.SSO_TEST_ACCOUNT_PASSWORD)
112
113-print 'Changing password to', new_password
114+print('Changing password to', new_password)
115 # Change the password on the account and logout
116 write_textfield('id_password', new_password)
117 write_textfield('id_passwordconfirm', new_password)
118
119=== modified file 'django_project/paths.py'
120--- django_project/paths.py 2015-10-09 16:03:29 +0000
121+++ django_project/paths.py 2018-01-26 00:49:48 +0000
122@@ -1,5 +1,7 @@
123 #! /usr/bin/env python
124
125+from __future__ import print_function
126+
127 import sys
128 import os
129
130@@ -36,5 +38,5 @@
131 if __name__ == '__main__':
132 # For use in shell scripting
133 # e.g. $(python paths.py)
134- print "export PYTHONPATH=%s" % ":".join(get_paths(PATHS))
135- print "export DJANGO_SETTINGS_MODULE=settings"
136+ print("export PYTHONPATH=%s" % ":".join(get_paths(PATHS)))
137+ print("export DJANGO_SETTINGS_MODULE=settings")
138
139=== modified file 'docs/resources/email.txt'
140--- docs/resources/email.txt 2015-10-22 17:07:12 +0000
141+++ docs/resources/email.txt 2018-01-26 00:49:48 +0000
142@@ -48,7 +48,7 @@
143 response = requests.get(
144 SSO_API_URL + 'emails/' + email, auth=auth,
145 headers={'Accept': 'application/json'})
146- print response.json()
147+ print(response.json())
148
149 Use cases
150 =========
151
152=== modified file 'doctests/openidhelpers.py'
153--- doctests/openidhelpers.py 2010-04-21 15:29:24 +0000
154+++ doctests/openidhelpers.py 2018-01-26 00:49:48 +0000
155@@ -3,6 +3,8 @@
156
157 """Helpers for OpenID page tests."""
158
159+from __future__ import print_function
160+
161 from openid import fetchers
162 from openid.consumer.discover import (
163 discover, discoverNoYadis,
164@@ -17,17 +19,17 @@
165 claimed_id, services = discoverNoYadis(url)
166 else:
167 claimed_id, services = discover(url)
168- print 'Claimed ID:', claimed_id
169- print '----'
170+ print('Claimed ID:', claimed_id)
171+ print('----')
172 if not services:
173- print 'No services discovered'
174+ print('No services discovered')
175 for service in services:
176- print 'Local ID:', service.getLocalID()
177- print 'Server URL:', service.server_url
178- print 'Supports:'
179+ print('Local ID:', service.getLocalID())
180+ print('Server URL:', service.server_url)
181+ print('Supports:')
182 for type_uri in service.type_uris:
183- print ' ' + type_uri
184- print '----'
185+ print(' ' + type_uri)
186+ print('----')
187
188
189 PublisherFetcher = fetchers.Urllib2Fetcher
190
191=== modified file 'doctests/runner.py'
192--- doctests/runner.py 2013-01-04 19:28:48 +0000
193+++ doctests/runner.py 2018-01-26 00:49:48 +0000
194@@ -1,6 +1,8 @@
195 # Copyright 2010 Canonical Ltd. This software is licensed under the
196 # GNU Affero General Public License version 3 (see the file LICENSE).
197
198+from __future__ import print_function
199+
200 import sys
201 import os
202 import unittest
203@@ -105,7 +107,8 @@
204 else:
205 testfile = args[-1]
206 for f in files(testfile):
207- globs = {'anon_browser': Browser(),
208+ globs = {'print_function': print_function,
209+ 'anon_browser': Browser(),
210 'browser': Browser(),
211 'user_browser': Browser(),
212 'setupBrowser': setupBrowser,
213
214=== modified file 'doctests/stories/api-authentications.txt'
215--- doctests/stories/api-authentications.txt 2016-04-02 01:42:31 +0000
216+++ doctests/stories/api-authentications.txt 2018-01-26 00:49:48 +0000
217@@ -51,7 +51,7 @@
218 ... try:
219 ... exec method_name
220 ... except HTTPError as e:
221- ... print "%s %s" % (method_name, e.response.status)
222+ ... print("%s %s" % (method_name, e.response.status))
223 api.authentications.authenticate 401
224 api.authentications.invalidate_token 401
225 api.authentications.validate_token 401
226
227=== modified file 'scripts/generate-random-accounts'
228--- scripts/generate-random-accounts 2013-05-31 18:47:34 +0000
229+++ scripts/generate-random-accounts 2018-01-26 00:49:48 +0000
230@@ -3,6 +3,8 @@
231 # Copyright 2010 Canonical Ltd. This software is licensed under the
232 # GNU Affero General Public License version 3 (see the file LICENSE).
233
234+from __future__ import print_function
235+
236 import os
237 import sys
238 import random
239@@ -88,14 +90,14 @@
240 if __name__ == '__main__':
241 try:
242 accounts_count = int(sys.argv[1])
243- print "Generating %d accounts" % accounts_count
244+ print("Generating %d accounts" % accounts_count)
245
246 interval = 10 ** (int(math.log10(accounts_count)) - 1)
247 for i in xrange(accounts_count):
248 generate_account()
249 if i > 0 and (i % interval) == 0:
250- print "Created %d accounts" % i
251- print "Created %d accounts" % accounts_count
252+ print("Created %d accounts" % i)
253+ print("Created %d accounts" % accounts_count)
254
255 except (ValueError, IndexError, TypeError):
256- print "Usage: %s number-of-accounts-to-create" % sys.argv[0]
257+ print("Usage: %s number-of-accounts-to-create" % sys.argv[0])
258
259=== modified file 'src/identityprovider/management/commands/create_test_team.py'
260--- src/identityprovider/management/commands/create_test_team.py 2015-07-28 19:34:56 +0000
261+++ src/identityprovider/management/commands/create_test_team.py 2018-01-26 00:49:48 +0000
262@@ -1,3 +1,5 @@
263+from __future__ import print_function
264+
265 from django.core.management.base import BaseCommand
266 from django.conf import settings
267
268@@ -36,7 +38,7 @@
269 person = Person.objects.get(name=name)
270 account = person.account
271 except Person.DoesNotExist:
272- print 'Creating test team and user account.'
273+ print('Creating test team and user account.')
274 account = factory.make_account(fullname, email, password)
275 person = factory.make_person(name=name, account=account)
276 finally:
277
278=== modified file 'src/identityprovider/management/commands/readonly.py'
279--- src/identityprovider/management/commands/readonly.py 2015-02-04 21:35:26 +0000
280+++ src/identityprovider/management/commands/readonly.py 2018-01-26 00:49:48 +0000
281@@ -1,6 +1,8 @@
282 # Copyright 2010 Canonical Ltd. This software is licensed under the
283 # GNU Affero General Public License version 3 (see the file LICENSE).
284
285+from __future__ import print_function
286+
287 from optparse import make_option
288
289 from django.conf import settings
290@@ -66,4 +68,4 @@
291 def show_servers(self):
292 """Provides a report about readonly status of all app servers."""
293 atts = get_server_atts(settings.APP_SERVERS)
294- print loader.render_to_string('admin/readonly.txt', atts)
295+ print(loader.render_to_string('admin/readonly.txt', atts))
296
297=== modified file 'src/identityprovider/management/commands/runserver_plus.py'
298--- src/identityprovider/management/commands/runserver_plus.py 2016-04-02 01:42:31 +0000
299+++ src/identityprovider/management/commands/runserver_plus.py 2018-01-26 00:49:48 +0000
300@@ -1,3 +1,5 @@
301+from __future__ import print_function
302+
303 from optparse import make_option
304
305 import django
306@@ -73,14 +75,14 @@
307
308 def inner_run():
309 from django.conf import settings
310- print "Validating models..."
311+ print("Validating models...")
312 self.validate(display_num_errors=True)
313- print "\nDjango version %s, using settings %r" % (
314- django.get_version(), settings.SETTINGS_MODULE)
315- print "Development server is running at http://%s:%s/" % (
316- addr, port)
317- print "Using the Werkzeug debugger (http://werkzeug.pocoo.org/)"
318- print "Quit the server with CONTROL-C."
319+ print("\nDjango version %s, using settings %r" % (
320+ django.get_version(), settings.SETTINGS_MODULE))
321+ print("Development server is running at http://%s:%s/" % (
322+ addr, port))
323+ print("Using the Werkzeug debugger (http://werkzeug.pocoo.org/)")
324+ print("Quit the server with CONTROL-C.")
325 path = admin_media_path or (django.__path__[0] +
326 '/contrib/admin/media')
327 handler = AdminMediaHandler(WSGIHandler(), path)
328
329=== modified file 'src/identityprovider/models/captcha.py'
330--- src/identityprovider/models/captcha.py 2016-03-10 20:24:54 +0000
331+++ src/identityprovider/models/captcha.py 2018-01-26 00:49:48 +0000
332@@ -150,7 +150,7 @@
333
334 You can also get original response from reCaptcha:
335
336- >>> print captcha.response.data()
337+ >>> print(captcha.response.data())
338 true
339 success
340
341
342=== modified file 'src/mockservice/api-authentications.txt'
343--- src/mockservice/api-authentications.txt 2016-04-02 01:42:31 +0000
344+++ src/mockservice/api-authentications.txt 2018-01-26 00:49:48 +0000
345@@ -43,7 +43,7 @@
346 ... try:
347 ... exec method_name
348 ... except HTTPError as e:
349- ... print "%s %s" % (method_name, e.response.status)
350+ ... print("%s %s" % (method_name, e.response.status))
351 api.authentications.authenticate 401
352 api.authentications.invalidate_token 401
353 api.authentications.validate_token 401
354@@ -73,9 +73,9 @@
355 ... 'api.accounts.validate_email']
356 >>> for method_name in methods:
357 ... try:
358- ... exec 'print ' + method_name
359+ ... exec 'print(%s)' % method_name
360 ... except HTTPError as e:
361- ... print "%s %s" % (method_name, e.response.status)
362+ ... print("%s %s" % (method_name, e.response.status))
363 api.authentications.list_tokens 401
364 api.accounts.me 401
365 api.accounts.validate_email 401
366@@ -113,7 +113,7 @@
367 ... try:
368 ... exec method_name
369 ... except HTTPError as e:
370- ... print "%s %s" % (method_name, e.response.status)
371+ ... print("%s %s" % (method_name, e.response.status))
372 api.authentications.authenticate 401
373 api.authentications.invalidate_token 401
374
375@@ -142,7 +142,7 @@
376 ... try:
377 ... exec method_name
378 ... except HTTPError as e:
379- ... print "%s %s" % (method_name, e.response.status)
380+ ... print("%s %s" % (method_name, e.response.status))
381 api.auathntications.authenticate 401
382 api.accounts.me 401
383 api.accounts.validate_email 401
384
385=== modified file 'src/mockservice/sso_mockserver/mockserver.py'
386--- src/mockservice/sso_mockserver/mockserver.py 2014-12-04 15:33:28 +0000
387+++ src/mockservice/sso_mockserver/mockserver.py 2018-01-26 00:49:48 +0000
388@@ -1,6 +1,8 @@
389 # Copyright 2010 Canonical Ltd. This software is licensed under the
390 # GNU Affero General Public License version 3 (see the file LICENSE).
391
392+from __future__ import print_function
393+
394 import json
395 import os
396 import re
397@@ -374,7 +376,7 @@
398 # is no need nor reason for restoring stderr afterwards
399 sys.stderr = StringIO()
400
401- print "Serving on http://%s:%d%s..." % (httpd.server_name,
402+ print("Serving on http://%s:%d%s..." % (httpd.server_name,
403 httpd.server_port,
404- options.root,)
405+ options.root,))
406 httpd.serve_forever()