Skip to content

Commit

Permalink
[IMP] run_cmd logging
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkreud committed Nov 22, 2023
1 parent 923d5a2 commit adeea2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/godoo_cli/commands/backup/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def load_pg_dump(
command = "cat %s | psql {} >/dev/null" % dump_path
load_return = conn.run_psql_shell_command(
command=command,
log_name="Reading DB",
text=True,
capture_output=True,
)
if load_return.returncode != 0:
LOGGER.error("Failed to load DB Dump: %s", load_return.stderr)
raise typer.Exit(1)
LOGGER.info("Deleting RPC Import Cache using plain SQL")
with conn.connect() as cur:
Expand Down
5 changes: 2 additions & 3 deletions src/godoo_cli/helpers/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
LOGGER = logging.getLogger(__name__)


def run_cmd(command: str, log_name: str = "", **kwargs) -> subprocess.CompletedProcess:
def run_cmd(command: str, **kwargs) -> subprocess.CompletedProcess:
"""Runs command via subprocess.run
Parameters
Expand All @@ -37,8 +37,7 @@ def run_cmd(command: str, log_name: str = "", **kwargs) -> subprocess.CompletedP
if not kwargs.get("shell"):
kwargs["shell"] = True
proc = subprocess.run(command, **kwargs)
if proc.returncode != 0 and log_name:
LOGGER.error("Failed: %s", log_name)
LOGGER.debug("Return Code: %s", proc.returncode)
return proc


Expand Down

0 comments on commit adeea2f

Please sign in to comment.