1
0
Fork 0

Fix exit codes for each argparse function.

This commit is contained in:
voussoir 2021-08-23 22:25:43 -07:00
parent e48dd807e4
commit d11a72e163
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -59,7 +59,7 @@ sql.executescript(DB_INIT)
def ctrlc_commit(function): def ctrlc_commit(function):
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
try: try:
function(*args, **kwargs) return function(*args, **kwargs)
except KeyboardInterrupt: except KeyboardInterrupt:
commit() commit()
return wrapped return wrapped
@ -356,10 +356,12 @@ def get_argparse(args):
items = get_items(ids, threads=args.threads) items = get_items(ids, threads=args.threads)
insert_items(items, commit_period=args.commit_period) insert_items(items, commit_period=args.commit_period)
return 0
@ctrlc_commit @ctrlc_commit
def livestream_argparse(args): def livestream_argparse(args):
insert_items(livestream(), commit_period=args.commit_period) insert_items(livestream(), commit_period=args.commit_period)
return 0
@ctrlc_commit @ctrlc_commit
def update_argparse(args): def update_argparse(args):
@ -373,6 +375,7 @@ def update_argparse(args):
items = get_items(ids, threads=args.threads) items = get_items(ids, threads=args.threads)
insert_items(items, commit_period=args.commit_period) insert_items(items, commit_period=args.commit_period)
return 0
@ctrlc_commit @ctrlc_commit
def update_items_argparse(args): def update_items_argparse(args):
@ -396,6 +399,7 @@ def update_items_argparse(args):
items = get_items(ids, threads=args.threads) items = get_items(ids, threads=args.threads)
insert_items(items, commit_period=args.commit_period) insert_items(items, commit_period=args.commit_period)
return 0
@operatornotify.main_decorator(subject='hnarchive.py') @operatornotify.main_decorator(subject='hnarchive.py')
@vlogging.main_decorator @vlogging.main_decorator