check for required variables before doing anything else in _get_contents_from_keepass()

This commit is contained in:
Franzi 2021-07-03 17:22:06 +02:00
parent a500310042
commit 91ff5c57eb
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -29,6 +29,9 @@ except (FileNotFoundError, IndexError):
def _get_contents_from_keepass(path):
if not KEEPASS_FILE or not KEEPASS_PASS:
raise FaultUnavailable('BW_KEEPASS_FILE and/or BW_KEEPASS_PASSWORD missing')
if isinstance(path, list):
list_path = path
string_path = '|'.join(path)
@ -47,9 +50,6 @@ def _get_contents_from_keepass(path):
path=list_path,
file=KEEPASS_FILE,
)):
if not KEEPASS_FILE or not KEEPASS_PASS:
raise FaultUnavailable('BW_KEEPASS_FILE and/or BW_KEEPASS_PASSWORD missing')
try:
keepass = PyKeePass(expanduser(KEEPASS_FILE), KEEPASS_PASS)