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
This commit is contained in:
Dirk Mueller 2013-06-14 23:19:28 +02:00
parent cea720e793
commit 315d30c337
7 changed files with 8 additions and 8 deletions

View File

@ -280,7 +280,7 @@ class PanelGroup(object):
for name in self.panels: for name in self.panels:
try: try:
panel_instances.append(self.dashboard.get_panel(name)) panel_instances.append(self.dashboard.get_panel(name))
except NotRegistered, e: except NotRegistered as e:
LOG.debug(e) LOG.debug(e)
return iter(panel_instances) return iter(panel_instances)

View File

@ -65,7 +65,7 @@ class Command(TemplateCommand):
if not os.path.exists(target): if not os.path.exists(target):
try: try:
os.mkdir(target) os.mkdir(target)
except OSError, exc: except OSError as exc:
raise CommandError("Unable to create panel directory: %s" raise CommandError("Unable to create panel directory: %s"
% exc) % exc)

View File

@ -308,7 +308,7 @@ class LinkAction(BaseAction):
return urlresolvers.reverse(self.url, args=(obj_id,)) return urlresolvers.reverse(self.url, args=(obj_id,))
else: else:
return urlresolvers.reverse(self.url) 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)) LOG.info('No reverse found for "%s": %s' % (self.url, ex))
return self.url return self.url
@ -574,7 +574,7 @@ class BatchAction(Action):
self.success_ids.append(datum_id) self.success_ids.append(datum_id)
LOG.info('%s: "%s"' % LOG.info('%s: "%s"' %
(self._conjugate(past=True), datum_display)) (self._conjugate(past=True), datum_display))
except Exception, ex: except Exception as ex:
# Handle the exception but silence it since we'll display # Handle the exception but silence it since we'll display
# an aggregate error message later. Otherwise we'd get # an aggregate error message later. Otherwise we'd get
# multiple error messages displayed to the user. # multiple error messages displayed to the user.

View File

@ -114,7 +114,7 @@ class APIDictWrapper(object):
def __getitem__(self, item): def __getitem__(self, item):
try: try:
return self.__getattr__(item) return self.__getattr__(item)
except AttributeError, e: except AttributeError as e:
# caller is expecting a KeyError # caller is expecting a KeyError
raise KeyError(e) raise KeyError(e)

View File

@ -129,7 +129,7 @@ def download_rc_file(request):
response['Content-Length'] = str(len(response.content)) response['Content-Length'] = str(len(response.content))
return response return response
except Exception, e: except Exception as e:
LOG.exception("Exception in DownloadOpenRCForm.") LOG.exception("Exception in DownloadOpenRCForm.")
messages.error(request, _('Error Downloading RC File: %s') % e) messages.error(request, _('Error Downloading RC File: %s') % e)
return shortcuts.redirect(request.build_absolute_uri()) return shortcuts.redirect(request.build_absolute_uri())

View File

@ -142,7 +142,7 @@ class CopyObject(forms.SelfHandlingForm):
_('Copied "%(orig)s" to "%(dest)s" as "%(new)s".') _('Copied "%(orig)s" to "%(dest)s" as "%(new)s".')
% vals) % vals)
return True return True
except exceptions.HorizonException, exc: except exceptions.HorizonException as exc:
messages.error(request, exc) messages.error(request, exc)
raise exceptions.Http302(reverse(index, raise exceptions.Http302(reverse(index,
args=[wrap_delimiter(orig_container)])) args=[wrap_delimiter(orig_container)]))

View File

@ -231,7 +231,7 @@ class CreateForm(forms.SelfHandlingForm):
message = _('Creating volume "%s"') % data['name'] message = _('Creating volume "%s"') % data['name']
messages.info(request, message) messages.info(request, message)
return volume return volume
except ValidationError, e: except ValidationError as e:
self.api_error(e.messages[0]) self.api_error(e.messages[0])
return False return False
except: except: