Merge pull request 'ALBS-639: Create a CLI tool to generate SBOM' (#4) from ALBS-639 into master

Reviewed-on: almalinux/cas_wrapper#4
This commit is contained in:
Stepan Oksanichenko 2022-09-13 12:26:18 +00:00
commit 49c4c97645
2 changed files with 16 additions and 5 deletions

View File

@ -13,16 +13,20 @@ class CasWrapper:
binary_name = 'cas' 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__( def __init__(
self, self,
cas_api_key: str, cas_api_key: str,
cas_signer_id: str, cas_signer_id: str,
logger: logging.Logger = None, logger: logging.Logger = None,
): ):
if self.binary_name not in local: self._is_binary_present()
raise FileNotFoundError(
'Binary CAS is not found in PATH on the machine',
)
self._cas_api_key = cas_api_key self._cas_api_key = cas_api_key
self._cas_signer_id = cas_signer_id self._cas_signer_id = cas_signer_id
self._cas = local['cas'] self._cas = local['cas']
@ -30,6 +34,13 @@ class CasWrapper:
if self._logger is None: if self._logger is None:
self._logger = logging.getLogger() self._logger = logging.getLogger()
@classmethod
def get_version(cls):
cls._is_binary_present()
command = local['cas']['--version']
version = command().split()[-1].split('v')[1]
return version
def ensure_login(self): def ensure_login(self):
with local.env( with local.env(
CAS_API_KEY=self._cas_api_key, CAS_API_KEY=self._cas_api_key,

View File

@ -2,7 +2,7 @@ from setuptools import setup
setup( setup(
name="cas_wrapper", name="cas_wrapper",
version="0.0.3", version="0.0.4",
author="Stepan Oksanichenko", author="Stepan Oksanichenko",
author_email="soksanichenko@almalinux.org", author_email="soksanichenko@almalinux.org",
description="The python wrapper around binary cas from " description="The python wrapper around binary cas from "