Commit 6a4262c6 authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

windows compat

parent 774fdd90
Loading
Loading
Loading
Loading
+35 −27
Original line number Diff line number Diff line
@@ -4,16 +4,18 @@ from typing import Optional, Union, Iterator, List
from typing_extensions import Annotated
import gettext
import tempfile

locales_dir = Path(__file__).parent / "locales"
gettext.bindtextdomain("messages", str(locales_dir))
gettext.textdomain("messages")
_ = gettext.gettext

from bs4 import BeautifulSoup  # noqa: E402
from .eggs import get_yolk  # noqa: E402
from .model import MaXProjectConfig  # noqa: E402
from .config import (  # noqa: E402
import geler
import requests
import os
import hashlib
import platform
from bs4 import BeautifulSoup
import shutil
from functools import cache
import socket
from .eggs import get_yolk
from .model import MaXProjectConfig, db, MaxInstall
from .config import (
    WELCOME_PAGE,
    USER_MAX_DIR,
    CACHE_DIR,
@@ -29,21 +31,18 @@ from .config import ( # noqa: E402
    max_release,
    latest_max_release,
)
import geler  # noqa: E402
import requests  # noqa: E402
import os  # noqa: E402
import hashlib  # noqa: E402
import platform  # noqa: E402

locales_dir = Path(__file__).parent / "locales"
gettext.bindtextdomain("messages", str(locales_dir))
gettext.textdomain("messages")
_ = gettext.gettext


import typer  # noqa: E402
from rich import print  # noqa: E402
from rich.progress import track  # noqa: E402
from rich.console import Console  # noqa: E402
from rich.table import Table  # noqa: E402
import shutil  # noqa: E402
from functools import lru_cache  # noqa: E402
import socket  # noqa: E402
from .model import db, MaxInstall  # noqa: E402
from simple_term_menu import TerminalMenu  # noqa: E402

climax_db = db()

@@ -79,21 +78,25 @@ def _scan_dir(start_path: Union[str, Path], extension: str = None) -> Iterator[P
                yield Path(os.path.join(root, file)).resolve()


@lru_cache()
@cache
def current_system() -> str:
    return f"{platform.system()}/{platform.machine()}".lower()


@lru_cache
@cache
def current_os() -> str:
    return current_system().split("/")[0]


@cache
def class_path_separator() -> str:
    separator = ":"
    current_os = current_system().split("/")[0]
    if current_os == "windows":
    if current_os() == "windows":
        separator = ";"
    return separator


@lru_cache
@cache
def cp_paths() -> str:
    basex_dir_path = Path(os.getcwd(), ".max", "basex")
    paths = class_path_separator().join(
@@ -106,7 +109,7 @@ def cp_paths() -> str:
    return paths


@lru_cache()
@cache
def find_jdk(cur_sys: str = None) -> Optional[str]:
    if not cur_sys:
        cur_sys = current_system()
@@ -175,7 +178,7 @@ def cached_download(
    return True


@lru_cache()
@cache
def ensure_java() -> Path:
    java_bin = shutil.which("java")
    if not java_bin:
@@ -402,9 +405,14 @@ def sync(


def _choose_between(values: List[str], label: str = "") -> str:
    try:
        from simple_term_menu import TerminalMenu

        terminal_menu = TerminalMenu(values, title=label)
        menu_entry_index = terminal_menu.show()
        return values[menu_entry_index]
    except NotImplementedError:  # mainly windows
        return typer.prompt("{} ({})".format(_(label), ", ".join(values)))


@app.command(help=_("Création d'une nouvelle instance de MaX"))