2021-05-17 12:43:16 -07:00
|
|
|
#!/usr/bin/env pyston3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
2021-06-07 07:10:18 -07:00
|
|
|
import os
|
2021-05-17 12:43:16 -07:00
|
|
|
import os.path
|
2021-06-07 07:10:18 -07:00
|
|
|
import sys
|
2021-05-17 12:43:16 -07:00
|
|
|
import traceback
|
|
|
|
|
2021-06-07 07:10:18 -07:00
|
|
|
sys.path.insert(0, os.path.abspath(
|
2021-06-25 02:33:40 -07:00
|
|
|
os.path.join(os.path.dirname(__file__), "..")))
|
2021-06-07 07:10:18 -07:00
|
|
|
import mango # nopep8
|
2021-05-17 12:43:16 -07:00
|
|
|
|
|
|
|
# We explicitly want argument parsing to be outside the main try-except block because some arguments
|
|
|
|
# (like --help) will cause an exit, which our except: block traps.
|
|
|
|
parser = argparse.ArgumentParser(description="Sends SOL to a different address.")
|
2021-06-07 07:10:18 -07:00
|
|
|
parser.add_argument("--notification-target", type=mango.parse_subscription_target, required=True, action="append",
|
2021-05-17 12:43:16 -07:00
|
|
|
help="The notification target - a compound string that varies depending on the target")
|
|
|
|
parser.add_argument("--message", type=str, help="Message to send")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
logging.getLogger().setLevel(args.log_level)
|
2021-06-07 07:10:18 -07:00
|
|
|
logging.warning(mango.WARNING_DISCLAIMER_TEXT)
|
2021-05-17 12:43:16 -07:00
|
|
|
|
|
|
|
try:
|
|
|
|
for notify in args.notification_target:
|
|
|
|
print("Sending to:", notify)
|
|
|
|
notify.send(args.message)
|
|
|
|
|
|
|
|
print("Notifications sent")
|
|
|
|
except Exception as exception:
|
2021-06-20 11:34:59 -07:00
|
|
|
logging.critical(f"send-notification stopped because of exception: {exception} - {traceback.format_exc()}")
|
2021-05-17 12:43:16 -07:00
|
|
|
except:
|
2021-06-20 11:34:59 -07:00
|
|
|
logging.critical(f"send-notification stopped because of uncatchable error: {traceback.format_exc()}")
|