Functions for operating system and filesystem interactions.
A builder syntax for shell commands.
Note
This class is currently incomplete. Specifically, the PipeFrom() method is not implemented.
The following table shows some example Bash commands, with the equivalent Cmd usage. In this table, C stands for an arbitrary command name and P is the currently executing Python script.
| Bash Shell Syntax | Python Builder Syntax |
|---|---|
| C | Cmd(“C”).Run() |
| C | P | Cmd(“C”).ReturnStdout() |
| C 1>F1 | Cmd(“C”).Redirect(“F”) |
| C 1>F1 2>F2 | Cmd(“C”).Redirect(“F1”, “F2”) |
| C1 | C2 1>F | Cmd(“C2”).PipeFrom(Cmd(“C1”)).Redirect(“F”) |
| C 1>F 2>&1 | Cmd(“C”).TieStderrToStdout().Redirect(“F”) |
| C 2>&1 | P | Cmd(“C”).TieStderrToStdout().ReturnStdout() |
| C 2>&1 1>/dev/null | P | Cmd(“C”).TieStderrToStdout().ReturnStderr() |
Run command, redirecting stdout and/or stderr to a file.
Only one of fout and fout_append should be specified (similarly for ferr and ferr_append).
| Parameters: |
|
|---|
Run command, capturing and returning stdout.
| Returns: | Data written to standard error by command. |
|---|---|
| Return type: | str |
Run command, capturing and returning stdout.
| Returns: | Data written to standard out by command. |
|---|---|
| Return type: | str |
Flag indicating that issued commands should be logged.
Determine if a file contains an image.
The decision is based on the extension portion of the filename.
| Parameters: | fname (str) – Path to file. |
|---|
Execute a command on the shell, and check the results.
See the Cmd class for a more flexibile solution.
| Parameters: |
|
|---|
A temporary directory.
The directory is deleted when this object is destroyed. For a temporary file, see the tempfile.TemporaryFile class.
Copy all files in temporary directory to another location.
Copy a single file into the temporary directory.
Remove a single file from the temporary directory.
Update a file’s access time, creating the file if it does not exist.
| Parameters: | fname (str) – Path to file. |
|---|