From af87610e608bba595e700a39a2bc67615edeb765 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Fri, 18 Feb 2022 14:15:11 -0800 Subject: [PATCH] wrap payout code in try/except block --- suchwow/app.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/suchwow/app.py b/suchwow/app.py index a234ebb..9e9eb1f 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -117,19 +117,20 @@ def payout_users(): _fa = wownero.from_atomic _aw = wownero.as_wownero for post in Post.select(): - submitter = Profile.get(username=post.submitter) - balances = wallet.balances(post.account_index) - url = url_for('post.read', id=post.id, _external=True) - if balances[1] > 0.1: - print(f"Post #{post.id} has {balances[1]} funds unlocked and ready to send. Sweeping all funds to user's address ({submitter.address}).") - sweep = wallet.sweep_all(account=post.account_index, dest_address=submitter.address) - print(sweep) - if "tx_hash_list" in sweep: - amount = 0 - for amt in sweep["amount_list"]: - amount += int(amt) - # post_webhook(f"Paid out :moneybag: {_aw(_fa(amount))} WOW to `{post.submitter}` for post [{post.id}]({url})") - # god damn you eimernase, why'd you ruin this for me? :P + try: + submitter = Profile.get(username=post.submitter) + balances = wallet.balances(post.account_index) + url = url_for('post.read', id=post.id, _external=True) + if balances[1] > 0.05: + print(f"Post #{post.id} has {balances[1]} funds unlocked and ready to send. Sweeping all funds to user's address ({submitter.address}).") + sweep = wallet.sweep_all(account=post.account_index, dest_address=submitter.address) + print(sweep) + if "tx_hash_list" in sweep: + amount = 0 + for amt in sweep["amount_list"]: + amount += int(amt) + except Exception as e: + print(f"Failed because: {e}") @app.cli.command("add_admin") @click.argument("username")