code: def _run(self, command: List[str], notebook: Optional[str] = None) -> int:
          
          if notebook is None:
              return Popen(command, cwd=self._build_dir).wait()
          cmd = Popen(command, cwd=self._build_dir, stdout=PIPE, stderr=STDOUT)
          while True:
              line = cmd.stdout.readline()
              if line == b'' and cmd.poll() is not None:
                  return cmd.poll()
              print(line.decode('utf-8'), end='')
          raise Exception()
docs: Run command from terminal and notebook and view output from subprocess.