Show message when downloading tools
This commit is contained in:
parent
b44fda2ccd
commit
ee3203c485
2 changed files with 11 additions and 3 deletions
|
|
@ -27,6 +27,8 @@ CACHED_DIRS = {}
|
||||||
def download_file(out_path, source_url, as_new=False, overwrite=False):
|
def download_file(out_path, source_url, as_new=False, overwrite=False):
|
||||||
"""Download a file using requests, returns pathlib.Path."""
|
"""Download a file using requests, returns pathlib.Path."""
|
||||||
out_path = pathlib.Path(out_path).resolve()
|
out_path = pathlib.Path(out_path).resolve()
|
||||||
|
cursor_left = '\u001B[14D'
|
||||||
|
print(f'Downloading...{cursor_left}', end='', flush=True)
|
||||||
|
|
||||||
# Avoid clobbering
|
# Avoid clobbering
|
||||||
if out_path.exists() and not overwrite:
|
if out_path.exists() and not overwrite:
|
||||||
|
|
@ -55,6 +57,7 @@ def download_file(out_path, source_url, as_new=False, overwrite=False):
|
||||||
_f.write(chunk)
|
_f.write(chunk)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
|
print(f' {cursor_left}', end='', flush=True)
|
||||||
return out_path
|
return out_path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ class TryAndPrint():
|
||||||
# Done
|
# Done
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def _format_function_output(self, output):
|
def _format_function_output(self, output, msg_good):
|
||||||
"""Format function output for use in try_and_print(), returns str."""
|
"""Format function output for use in try_and_print(), returns str."""
|
||||||
LOG.debug('Formatting output: %s', output)
|
LOG.debug('Formatting output: %s', output)
|
||||||
|
|
||||||
|
|
@ -468,6 +468,10 @@ class TryAndPrint():
|
||||||
if not isinstance(stdout, str):
|
if not isinstance(stdout, str):
|
||||||
stdout = stdout.decode('utf8')
|
stdout = stdout.decode('utf8')
|
||||||
output = stdout.strip().splitlines()
|
output = stdout.strip().splitlines()
|
||||||
|
if not output:
|
||||||
|
# Going to treat these as successes (for now)
|
||||||
|
LOG.warning('Program output was empty, assuming good result.')
|
||||||
|
return color_string(msg_good, 'GREEN')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
output = list(output)
|
output = list(output)
|
||||||
|
|
@ -560,6 +564,7 @@ class TryAndPrint():
|
||||||
verbose,
|
verbose,
|
||||||
)
|
)
|
||||||
f_exception = None
|
f_exception = None
|
||||||
|
msg_good = msg_good if msg_good else self.msg_good
|
||||||
output = None
|
output = None
|
||||||
result_msg = 'UNKNOWN'
|
result_msg = 'UNKNOWN'
|
||||||
if catch_all is None:
|
if catch_all is None:
|
||||||
|
|
@ -600,10 +605,10 @@ class TryAndPrint():
|
||||||
else:
|
else:
|
||||||
# Success
|
# Success
|
||||||
if output:
|
if output:
|
||||||
result_msg = self._format_function_output(output)
|
result_msg = self._format_function_output(output, msg_good)
|
||||||
print(result_msg)
|
print(result_msg)
|
||||||
else:
|
else:
|
||||||
result_msg = msg_good if msg_good else self.msg_good
|
result_msg = msg_good
|
||||||
print_success(result_msg, log=False)
|
print_success(result_msg, log=False)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue