From 182d36a3fceaf21cff8fafce2a442139739d4f42 Mon Sep 17 00:00:00 2001 From: JayPiKay Date: Sat, 19 Oct 2019 15:18:33 +0200 Subject: [PATCH] Catch connection errors --- src/sbeam.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sbeam.py b/src/sbeam.py index 4c7a5fb..6d98f8e 100755 --- a/src/sbeam.py +++ b/src/sbeam.py @@ -102,8 +102,8 @@ def receive(host, destination): fullpath = os.path.join(destination, filepath[1:]) os.makedirs(fullpath, exist_ok=True) with open(os.path.join(fullpath, filename), 'wb') as fd: - # TODO split filesize in chunks with remainder fd.write(response.raw.read(int(filesize))) + bar.update(len(filelist)) @cli.command() @@ -153,4 +153,7 @@ def tui(): if __name__ == '__main__': - cli() + try: + cli() + except requests.exceptions.ConnectionError as conerr: + print(f'Failed to connect. Target alive?')