Fixing Docker compile time errors irt exception handling for Python 3
This commit is contained in:
parent
3fa745eef9
commit
e2dbd0f445
3 changed files with 17 additions and 17 deletions
|
@ -724,7 +724,7 @@ class TaskParameters(DockerBaseClass):
|
|||
if client.module.params.get(param_name):
|
||||
try:
|
||||
setattr(self, param_name, human_to_bytes(client.module.params.get(param_name)))
|
||||
except ValueError, exc:
|
||||
except ValueError as exc:
|
||||
self.fail("Failed to convert %s to bytes: %s" % (param_name, exc))
|
||||
|
||||
self.ports = self._parse_exposed_ports()
|
||||
|
@ -1016,7 +1016,7 @@ class TaskParameters(DockerBaseClass):
|
|||
limits['hard'] = int(pieces[2])
|
||||
try:
|
||||
results.append(Ulimit(**limits))
|
||||
except ValueError, exc:
|
||||
except ValueError as exc:
|
||||
self.fail("Error parsing ulimits value %s - %s" % (limit, exc))
|
||||
return results
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ class TaskParameters(DockerBaseClass):
|
|||
|
||||
try:
|
||||
return LogConfig(**options)
|
||||
except ValueError, exc:
|
||||
except ValueError as exc:
|
||||
self.fail('Error parsing logging options - %s' % (exc))
|
||||
|
||||
def _get_environment(self):
|
||||
|
@ -1062,7 +1062,7 @@ class TaskParameters(DockerBaseClass):
|
|||
if network['Name'] == network_name:
|
||||
network_id = network['Id']
|
||||
break
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error getting network id for %s - %s" % (network_name, str(exc)))
|
||||
return network_id
|
||||
|
||||
|
@ -1699,7 +1699,7 @@ class ContainerManager(DockerBaseClass):
|
|||
if not self.check_mode:
|
||||
try:
|
||||
self.client.disconnect_container_from_network(container.Id, diff['parameter']['id'])
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error disconnecting container from network %s - %s" % (diff['parameter']['name'],
|
||||
str(exc)))
|
||||
# connect to the network
|
||||
|
@ -1715,7 +1715,7 @@ class ContainerManager(DockerBaseClass):
|
|||
self.log("Connecting conainer to network %s" % diff['parameter']['id'])
|
||||
self.log(params, pretty_print=True)
|
||||
self.client.connect_container_to_network(container.Id, diff['parameter']['id'], **params)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error connecting container to network %s - %s" % (diff['parameter']['name'], str(exc)))
|
||||
return self._get_container(container.Id)
|
||||
|
||||
|
@ -1725,7 +1725,7 @@ class ContainerManager(DockerBaseClass):
|
|||
if not self.check_mode:
|
||||
try:
|
||||
self.client.disconnect_container_from_network(container.Id, network['id'])
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error disconnecting container from network %s - %s" % (network['name'],
|
||||
str(exc)))
|
||||
return self._get_container(container.Id)
|
||||
|
@ -1740,7 +1740,7 @@ class ContainerManager(DockerBaseClass):
|
|||
if not self.check_mode:
|
||||
try:
|
||||
new_container = self.client.create_container(image, **create_parameters)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error creating container: %s" % str(exc))
|
||||
return self._get_container(new_container['Id'])
|
||||
return new_container
|
||||
|
@ -1752,7 +1752,7 @@ class ContainerManager(DockerBaseClass):
|
|||
if not self.check_mode:
|
||||
try:
|
||||
self.client.start(container=container_id)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error starting container %s: %s" % (container_id, str(exc)))
|
||||
return self._get_container(container_id)
|
||||
|
||||
|
@ -1765,7 +1765,7 @@ class ContainerManager(DockerBaseClass):
|
|||
if not self.check_mode:
|
||||
try:
|
||||
response = self.client.remove_container(container_id, v=volume_state, link=link, force=force)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error removing container %s: %s" % (container_id, str(exc)))
|
||||
return response
|
||||
|
||||
|
@ -1778,7 +1778,7 @@ class ContainerManager(DockerBaseClass):
|
|||
if not self.check_mode and callable(getattr(self.client, 'update_container')):
|
||||
try:
|
||||
self.client.update_container(container_id, **update_parameters)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error updating container %s: %s" % (container_id, str(exc)))
|
||||
return self._get_container(container_id)
|
||||
|
||||
|
@ -1792,7 +1792,7 @@ class ContainerManager(DockerBaseClass):
|
|||
response = self.client.kill(container_id, signal=self.parameters.kill_signal)
|
||||
else:
|
||||
response = self.client.kill(container_id)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error killing container %s: %s" % (container_id, exc))
|
||||
return response
|
||||
|
||||
|
@ -1809,7 +1809,7 @@ class ContainerManager(DockerBaseClass):
|
|||
response = self.client.stop(container_id, timeout=self.parameters.stop_timeout)
|
||||
else:
|
||||
response = self.client.stop(container_id)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error stopping container %s: %s" % (container_id, str(exc)))
|
||||
return response
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ class ImageManager(DockerBaseClass):
|
|||
for image in images:
|
||||
try:
|
||||
inspection = self.client.inspect_image(image['Id'])
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error inspecting image %s - %s" % (image['Id'], str(exc)))
|
||||
results.append(inspection)
|
||||
return results
|
||||
|
|
|
@ -183,7 +183,7 @@ class LoginManager(DockerBaseClass):
|
|||
reauth=self.reauthorize,
|
||||
dockercfg_path=self.config_path
|
||||
)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Logging into %s for user %s failed - %s" % (self.registry_url, self.username, str(exc)))
|
||||
self.results['login_result'] = response
|
||||
|
||||
|
@ -209,14 +209,14 @@ class LoginManager(DockerBaseClass):
|
|||
if not os.path.exists(config_path_dir):
|
||||
try:
|
||||
os.makedirs(config_path_dir)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error: failed to create %s - %s" % (config_path_dir, str(exc)))
|
||||
self.write_config(path, dict(auths=dict()))
|
||||
|
||||
def write_config(self, path, config):
|
||||
try:
|
||||
json.dump(config, open(path, "w"), indent=5, sort_keys=True)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
self.fail("Error: failed to write config to %s - %s" % (path, str(exc)))
|
||||
|
||||
def update_config_file(self):
|
||||
|
|
Loading…
Reference in a new issue