411
411
status = self._check_last_status(output)
412
412
return status, output
414
# Override read for better performance in the case where a known number of
415
# bytes are being read. Pexpect uses a regular expression to implement
416
# this, which is bound to be slow when reading a significant amount of
419
def read(self, size = -1):
421
# We don't bother handling the read-until-EOF case. Anybody doing
422
# that doesn't care about read performance, which is the reason
423
# we're overriding the parent implementation, anyway.
424
return super(Shell, self).read(size)
429
s = os.read(self.child_fd, size - nbytes)
439
return ''.join(parts)
441
# FIXME: The broken behavior mentioned below would also affect send.
443
# Override write to get correct behavior. Pexpect does not correctly
444
# handle the situation where only part of the string is written. This will
445
# likely only be an issue when the write is interrupted by a signal, in
446
# which case Pexpect would only write part of the string and then return.
449
if isinstance(s, unicode):
454
nbytes += os.write(self.child_fd, s[nbytes:])
414
458
def encode(self, s):
415
459
return s.encode(self.shell_encoding)