casm.api.casm_capture

casm.api.casm_capture(args, root=None, combine_output=False)[source]

Execute a command via the c api and store stdout/stderr result as str. If required by the specific command, a temporary PrimClex instance will be constrcuted. Use Project.command or Project.capture to avoid re-initializations.

Parameters:
  • args (str) –

    A string containing the arguments for the casm command to be executed.

    Ex: “select –set-on -o /abspath/to/my_selection” Ex: “query -k ‘configname selected’ -v -o STDOUT”

  • root (str (optional)) – A string giving the path to a root directory of a CASM project, typically casm.project.Project.path. If None given, a ‘.casm’ directory is searched for starting at the current working directory, and if not found the empty string is used.

  • combine_output (bool (optional, default=False)) – If True, print stdout and stderr to same str and only ret

Notes

Prefer not to use this function if you have an existing casm.project.Project instance that the command will operate on. Instead use Project.command() which will execute the command and then update the Project instance’s ProjectSettings and DirectoryStructure to reflect any changes that have occurred.

Returns:

(stdout, stderr, returncode) (The result of running the command via the) – command line iterface. ‘stdout’ and ‘stderr’ are in text type (‘unicode’/’str’). If ‘combine_output’ is True, then returns (combined_output, returncode).