(session_id)
| 139 | |
| 140 | response = send_file(file_path, as_attachment=True, download_name=download_filename) |
| 141 | |
| 142 | expose_headers = ['Content-Disposition'] |
| 143 | response.headers['Access-Control-Expose-Headers'] = ', '.join(expose_headers) |
| 144 | |
| 145 | return response |
| 146 | |
| 147 | @app.route('/run_script/<session_id>/<int:script_index>/<int:retry_count>') |
| 148 | def run_script(session_id, script_index, retry_count): |
| 149 | total_scripts = len(STEP_SEQUENCE) |
| 150 | |
| 151 | if script_index >= total_scripts: |
| 152 | return jsonify({ |
| 153 | 'status': 'completed', |
| 154 | 'message': '所有脚本执行完成', |
| 155 | 'totalScripts': total_scripts |
| 156 | }) |
| 157 | |
| 158 | base_dir = os.path.abspath(os.path.join('data', session_id)) |
| 159 | step = run_step(script_index, base_dir, timeout=SCRIPT_TIMEOUT) |
| 160 | |
| 161 | if step.ok: |
| 162 | return jsonify({ |
| 163 | 'status': 'success', |
| 164 | 'currentScript': step.desc, |
| 165 | 'message': f'{step.desc}执行成功', |
| 166 | 'nextIndex': script_index + 1, |
| 167 | 'totalScripts': total_scripts, |
| 168 | 'retryCount': 0, |
| 169 | 'session_id': session_id, |
| 170 | 'stdout': step.stdout, |
| 171 | 'stderr': step.stderr |
| 172 | }) |
| 173 | |
| 174 | message = step.error or f'{step.desc}执行失败' |
| 175 | return jsonify({ |
| 176 | 'status': 'error', |
| 177 | 'currentScript': step.desc, |
| 178 | 'message': message, |
| 179 | 'stdout': step.stdout, |
| 180 | 'stderr': step.stderr, |
| 181 | 'retryCount': retry_count, |
| 182 | 'scriptIndex': script_index, |
| 183 | 'session_id': session_id |
nothing calls this directly
no outgoing calls
no test coverage detected