f
This commit is contained in:
@@ -56,6 +56,7 @@ import argparse
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import tempfile
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
@@ -119,7 +120,11 @@ def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[
|
||||
|
||||
|
||||
REPO_URL = "https://code.glowers.club/goyimnose/Medios-Macina.git"
|
||||
HYDRUS_INSTALLER_SCRIPT_URL = "https://raw.githubusercontent.com/hydrusnetwork/hydrus/master/scripts/hydrusnetwork.py"
|
||||
HYDRUS_REPO_URL = "https://github.com/hydrusnetwork/hydrus.git"
|
||||
HYDRUS_INSTALLER_SCRIPT_URLS = (
|
||||
"https://raw.githubusercontent.com/hydrusnetwork/hydrus/main/scripts/hydrusnetwork.py",
|
||||
"https://raw.githubusercontent.com/hydrusnetwork/hydrus/master/scripts/hydrusnetwork.py",
|
||||
)
|
||||
|
||||
|
||||
class ProgressBar:
|
||||
@@ -904,13 +909,19 @@ def main() -> int:
|
||||
|
||||
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
|
||||
last_exc: Exception | None = None
|
||||
for url in HYDRUS_INSTALLER_SCRIPT_URLS:
|
||||
try:
|
||||
with urllib.request.urlopen(url) as response:
|
||||
dest.write_bytes(response.read())
|
||||
return True
|
||||
except Exception as exc:
|
||||
last_exc = exc
|
||||
if last_exc:
|
||||
print(f"Error: Failed to download Hydrus installer script: {last_exc}", file=sys.stderr)
|
||||
else:
|
||||
print("Error: Failed to download Hydrus installer script", file=sys.stderr)
|
||||
return False
|
||||
|
||||
def _ensure_repo_available() -> bool:
|
||||
"""Prompt for a clone location when running outside the repository."""
|
||||
@@ -1147,14 +1158,13 @@ def main() -> int:
|
||||
# We preferentially use the local script if already in a repo.
|
||||
hydrus_script = None
|
||||
temp_installer_path: Path | None = None
|
||||
temp_hydrus_repo: Path | None = None
|
||||
if is_in_repo and repo_root:
|
||||
hydrus_script = repo_root / "scripts" / "hydrusnetwork.py"
|
||||
|
||||
if not hydrus_script or not hydrus_script.exists():
|
||||
print("Downloading the Hydrus installation helper...")
|
||||
try:
|
||||
import tempfile
|
||||
|
||||
fd, path = tempfile.mkstemp(prefix="mm_hydrus_", suffix=".py")
|
||||
os.close(fd)
|
||||
helper_path = Path(path)
|
||||
@@ -1162,12 +1172,25 @@ def main() -> int:
|
||||
hydrus_script = helper_path
|
||||
temp_installer_path = helper_path
|
||||
else:
|
||||
print("Error: Could not download the installation helper.")
|
||||
helper_path.unlink(missing_ok=True)
|
||||
return 1
|
||||
hydrus_script = None
|
||||
except Exception as e:
|
||||
print(f"Error setting up temporary installer: {e}")
|
||||
return 1
|
||||
hydrus_script = None
|
||||
|
||||
if (not hydrus_script or not hydrus_script.exists()) and temp_hydrus_repo is None:
|
||||
print("Falling back to clone the Hydrus repository to obtain the helper script...")
|
||||
try:
|
||||
temp_hydrus_repo_dir = Path(tempfile.mkdtemp(prefix="mm_hydrus_repo_"))
|
||||
if _clone_repo(HYDRUS_REPO_URL, temp_hydrus_repo_dir, depth=1):
|
||||
hydrus_script = temp_hydrus_repo_dir / "scripts" / "hydrusnetwork.py"
|
||||
temp_hydrus_repo = temp_hydrus_repo_dir
|
||||
else:
|
||||
shutil.rmtree(temp_hydrus_repo_dir, ignore_errors=True)
|
||||
hydrus_script = None
|
||||
except Exception as e:
|
||||
print(f"Error cloning Hydrus repo: {e}")
|
||||
hydrus_script = None
|
||||
|
||||
if hydrus_script and hydrus_script.exists():
|
||||
try:
|
||||
@@ -1199,6 +1222,8 @@ def main() -> int:
|
||||
finally:
|
||||
if temp_installer_path:
|
||||
temp_installer_path.unlink(missing_ok=True)
|
||||
if temp_hydrus_repo is not None:
|
||||
shutil.rmtree(temp_hydrus_repo, ignore_errors=True)
|
||||
else:
|
||||
print(f"\nError: {hydrus_script} not found.")
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user