ALBS-444 #2

Merged
anfimovdm merged 9 commits from ALBS-444 into master 2022-07-01 14:25:17 +00:00
1 changed files with 12 additions and 8 deletions
Showing only changes of commit 036d5c589a - Show all commits

View File

@ -83,22 +83,24 @@ class CasWrapper:
self,
local_path: str,
return_json: bool = False,
use_hash: bool = False,
):
"""
Wrapper around `cas authenticate`
:param local_path: path to a local Git repo
(should be started from `git://`)
or to a single local file
or to a single local file or hash
:param return_json: flag for return json response
:param use_hash: flag for authenticate by hash
:return: true if a commit is trusted, vice versa - false
or dict with result if return_json param is True
:rtype: bool or dict
"""
command = self._cas[
'authenticate',
local_path,
'-o',
'json',
]
command_args = ['authenticate', local_path]
if use_hash:
command_args = ['authenticate', '--hash', local_path]
command_args.extend(('-o', 'json'))
command = self._cas[command_args]
try:
with local.env(
CAS_API_KEY=self._cas_api_key,
@ -139,11 +141,13 @@ class CasWrapper:
def authenticate_artifact(
self,
local_path: str,
use_hash: bool = False,
) -> bool:
is_authenticated = False
with self as cas:
anfimovdm marked this conversation as resolved Outdated

Instead of with self I would prefer self.ensure_login() or something, because you didn't use exit

Instead of `with self` I would prefer `self.ensure_login()` or something, because you didn't use __exit__

Done

Done
try:
anfimovdm marked this conversation as resolved Outdated

I guess colon is not needed in the logging message or it's in wrong place of the message

I guess colon is not needed in the logging message or it's in wrong place of the message
is_authenticated = cas.authenticate(local_path)
is_authenticated = cas.authenticate(local_path,
use_hash=use_hash)
# we can fall with ProcessExecutionError,
# because source can be not notarized
except ProcessExecutionError: