k
This commit is contained in:
@@ -56,6 +56,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -118,6 +119,7 @@ def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[
|
|||||||
|
|
||||||
|
|
||||||
REPO_URL = "https://code.glowers.club/goyimnose/Medios-Macina.git"
|
REPO_URL = "https://code.glowers.club/goyimnose/Medios-Macina.git"
|
||||||
|
HYDRUS_INSTALLER_SCRIPT_URL = "https://raw.githubusercontent.com/hydrusnetwork/hydrus/master/scripts/hydrusnetwork.py"
|
||||||
|
|
||||||
|
|
||||||
class ProgressBar:
|
class ProgressBar:
|
||||||
@@ -900,6 +902,16 @@ def main() -> int:
|
|||||||
print(f"Error: Failed to clone repository: {e}", file=sys.stderr)
|
print(f"Error: Failed to clone repository: {e}", file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _download_hydrus_installer(dest: Path) -> bool:
|
||||||
|
"""Download the hydrusnetwork.py helper script into the provided path."""
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(HYDRUS_INSTALLER_SCRIPT_URL) as response:
|
||||||
|
dest.write_bytes(response.read())
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: Failed to download Hydrus installer script: {e}", file=sys.stderr)
|
||||||
|
return False
|
||||||
|
|
||||||
def _ensure_repo_available() -> bool:
|
def _ensure_repo_available() -> bool:
|
||||||
"""Prompt for a clone location when running outside the repository."""
|
"""Prompt for a clone location when running outside the repository."""
|
||||||
nonlocal repo_root, script_dir, is_in_repo
|
nonlocal repo_root, script_dir, is_in_repo
|
||||||
@@ -1134,28 +1146,30 @@ def main() -> int:
|
|||||||
# Choice 2 is for installing HydrusNetwork standalone/independently.
|
# Choice 2 is for installing HydrusNetwork standalone/independently.
|
||||||
# We preferentially use the local script if already in a repo.
|
# We preferentially use the local script if already in a repo.
|
||||||
hydrus_script = None
|
hydrus_script = None
|
||||||
|
temp_installer_path: Path | None = None
|
||||||
if is_in_repo and repo_root:
|
if is_in_repo and repo_root:
|
||||||
hydrus_script = repo_root / "scripts" / "hydrusnetwork.py"
|
hydrus_script = repo_root / "scripts" / "hydrusnetwork.py"
|
||||||
|
|
||||||
if not hydrus_script or not hydrus_script.exists():
|
if not hydrus_script or not hydrus_script.exists():
|
||||||
# If truly not in a repo (Web Installer), we don't want to install
|
print("Downloading the Hydrus installation helper...")
|
||||||
# Medios-Macina permanently. We'll use a temporary clone to get the installer.
|
|
||||||
try:
|
try:
|
||||||
import tempfile
|
import tempfile
|
||||||
# Create a temporary directory that persists for this run
|
|
||||||
temp_repo = Path(tempfile.mkdtemp(prefix="mm_hydrus_"))
|
fd, path = tempfile.mkstemp(prefix="mm_hydrus_", suffix=".py")
|
||||||
if _clone_repo(REPO_URL, temp_repo, depth=1):
|
os.close(fd)
|
||||||
hydrus_script = temp_repo / "scripts" / "hydrusnetwork.py"
|
helper_path = Path(path)
|
||||||
# We temporarily set repo_root so the script finds its dependencies if needed
|
if _download_hydrus_installer(helper_path):
|
||||||
repo_root = temp_repo
|
hydrus_script = helper_path
|
||||||
|
temp_installer_path = helper_path
|
||||||
else:
|
else:
|
||||||
print("Error: Could not download the installation helper.")
|
print("Error: Could not download the installation helper.")
|
||||||
|
helper_path.unlink(missing_ok=True)
|
||||||
return 1
|
return 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error setting up temporary installer: {e}")
|
print(f"Error setting up temporary installer: {e}")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if hydrus_script.exists():
|
if hydrus_script and hydrus_script.exists():
|
||||||
try:
|
try:
|
||||||
# Clear out project-venv related env vars to prevent auto-reexec
|
# Clear out project-venv related env vars to prevent auto-reexec
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
@@ -1182,6 +1196,9 @@ def main() -> int:
|
|||||||
print("\nHydrusNetwork setup exited with an error.")
|
print("\nHydrusNetwork setup exited with an error.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"\nFailed to run HydrusNetwork setup: {e}")
|
print(f"\nFailed to run HydrusNetwork setup: {e}")
|
||||||
|
finally:
|
||||||
|
if temp_installer_path:
|
||||||
|
temp_installer_path.unlink(missing_ok=True)
|
||||||
else:
|
else:
|
||||||
print(f"\nError: {hydrus_script} not found.")
|
print(f"\nError: {hydrus_script} not found.")
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user