Subprocess Specifications (xonsh.procs.specs
)¶
Subprocess specification and related utilities.
-
class
xonsh.procs.specs.
SubprocSpec
(cmd, cls=<class 'subprocess.Popen'>, stdin=None, stdout=None, stderr=None, universal_newlines=False, close_fds=False, captured=False, env=None)[source]¶ A container for specifying how a subprocess command should be executed.
- Parameters
- cmdlist of str
Command to be run.
- clsPopen-like
Class to run the subprocess with.
- stdinfile-like
Popen file descriptor or flag for stdin.
- stdoutfile-like
Popen file descriptor or flag for stdout.
- stderrfile-like
Popen file descriptor or flag for stderr.
- universal_newlinesbool
Whether or not to use universal newlines.
- close_fdsbool
Whether or not to close the file descriptiors when the process exits.
- capturedbool or str, optional
The flag for if the subprocess is captured, may be one of: False for $[], ‘stdout’ for $(), ‘hiddenobject’ for ![], or ‘object’ for !().
- envdict
Replacement environment to run the subporcess in.
- Attributes
- argslist of str
Arguments as originally supplied.
- aliaslist of str, callable, or None
The alias that was resolved for this command, if any.
- binary_locstr or None
Path to binary to execute.
- is_proxybool
Whether or not the subprocess is or should be run as a proxy.
- backgroundbool
Whether or not the subprocess should be started in the background.
- threadablebool
Whether or not the subprocess is able to be run in a background thread, rather than the main thread.
- pipeline_indexint or None
The index number of this sepc into the pipeline that is being setup.
- last_in_pipelinebool
Whether the subprocess is the last in the execution pipeline.
- captured_stdoutfile-like
Handle to captured stdin
- captured_stderrfile-like
Handle to captured stderr
- stacklist of FrameInfo namedtuples or None
The stack of the call-site of alias, if the alias requires it. None otherwise.
-
classmethod
build
(cmd, *, cls=<class 'subprocess.Popen'>, **kwargs)[source]¶ Creates an instance of the subprocess command, with any modifications and adjustments based on the actual cmd that was received.
-
kwnames
= ('stdin', 'stdout', 'stderr', 'universal_newlines', 'close_fds')¶
-
property
stderr
¶
-
property
stdin
¶
-
property
stdout
¶
-
xonsh.procs.specs.
cmds_to_specs
(cmds, captured=False, envs=None)[source]¶ Converts a list of cmds to a list of SubprocSpec objects that are ready to be executed.
-
xonsh.procs.specs.
get_script_subproc_command
(fname, args)[source]¶ Given the name of a script outside the path, returns a list representing an appropriate subprocess command to execute the script or None if the argument is not readable or not a script. Raises PermissionError if the script is not executable.
-
xonsh.procs.specs.
is_app_execution_alias
(fname)[source]¶ App execution aliases behave strangly on Windows and Python. Here we try to detect if a file is an app execution alias.
-
xonsh.procs.specs.
no_pg_xonsh_preexec_fn
()[source]¶ Default subprocess preexec function for when there is no existing pipeline group.
-
xonsh.procs.specs.
run_subproc
(cmds, captured=False, envs=None)[source]¶ Runs a subprocess, in its many forms. This takes a list of ‘commands,’ which may be a list of command line arguments or a string, representing a special connecting character. For example:
$ ls | grep wakka
is represented by the following cmds:
[['ls'], '|', ['grep', 'wakka']]
Lastly, the captured argument affects only the last real command.