This module is mainly for internal use.

Pty implements a terminal abstraction. This can be around the default stdin/out pair, but also around a pseudo terminal that was created through the openpty system call.

class deployer.pseudo_terminal.DummyPty(input_data='')

Pty compatible object which insn’t attached to an interactive terminal, but to dummy StringIO instead.

This is mainly for unit testing, normally you want to see the execution in your terminal.

class deployer.pseudo_terminal.Pty(stdin=None, stdout=None, interactive=True, term_var='')

Terminal abstraction around a stdin/stdout pair.

Contains helper function, for opening an additional Pty, if parallel deployments are supported.

Stdin:The input stream. (sys.__stdin__ by default)
Stdout:The output stream. (sys.__stdout__ by default)
Interactive:When False, we should never ask for input during the deployment. Choose default options when possible.

Return the height.


Get the size of this pseudo terminal.

Returns:A (rows, cols) tuple.

Return the width.


For each callback, open an additional terminal, and call it with the new ‘pty’ as parameter. The callback can potentially run in another thread.

The default behaviour is not in parallel, but sequential. Socket_server however, inherits this pty, and overrides this function for parrallel execution.

Parameters:callbacks – A list of callables.
set_size(rows, cols)

Set terminal size.

(This is also mainly for internal use. Setting the terminal size automatically happens when the window resizes. However, sometimes the process that created a pseudo terminal, and the process that’s attached to the output window are not the same, e.g. in case of a telnet connection, or unix domain socket, and then we have to sync the sizes by hand.)


Return the input file object.


Return the output file object.*args, **kwargs)

Wrapper around

When the SIGWINCH signal is handled, other system calls, like select are aborted in Python. This wrapper will retry the system call.