Fix review comments
This commit is contained in:
parent
46b61be603
commit
1133a96f0e
@ -6,6 +6,9 @@ from pathlib import Path
|
|||||||
|
|
||||||
from plumbum import ProcessExecutionError, local
|
from plumbum import ProcessExecutionError, local
|
||||||
|
|
||||||
|
DEFAULT_BINARY_NAME = "vcn"
|
||||||
|
DEFAULT_BINARY_PATH = "/usr/local/bin/"
|
||||||
|
|
||||||
|
|
||||||
def with_env_context(func):
|
def with_env_context(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
@ -30,10 +33,15 @@ class CasWrapper:
|
|||||||
from Codenotary Community Attestation Service
|
from Codenotary Community Attestation Service
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _is_binary_present(self):
|
@classmethod
|
||||||
if not self._full_binary_path.exists():
|
def _is_binary_present(
|
||||||
|
cls,
|
||||||
|
binary_name: str,
|
||||||
|
binary_path: str,
|
||||||
|
):
|
||||||
|
if not Path(binary_path, binary_name).exists():
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
f"Binary VCN is not found in {self._binary_path} on the machine",
|
f"Binary VCN is not found in {binary_path} on the machine",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -42,9 +50,10 @@ class CasWrapper:
|
|||||||
vcn_lc_host: str = "eval-honeywell.codenotary.com",
|
vcn_lc_host: str = "eval-honeywell.codenotary.com",
|
||||||
vcn_lc_port: int = 443,
|
vcn_lc_port: int = 443,
|
||||||
logger: logging.Logger = None,
|
logger: logging.Logger = None,
|
||||||
binary_name: str = "vcn",
|
binary_name: str = DEFAULT_BINARY_NAME,
|
||||||
binary_path: str = "/usr/local/bin/",
|
binary_path: str = DEFAULT_BINARY_PATH,
|
||||||
):
|
):
|
||||||
|
self._is_binary_present(binary_name, binary_path)
|
||||||
self._vcn_lc_api_key = vcn_lc_api_key
|
self._vcn_lc_api_key = vcn_lc_api_key
|
||||||
self._vcn_lc_host = vcn_lc_host
|
self._vcn_lc_host = vcn_lc_host
|
||||||
self._vcn_lc_port = vcn_lc_port
|
self._vcn_lc_port = vcn_lc_port
|
||||||
@ -55,11 +64,16 @@ class CasWrapper:
|
|||||||
self._logger = logger
|
self._logger = logger
|
||||||
if self._logger is None:
|
if self._logger is None:
|
||||||
self._logger = logging.getLogger()
|
self._logger = logging.getLogger()
|
||||||
self._is_binary_present()
|
|
||||||
|
|
||||||
def get_version(self):
|
@classmethod
|
||||||
self._is_binary_present()
|
def get_version(
|
||||||
command = self._vcn["--version"]
|
cls,
|
||||||
|
binary_name: str = DEFAULT_BINARY_NAME,
|
||||||
|
binary_path: str = DEFAULT_BINARY_PATH,
|
||||||
|
):
|
||||||
|
cls._is_binary_present(binary_name, binary_path)
|
||||||
|
full_path = Path(binary_path, binary_name)
|
||||||
|
command = local[str(full_path)]["--version"]
|
||||||
version = command().split()[-1].split("v")[1]
|
version = command().split()[-1].split("v")[1]
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user