Skip to content

Commit

Permalink
Properly capture the missing error
Browse files Browse the repository at this point in the history
  • Loading branch information
avdata99 committed Oct 4, 2024
1 parent ce8b27b commit 055737b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ckanext/datapusher_plus/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,16 @@ def _log_command_error(details, logger, e):
if not isinstance(e, subprocess.CalledProcessError):
logger.error(f"Error. {details} {e}")
return
command = e.cmd
output = e.output

command = ' '.join(e.cmd)
output = e.output.decode('utf-8') if e.output else ''
stdout = e.stdout.decode('utf-8') if e.stdout else ''
stderr = e.stderr.decode('utf-8') if e.stderr else ''
returncode = e.returncode
stderr = e.stderr

logger.error(
f"Error {details} running command: {command}.\n"
f"Return code: {returncode}.\n"
f"Output: {output}.\n"
f"Stderr: {stderr}"
f"Error [code: {returncode}]: {details} running command: {command}.\n"
f"{stderr} {output} {stdout}"
)


Expand Down Expand Up @@ -677,6 +678,8 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):

else:
qsv_input_utf_8_encoded_csv = tmp

logger.info("Normalizing & transcoding ...")
try:
qsv_input = subprocess.run(
[
Expand All @@ -688,6 +691,9 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
qsv_input_csv,
],
check=True,
# Without this two lines, we see the output in the terminal but not in the logs
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e:
# return as we can't push an invalid CSV file
Expand Down

0 comments on commit 055737b

Please sign in to comment.