[#263] Unify version parsing #263
1 changed files with 7 additions and 7 deletions
|
@ -18,14 +18,14 @@ def get_local_binaries_versions(shell: Shell) -> dict[str, str]:
|
||||||
|
|
||||||
for binary in [NEOGO_EXECUTABLE, FROSTFS_AUTHMATE_EXEC]:
|
for binary in [NEOGO_EXECUTABLE, FROSTFS_AUTHMATE_EXEC]:
|
||||||
out = shell.exec(f"{binary} --version").stdout
|
out = shell.exec(f"{binary} --version").stdout
|
||||||
versions[binary] = _parse_version(out)
|
versions[binary] = parse_version(out)
|
||||||
|
|
||||||
frostfs_cli = FrostfsCli(shell, FROSTFS_CLI_EXEC)
|
frostfs_cli = FrostfsCli(shell, FROSTFS_CLI_EXEC)
|
||||||
versions[FROSTFS_CLI_EXEC] = _parse_version(frostfs_cli.version.get().stdout)
|
versions[FROSTFS_CLI_EXEC] = parse_version(frostfs_cli.version.get().stdout)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
frostfs_adm = FrostfsAdm(shell, FROSTFS_ADM_EXEC)
|
frostfs_adm = FrostfsAdm(shell, FROSTFS_ADM_EXEC)
|
||||||
versions[FROSTFS_ADM_EXEC] = _parse_version(frostfs_adm.version.get().stdout)
|
versions[FROSTFS_ADM_EXEC] = parse_version(frostfs_adm.version.get().stdout)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
logger.info(f"{FROSTFS_ADM_EXEC} not installed")
|
logger.info(f"{FROSTFS_ADM_EXEC} not installed")
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ def parallel_binary_verions(host: Host) -> dict[str, str]:
|
||||||
binary_path = binary["exec_path"]
|
binary_path = binary["exec_path"]
|
||||||
try:
|
try:
|
||||||
result = shell.exec(f"{binary_path} {binary['param']}")
|
result = shell.exec(f"{binary_path} {binary['param']}")
|
||||||
version = _parse_version(result.stdout) or _parse_version(result.stderr) or "Unknown"
|
version = parse_version(result.stdout) or parse_version(result.stderr) or "Unknown"
|
||||||
versions_at_host[binary_name] = version
|
versions_at_host[binary_name] = version
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error(f"Cannot get version for {binary_path} because of\n{exc}")
|
logger.error(f"Cannot get version for {binary_path} because of\n{exc}")
|
||||||
|
@ -85,6 +85,6 @@ def get_remote_binaries_versions(hosting: Hosting) -> dict[str, dict[str, str]]:
|
||||||
return versions_by_host
|
return versions_by_host
|
||||||
|
|
||||||
|
|
||||||
def _parse_version(version_output: str) -> str:
|
def parse_version(version_output: str) -> str:
|
||||||
version = re.search(r"version[:\s]*v?(.+)", version_output, re.IGNORECASE)
|
version = re.search(r"(?<=version[:=])\s?[\"\']?v?(.+)", version_output, re.IGNORECASE)
|
||||||
return version.group(1).strip() if version else version_output
|
return version.group(1).strip("\"'\n\t ") if version else version_output
|
||||||
|
|
Loading…
Reference in a new issue