run command and return output and result.
(cmd, output_info=True)
| 26 | |
| 27 | |
| 28 | def run_cmd(cmd, output_info=True): |
| 29 | """ |
| 30 | run command and return output and result. |
| 31 | """ |
| 32 | print('\033[1;32m' + cmd + '\033[0m') |
| 33 | |
| 34 | output_str_list = [] |
| 35 | res = 0 |
| 36 | |
| 37 | if output_info: |
| 38 | res = os.system(cmd + " > output.txt 2>&1") |
| 39 | else: |
| 40 | res = os.system(cmd + " > /dev/null 2>output.txt") |
| 41 | |
| 42 | with open("output.txt", "r") as file: |
| 43 | output_str_list = file.readlines() |
| 44 | |
| 45 | for line in output_str_list: |
| 46 | print(line, end='') |
| 47 | |
| 48 | os.remove("output.txt") |
| 49 | |
| 50 | return output_str_list, res |
| 51 | |
| 52 | |
| 53 | def build_bsp(bsp, scons_args='',name='default', pre_build_commands=None, post_build_command=None,build_check_result = None,bsp_build_env=None): |