Open a file or directory in the default web browser. Args: path: File path or directory path to open For directories (heatmap), opens the index.html file inside.
(path)
| 625 | |
| 626 | |
| 627 | def _open_in_browser(path): |
| 628 | """Open a file or directory in the default web browser. |
| 629 | |
| 630 | Args: |
| 631 | path: File path or directory path to open |
| 632 | |
| 633 | For directories (heatmap), opens the index.html file inside. |
| 634 | """ |
| 635 | abs_path = os.path.abspath(path) |
| 636 | |
| 637 | # For heatmap directories, open the index.html file |
| 638 | if os.path.isdir(abs_path): |
| 639 | index_path = os.path.join(abs_path, 'index.html') |
| 640 | if os.path.exists(index_path): |
| 641 | abs_path = index_path |
| 642 | else: |
| 643 | print(f"Warning: Could not find index.html in {path}", file=sys.stderr) |
| 644 | return |
| 645 | |
| 646 | file_url = f"file://{abs_path}" |
| 647 | try: |
| 648 | webbrowser.open(file_url) |
| 649 | except Exception as e: |
| 650 | print(f"Warning: Could not open browser: {e}", file=sys.stderr) |
| 651 | |
| 652 | |
| 653 | def _handle_output(collector, args, pid, mode): |
no test coverage detected
searching dependent graphs…