feat(command): add command result
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -43,7 +44,7 @@ class CommandExecutor:
|
|||||||
def __init__(self, command: str):
|
def __init__(self, command: str):
|
||||||
self._command = command
|
self._command = command
|
||||||
|
|
||||||
def run(self, basepath: Path):
|
def run(self, basepath: Path) -> dict | None:
|
||||||
self._logger.debug(self._command)
|
self._logger.debug(self._command)
|
||||||
out_logger = CommandLogger(logging.TRACE)
|
out_logger = CommandLogger(logging.TRACE)
|
||||||
err_logger = CommandLogger(logging.TRACE)
|
err_logger = CommandLogger(logging.TRACE)
|
||||||
@@ -59,5 +60,13 @@ class CommandExecutor:
|
|||||||
finally:
|
finally:
|
||||||
out_logger.close()
|
out_logger.close()
|
||||||
err_logger.close()
|
err_logger.close()
|
||||||
|
out_logger.join()
|
||||||
|
err_logger.join()
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise CommandError("".join(err_logger.lines or out_logger.lines))
|
raise CommandError("".join(err_logger.lines or out_logger.lines))
|
||||||
|
if out_logger.lines:
|
||||||
|
try:
|
||||||
|
return json.loads(out_logger.lines[0])
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
return None
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Entry:
|
|||||||
@property
|
@property
|
||||||
def sensentive_data(self):
|
def sensentive_data(self):
|
||||||
for k, v in self._variables.items():
|
for k, v in self._variables.items():
|
||||||
if "pass" in k.lower():
|
if "pass" in k.lower() and v:
|
||||||
yield v
|
yield v
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user