mirror of https://github.com/docker/docker-py.git
Merge pull request #486 from nir0s/fix-old-style-string-formatting
Fix old style string formatting
This commit is contained in:
commit
5f552fd55b
|
@ -30,15 +30,15 @@ class APIError(requests.exceptions.HTTPError):
|
||||||
message = super(APIError, self).__str__()
|
message = super(APIError, self).__str__()
|
||||||
|
|
||||||
if self.is_client_error():
|
if self.is_client_error():
|
||||||
message = '%s Client Error: %s' % (
|
message = '{0} Client Error: {1}'.format(
|
||||||
self.response.status_code, self.response.reason)
|
self.response.status_code, self.response.reason)
|
||||||
|
|
||||||
elif self.is_server_error():
|
elif self.is_server_error():
|
||||||
message = '%s Server Error: %s' % (
|
message = '{0} Server Error: {1}'.format(
|
||||||
self.response.status_code, self.response.reason)
|
self.response.status_code, self.response.reason)
|
||||||
|
|
||||||
if self.explanation:
|
if self.explanation:
|
||||||
message = '%s ("%s")' % (message, self.explanation)
|
message = '{0} ("{1}")'.format(message, self.explanation)
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
|
@ -165,11 +165,11 @@ def convert_volume_binds(binds):
|
||||||
result = []
|
result = []
|
||||||
for k, v in binds.items():
|
for k, v in binds.items():
|
||||||
if isinstance(v, dict):
|
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'
|
k, v['bind'], 'ro' if v.get('ro', False) else 'rw'
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
result.append('%s:%s:rw' % (k, v))
|
result.append('{0}:{1}:rw'.format(k, v))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,7 +203,8 @@ def parse_host(addr):
|
||||||
addr = addr.replace('http+unix://', 'unix://')
|
addr = addr.replace('http+unix://', 'unix://')
|
||||||
|
|
||||||
if addr == 'tcp://':
|
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://'):
|
elif addr.startswith('unix://'):
|
||||||
addr = addr[7:]
|
addr = addr[7:]
|
||||||
elif addr.startswith('tcp://'):
|
elif addr.startswith('tcp://'):
|
||||||
|
@ -217,7 +218,7 @@ def parse_host(addr):
|
||||||
else:
|
else:
|
||||||
if "://" in addr:
|
if "://" in addr:
|
||||||
raise errors.DockerException(
|
raise errors.DockerException(
|
||||||
"Invalid bind address protocol: %s" % addr
|
"Invalid bind address protocol: {0}".format(addr)
|
||||||
)
|
)
|
||||||
proto = "http"
|
proto = "http"
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ def parse_host(addr):
|
||||||
host_parts = addr.split(':')
|
host_parts = addr.split(':')
|
||||||
if len(host_parts) != 2:
|
if len(host_parts) != 2:
|
||||||
raise errors.DockerException(
|
raise errors.DockerException(
|
||||||
"Invalid bind address format: %s" % addr
|
"Invalid bind address format: {0}".format(addr)
|
||||||
)
|
)
|
||||||
if host_parts[0]:
|
if host_parts[0]:
|
||||||
host = host_parts[0]
|
host = host_parts[0]
|
||||||
|
@ -238,13 +239,14 @@ def parse_host(addr):
|
||||||
)
|
)
|
||||||
|
|
||||||
elif proto in ("http", "https") and ':' not in 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:
|
else:
|
||||||
host = addr
|
host = addr
|
||||||
|
|
||||||
if proto == "http+unix":
|
if proto == "http+unix":
|
||||||
return "%s://%s" % (proto, host)
|
return "{0}://{1}".format(proto, host)
|
||||||
return "%s://%s:%d" % (proto, host, port)
|
return "{0}://{1}:{2}".format(proto, host, port)
|
||||||
|
|
||||||
|
|
||||||
def parse_devices(devices):
|
def parse_devices(devices):
|
||||||
|
|
Loading…
Reference in New Issue