From eb52dc9af0e4d83484e19232dbf4c8dbdaaa7911 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 16 May 2016 14:42:28 +0200 Subject: [PATCH] Port azure_rm_common.py to py3 syntax (#15880) Since the rest of the file already use a non 2.4 syntax (such as format), I didn't bother using the 2.4 syntax for exceptions. --- lib/ansible/module_utils/azure_rm_common.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ansible/module_utils/azure_rm_common.py b/lib/ansible/module_utils/azure_rm_common.py index 526655fcb75..6fe285e26a8 100644 --- a/lib/ansible/module_utils/azure_rm_common.py +++ b/lib/ansible/module_utils/azure_rm_common.py @@ -88,7 +88,7 @@ try: from azure.mgmt.compute.compute_management_client import ComputeManagementClient,\ ComputeManagementClientConfiguration from azure.storage.cloudstorageaccount import CloudStorageAccount -except ImportError, exc: +except ImportError as exc: HAS_AZURE_EXC = exc HAS_AZURE = False @@ -323,7 +323,7 @@ class AzureRMModuleBase(object): return self.rm_client.resource_groups.get(resource_group) except CloudError: self.fail("Parameter error: resource group {0} not found".format(resource_group)) - except Exception, exc: + except Exception as exc: self.fail("Error retrieving resource group {0} - {1}".format(resource_group, str(exc))) def _get_profile(self, profile="default"): @@ -331,7 +331,7 @@ class AzureRMModuleBase(object): try: config = ConfigParser.ConfigParser() config.read(path) - except Exception, exc: + except Exception as exc: self.fail("Failed to access {0}. Check that the file exists and you have read " "access. {1}".format(path, str(exc))) credentials = dict() @@ -418,7 +418,7 @@ class AzureRMModuleBase(object): self.log("Waiting for {0} sec".format(delay)) poller.wait(timeout=delay) return poller.result() - except Exception, exc: + except Exception as exc: self.log(str(exc)) raise @@ -465,13 +465,13 @@ class AzureRMModuleBase(object): account_keys = self.storage_client.storage_accounts.list_keys(resource_group_name, storage_account_name) keys['key1'] = account_keys.key1 keys['key2'] = account_keys.key2 - except Exception, exc: + except Exception as exc: self.fail("Error getting keys for account {0} - {1}".format(storage_account_name, str(exc))) try: self.log('Create blob service') return CloudStorageAccount(storage_account_name, keys['key1']).create_block_blob_service() - except Exception, exc: + except Exception as exc: self.fail("Error creating blob service client for storage account {0} - {1}".format(storage_account_name, str(exc))) @@ -508,7 +508,7 @@ class AzureRMModuleBase(object): self.log('Creating default public IP {0}'.format(public_ip_name)) try: poller = self.network_client.public_ip_addresses.create_or_update(resource_group, public_ip_name, params) - except Exception, exc: + except Exception as exc: self.fail("Error creating {0} - {1}".format(public_ip_name, str(exc))) return self.get_poller_result(poller) @@ -578,7 +578,7 @@ class AzureRMModuleBase(object): poller = self.network_client.network_security_groups.create_or_update(resource_group, security_group_name, parameters) - except Exception, exc: + except Exception as exc: self.fail("Error creating default security rule {0} - {1}".format(security_group_name, str(exc))) return self.get_poller_result(poller) @@ -589,7 +589,7 @@ class AzureRMModuleBase(object): # time we attempt to use the requested client. resource_client = self.rm_client resource_client.providers.register(key) - except Exception, exc: + except Exception as exc: self.fail("One-time registration of {0} failed - {1}".format(key, str(exc))) @property