run_cli

Contents

run_cli#

run_cli(cmd: str | list, timeout: float | None = None, check_return_value: bool = True, in_background: bool = True, cwd='/') -> (<class 'int'>, <class 'str'>)[source]#

Run a command line.

Parameters:
  • cmd (str or list[str]) – Command as a list

  • timeout (float) – Timeout

  • check_return_value (bool) – Check output value of the exe

  • in_background (bool) – Run the subprocess in background

  • cwd (str) – Working directory

Returns:

return value and output log

Return type:

int, str

Example

>>> cmd_hillshade = ["gdaldem", "--config",
>>>                  "NUM_THREADS", "1",
>>>                  "hillshade", strings.to_cmd_string(dem_path),
>>>                  "-compute_edges",
>>>                  "-z", self.nof_threads,
>>>                  "-az", azimuth,
>>>                  "-alt", zenith,
>>>                  "-of", "GTiff",
>>>                  strings.to_cmd_string(hillshade_dem)]
>>> # Run command
>>> run_cli(cmd_hillshade)