summaryrefslogtreecommitdiff
path: root/pexpect/pty_spawn.py
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2015-09-22 15:55:14 +0100
committerThomas Kluyver <takowl@gmail.com>2015-09-22 15:55:14 +0100
commitea586fb9a545854f9b1212779653ec80f3428a2c (patch)
tree73314e01eb5a39299465d1cfa4e4d5d7b4bdedbb /pexpect/pty_spawn.py
parent4411cd9203c0624f9f800726ea4b5ea24c989424 (diff)
parent3cdab2ef2eebb62514dee116142c73e475735a87 (diff)
downloadpexpect-git-ea586fb9a545854f9b1212779653ec80f3428a2c.tar.gz
Merge remote-tracking branch 'origin/setwinsize_on_spawn'
Conflicts: doc/history.rst
Diffstat (limited to 'pexpect/pty_spawn.py')
-rw-r--r--pexpect/pty_spawn.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index 0b9ad4c..9141b17 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -37,7 +37,7 @@ class spawn(SpawnBase):
def __init__(self, command, args=[], timeout=30, maxread=2000,
searchwindowsize=None, logfile=None, cwd=None, env=None,
ignore_sighup=True, echo=True, preexec_fn=None,
- encoding=None, codec_errors='strict'):
+ encoding=None, codec_errors='strict', dimensions=None):
'''This is the constructor. The command parameter may be a string that
includes a command and any arguments to the command. For example::
@@ -174,6 +174,10 @@ class spawn(SpawnBase):
If preexec_fn is given, it will be called in the child process before
launching the given command. This is useful to e.g. reset inherited
signal handlers.
+
+ The dimensions attribute specifies the size of the pseudo-terminal as
+ seen by the subprocess, and is specified as a two-entry tuple (rows,
+ columns). If this is unspecified, the defaults in ptyprocess will apply.
'''
super(spawn, self).__init__(timeout=timeout, maxread=maxread, searchwindowsize=searchwindowsize,
logfile=logfile, encoding=encoding, codec_errors=codec_errors)
@@ -190,7 +194,7 @@ class spawn(SpawnBase):
self.args = None
self.name = '<pexpect factory incomplete>'
else:
- self._spawn(command, args, preexec_fn)
+ self._spawn(command, args, preexec_fn, dimensions)
def __str__(self):
'''This returns a human-readable string that represents the state of
@@ -226,7 +230,7 @@ class spawn(SpawnBase):
s.append('delayafterterminate: ' + str(self.delayafterterminate))
return '\n'.join(s)
- def _spawn(self, command, args=[], preexec_fn=None):
+ def _spawn(self, command, args=[], preexec_fn=None, dimensions=None):
'''This starts the given command in a child process. This does all the
fork/exec type of stuff for a pty. This is called by __init__. If args
is empty then command will be parsed (split on spaces) and args will be
@@ -281,6 +285,9 @@ class spawn(SpawnBase):
preexec_fn()
kwargs['preexec_fn'] = preexec_wrapper
+ if dimensions is not None:
+ kwargs['dimensions'] = dimensions
+
self.ptyproc = ptyprocess.PtyProcess.spawn(self.args, env=self.env,
cwd=self.cwd, **kwargs)