f
This commit is contained in:
@@ -56,6 +56,7 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
import tempfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
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"
|
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:
|
class ProgressBar:
|
||||||
@@ -904,13 +909,19 @@ def main() -> int:
|
|||||||
|
|
||||||
def _download_hydrus_installer(dest: Path) -> bool:
|
def _download_hydrus_installer(dest: Path) -> bool:
|
||||||
"""Download the hydrusnetwork.py helper script into the provided path."""
|
"""Download the hydrusnetwork.py helper script into the provided path."""
|
||||||
try:
|
last_exc: Exception | None = None
|
||||||
with urllib.request.urlopen(HYDRUS_INSTALLER_SCRIPT_URL) as response:
|
for url in HYDRUS_INSTALLER_SCRIPT_URLS:
|
||||||
dest.write_bytes(response.read())
|
try:
|
||||||
return True
|
with urllib.request.urlopen(url) as response:
|
||||||
except Exception as e:
|
dest.write_bytes(response.read())
|
||||||
print(f"Error: Failed to download Hydrus installer script: {e}", file=sys.stderr)
|
return True
|
||||||
return False
|
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:
|
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."""
|
||||||
@@ -1147,14 +1158,13 @@ def main() -> int:
|
|||||||
# 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
|
temp_installer_path: Path | None = None
|
||||||
|
temp_hydrus_repo: 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():
|
||||||
print("Downloading the Hydrus installation helper...")
|
print("Downloading the Hydrus installation helper...")
|
||||||
try:
|
try:
|
||||||
import tempfile
|
|
||||||
|
|
||||||
fd, path = tempfile.mkstemp(prefix="mm_hydrus_", suffix=".py")
|
fd, path = tempfile.mkstemp(prefix="mm_hydrus_", suffix=".py")
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
helper_path = Path(path)
|
helper_path = Path(path)
|
||||||
@@ -1162,12 +1172,25 @@ def main() -> int:
|
|||||||
hydrus_script = helper_path
|
hydrus_script = helper_path
|
||||||
temp_installer_path = helper_path
|
temp_installer_path = helper_path
|
||||||
else:
|
else:
|
||||||
print("Error: Could not download the installation helper.")
|
|
||||||
helper_path.unlink(missing_ok=True)
|
helper_path.unlink(missing_ok=True)
|
||||||
return 1
|
hydrus_script = None
|
||||||
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
|
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():
|
if hydrus_script and hydrus_script.exists():
|
||||||
try:
|
try:
|
||||||
@@ -1199,6 +1222,8 @@ def main() -> int:
|
|||||||
finally:
|
finally:
|
||||||
if temp_installer_path:
|
if temp_installer_path:
|
||||||
temp_installer_path.unlink(missing_ok=True)
|
temp_installer_path.unlink(missing_ok=True)
|
||||||
|
if temp_hydrus_repo is not None:
|
||||||
|
shutil.rmtree(temp_hydrus_repo, ignore_errors=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