class_docstr: Magics related to packaging & installation
class_docstr_tok: ["Magics","related","to","packaging","&","installation"]
code: def _run_command(self, cmd, line):
      args = shlex.split(line)
      command = args[0] if len(args) > 0 else ""
      args = args[1:] if len(args) > 1 else [""]
  
      extra_args = []
  
      # When the subprocess does not allow us to respond "yes" during the installation,
      # we need to insert --yes in the argument list for some commands
      stdin_disabled = getattr(self.shell, "kernel", None) is not None
      needs_yes = command in CONDA_COMMANDS_REQUIRING_YES
      has_yes = set(args).intersection(CONDA_YES_FLAGS)
      if stdin_disabled and needs_yes and not has_yes:
          extra_args.append("--yes")
  
      # Add --prefix to point conda installation to the current environment
      needs_prefix = command in CONDA_COMMANDS_REQUIRING_PREFIX
      has_prefix = set(args).intersection(CONDA_ENV_FLAGS)
      if needs_prefix and not has_prefix:
          extra_args.extend(["--prefix", sys.prefix])
  
      self.shell.system(" ".join([cmd, command] + extra_args + args))
      print(
          "\nNote: you may need to restart the kernel to use updated packages."
      )
  
file_path: catboost/contrib/python/ipython/py3/IPython/core/magics/packaging.py
imports: import functools
  import re
  import shlex
  import sys
  from pathlib import Path
  from IPython.core.magic import Magics, magics_class, line_magic
label_desc: Use image node_id 2 for calling the PackagingMagics obj's underlying member method code with example usage: obj._run_command(cmd, line) without return types