pysubprocess

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNtShellNotFound = errors.New("shell not found: neither %ComSpec% nor %SystemRoot% is set")

ErrNtShellNotFound is the FileNotFoundError Popen raises when neither ComSpec nor SystemRoot names a shell

Functions

func List2cmdline

func List2cmdline(seq []string) string

Windows command line of the argument sequence with the MS C runtime quoting subprocess uses

func NtCommandLineModule

func NtCommandLineModule(cmdline string, s NtSearch, isFile func(string) bool) (string, bool)

Module CreateProcess starts for a command line without an application name, false when no candidate exists

func NtShell

func NtShell(args string, getenv func(string) string) (string, string, error)

Executable and command line Popen hands CreateProcess for shell=True, an empty executable leaving CreateProcess to search

func Returncode

func Returncode(e *exec.ExitError) int

Popen returncode of an exited child, negative for a signal on POSIX

func Run

func Run(argv []string, timeoutSeconds int, check bool) (stdout, stderr []byte, err error)

Runs argv with captured output and a whole second timeout, failing like check=True on a nonzero exit

func ShellCommand

func ShellCommand(command string) (*exec.Cmd, error)

Command Popen runs for shell=True, the string handed to /bin/sh -c or the Android system shell

func UnixShell

func UnixShell() string

Shell Popen runs for shell=True, the Android system shell on Android

Types

type CalledProcessError

type CalledProcessError struct {
	Cmd        []string
	Returncode int
	Stdout     []byte
	Stderr     []byte
}

Failure subprocess.run raises with check=True when the command exits nonzero

func (*CalledProcessError) Error

func (e *CalledProcessError) Error() string

type Completed

type Completed struct {
	Args       []string
	Returncode int
	Stdout     []byte
	Stderr     []byte
}

Finished command with its exit status and both captured streams

func RunWith

func RunWith(ctx context.Context, argv []string, o Options) (*Completed, error)

Runs argv like subprocess.run, a timeout kills the child and raises TimeoutExpired, a cancelled ctx returns its error

type NtSearch

type NtSearch struct {
	AppDir     string
	Cwd        string
	SkipCwd    bool
	SystemDir  string
	WindowsDir string
	Path       string
}

Search places CreateProcess walks for a module named without a directory

type Options

type Options struct {
	Dir     string
	Env     []string
	Input   []byte
	Timeout time.Duration
	Check   bool
	Attr    *syscall.SysProcAttr
}

Keywords of one subprocess.run call with capture_output, nil Env inherits and nil Input reads the null device

type TimeoutExpired

type TimeoutExpired struct {
	Cmd          []string
	Timeout      int
	TimeoutFloat *float64
	Stdout       []byte
	Stderr       []byte
}

Failure subprocess.run raises after killing a command that outlived its timeout

func (*TimeoutExpired) Error

func (e *TimeoutExpired) Error() string

Message with the timeout printed as Python prints the int or the float the caller passed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL