From e5fd2bf3b1d0589632717549abf7b318377a9dfa Mon Sep 17 00:00:00 2001 From: soksanichenko Date: Tue, 13 Sep 2022 14:39:54 +0300 Subject: [PATCH] ALBS-639: Create a CLI tool to generate SBOM - Class method `get_version` is implemented --- cas_wrapper.py | 19 +++++++++++++++---- setup.py | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/cas_wrapper.py b/cas_wrapper.py index 53de41b..db74821 100644 --- a/cas_wrapper.py +++ b/cas_wrapper.py @@ -13,16 +13,20 @@ class CasWrapper: binary_name = 'cas' + @classmethod + def _is_binary_present(cls): + if cls.binary_name not in local: + raise FileNotFoundError( + 'Binary CAS is not found in PATH on the machine', + ) + def __init__( self, cas_api_key: str, cas_signer_id: str, logger: logging.Logger = None, ): - if self.binary_name not in local: - raise FileNotFoundError( - 'Binary CAS is not found in PATH on the machine', - ) + self._is_binary_present() self._cas_api_key = cas_api_key self._cas_signer_id = cas_signer_id self._cas = local['cas'] @@ -30,6 +34,13 @@ class CasWrapper: if self._logger is None: self._logger = logging.getLogger() + @classmethod + def get_version(cls): + cls._is_binary_present() + command = local['cas']['--version'] + version = command()[:-1].split().split('v')[1] + return version + def ensure_login(self): with local.env( CAS_API_KEY=self._cas_api_key, diff --git a/setup.py b/setup.py index 946af85..8cca4ab 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name="cas_wrapper", - version="0.0.3", + version="0.0.4", author="Stepan Oksanichenko", author_email="soksanichenko@almalinux.org", description="The python wrapper around binary cas from "