def _wrap_docker_stream(self, stream):
        """Wrapper to parse the different types of messages from the
        Docker Remote API and spit them out in a friendly format."""

        for msg in stream:
            logger.info("Received update from docker: %s", msg.rstrip())

            # Parse the message / handle any errors from docker
            try:
                update = json.loads(msg.rstrip())
            except Exception, e:
                logger.error("Caught exception parsing message %s %r", msg, e)
            else:
                if "error" in update:
                    logger.error("Docker error: %s", update["error"])
                    yield update["error"], False
                    raise Exception("Docker encountered an error")

                friendly_message = None
                is_stream = False

                if "stream" in update:
                    is_stream = True
                    friendly_message = re.sub(r'\033\[[0-9;]*m', '',
                                              update["stream"].rstrip())
                if "status" in update:
                    friendly_message = update["status"].rstrip()
                    if "id" in update:
                        friendly_message = "[%s] %s" % (update["id"], friendly_message)
                    if "progress" in update:
                        friendly_message += update["progress"] % " (%s)"

                if friendly_message is not None:
                    yield friendly_message, is_stream
dataset/ETHPy150Open duedil-ltd/portainer/portainer/app/executor.py/Executor._wrap_docker_stream/swapped operands of `%`