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