From d11a72e163f0d8133e8d73ad23d9a0cf06543129 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 23 Aug 2021 22:25:43 -0700 Subject: [PATCH] Fix exit codes for each argparse function. --- hnarchive.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hnarchive.py b/hnarchive.py index 764520b..c4dab98 100644 --- a/hnarchive.py +++ b/hnarchive.py @@ -59,7 +59,7 @@ sql.executescript(DB_INIT) def ctrlc_commit(function): def wrapped(*args, **kwargs): try: - function(*args, **kwargs) + return function(*args, **kwargs) except KeyboardInterrupt: commit() return wrapped @@ -356,10 +356,12 @@ def get_argparse(args): items = get_items(ids, threads=args.threads) insert_items(items, commit_period=args.commit_period) + return 0 @ctrlc_commit def livestream_argparse(args): insert_items(livestream(), commit_period=args.commit_period) + return 0 @ctrlc_commit def update_argparse(args): @@ -373,6 +375,7 @@ def update_argparse(args): items = get_items(ids, threads=args.threads) insert_items(items, commit_period=args.commit_period) + return 0 @ctrlc_commit def update_items_argparse(args): @@ -396,6 +399,7 @@ def update_items_argparse(args): items = get_items(ids, threads=args.threads) insert_items(items, commit_period=args.commit_period) + return 0 @operatornotify.main_decorator(subject='hnarchive.py') @vlogging.main_decorator