(command, path=script_path, ensure_pass=True, get_result=False)
| 73 | ] |
| 74 | |
| 75 | def 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 | |
| 103 | def prune_existing_sys_deps(deps_list): |
| 104 | remove_deps = [] |
no outgoing calls
no test coverage detected