Loading src/climax/__main__.py +39 −14 Changes for src/climax/__main__.py: 39 added lines, 14 removed lines. Original line number Diff line number Diff line import subprocess from http.client import HTTP_PORT from pathlib import Path from typing import Optional, Union from typing_extensions import Annotated Loading Loading @@ -38,6 +39,7 @@ JAVA_DISTROS = { } WEB_PORT = 8080 BASEX_PORT = 1984 DEFAULT_XML_FORMAT = "TEI" @lru_cache() Loading Loading @@ -179,9 +181,10 @@ def init( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = os.getcwd(), xml_format: str = typer.Option(DEFAULT_XML_FORMAT, help=_("vocabulaire XML")), http_port: int = typer.Option(WEB_PORT, help=_("port du serveur web")), basex_port: int = typer.Option(BASEX_PORT, help=_("port du serveur basex")), ): # TODO: sélectionner le vocabulaire dès l'init ): root_directory = ensure_new_max_directory(directory) java_bin = ensure_java() max_path = ensure_max() Loading Loading @@ -211,6 +214,7 @@ def init( "saxon_distro": SAXON_DISTRO, "max_distro": MAX_DISTRO, "java_bin": java_bin, "xml_format": xml_format, } with open(Path(root_directory, CLIMAX_CONFIG_FILE), "w") as f: json.dump(cli_config, f, indent=2) Loading Loading @@ -281,21 +285,32 @@ def demo(): @app.command(help=_("Démarre l'instance de MaX du dossier en cours")) def run(): # TODO: se passer des scripts de démarrage fournis par BaseX config = read_climax_config() print("[green]" + _("Démarrage de MaX...") + "[/green]") subprocess.run( def run(): class_path_separator = ":" current_os = current_system().split("/")[0] if current_os == "windows": class_path_separator = ";" climax_config = read_climax_config() java_bin_path = ensure_java() basex_dir_path = Path(os.getcwd(), ".max", "basex") cp_paths = class_path_separator.join( [ Path( os.getcwd(), ".max", "basex", "bin", "basexhttp", ), f"-h{config.get('http_port')}", str(Path(basex_dir_path, "BaseX.jar")), str(Path(basex_dir_path, "lib", "custom", "*")), str(Path(basex_dir_path, "lib", "*")), ] ) process_args = [ str(java_bin_path), "-cp", cp_paths, "-Xmx2g", "org.basex.BaseXHTTP", f"-h{climax_config.get('http_port', HTTP_PORT)}", ] print("[green]" + _("Démarrage de MaX...") + "[/green]") print(f"java path: {java_bin_path}") subprocess.run(process_args) @app.command(help=_("Efface le cache de climax")) Loading @@ -313,9 +328,19 @@ def getconfig(): @app.command(help=_("Modifie la configuration de l'instance de MaX en cours")) def setconfig(key: str, value): try: config = read_climax_config() config[key] = value if key == "http_port": config[key] = int(value) write_climax_config(config) except ValueError: print( "[red]" + _("Erreur: valeur {} impossible pour la clef {}").format( f"[bold]{value}[/bold]", f"[bold]{key}[/bold]" ) + "[/red]" ) if __name__ == "__main__": Loading Loading
src/climax/__main__.py +39 −14 Changes for src/climax/__main__.py: 39 added lines, 14 removed lines. Original line number Diff line number Diff line import subprocess from http.client import HTTP_PORT from pathlib import Path from typing import Optional, Union from typing_extensions import Annotated Loading Loading @@ -38,6 +39,7 @@ JAVA_DISTROS = { } WEB_PORT = 8080 BASEX_PORT = 1984 DEFAULT_XML_FORMAT = "TEI" @lru_cache() Loading Loading @@ -179,9 +181,10 @@ def init( directory: Annotated[ Optional[Path], typer.Argument(help=_("chemin vers un dossier")) ] = os.getcwd(), xml_format: str = typer.Option(DEFAULT_XML_FORMAT, help=_("vocabulaire XML")), http_port: int = typer.Option(WEB_PORT, help=_("port du serveur web")), basex_port: int = typer.Option(BASEX_PORT, help=_("port du serveur basex")), ): # TODO: sélectionner le vocabulaire dès l'init ): root_directory = ensure_new_max_directory(directory) java_bin = ensure_java() max_path = ensure_max() Loading Loading @@ -211,6 +214,7 @@ def init( "saxon_distro": SAXON_DISTRO, "max_distro": MAX_DISTRO, "java_bin": java_bin, "xml_format": xml_format, } with open(Path(root_directory, CLIMAX_CONFIG_FILE), "w") as f: json.dump(cli_config, f, indent=2) Loading Loading @@ -281,21 +285,32 @@ def demo(): @app.command(help=_("Démarre l'instance de MaX du dossier en cours")) def run(): # TODO: se passer des scripts de démarrage fournis par BaseX config = read_climax_config() print("[green]" + _("Démarrage de MaX...") + "[/green]") subprocess.run( def run(): class_path_separator = ":" current_os = current_system().split("/")[0] if current_os == "windows": class_path_separator = ";" climax_config = read_climax_config() java_bin_path = ensure_java() basex_dir_path = Path(os.getcwd(), ".max", "basex") cp_paths = class_path_separator.join( [ Path( os.getcwd(), ".max", "basex", "bin", "basexhttp", ), f"-h{config.get('http_port')}", str(Path(basex_dir_path, "BaseX.jar")), str(Path(basex_dir_path, "lib", "custom", "*")), str(Path(basex_dir_path, "lib", "*")), ] ) process_args = [ str(java_bin_path), "-cp", cp_paths, "-Xmx2g", "org.basex.BaseXHTTP", f"-h{climax_config.get('http_port', HTTP_PORT)}", ] print("[green]" + _("Démarrage de MaX...") + "[/green]") print(f"java path: {java_bin_path}") subprocess.run(process_args) @app.command(help=_("Efface le cache de climax")) Loading @@ -313,9 +328,19 @@ def getconfig(): @app.command(help=_("Modifie la configuration de l'instance de MaX en cours")) def setconfig(key: str, value): try: config = read_climax_config() config[key] = value if key == "http_port": config[key] = int(value) write_climax_config(config) except ValueError: print( "[red]" + _("Erreur: valeur {} impossible pour la clef {}").format( f"[bold]{value}[/bold]", f"[bold]{key}[/bold]" ) + "[/red]" ) if __name__ == "__main__": Loading