cape.cfdx.cmdrun
: Execute system calls for CAPE¶
This template module provides an interface for simple command-line
tools. The general approach for CAPE is to create a function for each
command-line binary that is called. This module contains two methods,
calli()
and callf()
, that are wrappers for the built-in
subprocess.call()
, and several useful command-line utilities.
- See also:
- cape.cfdx.cmdrun.aflr3(opts=None, j=0, **kw)¶
Run AFLR3 with the appropriate options
- Call:
>>> aflr3(opts=None, j=0, **kw)
- Inputs:
- See also:
- Versions:
2016-04-04
@ddalle
: v1.0
- cape.cfdx.cmdrun.callf(cmdi: list, f: str | None = None, e: str | None = None, i: str | None = None, shell: bool = False, v: bool = True, check: bool = True) int ¶
Call a command with alternate STDOUT by filename
- Call:
>>> ierr = callf(cmdi, **kw)
- Inputs:
- cmdi:
list
(str
) List of strings as for
subprocess.call()
- f:
str
File name to which to store STDOUT
- e: {f} |
str
Separate file name for STDERR
- i: {
None
} |str
Name of file to read and use as STDIN
- shell:
bool
Whether or not a shell is needed
- v: {
True
} |False
Verbose option; display PWD and STDOUT values
- check: {
True
} |False
Option to raise an exception with nonzero return code
- cmdi:
- Outputs:
- ierr:
int
Return code of command executed
- ierr:
- Versions:
2014-08-30
@ddalle
: v1.02015-02-13
@ddalle
: v2.0; rely oncalli()
2017-03-12
@ddalle
: v2.1; add v option2019-06-10
@ddalle
: v2.2; add e option2024-05-25
@ddalle
: v2.3; don’t remove RUNNING2025–1022
@ddalle
: v2.4; add i option
- cape.cfdx.cmdrun.calli(cmdi: list, f: str | None = None, e: str | None = None, i: str | None = None, shell: bool = False, v: bool = True) int ¶
Call a command with alternate STDOUT by filename
- Call:
>>> ierr = calli(cmdi, f=None, e=None, shell=None, v=True)
- Inputs:
- cmdi:
list
[str
] List of strings as for
subprocess.call()
- f: {
None
} |str
File name to which to store STDOUT
- e: {f} |
str
Name of separate file to write STDERR to
- i: {
None
} |str
Name of file to read and use as STDIN
- shell:
bool
Whether or not a shell is needed
- v: {
True
} |False
Verbose option; display PWD and STDOUT values
- cmdi:
- Outputs:
- ierr:
int
Return code,
0
for successful execution
- ierr:
- Versions:
2014-08-30
@ddalle
: v1.02015-02-13
@ddalle
: v2.0; return code2017-03-12
@ddalle
: v2.1; Add v option2019-06-10
@ddalle
: v2.2; Add e option2024-01-17
@ddalle
: v2.3; flush() STDOUT manually2025-01-22
@ddalle
: v2.4; Add i option
- cape.cfdx.cmdrun.callo(cmdi: list, shell: bool = False) str ¶
Call a command and get the output text
This function is basically a substitute for
subprocess.check_output()
, which was not available in Python 2.6.
- cape.cfdx.cmdrun.find_executable(cmdname: str | list | tuple, title: str) str ¶
Find an executable from a list of one or more candidates
- Call:
>>> cmd = find_executable(cmdname, title) >>> cmd = find_executable(cmdnames, title)
- Inputs:
- Outputs:
- cmd:
str
Name of executable found on current path
- cmd:
- Raises:
SystemError
if no candidate found on path- Versions:
2025-01-22
@ddalle
: v1.0
- cape.cfdx.cmdrun.grep(regex, fname)¶
Search for a regular expression in a file
- cape.cfdx.cmdrun.head(fname, n=1)¶
Extract the first n lines of a file
- cape.cfdx.cmdrun.intersect(opts=None, **kw)¶
Run Cart3D
intersect
to combine overlapping triangulations- Call:
>>> intersect(opts=None, **kw)
- Inputs:
- opts:
cape.options.Options
Options interface with access to
verify
options- kw:
dict
Raw dictionary of command-line arguments
- opts:
- See also:
- Versions:
2016-04-05
@ddalle
: v1.0
- cape.cfdx.cmdrun.pvpython(lay, *args, **kw)¶
Stand-alone function to execute a Paraview Python script
- cape.cfdx.cmdrun.tail(fname, n=1)¶
Tail the last n lines of a file
- cape.cfdx.cmdrun.tecmcr(mcr='export-lay.mcr', **kwargs)¶
Run a Tecplot macro
- Call:
>>> tecmcr(mcr="export-lay.mcr")
- Inputs:
- mcr:
str
File name of Tecplot macro
- mcr:
- Versions:
2015-03-10
@ddalle
: v1.0
- cape.cfdx.cmdrun.verify(opts=None, **kw)¶
Run Cart3D binary
verify
to test a triangulation- Call:
>>> verify(opts=None, **kw)
- Inputs:
- opts:
cape.options.Options
Options interface with access to
verify
options- kw:
dict
Raw dictionary of command-line arguments
- opts:
- See also:
- Versions:
2016-04-05
@ddalle
: v1.0