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

Proposed by Brian Curtin
Status: Merged
Approved by: dobey
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
Roberto Alsina (community) Approve
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.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
973. By dobey

Remove the xdg_base_directory module as it duplicates dirspec now

Revision history for this message
dobey (dobey) wrote :

Can we have bugs for these py3 related issues?

review: Needs Information
974. By Brian Curtin

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

975. By Brian Curtin

Tag #1016711

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntu_sso/account.py'
--- ubuntu_sso/account.py 2012-06-22 16:55:35 +0000
+++ ubuntu_sso/account.py 2012-06-22 20:08:18 +0000
@@ -249,7 +249,7 @@
249 try:249 try:
250 operation = u"registration.request_password_reset_token"250 operation = u"registration.request_password_reset_token"
251 result = yield restful_client.restcall(operation, email=email)251 result = yield restful_client.restcall(operation, email=email)
252 except WebClientError, e:252 except WebClientError as e:
253 logger.exception('request_password_reset_token failed with:')253 logger.exception('request_password_reset_token failed with:')
254 raise ResetPasswordTokenError(e[1].split('\n')[0])254 raise ResetPasswordTokenError(e[1].split('\n')[0])
255 finally:255 finally:
@@ -275,7 +275,7 @@
275 u"registration.set_new_password",275 u"registration.set_new_password",
276 email=email, token=token,276 email=email, token=token,
277 new_password=new_password)277 new_password=new_password)
278 except WebClientError, e:278 except WebClientError as e:
279 logger.exception('set_new_password failed with:')279 logger.exception('set_new_password failed with:')
280 raise NewPasswordError(e[1].split('\n')[0])280 raise NewPasswordError(e[1].split('\n')[0])
281 finally:281 finally:
282282
=== modified file 'ubuntu_sso/networkstate/darwin.py'
--- ubuntu_sso/networkstate/darwin.py 2012-06-22 16:55:35 +0000
+++ ubuntu_sso/networkstate/darwin.py 2012-06-22 20:08:18 +0000
@@ -298,6 +298,6 @@
298 """298 """
299 try:299 try:
300 return defer.succeed(check_connected_state())300 return defer.succeed(check_connected_state())
301 except Exception, e: # pylint: disable=W0703301 except Exception as e: # pylint: disable=W0703
302 logger.exception("Exception calling check_connected_state:")302 logger.exception("Exception calling check_connected_state:")
303 return defer.fail(NetworkFailException(e))303 return defer.fail(NetworkFailException(e))
304304
=== modified file 'ubuntu_sso/networkstate/linux.py'
--- ubuntu_sso/networkstate/linux.py 2012-06-22 16:55:35 +0000
+++ ubuntu_sso/networkstate/linux.py 2012-06-22 20:08:18 +0000
@@ -107,7 +107,7 @@
107 nm_proxy.Get(NM_DBUS_INTERFACE, "State",107 nm_proxy.Get(NM_DBUS_INTERFACE, "State",
108 reply_handler=self.got_state,108 reply_handler=self.got_state,
109 error_handler=self.got_error)109 error_handler=self.got_error)
110 except Exception, e: # pylint: disable=W0703110 except Exception as e: # pylint: disable=W0703
111 self.got_error(e)111 self.got_error(e)
112112
113113
@@ -127,7 +127,7 @@
127 try:127 try:
128 network = NetworkManagerState(got_state)128 network = NetworkManagerState(got_state)
129 network.find_online_state()129 network.find_online_state()
130 except Exception, e:130 except Exception as e:
131 logger.exception('is_machine_connected failed with:')131 logger.exception('is_machine_connected failed with:')
132 d.errback(NetworkFailException(e))132 d.errback(NetworkFailException(e))
133 # pylint: enable=W0702, W0703133 # pylint: enable=W0702, W0703
134134
=== modified file 'ubuntu_sso/networkstate/windows.py'
--- ubuntu_sso/networkstate/windows.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/networkstate/windows.py 2012-06-22 20:08:18 +0000
@@ -184,7 +184,7 @@
184 flags = DWORD()184 flags = DWORD()
185 connected = wininet.InternetGetConnectedState(byref(flags), None)185 connected = wininet.InternetGetConnectedState(byref(flags), None)
186 return defer.succeed(connected == 1)186 return defer.succeed(connected == 1)
187 except Exception, e:187 except Exception as e:
188 logger.exception('is_machine_connected failed with:')188 logger.exception('is_machine_connected failed with:')
189 return defer.fail(NetworkFailException(e))189 return defer.fail(NetworkFailException(e))
190 # pylint: enable=W0703, W0702190 # pylint: enable=W0703, W0702
191191
=== modified file 'ubuntu_sso/qt/proxy_dialog.py'
--- ubuntu_sso/qt/proxy_dialog.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/qt/proxy_dialog.py 2012-06-22 20:08:18 +0000
@@ -116,7 +116,7 @@
116 try:116 try:
117 logger.debug('Save credentials as for domain %s.', self.domain)117 logger.debug('Save credentials as for domain %s.', self.domain)
118 yield self.keyring.set_credentials(self.domain, creds)118 yield self.keyring.set_credentials(self.domain, creds)
119 except Exception, e:119 except Exception as e:
120 logger.exception('Could not set credentials:')120 logger.exception('Could not set credentials:')
121 self.done(EXCEPTION_RAISED)121 self.done(EXCEPTION_RAISED)
122 logger.debug('Stored creds')122 logger.debug('Stored creds')
123123
=== modified file 'ubuntu_sso/utils/__init__.py'
--- ubuntu_sso/utils/__init__.py 2012-04-25 14:17:16 +0000
+++ ubuntu_sso/utils/__init__.py 2012-06-22 20:08:18 +0000
@@ -165,7 +165,7 @@
165 logger.debug("Calculated server-local time skew: %r",165 logger.debug("Calculated server-local time skew: %r",
166 self.skew)166 self.skew)
167 #pylint: disable=W0703167 #pylint: disable=W0703
168 except Exception, server_error:168 except Exception as server_error:
169 logger.debug("Error while verifying the server time skew: %r",169 logger.debug("Error while verifying the server time skew: %r",
170 server_error)170 server_error)
171 self.next_check = local_time + self.ERROR_INTERVAL171 self.next_check = local_time + self.ERROR_INTERVAL
172172
=== modified file 'ubuntu_sso/utils/runner/glib.py'
--- ubuntu_sso/utils/runner/glib.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/utils/runner/glib.py 2012-06-22 20:08:18 +0000
@@ -89,7 +89,7 @@
8989
90 try:90 try:
91 pid, _, _, _ = GLib.spawn_async(argv=bytes_args, flags=flags)91 pid, _, _, _ = GLib.spawn_async(argv=bytes_args, flags=flags)
92 except GLib.GError, e:92 except GLib.GError as e:
93 handle_error(e)93 handle_error(e)
94 else:94 else:
95 logger.debug('Spawning the program %r with the glib mainloop '95 logger.debug('Spawning the program %r with the glib mainloop '
9696
=== modified file 'ubuntu_sso/utils/runner/tests/test_glib.py'
--- ubuntu_sso/utils/runner/tests/test_glib.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/utils/runner/tests/test_glib.py 2012-06-22 20:08:18 +0000
@@ -87,7 +87,7 @@
8787
88 try:88 try:
89 subprocess.call(argv)89 subprocess.call(argv)
90 except Exception, e:90 except Exception as e:
91 exc = GLib.GError()91 exc = GLib.GError()
92 exc.message = str(e)92 exc.message = str(e)
93 exc.code = 4293 exc.code = 42
9494
=== modified file 'ubuntu_sso/utils/runner/tests/test_qt.py'
--- ubuntu_sso/utils/runner/tests/test_qt.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/utils/runner/tests/test_qt.py 2012-06-22 20:08:18 +0000
@@ -86,12 +86,12 @@
8686
87 try:87 try:
88 subprocess.call(bytes_args)88 subprocess.call(bytes_args)
89 except OSError, e:89 except OSError as e:
90 if e.errno == 2:90 if e.errno == 2:
91 self.error.emit(self.FailedToStart)91 self.error.emit(self.FailedToStart)
92 else:92 else:
93 self.error.emit(e)93 self.error.emit(e)
94 except Exception, e:94 except Exception as e:
95 self.error.emit(e)95 self.error.emit(e)
96 else:96 else:
97 self.finished.emit(self._status_code)97 self.finished.emit(self._status_code)
9898
=== modified file 'ubuntu_sso/utils/runner/tx.py'
--- ubuntu_sso/utils/runner/tx.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/utils/runner/tx.py 2012-06-22 20:08:18 +0000
@@ -102,9 +102,9 @@
102102
103 try:103 try:
104 d = utils.getProcessOutputAndValue(program, bytes_args, env=os.environ)104 d = utils.getProcessOutputAndValue(program, bytes_args, env=os.environ)
105 except OSError, e:105 except OSError as e:
106 error_handler(msg=e, failed_to_start=True)106 error_handler(msg=e, failed_to_start=True)
107 except Exception, e:107 except Exception as e:
108 error_handler(msg=e, failed_to_start=False)108 error_handler(msg=e, failed_to_start=False)
109 else:109 else:
110 logger.debug('Spawning the program %r with the twisted reactor '110 logger.debug('Spawning the program %r with the twisted reactor '
111111
=== modified file 'ubuntu_sso/utils/txsecrets.py'
--- ubuntu_sso/utils/txsecrets.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/utils/txsecrets.py 2012-06-22 20:08:18 +0000
@@ -100,7 +100,7 @@
100 self.service.OpenSession(ALGORITHM, parameters,100 self.service.OpenSession(ALGORITHM, parameters,
101 reply_handler=session_opened,101 reply_handler=session_opened,
102 error_handler=d.errback)102 error_handler=d.errback)
103 except dbus.exceptions.DBusException, e:103 except dbus.exceptions.DBusException as e:
104 d.errback(e)104 d.errback(e)
105 return d105 return d
106106
107107
=== modified file 'ubuntu_sso/utils/webclient/common.py'
--- ubuntu_sso/utils/webclient/common.py 2012-04-12 12:07:46 +0000
+++ ubuntu_sso/utils/webclient/common.py 2012-06-22 20:08:18 +0000
@@ -206,7 +206,7 @@
206 try:206 try:
207 creds = yield keyring.get_credentials(str(domain))207 creds = yield keyring.get_credentials(str(domain))
208 logger.debug('Got credentials from keyring.')208 logger.debug('Got credentials from keyring.')
209 except Exception, e:209 except Exception as e:
210 logger.error('Error when retrieving the creds.')210 logger.error('Error when retrieving the creds.')
211 raise WebClientError('Error when retrieving the creds.', e)211 raise WebClientError('Error when retrieving the creds.', e)
212 if creds is not None:212 if creds is not None:
@@ -249,7 +249,7 @@
249249
250 try:250 try:
251 return_code = yield self._launch_proxy_creds_dialog(domain, retry)251 return_code = yield self._launch_proxy_creds_dialog(domain, retry)
252 except Exception, e:252 except Exception as e:
253 logger.error('Error when running external ui process.')253 logger.error('Error when running external ui process.')
254 raise WebClientError('Error when running external ui process.', e)254 raise WebClientError('Error when running external ui process.', e)
255255
256256
=== modified file 'ubuntu_sso/utils/webclient/qtnetwork.py'
--- ubuntu_sso/utils/webclient/qtnetwork.py 2012-04-24 14:05:22 +0000
+++ ubuntu_sso/utils/webclient/qtnetwork.py 2012-06-22 20:08:18 +0000
@@ -165,7 +165,7 @@
165 post_buffer.setData(post_content)165 post_buffer.setData(post_content)
166 try:166 try:
167 result = yield self._perform_request(request, method, post_buffer)167 result = yield self._perform_request(request, method, post_buffer)
168 except ProxyUnauthorizedError, e:168 except ProxyUnauthorizedError as e:
169 app_proxy = QNetworkProxy.applicationProxy()169 app_proxy = QNetworkProxy.applicationProxy()
170 proxy_host = app_proxy.hostName() if app_proxy else "proxy server"170 proxy_host = app_proxy.hostName() if app_proxy else "proxy server"
171 got_creds = yield self.request_proxy_auth_credentials(171 got_creds = yield self.request_proxy_auth_credentials(
172172
=== modified file 'ubuntu_sso/utils/webclient/timestamp.py'
--- ubuntu_sso/utils/webclient/timestamp.py 2012-04-09 17:38:24 +0000
+++ ubuntu_sso/utils/webclient/timestamp.py 2012-06-22 20:08:18 +0000
@@ -83,7 +83,7 @@
83 logger.debug("Calculated server time skew: %r", self.skew)83 logger.debug("Calculated server time skew: %r", self.skew)
84 # We just log all exceptions while trying to get the server time84 # We just log all exceptions while trying to get the server time
85 # pylint: disable=W070385 # pylint: disable=W0703
86 except Exception, e:86 except Exception as e:
87 logger.debug("Error while verifying server time skew: %r", e)87 logger.debug("Error while verifying server time skew: %r", e)
88 self.next_check = local_time + self.ERROR_INTERVAL88 self.next_check = local_time + self.ERROR_INTERVAL
89 # delay import, otherwise a default reactor gets installed89 # delay import, otherwise a default reactor gets installed

Subscribers

People subscribed via source and target branches