()
| 770 | if update: |
| 771 | args.append("--upgrade") |
| 772 | args.append(package) |
| 773 | |
| 774 | result = run_cmd(args, check=False) |
| 775 | if result.returncode == 0 and shutil.which(command): |
| 776 | action = "Updated" if update else "Installed" |
| 777 | SUMMARY.success(f"{action} Python developer tool {package}") |
| 778 | else: |
| 779 | SUMMARY.failure(f"Required Python developer tool failed: {package}") |
| 780 | all_ok = False |
| 781 | return all_ok |
| 782 | |
| 783 | # ----------------------------------------------------------------------------- |
| 784 | # Legacy DedSec Bash environment cleanup |
| 785 | # ----------------------------------------------------------------------------- |
| 786 | |
| 787 | |
| 788 | def _looks_like_dedsec_ps1(line: str) -> bool: |
| 789 | stripped = line.lstrip() |
| 790 | return ( |
| 791 | stripped.startswith("PS1=") |
| 792 | and r"\D{%d/%m/%Y}" in line |
| 793 | and r"\A" in line |
| 794 | and r"\W" in line |
| 795 | ) |
| 796 | |
| 797 | |
| 798 | |
| 799 | def extract_dedsec_prompt_name(text: str) -> str: |
| 800 | """Extract the visible username from the DedSec Settings.py PS1, if present.""" |
| 801 | for line in text.splitlines(): |
| 802 | if not _looks_like_dedsec_ps1(line): |
| 803 | continue |
| 804 | match = re.search(r"1;34m\\\]([^\\'\n]+?)\\\[\\e\[0m", line) |
| 805 | if match: |
| 806 | return sanitize_prompt_name(match.group(1)) |
| 807 | return "" |
| 808 | |
| 809 | |
| 810 | def clean_dedsec_bash_environment() -> bool: |
| 811 | """Remove only shell hooks created by DedSec Settings.py. |
no test coverage detected