The sh function

dna.utils.sh(*args, stream=True, **kwargs)[source]

A wrapper around subprocess.Popen that returns a generator streaming output from the command specified by args

Parameters
  • args – the command to run, split on whitespaces

  • stream (bool) – whether to stream the output as a generator (defaults to True)

  • kwargs – other options to pass into Popen, such as a cwd

Returns

a generator to stream lines from the subprocess output if stream is True, else the subprocess output as a completed string