An copy-on-write version of Runner.
This subclass of Runner is unmodifiable. It is meant to be used for re-usable exe()-like objects. For example, if one wants an object lsl that runs exe('ls')['-l'] with optional extra arguments, one could do:
lsl=ImmutableRunner(Runner('ls')['-l'])
and then every time one does run(lsl[argument list]), it generates a new object without modifying the original lsl, ensuring later calls to lsl will have the same effect:
lsl['/'] lsl['~'] lsl['/'] # prints the same as the first
This is implemented by a copy-on-write method: if a modification is requested, a Runner is returned with the requested modifications.
Definition at line 884 of file prog.py.
|
| def | __init__ (self, args, kwargs) |
| | Creates a new ImmutableRunner. More...
|
| |
| def | copy |
| | Creates a deep copy of this runner, except if stream objects are connected to stdin, stdout or stderr. More...
|
| |
| def | runner (self) |
| | Returns a modifiable version of this object (as a Runner). More...
|
| |
| def | copyenv (self) |
| | Creates a new Runner that is like self in all ways except that it uses the parent process environment. More...
|
| |
| def | clearenv (self) |
| | Creates a new Runner which is like self in all ways except that it uses an empty environment except for a few critical variables without which most programs cannot run. More...
|
| |
| def | cd (self, cd) |
| | Returns a new Runner that is like self, except that it cd's to the target directory before running. More...
|
| |
| def | env (self, kwargs) |
| | Returns a new Runner that is like self in all ways except that the specified environment variables are set. More...
|
| |
| def | pipeto (self, other) |
| | Returns a new Runner that is like self in all ways, except that it has been piped into the other Runner. More...
|
| |
| def | inp |
| | Returns a new Runner that is like self in all ways except that it has a different stdin. More...
|
| |
| def | out |
| | Returns a new Runner that is like self in all ways except with a different stdout. More...
|
| |
| def | err |
| | Returns a new Runner that is like self in all ways except with a different stderr. More...
|
| |
| def | err2out (self) |
| | Returns a new Runner that is like self in all ways except that stderr is piped into stdout. More...
|
| |
| def | prerun (self, arg) |
| | Returns a new Runner that is like self in all ways except that a new prerun function has been added. More...
|
| |
| def | __getitem__ (self, args) |
| | Returns a new Runner that is like self in all ways except with new arguments. More...
|
| |
| def | argins (self, index, arg) |
| | Returns a new Runner that is like self in all ways, except with the specified argument inserted. More...
|
| |
| def | setthreads (self, nthreads) |
| | Sets the number of threads requested by this program. More...
|
| |
| def | delthreads (self) |
| | Removes the request for threads. More...
|
| |
| def | __init__ (self, args, kwargs) |
| | Creates a new Runner. More...
|
| |
| def | getthreads (self) |
| | Returns the number of threads requested by this program. More...
|
| |
| def | setthreads (self, nthreads) |
| | Sets the number of threads requested by this program. More...
|
| |
| def | delthreads (self) |
| | Removes the request for threads. More...
|
| |
| def | first (self) |
| | Returns the first Runner in this pipeline. More...
|
| |
| def | prerun (self, arg) |
| | Adds a function or callable object to be called before running the program. More...
|
| |
| def | __getitem__ (self, args) |
| | Add one or more arguments to the executable. More...
|
| |
|
def | __str__ (self) |
| | Alias for repr()
|
| |
| def | __repr__ (self) |
| | Attempts to produce valid Python code to represent this Runnable. More...
|
| |
| def | __eq__ (self, other) |
| | Returns True if the other object is a Runner that is equal to this one, and False otherwise. More...
|
| |
| def | isplainexe (self) |
| | Returns true if this is simply an executable with arguments (no redirection, no prerun objects, no environment modification, no piping), and False otherwise. More...
|
| |
| def | cd (self, dirpath) |
| | Requests that this process run in the specified directory. More...
|
| |
| def | __lt__ (self, stdin) |
| | Connects the given object to stdin, via inp(stdin,string=False). More...
|
| |
| def | __gt__ (self, stdout) |
| | Connects the given object to stdout, truncating it if it is a file. More...
|
| |
| def | __lshift__ (self, stdin) |
| | Sends the specified string into stdin. More...
|
| |
| def | __rshift__ (self, stdout) |
| | Appends stdout to the specified file. More...
|
| |
| def | __pos__ (self) |
| | Sends stderr to stdout. More...
|
| |
| def | __ge__ (self, outerr) |
| | Redirects stderr and stdout to the specified file, truncating it. More...
|
| |
| def | __or__ (self, other) |
| | Pipes this Runner to the other Runner. More...
|
| |
| def | argins (self, index, arg) |
| | Inserts the specified argument before the given index. More...
|
| |
|
def | args (self) |
| | Iterates over the executable and arguments of this command.
|
| |
| def | copy |
| | Returns a deep copy of this object, almost. More...
|
| |
| def | copyenv (self) |
| | Instructs this command to duplicate the parent process environment (the default). More...
|
| |
| def | clearenv (self) |
| | Instructs this command to start with an empty environment except for certain critical variables without which most programs cannot run. More...
|
| |
| def | env (self, kwargs) |
| | Sets environment variables for this Runner. More...
|
| |
| def | to_shell (self) |
| | Returns a string that expresses this object as a POSIX sh shell command if possible, or raises a subclass of NotValidPosixSh if not. More...
|
| |
| def | runner (self) |
| | Returns self if self is modifiable, otherwise returns a modifiable copy of self. More...
|
| |
| def | pipeto (self, other) |
| | Specifies that this Runner will send its stdout to the other runner's stdin. More...
|
| |
| def | inp |
| | Specifies that the first Runner in this pipeline takes input from the given file or string specified by stdin. More...
|
| |
| def | out |
| | Specifies that this process sends output from its stdout stream to the given file or stream. More...
|
| |
| def | err2out (self) |
| | Sends stderr to stdout. More...
|
| |
| def | err |
| | Specifies that this process sends output from its stderr stream to the given file or stream. More...
|
| |