MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / run_grid_menu

Function run_grid_menu

Scripts/Settings.py:2589–2770  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2587 except Exception:
2588 pass
2589
2590
2591def cleanup_bashrc():
2592 """Removes all DedSec-related blocks and aliases from bash.bashrc."""
2593 try:
2594 with open(BASHRC_PATH, "r") as f:
2595 lines = f.readlines()
2596 except Exception as e:
2597 print(f"Error reading {BASHRC_PATH}: {e}")
2598 return False
2599
2600 filtered_lines = []
2601 regex_pattern = re.compile(r"(cd\s+.*DedSec/Scripts.*python3\s+.*Settings\.py\s+--menu.*|alias\s+(m|e|g)=.*cd\s+.*DedSec/Scripts.*)")
2602
2603 in_marked_block = False
2604
2605 for line in lines:
2606 if BASHRC_START_MARKER in line or NETWORK_BASHRC_START_MARKER in line or (line.startswith("# --- DedSec ") and "Background Checker" in line):
2607 in_marked_block = True
2608 continue
2609 if BASHRC_END_MARKER in line or NETWORK_BASHRC_END_MARKER in line or (line.startswith("# --- End DedSec ") and "Background Checker" in line):
2610 in_marked_block = False
2611 continue
2612
2613 if in_marked_block:
2614 continue
2615
2616 if not regex_pattern.search(line):
2617 filtered_lines.append(line)
2618
2619 try:
2620 with open(BASHRC_PATH, "w") as f:
2621 f.writelines(filtered_lines)
2622 return True
2623 except Exception as e:
2624 print(f"Error writing to {BASHRC_PATH}: {e}")
2625 return False
2626
2627
2628def update_bashrc(current_language_path, current_style):
2629 """Write the DedSec startup block without any hidden background workers."""
2630 save_menu_style_preference(current_style)
2631 try:
2632 with open(BASHRC_PATH, "r", encoding="utf-8", errors="replace") as handle:
2633 lines = handle.readlines()
2634 except Exception as exc:
2635 print(_("Error reading") + f" {BASHRC_PATH}: {exc}")
2636 return
2637
2638 filtered_lines = []
2639 regex_pattern = re.compile(
2640 r"(cd\s+.*DedSec/Scripts.*python3\s+.*Settings\.py\s+--menu.*|"
2641 r"alias\s+(m|e|g)=.*cd\s+.*DedSec/Scripts.*|"
2642 r"Settings\.py.*--pipboy-scan)"
2643 )
2644 in_marked_block = False
2645 for line in lines:
2646 if BASHRC_START_MARKER in line or (line.startswith("# --- DedSec ") and "Background Checker" in line):

Callers 1

Settings.pyFile · 0.70

Calls 6

printFunction · 0.85
list_directory_entriesFunction · 0.70
_Function · 0.70
draw_grid_menuFunction · 0.70
run_selected_fileFunction · 0.70

Tested by

no test coverage detected