MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / run_command

Function run_command

src/codegraphcontext/cli/setup_wizard.py:537–570  ·  view source on GitHub ↗

Runs a command, captures its output, and handles execution. Returns the completed process object on success, None on failure.

(command, console, shell=False, check=True, input_text=None)

Source from the content-addressed store, hash-verified

535 return Path.cwd()
536
537def run_command(command, console, shell=False, check=True, input_text=None):
538 """
539 Runs a command, captures its output, and handles execution.
540 Returns the completed process object on success, None on failure.
541 """
542 cmd_str = command if isinstance(command, str) else ' '.join(command)
543
544 # Mask passwords from being printed out
545 if "set-initial-password" in cmd_str:
546 import re
547 cmd_str = re.sub(r'(set-initial-password\s+)(\S+)', r'\g<1>********', cmd_str)
548
549 console.print(f"[cyan]$ {cmd_str}[/cyan]")
550 try:
551 process = subprocess.run(
552 command,
553 shell=shell,
554 check=check,
555 capture_output=True, # Always capture to control what gets displayed
556 text=True,
557 timeout=300,
558 input=input_text
559 )
560 return process
561 except subprocess.CalledProcessError as e:
562 console.print(f"[bold red]Error executing command:[/bold red] {cmd_str}")
563 if e.stdout:
564 console.print(f"[red]STDOUT: {e.stdout}[/red]")
565 if e.stderr:
566 console.print(f"[red]STDERR: {e.stderr}[/red]")
567 return None
568 except subprocess.TimeoutExpired:
569 console.print(f"[bold red]Command timed out:[/bold red] {cmd_str}")
570 return None
571
572def run_neo4j_setup_wizard():
573 """Guides the user through setting up Neo4j database for CodeGraphContext."""

Callers 6

_has_brewFunction · 0.85
_brew_install_neo4jFunction · 0.85
_brew_startFunction · 0.85
_set_initial_passwordFunction · 0.85
setup_dockerFunction · 0.85
setup_local_binaryFunction · 0.85

Calls 2

printMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected