Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

show command error output when commands fail #118

Open
dustymabe opened this issue Apr 25, 2018 · 0 comments
Open

show command error output when commands fail #118

dustymabe opened this issue Apr 25, 2018 · 0 comments

Comments

@dustymabe
Copy link
Contributor

In the code

fedimg/fedimg/utils.py

Lines 101 to 109 in 3946ed1

def external_run_command(command):
_log.debug("Starting the command: %r" % command)
ret = subprocess.Popen(' '.join(command), stdin=subprocess.PIPE, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
close_fds=True)
out, err = ret.communicate()
_log.debug("Finished executing the command: %r" % command)
retcode = ret.returncode
return out, err, retcode

we need to give the user the error message in the logs when something fails. This mainly stems from

fedimg/fedimg/utils.py

Lines 124 to 140 in 3946ed1

def get_source_from_image(image_url):
tmpdir = tempfile.mkdtemp()
file_name = get_file_name_image(image_url)
file_path = os.path.join(tmpdir, file_name)
_log.info("[PREP] Preparing temporary directory for download: %r" % tmpdir)
output, error, retcode = external_run_command([
'wget',
image_url,
'-P',
tmpdir
])
if retcode != 0:
return ''
return file_path
where the code doesn't tell you anything about what failed, just returns ''

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants