Exemplo n.º 1
0
    def __init__(self, proto):
        """
		Start talking to standard IO with the given protocol.

		Also, put it stdin/stdout/stderr into binary mode.
		"""
        from lib.twisted.internet import reactor

        for stdfd in range(0, 1, 2):
            msvcrt.setmode(stdfd, os.O_BINARY)

        _pollingfile._PollingTimer.__init__(self, reactor)
        self.proto = proto

        hstdin = win32api.GetStdHandle(win32api.STD_INPUT_HANDLE)
        hstdout = win32api.GetStdHandle(win32api.STD_OUTPUT_HANDLE)

        self.stdin = _pollingfile._PollableReadPipe(hstdin, self.dataReceived,
                                                    self.readConnectionLost)

        self.stdout = _pollingfile._PollableWritePipe(hstdout,
                                                      self.writeConnectionLost)

        self._addPollableResource(self.stdin)
        self._addPollableResource(self.stdout)

        self.proto.makeConnection(self)
Exemplo n.º 2
0
	def __init__(self, proto):
		"""
		Start talking to standard IO with the given protocol.

		Also, put it stdin/stdout/stderr into binary mode.
		"""
		from lib.twisted.internet import reactor

		for stdfd in range(0, 1, 2):
			msvcrt.setmode(stdfd, os.O_BINARY)

		_pollingfile._PollingTimer.__init__(self, reactor)
		self.proto = proto

		hstdin = win32api.GetStdHandle(win32api.STD_INPUT_HANDLE)
		hstdout = win32api.GetStdHandle(win32api.STD_OUTPUT_HANDLE)

		self.stdin = _pollingfile._PollableReadPipe(
			hstdin, self.dataReceived, self.readConnectionLost)

		self.stdout = _pollingfile._PollableWritePipe(
			hstdout, self.writeConnectionLost)

		self._addPollableResource(self.stdin)
		self._addPollableResource(self.stdout)

		self.proto.makeConnection(self)
Exemplo n.º 3
0
		win32file.CloseHandle(hStderrW)
		win32file.CloseHandle(hStdoutW)
		win32file.CloseHandle(hStdinR)

		# set up everything
		self.stdout = _pollingfile._PollableReadPipe(
			self.hStdoutR,
			lambda data: self.proto.childDataReceived(1, data),
			self.outConnectionLost)

		self.stderr = _pollingfile._PollableReadPipe(
				self.hStderrR,
				lambda data: self.proto.childDataReceived(2, data),
				self.errConnectionLost)

		self.stdin = _pollingfile._PollableWritePipe(
			self.hStdinW, self.inConnectionLost)

		for pipewatcher in self.stdout, self.stderr, self.stdin:
			self._addPollableResource(pipewatcher)


		# notify protocol
		self.proto.makeConnection(self)

		self._addPollableResource(_Reaper(self))


	def signalProcess(self, signalID):
		if self.pid is None:
			raise error.ProcessExitedAlready()
		if signalID in ("INT", "TERM", "KILL"):
Exemplo n.º 4
0
        # close handles which only the child will use
        win32file.CloseHandle(hStderrW)
        win32file.CloseHandle(hStdoutW)
        win32file.CloseHandle(hStdinR)

        # set up everything
        self.stdout = _pollingfile._PollableReadPipe(
            self.hStdoutR, lambda data: self.proto.childDataReceived(1, data),
            self.outConnectionLost)

        self.stderr = _pollingfile._PollableReadPipe(
            self.hStderrR, lambda data: self.proto.childDataReceived(2, data),
            self.errConnectionLost)

        self.stdin = _pollingfile._PollableWritePipe(self.hStdinW,
                                                     self.inConnectionLost)

        for pipewatcher in self.stdout, self.stderr, self.stdin:
            self._addPollableResource(pipewatcher)

        # notify protocol
        self.proto.makeConnection(self)

        self._addPollableResource(_Reaper(self))

    def signalProcess(self, signalID):
        if self.pid is None:
            raise error.ProcessExitedAlready()
        if signalID in ("INT", "TERM", "KILL"):
            win32process.TerminateProcess(self.hProcess, 1)