ALBS-443: Integrate CodeNotary with git updater tool #1
@ -30,38 +30,20 @@ class CasWrapper:
|
|||||||
self._cas = local['cas']
|
self._cas = local['cas']
|
||||||
self._cas['login']()
|
self._cas['login']()
|
||||||
soksanichenko marked this conversation as resolved
|
|||||||
|
|
||||||
def notarize(self, local_git_repo_path: str) -> str:
|
def notarize(
|
||||||
|
self,
|
||||||
|
local_path: str,
|
||||||
|
metadata: Dict = None,
|
||||||
|
) -> str:
|
||||||
"""
|
"""
|
||||||
Wrapper around `cas notarize`
|
Wrapper around `cas notarize`
|
||||||
:param local_git_repo_path: path to a local Git repo
|
:param local_path: path to a local Git repo
|
||||||
|
:param metadata: additional metadata
|
||||||
:return: hash of notarized commit
|
:return: hash of notarized commit
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
command = self._cas[
|
command = self._cas[
|
||||||
'notarize',
|
'notarize',
|
||||||
local_git_repo_path,
|
|
||||||
'-o',
|
|
||||||
'json',
|
|
||||||
]
|
|
||||||
result_of_execution = command()
|
|
||||||
return json.loads(result_of_execution)['hash']
|
|
||||||
|
|
||||||
def authenticate(
|
|
||||||
self,
|
|
||||||
local_path: str,
|
|
||||||
metadata: Dict = None,
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Wrapper around `cas authenticate`
|
|
||||||
:param local_path: path to a local Git repo
|
|
||||||
(should be started from `git://`)
|
|
||||||
or to a single local file
|
|
||||||
:param metadata: additional metadata
|
|
||||||
:return: true if a commit is trusted, vice versa - false
|
|
||||||
:rtype: bool
|
|
||||||
"""
|
|
||||||
command = self._cas[
|
|
||||||
'authenticate',
|
|
||||||
local_path,
|
local_path,
|
||||||
'-o',
|
'-o',
|
||||||
'json',
|
'json',
|
||||||
@ -72,6 +54,27 @@ class CasWrapper:
|
|||||||
'-a',
|
'-a',
|
||||||
f'{key}={value}',
|
f'{key}={value}',
|
||||||
]
|
]
|
||||||
|
result_of_execution = command()
|
||||||
|
return json.loads(result_of_execution)['hash']
|
||||||
|
|
||||||
|
def authenticate(
|
||||||
|
self,
|
||||||
|
local_path: str,
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Wrapper around `cas authenticate`
|
||||||
|
:param local_path: path to a local Git repo
|
||||||
|
(should be started from `git://`)
|
||||||
|
or to a single local file
|
||||||
|
:return: true if a commit is trusted, vice versa - false
|
||||||
|
:rtype: bool
|
||||||
|
"""
|
||||||
|
command = self._cas[
|
||||||
|
'authenticate',
|
||||||
|
local_path,
|
||||||
|
'-o',
|
||||||
|
'json',
|
||||||
|
]
|
||||||
try:
|
try:
|
||||||
result_of_execution = command()
|
result_of_execution = command()
|
||||||
except ProcessExecutionError:
|
except ProcessExecutionError:
|
||||||
|
Loading…
Reference in New Issue
Block a user
I feel uncomfortable with
login()
in__init__
, can't we do it in__enter__
and__exit__
?Do you suggest convert it to context manager?
yes