Improve logging of LS installations

This commit is contained in:
Dominik Jain
2025-07-26 22:08:19 +02:00
parent cc2ac85163
commit bc621bb3a5
3 changed files with 28 additions and 20 deletions
+22 -19
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import logging
import os
import subprocess
from collections.abc import Sequence
@@ -8,6 +9,8 @@ from dataclasses import dataclass
from solidlsp.ls_logger import LanguageServerLogger
from solidlsp.ls_utils import FileUtils, PlatformUtils
log = logging.getLogger(__name__)
@dataclass(kw_only=True)
class RuntimeDependency:
@@ -69,28 +72,28 @@ class RuntimeDependencyCollection:
@staticmethod
def _run_command(command: str, cwd: str) -> None:
if PlatformUtils.get_platform_id().value.startswith("win"):
subprocess.run(
command,
shell=True,
check=True,
cwd=cwd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
kwargs = {}
if PlatformUtils.get_platform_id().is_windows():
kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW # type: ignore
else:
import pwd
user = pwd.getpwuid(os.getuid()).pw_name
subprocess.run(
command,
shell=True,
check=True,
user=user,
cwd=cwd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
kwargs["user"] = pwd.getpwuid(os.getuid()).pw_name
log.info("Running command '%s' in '%s'", command, cwd)
completed_proces = subprocess.run(
command,
shell=True,
check=True,
cwd=cwd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
**kwargs,
)
log.log(
logging.WARNING if completed_proces.returncode else logging.INFO,
"Command completed with return code %d",
completed_proces.returncode,
)
@staticmethod
def _install_from_url(dep: RuntimeDependency, logger: LanguageServerLogger, target_dir: str) -> None:
@@ -10,6 +10,7 @@ import threading
from time import sleep
from overrides import override
from sensai.util.logging import LogTime
from solidlsp.ls import SolidLanguageServer
from solidlsp.ls_config import LanguageServerConfig
@@ -117,7 +118,8 @@ class TypeScriptLanguageServer(SolidLanguageServer):
tsserver_executable_path = os.path.join(tsserver_ls_dir, "node_modules", ".bin", "typescript-language-server")
if not os.path.exists(tsserver_executable_path):
logger.log(f"Typescript Language Server executable not found at {tsserver_executable_path}. Installing...", logging.INFO)
deps.install(logger, tsserver_ls_dir)
with LogTime("Installation of TypeScript language server dependencies", logger=logger.logger):
deps.install(logger, tsserver_ls_dir)
if not os.path.exists(tsserver_executable_path):
raise FileNotFoundError(
+3
View File
@@ -247,6 +247,9 @@ class PlatformId(str, Enum):
LINUX_MUSL_x64 = "linux-musl-x64"
LINUX_MUSL_arm64 = "linux-musl-arm64"
def is_windows(self):
return self.value.startswith("win")
class DotnetVersion(str, Enum):
"""