From 315d30c33736d66fba278912c16291d124c9dd67 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 14 Jun 2013 23:19:28 +0200 Subject: [PATCH] Use Python 3.x compatible except construct Python 3.x removed the "except x,y:" construct. Use "except x as y:" instead which works with all Python versions >= 2.6. Change-Id: Iedb4c5a6d8580cbb6c9697933d006e94b1db916d --- horizon/base.py | 2 +- horizon/management/commands/startpanel.py | 2 +- horizon/tables/actions.py | 4 ++-- openstack_dashboard/api/base.py | 2 +- .../project/access_and_security/api_access/views.py | 2 +- openstack_dashboard/dashboards/project/containers/forms.py | 2 +- openstack_dashboard/dashboards/project/volumes/forms.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/horizon/base.py b/horizon/base.py index 7b0c4f721..8ad980769 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -280,7 +280,7 @@ class PanelGroup(object): for name in self.panels: try: panel_instances.append(self.dashboard.get_panel(name)) - except NotRegistered, e: + except NotRegistered as e: LOG.debug(e) return iter(panel_instances) diff --git a/horizon/management/commands/startpanel.py b/horizon/management/commands/startpanel.py index 7250db71a..61369fa69 100644 --- a/horizon/management/commands/startpanel.py +++ b/horizon/management/commands/startpanel.py @@ -65,7 +65,7 @@ class Command(TemplateCommand): if not os.path.exists(target): try: os.mkdir(target) - except OSError, exc: + except OSError as exc: raise CommandError("Unable to create panel directory: %s" % exc) diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index 068408c4d..b6aa0a4ad 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -308,7 +308,7 @@ class LinkAction(BaseAction): return urlresolvers.reverse(self.url, args=(obj_id,)) else: return urlresolvers.reverse(self.url) - except urlresolvers.NoReverseMatch, ex: + except urlresolvers.NoReverseMatch as ex: LOG.info('No reverse found for "%s": %s' % (self.url, ex)) return self.url @@ -574,7 +574,7 @@ class BatchAction(Action): self.success_ids.append(datum_id) LOG.info('%s: "%s"' % (self._conjugate(past=True), datum_display)) - except Exception, ex: + except Exception as ex: # Handle the exception but silence it since we'll display # an aggregate error message later. Otherwise we'd get # multiple error messages displayed to the user. diff --git a/openstack_dashboard/api/base.py b/openstack_dashboard/api/base.py index 3b2fae684..ff227f6f1 100644 --- a/openstack_dashboard/api/base.py +++ b/openstack_dashboard/api/base.py @@ -114,7 +114,7 @@ class APIDictWrapper(object): def __getitem__(self, item): try: return self.__getattr__(item) - except AttributeError, e: + except AttributeError as e: # caller is expecting a KeyError raise KeyError(e) diff --git a/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py b/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py index 9270b3b45..9fc330083 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py +++ b/openstack_dashboard/dashboards/project/access_and_security/api_access/views.py @@ -129,7 +129,7 @@ def download_rc_file(request): response['Content-Length'] = str(len(response.content)) return response - except Exception, e: + except Exception as e: LOG.exception("Exception in DownloadOpenRCForm.") messages.error(request, _('Error Downloading RC File: %s') % e) return shortcuts.redirect(request.build_absolute_uri()) diff --git a/openstack_dashboard/dashboards/project/containers/forms.py b/openstack_dashboard/dashboards/project/containers/forms.py index 50fe259a8..ba5d2c87d 100644 --- a/openstack_dashboard/dashboards/project/containers/forms.py +++ b/openstack_dashboard/dashboards/project/containers/forms.py @@ -142,7 +142,7 @@ class CopyObject(forms.SelfHandlingForm): _('Copied "%(orig)s" to "%(dest)s" as "%(new)s".') % vals) return True - except exceptions.HorizonException, exc: + except exceptions.HorizonException as exc: messages.error(request, exc) raise exceptions.Http302(reverse(index, args=[wrap_delimiter(orig_container)])) diff --git a/openstack_dashboard/dashboards/project/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/forms.py index 26cadc0d0..4405fa52c 100644 --- a/openstack_dashboard/dashboards/project/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/forms.py @@ -231,7 +231,7 @@ class CreateForm(forms.SelfHandlingForm): message = _('Creating volume "%s"') % data['name'] messages.info(request, message) return volume - except ValidationError, e: + except ValidationError as e: self.api_error(e.messages[0]) return False except: