From 5804b8bd5095d4d18f615f07b937bac158c2434b Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Mon, 5 Nov 2012 10:13:25 -0600 Subject: [PATCH] HACKING compliance: consistent usage of 'except' Change-Id: I13988e94d7e20a9179874ec5be072bdb8db3a95e --- keystoneclient/service_catalog.py | 2 +- keystoneclient/shell.py | 2 +- keystoneclient/v2_0/client.py | 2 +- keystoneclient/v2_0/shell.py | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/keystoneclient/service_catalog.py b/keystoneclient/service_catalog.py index cbe5c5de2..11da572b8 100644 --- a/keystoneclient/service_catalog.py +++ b/keystoneclient/service_catalog.py @@ -42,7 +42,7 @@ class ServiceCatalog(object): try: token['user_id'] = self.catalog['user']['id'] token['tenant_id'] = self.catalog['token']['tenant']['id'] - except: + except Exception: # just leave the tenant and user out if it doesn't exist pass return token diff --git a/keystoneclient/shell.py b/keystoneclient/shell.py index e61bf2e9d..6e2826846 100644 --- a/keystoneclient/shell.py +++ b/keystoneclient/shell.py @@ -409,7 +409,7 @@ def main(): try: OpenStackIdentityShell().main(sys.argv[1:]) - except Exception, e: + except Exception as e: if httplib2.debuglevel == 1: raise # dump stack. else: diff --git a/keystoneclient/v2_0/client.py b/keystoneclient/v2_0/client.py index 02fd59b6f..37ab3d89e 100644 --- a/keystoneclient/v2_0/client.py +++ b/keystoneclient/v2_0/client.py @@ -111,7 +111,7 @@ class Client(client.HTTPClient): except (exceptions.AuthorizationFailure, exceptions.Unauthorized): _logger.debug("Authorization Failed.") raise - except Exception, e: + except Exception as e: raise exceptions.AuthorizationFailure("Authorization Failed: " "%s" % e) diff --git a/keystoneclient/v2_0/shell.py b/keystoneclient/v2_0/shell.py index 07968e90b..a976134da 100755 --- a/keystoneclient/v2_0/shell.py +++ b/keystoneclient/v2_0/shell.py @@ -96,7 +96,7 @@ def do_user_update(kc, args): try: kc.users.update(args.id, **kwargs) print 'User has been updated.' - except Exception, e: + except Exception as e: print 'Unable to update user: %s' % e @@ -321,7 +321,7 @@ def do_ec2_credentials_list(kc, args): for cred in credentials: try: cred.tenant = getattr(kc.tenants.get(cred.tenant_id), 'name') - except: + except Exception: # FIXME(dtroyer): Retrieving the tenant name fails for normal # users; stuff in the tenant_id instead. cred.tenant = cred.tenant_id @@ -340,7 +340,7 @@ def do_ec2_credentials_delete(kc, args): try: kc.ec2.delete(args.user_id, args.access) print 'Credential has been deleted.' - except Exception, e: + except Exception as e: print 'Unable to delete credential: %s' % e @@ -419,7 +419,7 @@ def do_endpoint_delete(kc, args): try: kc.endpoints.delete(args.id) print 'Endpoint has been deleted.' - except: + except Exception: print 'Unable to delete endpoint.'