Merge lp:~brian.curtin/ubuntu-sso-client/py3-exceptions into lp:ubuntu-sso-client

Proposed by Brian Curtin on 2012-06-22
Status: Merged
Approved by: dobey on 2012-06-22
Approved revision: 975
Merged at revision: 974
Proposed branch: lp:~brian.curtin/ubuntu-sso-client/py3-exceptions
Merge into: lp:ubuntu-sso-client
Diff against target: 216 lines (+19/-19)
14 files modified
ubuntu_sso/account.py (+2/-2)
ubuntu_sso/networkstate/darwin.py (+1/-1)
ubuntu_sso/networkstate/linux.py (+2/-2)
ubuntu_sso/networkstate/windows.py (+1/-1)
ubuntu_sso/qt/proxy_dialog.py (+1/-1)
ubuntu_sso/utils/__init__.py (+1/-1)
ubuntu_sso/utils/runner/glib.py (+1/-1)
ubuntu_sso/utils/runner/tests/test_glib.py (+1/-1)
ubuntu_sso/utils/runner/tests/test_qt.py (+2/-2)
ubuntu_sso/utils/runner/tx.py (+2/-2)
ubuntu_sso/utils/txsecrets.py (+1/-1)
ubuntu_sso/utils/webclient/common.py (+2/-2)
ubuntu_sso/utils/webclient/qtnetwork.py (+1/-1)
ubuntu_sso/utils/webclient/timestamp.py (+1/-1)
To merge this branch: bzr merge lp:~brian.curtin/ubuntu-sso-client/py3-exceptions
Reviewer Review Type Date Requested Status
dobey (community) Approve on 2012-06-22
Roberto Alsina (community) 2012-06-22 Approve on 2012-06-22
Review via email: mp+111637@code.launchpad.net

Commit message

Use Python 3 style exception handling syntax.

Description of the change

Convert remaining usage of exception handling in the form "except Exception, e" to the format introduced in Python 3 and backported to 2.6, "except Exception as e". The latter format is already used almost everywhere in the codebase, but several places used the old format.

To post a comment you must log in.
Roberto Alsina (ralsina) :
review: Approve
973. By dobey on 2012-06-22

Remove the xdg_base_directory module as it duplicates dirspec now

dobey (dobey) wrote :

Can we have bugs for these py3 related issues?

review: Needs Information
974. By Brian Curtin on 2012-06-22

Merge bzr merge lp:~brian.curtin/ubuntu-sso-client/py3-exceptions

975. By Brian Curtin on 2012-06-22

Tag #1016711

dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/account.py'
2--- ubuntu_sso/account.py 2012-06-22 16:55:35 +0000
3+++ ubuntu_sso/account.py 2012-06-22 20:08:18 +0000
4@@ -249,7 +249,7 @@
5 try:
6 operation = u"registration.request_password_reset_token"
7 result = yield restful_client.restcall(operation, email=email)
8- except WebClientError, e:
9+ except WebClientError as e:
10 logger.exception('request_password_reset_token failed with:')
11 raise ResetPasswordTokenError(e[1].split('\n')[0])
12 finally:
13@@ -275,7 +275,7 @@
14 u"registration.set_new_password",
15 email=email, token=token,
16 new_password=new_password)
17- except WebClientError, e:
18+ except WebClientError as e:
19 logger.exception('set_new_password failed with:')
20 raise NewPasswordError(e[1].split('\n')[0])
21 finally:
22
23=== modified file 'ubuntu_sso/networkstate/darwin.py'
24--- ubuntu_sso/networkstate/darwin.py 2012-06-22 16:55:35 +0000
25+++ ubuntu_sso/networkstate/darwin.py 2012-06-22 20:08:18 +0000
26@@ -298,6 +298,6 @@
27 """
28 try:
29 return defer.succeed(check_connected_state())
30- except Exception, e: # pylint: disable=W0703
31+ except Exception as e: # pylint: disable=W0703
32 logger.exception("Exception calling check_connected_state:")
33 return defer.fail(NetworkFailException(e))
34
35=== modified file 'ubuntu_sso/networkstate/linux.py'
36--- ubuntu_sso/networkstate/linux.py 2012-06-22 16:55:35 +0000
37+++ ubuntu_sso/networkstate/linux.py 2012-06-22 20:08:18 +0000
38@@ -107,7 +107,7 @@
39 nm_proxy.Get(NM_DBUS_INTERFACE, "State",
40 reply_handler=self.got_state,
41 error_handler=self.got_error)
42- except Exception, e: # pylint: disable=W0703
43+ except Exception as e: # pylint: disable=W0703
44 self.got_error(e)
45
46
47@@ -127,7 +127,7 @@
48 try:
49 network = NetworkManagerState(got_state)
50 network.find_online_state()
51- except Exception, e:
52+ except Exception as e:
53 logger.exception('is_machine_connected failed with:')
54 d.errback(NetworkFailException(e))
55 # pylint: enable=W0702, W0703
56
57=== modified file 'ubuntu_sso/networkstate/windows.py'
58--- ubuntu_sso/networkstate/windows.py 2012-04-09 17:38:24 +0000
59+++ ubuntu_sso/networkstate/windows.py 2012-06-22 20:08:18 +0000
60@@ -184,7 +184,7 @@
61 flags = DWORD()
62 connected = wininet.InternetGetConnectedState(byref(flags), None)
63 return defer.succeed(connected == 1)
64- except Exception, e:
65+ except Exception as e:
66 logger.exception('is_machine_connected failed with:')
67 return defer.fail(NetworkFailException(e))
68 # pylint: enable=W0703, W0702
69
70=== modified file 'ubuntu_sso/qt/proxy_dialog.py'
71--- ubuntu_sso/qt/proxy_dialog.py 2012-04-09 17:38:24 +0000
72+++ ubuntu_sso/qt/proxy_dialog.py 2012-06-22 20:08:18 +0000
73@@ -116,7 +116,7 @@
74 try:
75 logger.debug('Save credentials as for domain %s.', self.domain)
76 yield self.keyring.set_credentials(self.domain, creds)
77- except Exception, e:
78+ except Exception as e:
79 logger.exception('Could not set credentials:')
80 self.done(EXCEPTION_RAISED)
81 logger.debug('Stored creds')
82
83=== modified file 'ubuntu_sso/utils/__init__.py'
84--- ubuntu_sso/utils/__init__.py 2012-04-25 14:17:16 +0000
85+++ ubuntu_sso/utils/__init__.py 2012-06-22 20:08:18 +0000
86@@ -165,7 +165,7 @@
87 logger.debug("Calculated server-local time skew: %r",
88 self.skew)
89 #pylint: disable=W0703
90- except Exception, server_error:
91+ except Exception as server_error:
92 logger.debug("Error while verifying the server time skew: %r",
93 server_error)
94 self.next_check = local_time + self.ERROR_INTERVAL
95
96=== modified file 'ubuntu_sso/utils/runner/glib.py'
97--- ubuntu_sso/utils/runner/glib.py 2012-04-09 17:38:24 +0000
98+++ ubuntu_sso/utils/runner/glib.py 2012-06-22 20:08:18 +0000
99@@ -89,7 +89,7 @@
100
101 try:
102 pid, _, _, _ = GLib.spawn_async(argv=bytes_args, flags=flags)
103- except GLib.GError, e:
104+ except GLib.GError as e:
105 handle_error(e)
106 else:
107 logger.debug('Spawning the program %r with the glib mainloop '
108
109=== modified file 'ubuntu_sso/utils/runner/tests/test_glib.py'
110--- ubuntu_sso/utils/runner/tests/test_glib.py 2012-04-09 17:38:24 +0000
111+++ ubuntu_sso/utils/runner/tests/test_glib.py 2012-06-22 20:08:18 +0000
112@@ -87,7 +87,7 @@
113
114 try:
115 subprocess.call(argv)
116- except Exception, e:
117+ except Exception as e:
118 exc = GLib.GError()
119 exc.message = str(e)
120 exc.code = 42
121
122=== modified file 'ubuntu_sso/utils/runner/tests/test_qt.py'
123--- ubuntu_sso/utils/runner/tests/test_qt.py 2012-04-09 17:38:24 +0000
124+++ ubuntu_sso/utils/runner/tests/test_qt.py 2012-06-22 20:08:18 +0000
125@@ -86,12 +86,12 @@
126
127 try:
128 subprocess.call(bytes_args)
129- except OSError, e:
130+ except OSError as e:
131 if e.errno == 2:
132 self.error.emit(self.FailedToStart)
133 else:
134 self.error.emit(e)
135- except Exception, e:
136+ except Exception as e:
137 self.error.emit(e)
138 else:
139 self.finished.emit(self._status_code)
140
141=== modified file 'ubuntu_sso/utils/runner/tx.py'
142--- ubuntu_sso/utils/runner/tx.py 2012-04-09 17:38:24 +0000
143+++ ubuntu_sso/utils/runner/tx.py 2012-06-22 20:08:18 +0000
144@@ -102,9 +102,9 @@
145
146 try:
147 d = utils.getProcessOutputAndValue(program, bytes_args, env=os.environ)
148- except OSError, e:
149+ except OSError as e:
150 error_handler(msg=e, failed_to_start=True)
151- except Exception, e:
152+ except Exception as e:
153 error_handler(msg=e, failed_to_start=False)
154 else:
155 logger.debug('Spawning the program %r with the twisted reactor '
156
157=== modified file 'ubuntu_sso/utils/txsecrets.py'
158--- ubuntu_sso/utils/txsecrets.py 2012-04-09 17:38:24 +0000
159+++ ubuntu_sso/utils/txsecrets.py 2012-06-22 20:08:18 +0000
160@@ -100,7 +100,7 @@
161 self.service.OpenSession(ALGORITHM, parameters,
162 reply_handler=session_opened,
163 error_handler=d.errback)
164- except dbus.exceptions.DBusException, e:
165+ except dbus.exceptions.DBusException as e:
166 d.errback(e)
167 return d
168
169
170=== modified file 'ubuntu_sso/utils/webclient/common.py'
171--- ubuntu_sso/utils/webclient/common.py 2012-04-12 12:07:46 +0000
172+++ ubuntu_sso/utils/webclient/common.py 2012-06-22 20:08:18 +0000
173@@ -206,7 +206,7 @@
174 try:
175 creds = yield keyring.get_credentials(str(domain))
176 logger.debug('Got credentials from keyring.')
177- except Exception, e:
178+ except Exception as e:
179 logger.error('Error when retrieving the creds.')
180 raise WebClientError('Error when retrieving the creds.', e)
181 if creds is not None:
182@@ -249,7 +249,7 @@
183
184 try:
185 return_code = yield self._launch_proxy_creds_dialog(domain, retry)
186- except Exception, e:
187+ except Exception as e:
188 logger.error('Error when running external ui process.')
189 raise WebClientError('Error when running external ui process.', e)
190
191
192=== modified file 'ubuntu_sso/utils/webclient/qtnetwork.py'
193--- ubuntu_sso/utils/webclient/qtnetwork.py 2012-04-24 14:05:22 +0000
194+++ ubuntu_sso/utils/webclient/qtnetwork.py 2012-06-22 20:08:18 +0000
195@@ -165,7 +165,7 @@
196 post_buffer.setData(post_content)
197 try:
198 result = yield self._perform_request(request, method, post_buffer)
199- except ProxyUnauthorizedError, e:
200+ except ProxyUnauthorizedError as e:
201 app_proxy = QNetworkProxy.applicationProxy()
202 proxy_host = app_proxy.hostName() if app_proxy else "proxy server"
203 got_creds = yield self.request_proxy_auth_credentials(
204
205=== modified file 'ubuntu_sso/utils/webclient/timestamp.py'
206--- ubuntu_sso/utils/webclient/timestamp.py 2012-04-09 17:38:24 +0000
207+++ ubuntu_sso/utils/webclient/timestamp.py 2012-06-22 20:08:18 +0000
208@@ -83,7 +83,7 @@
209 logger.debug("Calculated server time skew: %r", self.skew)
210 # We just log all exceptions while trying to get the server time
211 # pylint: disable=W0703
212- except Exception, e:
213+ except Exception as e:
214 logger.debug("Error while verifying server time skew: %r", e)
215 self.next_check = local_time + self.ERROR_INTERVAL
216 # delay import, otherwise a default reactor gets installed

Subscribers

People subscribed via source and target branches