Print cmd_to_string to stdout. Optionally save the command to cmd_file file, and add extra_env environment variables to the command generated. If cmd contains at least one LF, newlines are only added on LF. Otherwise, newlines are added automatically after
(self, cmd, cwd=None, cmd_file=None, extra_env=None, extra_paths=None)
| 115 | ) |
| 116 | |
| 117 | def print_cmd(self, cmd, cwd=None, cmd_file=None, extra_env=None, extra_paths=None): |
| 118 | ''' |
| 119 | Print cmd_to_string to stdout. |
| 120 | |
| 121 | Optionally save the command to cmd_file file, and add extra_env |
| 122 | environment variables to the command generated. |
| 123 | |
| 124 | If cmd contains at least one LF, newlines are only added on LF. |
| 125 | Otherwise, newlines are added automatically after every word. |
| 126 | ''' |
| 127 | if type(cmd) is str: |
| 128 | cmd_string = cmd |
| 129 | else: |
| 130 | cmd_string = self.cmd_to_string(cmd, cwd=cwd, extra_env=extra_env, extra_paths=extra_paths) |
| 131 | if not self.quiet: |
| 132 | self._print_thread_safe('+ ' + cmd_string) |
| 133 | if cmd_file is not None: |
| 134 | with open(cmd_file, 'w') as f: |
| 135 | f.write('#!/usr/bin/env bash\n') |
| 136 | f.write(cmd_string) |
| 137 | st = os.stat(cmd_file) |
| 138 | os.chmod(cmd_file, st.st_mode | stat.S_IXUSR) |
| 139 | |
| 140 | def run_cmd( |
| 141 | self, |
no test coverage detected