Beispiel #1
0
    def _connect_and_execute(self, port):
        # Merge the nailgun TTY capability environment variables with the passed environment dict.
        ng_env = NailgunProtocol.isatty_to_env(self._stdin, self._stdout,
                                               self._stderr)
        modified_env = combined_dict(self._env, ng_env)
        modified_env['PANTSD_RUNTRACKER_CLIENT_START_TIME'] = str(
            self._start_time)

        assert isinstance(port, int), 'port {} is not an integer!'.format(port)

        # Instantiate a NailgunClient.
        client = NailgunClient(port=port,
                               ins=self._stdin,
                               out=self._stdout,
                               err=self._stderr,
                               exit_on_broken_pipe=True,
                               expects_pid=True)

        with self._trapped_signals(client), STTYSettings.preserved():
            # Execute the command on the pailgun.
            result = client.execute(self.PANTS_COMMAND, *self._args,
                                    **modified_env)

        # Exit.
        self._exiter.exit(result)
Beispiel #2
0
    def _connect_and_execute(self, pantsd_handle: PantsDaemon.Handle) -> ExitCode:
        port = pantsd_handle.port
        pid = pantsd_handle.pid
        # Merge the nailgun TTY capability environment variables with the passed environment dict.
        ng_env = NailgunProtocol.ttynames_to_env(self._stdin, self._stdout, self._stderr)
        modified_env = {
            **self._env,
            **ng_env,
            "PANTSD_RUNTRACKER_CLIENT_START_TIME": str(self._start_time),
            "PANTSD_REQUEST_TIMEOUT_LIMIT": str(
                self._bootstrap_options.for_global_scope().pantsd_timeout_when_multiple_invocations
            ),
        }

        assert isinstance(port, int), "port {} is not an integer! It has type {}.".format(
            port, type(port)
        )

        # Instantiate a NailgunClient.
        client = NailgunClient(
            port=port,
            remote_pid=pid,
            ins=self._stdin,
            out=self._stdout,
            err=self._stderr,
            exit_on_broken_pipe=True,
            metadata_base_dir=pantsd_handle.metadata_base_dir,
        )

        with self._trapped_signals(client, pantsd_handle.pid), STTYSettings.preserved():
            # Execute the command on the pailgun.
            return client.execute(self._args[0], self._args[1:], modified_env)
    def _connect_and_execute(self, pantsd_handle):
        port = pantsd_handle.port
        # Merge the nailgun TTY capability environment variables with the passed environment dict.
        ng_env = NailgunProtocol.isatty_to_env(self._stdin, self._stdout,
                                               self._stderr)
        modified_env = combined_dict(self._env, ng_env)
        modified_env['PANTSD_RUNTRACKER_CLIENT_START_TIME'] = str(
            self._start_time)
        modified_env['PANTSD_REQUEST_TIMEOUT_LIMIT'] = str(
            self._bootstrap_options.for_global_scope(
            ).pantsd_timeout_when_multiple_invocations)

        assert isinstance(port, int), \
          'port {} is not an integer! It has type {}.'.format(port, type(port))

        # Instantiate a NailgunClient.
        client = NailgunClient(
            port=port,
            ins=self._stdin,
            out=self._stdout,
            err=self._stderr,
            exit_on_broken_pipe=True,
            metadata_base_dir=pantsd_handle.metadata_base_dir)

        with self._trapped_signals(client), STTYSettings.preserved():
            # Execute the command on the pailgun.
            result = client.execute(self.PANTS_COMMAND, *self._args,
                                    **modified_env)

        # Exit.
        self._exiter.exit(result)
Beispiel #4
0
  def run(self, args=None):
    # Merge the nailgun TTY capability environment variables with the passed environment dict.
    ng_env = NailgunProtocol.isatty_to_env(self._stdin, self._stdout, self._stderr)
    modified_env = self._combine_dicts(self._env, ng_env)

    # Instantiate a NailgunClient.
    client = NailgunClient(port=self._port,
                           ins=self._stdin,
                           out=self._stdout,
                           err=self._stderr,
                           exit_on_broken_pipe=True)

    with self._trapped_control_c(client):
      # Execute the command on the pailgun.
      result = client.execute(self.PANTS_COMMAND, *self._args, **modified_env)

    # Exit.
    self._exiter.exit(result)
Beispiel #5
0
  def _connect_and_execute(self, port):
    # Merge the nailgun TTY capability environment variables with the passed environment dict.
    ng_env = NailgunProtocol.isatty_to_env(self._stdin, self._stdout, self._stderr)
    modified_env = combined_dict(self._env, ng_env)

    assert isinstance(port, int), 'port {} is not an integer!'.format(port)

    # Instantiate a NailgunClient.
    client = NailgunClient(port=port,
                           ins=self._stdin,
                           out=self._stdout,
                           err=self._stderr,
                           exit_on_broken_pipe=True)

    with self._trapped_control_c(client):
      # Execute the command on the pailgun.
      result = client.execute(self.PANTS_COMMAND, *self._args, **modified_env)

    # Exit.
    self._exiter.exit(result)
 def setUp(self):
     self.nailgun_client = NailgunClient()
Beispiel #7
0
 def _create_ngclient(self, port, stdout, stderr, stdin):
     return NailgunClient(port=port, ins=stdin, out=stdout, err=stderr)
Beispiel #8
0
 def _create_ngclient(self, port, stdout, stderr):
   return NailgunClient(port=port, ins=self._ins, out=stdout, err=stderr, workdir=get_buildroot())