Code refactoring

This commit is contained in:
Daniil Anfimov 2022-06-30 15:24:56 +02:00
parent 07becc78df
commit fa16027062

View File

@ -122,8 +122,7 @@ class CasWrapper:
self.ensure_login() self.ensure_login()
try: try:
result_json = self.authenticate(local_path, return_json=True) result_json = self.authenticate(local_path, return_json=True)
# it should return 0 for authenticated and trusted commits is_authenticated = result_json['verified']
is_authenticated = not bool(result_json['status'])
commit_cas_hash = result_json['hash'] commit_cas_hash = result_json['hash']
# we can fall with ProcessExecutionError, # we can fall with ProcessExecutionError,
# because source can be not notarized # because source can be not notarized
@ -135,7 +134,6 @@ class CasWrapper:
self, self,
local_path: str, local_path: str,
use_hash: bool = False, use_hash: bool = False,
return_json: bool = False,
) -> bool: ) -> bool:
""" """
Authenticates artifact by artifact path or hash if `use_hash` is True. Authenticates artifact by artifact path or hash if `use_hash` is True.
@ -147,10 +145,10 @@ class CasWrapper:
is_authenticated = self.authenticate( is_authenticated = self.authenticate(
local_path, local_path,
use_hash=use_hash, use_hash=use_hash,
return_json=return_json, return_json=True,
) )['verified']
# we can fall with ProcessExecutionError, # we can fall with ProcessExecutionError,
# because source can be not notarized # because artifact can be not notarized
except ProcessExecutionError: except ProcessExecutionError:
self._logger.exception('Cannot authenticate: %s', local_path) self._logger.exception('Cannot authenticate: %s', local_path)
return is_authenticated return is_authenticated