def registered(self, driver, executorInfo, frameworkInfo, slaveInfo):

        logger.info("Setting up environment for building containers")

        # Parse the build task object
        try:
            build_task = portainer_pb2.BuildTask()
            build_task.ParseFromString(executorInfo.data)
        except Exception:
            logger.error("Failed to parse BuildTask in ExecutorInfo.data")
            raise

        self.build_task = build_task

        # Launch the docker daemon
        def launch_docker_daemon():
            logger.info("Launching docker daemon subprocess")

            env = dict(os.environ)
            env["DOCKER_DAEMON_ARGS"] = " -g %s" % (
                os.path.join(os.environ.get("MESOS_SANDBOX", os.environ["MESOS_DIRECTORY"]), "docker")
            )

            for reg in build_task.daemon.insecure_registries:
                env["DOCKER_DAEMON_ARGS"] += reg % " --insecure-registry %s"

            # Use the `wrapdocker` script included in our docker image
            proc = subprocess.Popen(["/usr/local/bin/wrapdocker"], env=env)

            self.docker = docker.Client()
            while True:
                try:
                    self.docker.ping()
                except:
                    logger.info("Waiting for docker daemon to respond to pings")
                    time.sleep(1)
                else:
                    self.docker_daemon_up = True
                    break

            proc.wait()

        if not build_task.daemon.HasField("docker_host"):
            daemon_thread = threading.Thread(target=launch_docker_daemon)
            daemon_thread.setDaemon(True)
            daemon_thread.start()
        else:
            self.docker = docker.Client(build_task.daemon.docker_host)
            self.docker_daemon_up = True
dataset/ETHPy150Open duedil-ltd/portainer/portainer/app/executor.py/Executor.registered/swapped operands of `%`