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):
|
||||
"""Download a file using requests, returns pathlib.Path."""
|
||||
out_path = pathlib.Path(out_path).resolve()
|
||||
cursor_left = '\u001B[14D'
|
||||
print(f'Downloading...{cursor_left}', end='', flush=True)
|
||||
|
||||
# Avoid clobbering
|
||||
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)
|
||||
|
||||
# Done
|
||||
print(f' {cursor_left}', end='', flush=True)
|
||||
return out_path
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ class TryAndPrint():
|
|||
# Done
|
||||
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."""
|
||||
LOG.debug('Formatting output: %s', output)
|
||||
|
||||
|
|
@ -468,6 +468,10 @@ class TryAndPrint():
|
|||
if not isinstance(stdout, str):
|
||||
stdout = stdout.decode('utf8')
|
||||
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:
|
||||
try:
|
||||
output = list(output)
|
||||
|
|
@ -560,6 +564,7 @@ class TryAndPrint():
|
|||
verbose,
|
||||
)
|
||||
f_exception = None
|
||||
msg_good = msg_good if msg_good else self.msg_good
|
||||
output = None
|
||||
result_msg = 'UNKNOWN'
|
||||
if catch_all is None:
|
||||
|
|
@ -600,10 +605,10 @@ class TryAndPrint():
|
|||
else:
|
||||
# Success
|
||||
if output:
|
||||
result_msg = self._format_function_output(output)
|
||||
result_msg = self._format_function_output(output, msg_good)
|
||||
print(result_msg)
|
||||
else:
|
||||
result_msg = msg_good if msg_good else self.msg_good
|
||||
result_msg = msg_good
|
||||
print_success(result_msg, log=False)
|
||||
|
||||
# Done
|
||||
|
|
|
|||
Loading…
Reference in a new issue