Fix output decoding and stripping for passwords
This commit is contained in:
parent
1adab407e8
commit
49be06d41f
@ -7,8 +7,8 @@ from PyInquirer import prompt
|
|||||||
|
|
||||||
from autonomic.config import ACTIONS_DIR, INFRA_DIR, PASS_STORE_DIR
|
from autonomic.config import ACTIONS_DIR, INFRA_DIR, PASS_STORE_DIR
|
||||||
from autonomic.infra import get_passwd, run_play
|
from autonomic.infra import get_passwd, run_play
|
||||||
from autonomic.utils import git_status, qlist
|
|
||||||
from autonomic.settings import get
|
from autonomic.settings import get
|
||||||
|
from autonomic.utils import git_status, qlist
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
@ -40,4 +40,4 @@ def get_passwd(path):
|
|||||||
cmd = ["pass", "show", path]
|
cmd = ["pass", "show", path]
|
||||||
output = run(cmd, cwd=INFRA_DIR, env=env)
|
output = run(cmd, cwd=INFRA_DIR, env=env)
|
||||||
|
|
||||||
return output.decode("utf-8").strip()
|
return output.strip()
|
||||||
|
@ -8,10 +8,11 @@ things here.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from os import chdir
|
from os import chdir
|
||||||
from subprocess import check_output, call
|
from subprocess import call, check_output
|
||||||
|
|
||||||
from psutil import process_iter
|
from psutil import process_iter
|
||||||
|
|
||||||
|
from autonomic.config import INFRA_DIR
|
||||||
from autonomic.logger import log
|
from autonomic.logger import log
|
||||||
from autonomic.yaml import yaml
|
from autonomic.yaml import yaml
|
||||||
|
|
||||||
@ -32,7 +33,9 @@ def run(cmd, cwd=None, interactive=False, **kwargs):
|
|||||||
|
|
||||||
if interactive:
|
if interactive:
|
||||||
return call(cmd, **kwargs)
|
return call(cmd, **kwargs)
|
||||||
return check_output(cmd, **kwargs)
|
|
||||||
|
output = check_output(cmd, **kwargs)
|
||||||
|
return output.decode("utf-8")
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
msg = "{} failed! Saw {}".format(" ".join(cmd), str(exception))
|
msg = "{} failed! Saw {}".format(" ".join(cmd), str(exception))
|
||||||
exit(msg)
|
exit(msg)
|
||||||
|
@ -15,7 +15,7 @@ def test_run_cwd(tmp_path):
|
|||||||
testfile.write_text("hello, world")
|
testfile.write_text("hello, world")
|
||||||
|
|
||||||
output = run(["ls"], cwd=directory.absolute())
|
output = run(["ls"], cwd=directory.absolute())
|
||||||
assert "testfile.txt" in output.decode()
|
assert "testfile.txt" in output
|
||||||
|
|
||||||
|
|
||||||
def test_make_qlist():
|
def test_make_qlist():
|
||||||
|
Reference in New Issue
Block a user