summaryrefslogtreecommitdiff
path: root/compose/service.py
diff options
context:
space:
mode:
authorUlysses Souza <ulyssessouza@gmail.com>2020-01-06 16:00:34 +0100
committerUlysses Souza <ulyssessouza@gmail.com>2020-01-06 16:00:34 +0100
commit37eb7a509b41e5f39cfb6506ebfdef0a59f02765 (patch)
tree636593c61f6e56aa2d8fdc060e9aae83b6ac07e5 /compose/service.py
parentcba8ad474ca0b3b2af20c792cf3cb4d331524bde (diff)
Decode APIError explanation to unicode before usage
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
Diffstat (limited to 'compose/service.py')
-rw-r--r--compose/service.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/compose/service.py b/compose/service.py
index d329be97..024e7fbd 100644
--- a/compose/service.py
+++ b/compose/service.py
@@ -60,6 +60,7 @@ from .utils import parse_bytes
from .utils import parse_seconds_float
from .utils import truncate_id
from .utils import unique_everseen
+from compose.cli.utils import binarystr_to_unicode
if six.PY2:
import subprocess32 as subprocess
@@ -343,7 +344,7 @@ class Service(object):
return Container.create(self.client, **container_options)
except APIError as ex:
raise OperationFailedError("Cannot create container for service %s: %s" %
- (self.name, ex.explanation))
+ (self.name, binarystr_to_unicode(ex.explanation)))
def ensure_image_exists(self, do_build=BuildAction.none, silent=False, cli=False):
if self.can_be_built() and do_build == BuildAction.force:
@@ -624,9 +625,10 @@ class Service(object):
try:
container.start()
except APIError as ex:
- if "driver failed programming external connectivity" in ex.explanation:
+ expl = binarystr_to_unicode(ex.explanation)
+ if "driver failed programming external connectivity" in expl:
log.warn("Host is already in use by another container")
- raise OperationFailedError("Cannot start service %s: %s" % (self.name, ex.explanation))
+ raise OperationFailedError("Cannot start service %s: %s" % (self.name, expl))
return container
@property