Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docker/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def __str__(self):
message = super(APIError, self).__str__()

if self.is_client_error():
message = '%s Client Error: %s' % (
message = '{0} Client Error: {1}'.format(
self.response.status_code, self.response.reason)

elif self.is_server_error():
message = '%s Server Error: %s' % (
message = '{0} Server Error: {1}'.format(
self.response.status_code, self.response.reason)

if self.explanation:
message = '%s ("%s")' % (message, self.explanation)
message = '{0} ("{1}")'.format(message, self.explanation)

return message

Expand Down
18 changes: 10 additions & 8 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def convert_volume_binds(binds):
result = []
for k, v in binds.items():
if isinstance(v, dict):
result.append('%s:%s:%s' % (
result.append('{0}:{1}:{2}'.format(
k, v['bind'], 'ro' if v.get('ro', False) else 'rw'
))
else:
result.append('%s:%s:rw' % (k, v))
result.append('{0}:{1}:rw'.format(k, v))
return result


Expand Down Expand Up @@ -201,7 +201,8 @@ def parse_host(addr):
addr = addr.replace('http+unix://', 'unix://')

if addr == 'tcp://':
raise errors.DockerException("Invalid bind address format: %s" % addr)
raise errors.DockerException(
"Invalid bind address format: {0}".format(addr))
elif addr.startswith('unix://'):
addr = addr[7:]
elif addr.startswith('tcp://'):
Expand All @@ -215,15 +216,15 @@ def parse_host(addr):
else:
if "://" in addr:
raise errors.DockerException(
"Invalid bind address protocol: %s" % addr
"Invalid bind address protocol: {0}".format(addr)
)
proto = "http"

if proto != "http+unix" and ":" in addr:
host_parts = addr.split(':')
if len(host_parts) != 2:
raise errors.DockerException(
"Invalid bind address format: %s" % addr
"Invalid bind address format: {0}".format(addr)
)
if host_parts[0]:
host = host_parts[0]
Expand All @@ -236,13 +237,14 @@ def parse_host(addr):
)

elif proto in ("http", "https") and ':' not in addr:
raise errors.DockerException("Bind address needs a port: %s" % addr)
raise errors.DockerException(
"Bind address needs a port: {0}".format(addr))
else:
host = addr

if proto == "http+unix":
return "%s://%s" % (proto, host)
return "%s://%s:%d" % (proto, host, port)
return "{0}://{1}".format(proto, host)
return "{0}://{1}:{2}".format(proto, host, port)


def parse_devices(devices):
Expand Down