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