diff options
| author | erkin <e.altunbas@vyos.io> | 2022-01-11 12:02:32 +0300 | 
|---|---|---|
| committer | Christian Poessinger <christian@poessinger.com> | 2022-01-11 10:35:38 +0100 | 
| commit | d5775339f9d1ee33c04f5d923684cd254b400364 (patch) | |
| tree | b674f411f69567974d0f631b96ed49abcf90380b | |
| parent | 54675c2cc9aa9c1315478107cce14e5ba23d865e (diff) | |
| download | vyos-1x-d5775339f9d1ee33c04f5d923684cd254b400364.tar.gz vyos-1x-d5775339f9d1ee33c04f5d923684cd254b400364.zip | |
remote: T3950: Gracefully handle chained exceptions
| -rw-r--r-- | python/vyos/remote.py | 10 | 
1 files changed, 5 insertions, 5 deletions
| diff --git a/python/vyos/remote.py b/python/vyos/remote.py index aa62ac60d..66044fa52 100644 --- a/python/vyos/remote.py +++ b/python/vyos/remote.py @@ -83,8 +83,7 @@ def check_storage(path, size):      directory = path if os.path.isdir(path) else (os.path.dirname(os.path.expanduser(path)) or os.getcwd())      # `size` can be None or 0 to indicate unknown size.      if not size: -        print_error('Warning: Cannot determine size of remote file.') -        print_error('Bravely continuing regardless.') +        print_error('Warning: Cannot determine size of remote file. Bravely continuing regardless.')          return      if size < 1024 * 1024: @@ -227,7 +226,7 @@ class HttpC:                  r.raise_for_status()                  # If the request got redirected, keep the last URL we ended up with.                  final_urlstring = r.url -                if r.history: +                if r.history and self.progressbar:                      print_error('Redirecting to ' + final_urlstring)                  # Check for the prospective file size.                  try: @@ -317,11 +316,12 @@ def friendly_download(local_path, urlstring, source_host='', source_port=0):          sys.exit(1)      except:          import traceback +        print_error(f'Failed to download {urlstring}.')          # There are a myriad different reasons a download could fail.          # SSH errors, FTP errors, I/O errors, HTTP errors (403, 404...)          # We omit the scary stack trace but print the error nevertheless. -        print_error(f'Failed to download {urlstring}.') -        traceback.print_exception(*sys.exc_info()[:2], None) +        exc_type, exc_value, exc_traceback = sys.exc_info() +        traceback.print_exception(exc_type, exc_value, None, 0, None, False)          sys.exit(1)      else:          print_error('Download complete.') | 
