Format: application/octet-stream
⬇ Download File (3.2 KB)
   1  from typing import IO, Any, Callable, Generic, List, Mapping, Optional, Sequence, Text, Tuple, TypeVar, Union
   2  
   3  _FILE = Union[None, int, IO[Any]]
   4  _TXT = Union[bytes, Text]
   5  _CMD = Union[_TXT, Sequence[_TXT]]
   6  _ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]]
   7  
   8  # Same args as Popen.__init__
   9  def call(
  10      args: _CMD,
  11      bufsize: int = ...,
  12      executable: _TXT = ...,
  13      stdin: _FILE = ...,
  14      stdout: _FILE = ...,
  15      stderr: _FILE = ...,
  16      preexec_fn: Callable[[], Any] = ...,
  17      close_fds: bool = ...,
  18      shell: bool = ...,
  19      cwd: Optional[_TXT] = ...,
  20      env: Optional[_ENV] = ...,
  21      universal_newlines: bool = ...,
  22      startupinfo: Any = ...,
  23      creationflags: int = ...,
  24  ) -> int: ...
  25  def check_call(
  26      args: _CMD,
  27      bufsize: int = ...,
  28      executable: _TXT = ...,
  29      stdin: _FILE = ...,
  30      stdout: _FILE = ...,
  31      stderr: _FILE = ...,
  32      preexec_fn: Callable[[], Any] = ...,
  33      close_fds: bool = ...,
  34      shell: bool = ...,
  35      cwd: Optional[_TXT] = ...,
  36      env: Optional[_ENV] = ...,
  37      universal_newlines: bool = ...,
  38      startupinfo: Any = ...,
  39      creationflags: int = ...,
  40  ) -> int: ...
  41  
  42  # Same args as Popen.__init__ except for stdout
  43  def check_output(
  44      args: _CMD,
  45      bufsize: int = ...,
  46      executable: _TXT = ...,
  47      stdin: _FILE = ...,
  48      stderr: _FILE = ...,
  49      preexec_fn: Callable[[], Any] = ...,
  50      close_fds: bool = ...,
  51      shell: bool = ...,
  52      cwd: Optional[_TXT] = ...,
  53      env: Optional[_ENV] = ...,
  54      universal_newlines: bool = ...,
  55      startupinfo: Any = ...,
  56      creationflags: int = ...,
  57  ) -> bytes: ...
  58  
  59  PIPE: int
  60  STDOUT: int
  61  
  62  class CalledProcessError(Exception):
  63      returncode: int
  64      # morally: _CMD
  65      cmd: Any
  66      # morally: Optional[bytes]
  67      output: bytes
  68      def __init__(self, returncode: int, cmd: _CMD, output: Optional[bytes] = ...) -> None: ...
  69  
  70  # We use a dummy type variable used to make Popen generic like it is in python 3
  71  _T = TypeVar("_T", bound=bytes)
  72  
  73  class Popen(Generic[_T]):
  74      stdin: Optional[IO[bytes]]
  75      stdout: Optional[IO[bytes]]
  76      stderr: Optional[IO[bytes]]
  77      pid: int
  78      returncode: int
  79      def __new__(
  80          cls,
  81          args: _CMD,
  82          bufsize: int = ...,
  83          executable: Optional[_TXT] = ...,
  84          stdin: Optional[_FILE] = ...,
  85          stdout: Optional[_FILE] = ...,
  86          stderr: Optional[_FILE] = ...,
  87          preexec_fn: Optional[Callable[[], Any]] = ...,
  88          close_fds: bool = ...,
  89          shell: bool = ...,
  90          cwd: Optional[_TXT] = ...,
  91          env: Optional[_ENV] = ...,
  92          universal_newlines: bool = ...,
  93          startupinfo: Optional[Any] = ...,
  94          creationflags: int = ...,
  95      ) -> Popen[bytes]: ...
  96      def poll(self) -> Optional[int]: ...
  97      def wait(self) -> int: ...
  98      # morally: -> Tuple[Optional[bytes], Optional[bytes]]
  99      def communicate(self, input: Optional[_TXT] = ...) -> Tuple[bytes, bytes]: ...
 100      def send_signal(self, signal: int) -> None: ...
 101      def terminate(self) -> None: ...
 102      def kill(self) -> None: ...
 103  
 104  def list2cmdline(seq: Sequence[str]) -> str: ...  # undocumented
 105  
 106  # Windows-only: STARTUPINFO etc.
 107  
 108  STD_INPUT_HANDLE: Any
 109  STD_OUTPUT_HANDLE: Any
 110  STD_ERROR_HANDLE: Any
 111  SW_HIDE: Any
 112  STARTF_USESTDHANDLES: Any
 113  STARTF_USESHOWWINDOW: Any
 114  CREATE_NEW_CONSOLE: Any
 115  CREATE_NEW_PROCESS_GROUP: Any
 116