From 0530d24110bfea1896b5441d54a144445e914d52 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 12 Mar 2023 00:14:21 +0000 Subject: [PATCH] Translate SSL/TLS and connection refused logs to ConnectionRefusedErrors --- devine/core/downloaders/aria2c.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/devine/core/downloaders/aria2c.py b/devine/core/downloaders/aria2c.py index fa1ac52..507e741 100644 --- a/devine/core/downloaders/aria2c.py +++ b/devine/core/downloaders/aria2c.py @@ -140,9 +140,18 @@ async def aria2c( log_buffer += f"{line.strip()}\n" if log_buffer: + log_buffer = log_buffer.rstrip() + refused_errors = ( + "the target machine actively refused it", + "SSL/TLS handshake failure" + ) + if segmented and any(x in log_buffer for x in refused_errors): + # likely too many connections + raise ConnectionRefusedError("Aria2 could not connect as the target machine actively refused it.") + # wrap to console width - padding - '[Aria2c]: ' log_buffer = "\n ".join(textwrap.wrap( - log_buffer.rstrip(), + log_buffer, width=console.width - 20, initial_indent="" ))