(section, program, url_distro, url_release)
| 306 | |
| 307 | |
| 308 | def _handle_explain_program(section, program, url_distro, url_release): |
| 309 | logger.info( |
| 310 | "/explain section=%r program=%r distro=%r release=%r", |
| 311 | section, |
| 312 | program, |
| 313 | url_distro, |
| 314 | url_release, |
| 315 | ) |
| 316 | |
| 317 | if section is not None: |
| 318 | program = f"{program}.{section}" |
| 319 | |
| 320 | if url_distro: |
| 321 | distros_to_try = [(url_distro, url_release)] |
| 322 | else: |
| 323 | distros_to_try = sorted( |
| 324 | get_distros(), |
| 325 | key=lambda dr: (dr[0] == "ubuntu", dr[1]), |
| 326 | reverse=True, |
| 327 | ) |
| 328 | |
| 329 | last_error = None |
| 330 | for d, r in distros_to_try: |
| 331 | try: |
| 332 | mp, suggestions, raw_mp, debug_info = explain_program( |
| 333 | program, get_store(), distro=d, release=r |
| 334 | ) |
| 335 | cmd_distros = get_store().distros_for_name(raw_mp.name) |
| 336 | body = render_template( |
| 337 | "options.html", |
| 338 | mp=mp, |
| 339 | suggestions=suggestions, |
| 340 | raw_mp=raw_mp, |
| 341 | debug_info=debug_info, |
| 342 | available_distros=cmd_distros, |
| 343 | ) |
| 344 | return _cacheable_explain_response(body) |
| 345 | except errors.ProgramDoesNotExist as e: |
| 346 | last_error = e |
| 347 | continue |
| 348 | |
| 349 | return render_template( |
| 350 | "errors/missingmanpage.html", title="missing man page", e=last_error |
| 351 | ) |
| 352 | |
| 353 | |
| 354 | # 7 days for both browser and CDN, with a 1-day grace window for |
no test coverage detected