From 235b3e6a723e3e18962212c7d2c0f19619c2fa6f Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Wed, 1 Nov 2023 12:27:19 -0700 Subject: Make process_download return an exit code instead of exiting directly --- src/wikiget/dl.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/wikiget/dl.py') diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py index 20d8a07..f39c355 100644 --- a/src/wikiget/dl.py +++ b/src/wikiget/dl.py @@ -49,7 +49,7 @@ def prep_download(dl: str, args: Namespace) -> File: return file -def process_download(args: Namespace) -> None: +def process_download(args: Namespace) -> int: if args.batch: # batch download mode errors = batch_download(args) @@ -59,23 +59,25 @@ def process_download(args: Namespace) -> None: logger.warning( f"{errors} problem{'s'[:errors^1]} encountered during batch processing" ) - sys.exit(1) # completed with errors + return 1 # completed with errors + return 0 else: # single download mode try: file = prep_download(args.FILE, args) except ParseError as e: logger.error(e) - sys.exit(1) + return 1 except FileExistsError as e: logger.warning(e) - sys.exit(1) + return 1 except (ConnectionError, HTTPError, InvalidResponse, LoginError, APIError): - sys.exit(1) + return 1 errors = download(file, args) if errors: - sys.exit(1) # completed with errors + return 1 # completed with errors + return 0 def batch_download(args: Namespace) -> int: -- cgit v1.2.3