fix: if mock is active, do not search rbw or bw
This commit is contained in:
parent
4c72346aa6
commit
a12cf396fd
3 changed files with 36 additions and 27 deletions
|
@ -55,33 +55,34 @@ class RougailUserDataBitwarden:
|
|||
self.leader_informations = {}
|
||||
bitwarden_command_line = None
|
||||
one_is_find = False
|
||||
if which('rbw'):
|
||||
one_is_find = True
|
||||
try:
|
||||
cpe = run(['rbw', 'unlocked'], capture_output=True)
|
||||
except Exception as exc:
|
||||
pass
|
||||
else:
|
||||
if cpe.returncode == 0:
|
||||
bitwarden_command_line = 'rbw'
|
||||
if bitwarden_command_line is None and which('bw'):
|
||||
one_is_find = True
|
||||
try:
|
||||
cpe = run(['bw', 'status'], capture_output=True)
|
||||
except Exception as exc:
|
||||
pass
|
||||
else:
|
||||
if cpe.returncode == 0:
|
||||
try:
|
||||
data = loads(cpe.stdout.decode('utf8'))
|
||||
if data["status"] == "unlocked":
|
||||
bitwarden_command_line = 'bw'
|
||||
except:
|
||||
pass
|
||||
if bitwarden_command_line is None:
|
||||
if one_is_find:
|
||||
raise ExtentionError(_('please unlock Bitwarden password database'))
|
||||
raise ExtentionError(_('cannot find Bitwarden command (rbw or bw) please install it'))
|
||||
if 'ROUGAIL_BITWARDEN_MOCK_ENABLE' not in environ:
|
||||
if which('rbw'):
|
||||
one_is_find = True
|
||||
try:
|
||||
cpe = run(['rbw', 'unlocked'], capture_output=True)
|
||||
except Exception as exc:
|
||||
pass
|
||||
else:
|
||||
if cpe.returncode == 0:
|
||||
bitwarden_command_line = 'rbw'
|
||||
if bitwarden_command_line is None and which('bw'):
|
||||
one_is_find = True
|
||||
try:
|
||||
cpe = run(['bw', 'status'], capture_output=True)
|
||||
except Exception as exc:
|
||||
pass
|
||||
else:
|
||||
if cpe.returncode == 0:
|
||||
try:
|
||||
data = loads(cpe.stdout.decode('utf8'))
|
||||
if data["status"] == "unlocked":
|
||||
bitwarden_command_line = 'bw'
|
||||
except:
|
||||
pass
|
||||
if bitwarden_command_line is None:
|
||||
if one_is_find:
|
||||
raise ExtentionError(_('please unlock Bitwarden password database'))
|
||||
raise ExtentionError(_('cannot find Bitwarden command (rbw or bw) please install it'))
|
||||
self.bitwarden_command_line = bitwarden_command_line
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"errors": [],
|
||||
"warnings": []
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"rougail.username": "bitwarden_username",
|
||||
"rougail.secret": "bitwarden_password"
|
||||
}
|
Loading…
Reference in a new issue