Catch connection errors

This commit is contained in:
jpk 2019-10-19 15:18:33 +02:00
parent 2f653b31ac
commit 182d36a3fc
1 changed files with 5 additions and 2 deletions

View File

@ -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?')