Run command in a given directory with env variables set. On Linux multiple commands on one line with the use of && are not allowed.
(command, working_dir, env=None)
| 953 | |
| 954 | |
| 955 | def run_command(command, working_dir, env=None): |
| 956 | """Run command in a given directory with env variables set. |
| 957 | On Linux multiple commands on one line with the use of && are not allowed. |
| 958 | """ |
| 959 | if isinstance(command, list): |
| 960 | command_str = " ".join(command) |
| 961 | else: |
| 962 | command_str = command |
| 963 | print("[automate.py] Running '"+command_str+"' in '" + |
| 964 | working_dir+"'...") |
| 965 | if isinstance(command, str): |
| 966 | args = shlex.split(command.replace("\\", "\\\\")) |
| 967 | else: |
| 968 | args = command |
| 969 | if not env: |
| 970 | env = getenv() |
| 971 | # When passing list of args shell cannot be True on eg. Linux, read |
| 972 | # notes in build.py |
| 973 | shell = (platform.system() == "Windows") |
| 974 | return subprocess.check_call(args, cwd=working_dir, env=env, shell=shell) |
| 975 | |
| 976 | |
| 977 | def run_git(command_line, working_dir): |
no test coverage detected