def erase_flash(self): self.disconnect() cmd = [get_frontend_python(), '-u', '-m', 'esptool', '--port', self.port, 'erase_flash'] proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) dlg = SubprocessDialog(get_workbench(), proc, "Erasing flash", autoclose=False) dlg.wait_window()
def execute_command(cmd, title): """执行命令并监控输出结果""" env = os.environ.copy() env["PYTHONUSERBASE"] = THONNY_USER_DIR proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, env=env) dlg = SubprocessDialog(get_workbench(), proc, title, autoclose=False) dlg.wait_window()
def _show_subprocess_dialog(master, proc, title): dlg = SubprocessDialog(master, proc, title) dlg.wait_window() return dlg.returncode, dlg.stdout, dlg.stderr