Skip to content

Instantly share code, notes, and snippets.

@bitrot-sh
Created February 21, 2018 16:53
Show Gist options
  • Save bitrot-sh/d70ccacb33d95acbe87f6e615401af23 to your computer and use it in GitHub Desktop.
Save bitrot-sh/d70ccacb33d95acbe87f6e615401af23 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from redis import Redis
from rq import Queue
from argparse import ArgumentParser
from send_event import send_event
queue = Queue('pynma_queue', connection=Redis())
def get_key():
with open('/home/ubuntu/.pynma_key', 'r') as fd:
key = fd.read().split('\n', 1)[0]
return key
def main():
parser = ArgumentParser()
parser.add_argument("app", type=str, help="Name of app sending notification")
parser.add_argument("event", type=str, help="Type of event / notification")
parser.add_argument("desc", type=str, help="Description of notification")
parser.add_argument("-u", "--url", help="Send specified url with event")
parser.add_argument("-p", "--priority", help="Priority from -2 (low) to 2 (high)", type=int, default=0)
parser.add_argument("-k", "--key", help="Set API key", default=get_key())
args = parser.parse_args()
queue.enqueue(send_event, dict(args._get_kwargs()))
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment