MCPcopy
hub / github.com/emacs-eaf/emacs-application-framework / run_command

Function run_command

install-eaf.py:75–101  ·  view source on GitHub ↗
(command, path=script_path, ensure_pass=True, get_result=False)

Source from the content-addressed store, hash-verified

73]
74
75def run_command(command, path=script_path, ensure_pass=True, get_result=False):
76 print("[EAF] Running", ' '.join(command), "@", path)
77
78 # Throw exception if command not found,
79 # We found install-eaf.py still can work even it not found npm in system.
80 if (not which(command[0])) and ensure_pass:
81 raise Exception(f"Not found command: {command[0]}")
82
83 # Use LC_ALL=C to make sure command output use English.
84 # Then we can use English keyword to check command output.
85 english_env = os.environ.copy()
86 english_env['LC_ALL'] = 'C'
87
88 if get_result:
89 process = subprocess.Popen(command, env = english_env, stdin = subprocess.PIPE,
90 universal_newlines=True, text=True, cwd=path,
91 stdout = subprocess.PIPE)
92 else:
93 process = subprocess.Popen(command, env = english_env, stdin = subprocess.PIPE,
94 universal_newlines=True, text=True, cwd=path)
95 process.wait()
96 if process.returncode != 0 and ensure_pass:
97 raise Exception(process.returncode)
98 if get_result:
99 return process.stdout.readlines()
100 else:
101 return None
102
103def prune_existing_sys_deps(deps_list):
104 remove_deps = []

Callers 8

install_sys_depsFunction · 0.70
install_py_depsFunction · 0.70
install_npm_gloal_depsFunction · 0.70
install_npm_installFunction · 0.70
install_npm_rebuildFunction · 0.70
install_vue_installFunction · 0.70
add_or_update_appFunction · 0.70
get_distroFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected