Module ImportFrom alias alias alias alias alias alias alias Import alias Import alias ClassDef bases NameLoad body Expr Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore BinOpAdd NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Assign NameStore Num ClassDef bases NameLoad body Expr Str decorator_list ClassDef bases NameLoad body Expr Str decorator_list ClassDef bases NameLoad body Expr Str decorator_list ClassDef bases NameLoad body Expr Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults vararg kwarg body Expr Str For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad For NameStore Call AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore ListLoad Assign NameStore Dict While UnaryOpNot Call NameLoad TupleLoad NameLoad NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad If CompareEq NameLoad AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq NameLoad AttributeLoad NameLoad attr body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num Assign SubscriptStore NameLoad Index NameLoad NameLoad orelse If CompareEq NameLoad AttributeLoad NameLoad attr body Assign NameStore NameLoad orelse If CompareEq NameLoad AttributeLoad NameLoad attr body Assign NameStore NameLoad orelse Raise Call AttributeLoad NameLoad attr Str Return TupleLoad NameLoad NameLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str body Expr Str If Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad orelse If UnaryOpNot Call NameLoad NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Call AttributeLoad Str attr Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Return BinOpAdd NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str While CompareLt Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr BinOpSub NameLoad Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad Call NameLoad NameLoad AugAssignAdd NameStore NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr handlers ExceptHandler type AttributeLoad NameLoad attr name NameStore body Raise Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr name NameStore body Raise Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad If CompareNotIn NameLoad AttributeLoad NameLoad attr body Raise Call AttributeLoad NameLoad attr Call AttributeLoad Str attr NameLoad Return TupleLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str While Num body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad Expr Yield TupleLoad NameLoad NameLoad If CompareEq NameLoad AttributeLoad NameLoad attr body Break decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore TupleLoad NameLoad NameLoad NameLoad Return DictComp Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Call NameLoad Call NameLoad Call AttributeLoad NameLoad attr comprehension TupleStore NameStore NameStore Call NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam defaults body Return BoolOpAnd Call AttributeLoad NameLoad attr Call NameLoad Call NameLoad NameLoad decorator_list Return Call NameLoad GeneratorExp Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str comprehension NameStore Call NameLoad Num decorator_list NameLoad decorator_list
N/A __future__ absolute_import division generators nested_scopes print_function unicode_literals with_statement N/A struct N/A six ChunkType N/A object N/A N/A Nailgun protocol chunk types.

  N.B. Because we force `__future__.unicode_literals` in sources, string literals are automatically
  converted to unicode for us (e.g. 'xyz' automatically becomes u'xyz'). In the case of protocol
  implementations, supporting methods like struct.pack() require ASCII values - so we specify
  constants such as these as byte literals (e.g. b'xyz', which can only contain ASCII values)
  rather than their unicode counterparts. The alternative is to call str.encode('ascii') to
  convert the unicode string literals to ascii before use.
   N/A ARGUMENT A N/A ENVIRONMENT E N/A WORKING_DIR D N/A COMMAND C N/A PID P N/A STDIN 0 N/A STDOUT 1 N/A STDERR 2 N/A START_READING_INPUT S N/A STDIN_EOF . N/A EXIT X N/A REQUEST_TYPES N/A ARGUMENT ENVIRONMENT WORKING_DIR COMMAND N/A EXECUTION_TYPES N/A PID STDIN STDOUT STDERR START_READING_INPUT STDIN_EOF EXIT N/A VALID_TYPES N/A REQUEST_TYPES EXECUTION_TYPES N/A NailgunProtocol N/A object N/A N/A A mixin that provides a base implementation of the Nailgun protocol as described on
     http://martiansoftware.com/nailgun/protocol.html.

  Communications proceed as follows:

    1) Client connects to server
    2) Client transmits zero or more "Argument" chunks
    3) Client transmits zero or more "Environment" chunks
    4) Client transmits exactly one "Working Directory" chunk
    5) Client transmits exactly one "Command" chunk
    6) If server requires stdin input, server transmits exactly one "Start-reading-input" chunk

    After step 5 (and/or 6) the following may happen, interleaved and in any order:

    7) Client transmits zero or more "stdin" chunks (Only if the client has received a
       "Start-reading-input" chunk, and only until the client transmits a "stdin-eof" chunk).
    8) Server transmits zero or more "stdout" chunks.
    9) Server transmits zero or more "stderr" chunks.

    Steps 7-9 repeat indefinitely until the server transmits an "exit" chunk.

   N/A ENVIRON_SEP = N/A TTY_ENV_TMPL NAILGUN_TTY_{} N/A HEADER_FMT >Ic N/A HEADER_BYTES 5 ProtocolError N/A Exception N/A N/A Raised if there is an error in the underlying nailgun protocol. N/A TruncatedRead N/A ProtocolError N/A N/A Raised if there is a socket error while reading an expected number of bytes. N/A TruncatedHeaderError N/A TruncatedRead N/A N/A Raised if there is a socket error while reading the header bytes. N/A TruncatedPayloadError N/A TruncatedRead N/A N/A Raised if there is a socket error while reading the payload bytes. N/A send_request N/A N/A cls sock working_dir command N/A arguments environment N/A N/A Send the initial Nailgun request over the specified socket. N/A argument arguments N/A N/A N/A N/A cls write_chunk sock N/A ChunkType ARGUMENT argument N/A item_tuple N/A N/A environment items N/A N/A N/A N/A cls write_chunk sock N/A ChunkType ENVIRONMENT N/A N/A N/A cls ENVIRON_SEP join item_tuple N/A N/A N/A cls write_chunk sock N/A ChunkType WORKING_DIR working_dir N/A N/A N/A cls write_chunk sock N/A ChunkType COMMAND command N/A classmethod parse_request N/A N/A cls sock N/A N/A N/A Parse the request (the pre-execution) section of the nailgun protocol from the given socket.

    Handles reading of the Argument, Environment, Working Directory and Command chunks from the
    client which represents the "request" phase of the exchange. Working Directory and Command are
    required and must be sent as the last two chunks in this phase. Argument and Environment chunks
    are optional and can be sent more than once (thus we aggregate them).
     N/A command None N/A working_dir None N/A arguments N/A N/A environment N/A N/A N/A N/A all N/A working_dir command N/A N/A N/A chunk_type payload N/A N/A cls read_chunk sock N/A N/A chunk_type N/A ChunkType ARGUMENT N/A N/A N/A N/A arguments append payload N/A N/A N/A chunk_type N/A ChunkType ENVIRONMENT N/A N/A N/A key val N/A N/A payload split N/A cls ENVIRON_SEP 1 N/A N/A environment N/A key val N/A N/A N/A chunk_type N/A ChunkType WORKING_DIR N/A N/A working_dir payload N/A N/A N/A chunk_type N/A ChunkType COMMAND N/A N/A command payload N/A N/A N/A N/A cls ProtocolError received non-request chunk before header was fully received! N/A N/A working_dir command arguments environment N/A classmethod write_chunk N/A N/A cls sock chunk_type payload N/A N/A N/A Write a single chunk to the connected client. N/A chunk N/A N/A cls construct_chunk chunk_type payload N/A N/A N/A sock sendall chunk N/A classmethod construct_chunk N/A N/A cls chunk_type payload encoding N/A utf-8 N/A N/A Construct and return a single chunk. N/A N/A isinstance payload N/A six text_type N/A N/A payload N/A N/A payload encode encoding N/A N/A N/A N/A isinstance payload N/A six binary_type N/A N/A N/A TypeError N/A N/A cannot encode type: {} format N/A type payload N/A header N/A N/A struct pack N/A cls HEADER_FMT N/A len payload chunk_type N/A N/A header payload N/A classmethod _read_until N/A N/A cls sock desired_size N/A N/A N/A Read a certain amount of content from a socket before returning. N/A buf N/A N/A N/A len buf desired_size N/A N/A recv_bytes N/A N/A sock recv N/A desired_size N/A len buf N/A N/A recv_bytes N/A N/A N/A N/A cls TruncatedRead N/A N/A Expected {} bytes before socket shutdown, instead received {} format desired_size N/A len buf N/A buf recv_bytes N/A buf N/A classmethod read_chunk N/A N/A cls sock N/A N/A N/A Read a single chunk from the connected client.

     A "chunk" is a variable-length block of data beginning with a 5-byte chunk header and followed
     by an optional payload. The chunk header consists of:

          1) The length of the chunk's payload (not including the header) as a four-byte big-endian
             unsigned long. The high-order byte is header[0] and the low-order byte is header[3].

          2) A single byte identifying the type of chunk.
     N/A N/A N/A header N/A N/A cls _read_until sock N/A cls HEADER_BYTES N/A N/A N/A N/A cls TruncatedRead N/A e N/A N/A N/A N/A cls TruncatedHeaderError N/A N/A Failed to read nailgun chunk header ({!r}). format e N/A N/A payload_len chunk_type N/A N/A struct unpack N/A cls HEADER_FMT header N/A N/A N/A payload N/A N/A cls _read_until sock payload_len N/A N/A N/A N/A cls TruncatedRead N/A e N/A N/A N/A N/A cls TruncatedPayloadError N/A N/A Failed to read nailgun chunk payload ({!r}). format e N/A N/A chunk_type N/A ChunkType VALID_TYPES N/A N/A N/A N/A cls ProtocolError N/A N/A invalid chunk type: {} format chunk_type N/A N/A chunk_type payload N/A classmethod iter_chunks N/A N/A cls sock N/A N/A N/A Generates chunks from a connected socket until an Exit chunk is sent. N/A 1 N/A N/A N/A chunk_type payload N/A N/A cls read_chunk sock N/A N/A N/A chunk_type payload N/A N/A chunk_type N/A ChunkType EXIT N/A N/A N/A classmethod send_start_reading_input N/A N/A cls sock N/A N/A N/A Send the Start-Reading-Input chunk over the specified socket. N/A N/A N/A cls write_chunk sock N/A ChunkType START_READING_INPUT N/A classmethod send_stdout N/A N/A cls sock payload N/A N/A N/A Send the Stdout chunk over the specified socket. N/A N/A N/A cls write_chunk sock N/A ChunkType STDOUT payload N/A classmethod send_stderr N/A N/A cls sock payload N/A N/A N/A Send the Stderr chunk over the specified socket. N/A N/A N/A cls write_chunk sock N/A ChunkType STDERR payload N/A classmethod send_exit N/A N/A cls sock payload N/A N/A N/A Send the Exit chunk over the specified socket. N/A N/A N/A cls write_chunk sock N/A ChunkType EXIT payload N/A classmethod isatty_to_env N/A N/A cls stdin stdout stderr N/A N/A N/A Generate nailgun tty capability environment variables based on checking a set of fds.

    :param file stdin: The stream to check for stdin tty capabilities.
    :param file stdout: The stream to check for stdout tty capabilities.
    :param file stderr: The stream to check for stderr tty capabilities.
    :returns: A dict containing the tty capability environment variables.
     N/A fds N/A stdin stdout stderr N/A N/A N/A N/A N/A cls TTY_ENV_TMPL format fd_id N/A bytes N/A int N/A N/A fd isatty N/A N/A fd_id fd N/A enumerate fds N/A classmethod isatty_from_env N/A N/A cls env N/A N/A N/A Determine whether remote file descriptors are tty capable using std nailgunned env variables.

    :param dict env: A dictionary representing the environment.
    :returns: A tuple of boolean values indicating istty or not for (stdin, stdout, stderr).
     str_int_bool N/A N/A i N/A N/A N/A N/A N/A N/A i isdigit N/A bool N/A int i N/A N/A N/A tuple N/A N/A str_int_bool N/A N/A env get N/A N/A N/A cls TTY_ENV_TMPL format fd_id 0 N/A fd_id N/A range 3 N/A classmethod N/A