This commit is contained in:
2026-01-11 12:28:16 -08:00
parent d86caa902f
commit 1f3de7db1c
2 changed files with 88 additions and 30 deletions

View File

@@ -593,38 +593,61 @@ def main() -> int:
return 1
return 0
def _update_config_value(root: Path, key: str, value: str) -> bool:
config_path = root / "config.conf"
if not config_path.exists():
fallback = root / "config.conf.remove"
if fallback.exists():
shutil.copy(fallback, config_path)
else:
return False
try:
content = config_path.read_text(encoding="utf-8")
pattern = rf'^(\s*{re.escape(key)}\s*=\s*)(.*)$'
if re.search(pattern, content, flags=re.MULTILINE):
new_content = re.sub(pattern, rf'\1"{value}"', content, flags=re.MULTILINE)
else:
section_pattern = r'\[store=hydrusnetwork\]'
if re.search(section_pattern, content):
new_content = re.sub(section_pattern, f'[store=hydrusnetwork]\n{key}="{value}"', content, count=1)
else:
new_content = content + f'\n\n[store=hydrusnetwork]\nname="hydrus"\n{key}="{value}"'
config_path.write_text(new_content, encoding="utf-8")
return True
except Exception as e:
print(f"Error updating config: {e}")
return False
def _interactive_menu() -> str | int:
"""Show a simple interactive menu to choose install/uninstall or delegate."""
try:
installed = _is_installed()
while True:
print("\nMedeia-Macina bootstrap - interactive menu")
os.system("cls" if os.name == "nt" else "clear")
print("====================================")
print(" MEDEIA MACINA BOOTSTRAP MENU")
print("====================================")
print("1) Install / Reinstall")
print("2) Extras")
print("2) Extras > HydrusNetwork")
if installed:
print("3) Uninstall")
print("4) Status")
print("q) Quit")
choice = input("Choose an option: ").strip().lower()
choice = input("\nChoose an option: ").strip().lower()
if choice in ("1", "install", "reinstall"):
return "install"
if choice in ("2", "extras"):
print("\nExtras Menu:")
print(" 1) HydrusNetwork (Setup & Clone)")
print(" b) Back")
extra_choice = input("Choose an extra: ").strip().lower()
if extra_choice == "1":
return "extras_hydrus"
continue # back to main menu
if choice in ("2", "extras", "hydrus"):
return "extras_hydrus"
if installed and choice in ("3", "uninstall"):
return "uninstall"
if installed and choice in ("4", "status"):
print("Installation detected." if installed else "Not installed.")
print("\nInstallation detected." if installed else "\nNot installed.")
input("\nPress Enter to continue...")
continue
if choice in ("q", "quit", "exit"):
@@ -795,6 +818,15 @@ def main() -> int:
if hydrus_script.exists():
try:
subprocess.check_call([sys.executable, str(hydrus_script)])
# New: Prompt for location as requested
print("\n" + "="*40)
print(" HYDRUS CONFIGURATION")
print("="*40)
location = input("\nEnter the absolute path to your Hydrus git clone\n(to link it with Medios-Macina config): ").strip()
if location:
if _update_config_value(repo_root, "gitclone", location):
print(f"✅ Updated config.conf with gitclone=\"{location}\"")
except subprocess.CalledProcessError:
print("\nHydrusNetwork setup exited with an error.")
except Exception as e: