diff options
author | Thomas Kluyver <takowl@gmail.com> | 2015-09-12 11:19:51 +0100 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2015-09-12 11:19:51 +0100 |
commit | 617ec75f361bf6ffd61baca7d84ad581541c9733 (patch) | |
tree | 7126f7e68ae99540018de9fdba9d83f0287002b7 | |
parent | 82e38877c9806fd8afd534ed31f911ed570c2c40 (diff) | |
parent | 09773b39f4b791ea89e17711f214ac8f98d34269 (diff) | |
download | pexpect-git-617ec75f361bf6ffd61baca7d84ad581541c9733.tar.gz |
Merge pull request #236 from takluyver/restore-fdspawn-send
Restore send/write methods to fdpexpect
-rw-r--r-- | pexpect/fdpexpect.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pexpect/fdpexpect.py b/pexpect/fdpexpect.py index 96ca2e1..2b51e24 100644 --- a/pexpect/fdpexpect.py +++ b/pexpect/fdpexpect.py @@ -84,3 +84,27 @@ class fdspawn(SpawnBase): def terminate (self, force=False): # pragma: no cover raise ExceptionPexpect('This method is not valid for file descriptors.') + + # These four methods are left around for backwards compatibility, but not + # documented as part of fdpexpect. You're encouraged to use os.write# + # directly. + def send(self, s): + "Write to fd, return number of bytes written" + s = self._coerce_send_string(s) + self._log(s, 'send') + + return os.write(self.child_fd, s) + + def sendline(self, s): + "Write to fd with trailing newline, return number of bytes written" + s = self._coerce_send_string(s) + return self.send(s + self.linesep) + + def write(self, s): + "Write to fd, return None" + self.send(s) + + def writelines(self, sequence): + "Call self.write() for each item in sequence" + for s in sequence: + self.write(s) |