(path)
| 317 | |
| 318 | @route('/<path:path>') |
| 319 | def catch_all(path): |
| 320 | # Return static files. |
| 321 | if path in STATIC_FILES: |
| 322 | mimetype = MIME_TYPES.get(Path(path).suffix, 'auto') |
| 323 | return static_file(path, STATIC_DIR, mimetype=mimetype) |
| 324 | |
| 325 | # Parse path. |
| 326 | run_dir, test_dir = parse_path(path) |
| 327 | |
| 328 | if run_dir and not test_dir: |
| 329 | # Show run page. |
| 330 | run = database.load_run(database.run_report_file(run_dir)) |
| 331 | if not run: |
| 332 | return template('error', message=f'Run "{run_dir}" does not exist.') |
| 333 | |
| 334 | nav = [ |
| 335 | { 'title': 'Home', 'link': '/'}, |
| 336 | { 'title': 'Run: ' + run_dir, 'link': '/' + run_dir } |
| 337 | ] |
| 338 | stats = run_stats(run) |
| 339 | return template( |
| 340 | 'run', |
| 341 | nav=nav, |
| 342 | tag_titles=TAG_TITLES, |
| 343 | stats=stats, |
| 344 | run_dir=run_dir, |
| 345 | run=run, |
| 346 | run_tags=database.run_tags, |
| 347 | format_date=format_date, |
| 348 | format_duration=format_duration |
| 349 | ) |
| 350 | |
| 351 | elif run_dir and test_dir: |
| 352 | # Show test page. |
| 353 | test = database.load_test(database.test_report_file(run_dir, test_dir)) |
| 354 | if not test: |
| 355 | return template('error', message=f'Test "{test_dir}" does not exist for run "{run_dir}".') |
| 356 | |
| 357 | action = request.query.get('action', None) |
| 358 | if action == 'compare': |
| 359 | # Compare images. |
| 360 | image = Path(request.query['image']).as_posix() |
| 361 | result_image = Path('/result') / run_dir / test_dir / image |
| 362 | error_image = Path(str(result_image) + config.ERROR_IMAGE_SUFFIX) |
| 363 | ref_dir = Path(test['ref_dir']).relative_to(database.ref_dir) |
| 364 | ref_image = Path('/ref') / ref_dir / image |
| 365 | jeri_data = create_jeri_data(result_image, ref_image, error_image) |
| 366 | return template( |
| 367 | 'compare', |
| 368 | image=str(image), |
| 369 | jeri_data=json.dumps(jeri_data) |
| 370 | ) |
| 371 | else: |
| 372 | nav = [ |
| 373 | { 'title': 'Home', 'link': '/'}, |
| 374 | { 'title': 'Run: ' + run_dir, 'link': '/' + run_dir }, |
| 375 | { 'title': 'Test: ' + test_dir, 'link': '/' + run_dir + '/' + test_dir } |
| 376 | ] |
nothing calls this directly
no test coverage detected