aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/dl.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-01 12:27:19 -0700
committerCody Logan <cody@lokken.dev>2023-11-01 12:27:19 -0700
commit235b3e6a723e3e18962212c7d2c0f19619c2fa6f (patch)
treed2a7be5662ad11f0a6bb6e2c71432f0eecfc6363 /src/wikiget/dl.py
parent15ffefbd0ca80f240b5468b4ab5cea5e9800ad83 (diff)
downloadwikiget-235b3e6a723e3e18962212c7d2c0f19619c2fa6f.tar.gz
wikiget-235b3e6a723e3e18962212c7d2c0f19619c2fa6f.zip
Make process_download return an exit code instead of exiting directly
Diffstat (limited to 'src/wikiget/dl.py')
-rw-r--r--src/wikiget/dl.py14
1 files changed, 8 insertions, 6 deletions
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: