MCPcopy Create free account
hub / github.com/pexpect/pexpect / send

Method send

pexpect/popen_spawn.py:132–147  ·  view source on GitHub ↗

Send data to the subprocess' stdin. Returns the number of bytes written.

(self, s)

Source from the content-addressed store, hash-verified

130 self.send(s)
131
132 def send(self, s):
133 '''Send data to the subprocess' stdin.
134
135 Returns the number of bytes written.
136 '''
137 s = self._coerce_send_string(s)
138 self._log(s, 'send')
139
140 b = self._encoder.encode(s, final=False)
141 if PY3:
142 return self.proc.stdin.write(b)
143 else:
144 # On Python 2, .write() returns None, so we return the length of
145 # bytes written ourselves. This assumes they all got written.
146 self.proc.stdin.write(b)
147 return len(b)
148
149 def sendline(self, s=''):
150 '''Wraps send(), sending string ``s`` to child process, with os.linesep

Callers 3

writeMethod · 0.95
writelinesMethod · 0.95
sendlineMethod · 0.95

Calls 4

_coerce_send_stringMethod · 0.80
_logMethod · 0.80
encodeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected