Fix output decoding and stripping for passwords

This commit is contained in:
Luke Murphy 2020-04-11 23:18:50 +02:00
parent 1adab407e8
commit 49be06d41f
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
4 changed files with 8 additions and 5 deletions

View File

@ -7,8 +7,8 @@ from PyInquirer import prompt
from autonomic.config import ACTIONS_DIR, INFRA_DIR, PASS_STORE_DIR
from autonomic.infra import get_passwd, run_play
from autonomic.utils import git_status, qlist
from autonomic.settings import get
from autonomic.utils import git_status, qlist
@click.command()

View File

@ -40,4 +40,4 @@ def get_passwd(path):
cmd = ["pass", "show", path]
output = run(cmd, cwd=INFRA_DIR, env=env)
return output.decode("utf-8").strip()
return output.strip()

View File

@ -8,10 +8,11 @@ things here.
"""
from os import chdir
from subprocess import check_output, call
from subprocess import call, check_output
from psutil import process_iter
from autonomic.config import INFRA_DIR
from autonomic.logger import log
from autonomic.yaml import yaml
@ -32,7 +33,9 @@ def run(cmd, cwd=None, interactive=False, **kwargs):
if interactive:
return call(cmd, **kwargs)
return check_output(cmd, **kwargs)
output = check_output(cmd, **kwargs)
return output.decode("utf-8")
except Exception as exception:
msg = "{} failed! Saw {}".format(" ".join(cmd), str(exception))
exit(msg)

View File

@ -15,7 +15,7 @@ def test_run_cwd(tmp_path):
testfile.write_text("hello, world")
output = run(["ls"], cwd=directory.absolute())
assert "testfile.txt" in output.decode()
assert "testfile.txt" in output
def test_make_qlist():