-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootlace.py
31 lines (23 loc) · 913 Bytes
/
bootlace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Bootlace - A simple Python app to send notifications via Pushover
Usage:
bootlace -m MESSAGE -t TOKEN -u USER [options]
bootlace --help
Options:
-h, --help Show this help message and exit
-m MESSAGE, --message=MESSAGE The message to be conveyed
-d DEVICE, --device=DEVICE Override device name
-T TITLE, --title=TITLE Override message title [default: Bootlace]
-t TOKEN, --token=TOKEN Pushover application token
-u USER, --user=USER Pushover user token
"""
import docopt
import requests
import socket
url = 'https://api.pushover.net/1/messages.json'
keys = ['token', 'user', 'device', 'message', 'title']
args = docopt.docopt(__doc__)
if not args['--device']:
args['--device'] = socket.gethostname()
constructed_message = {key: args['--'+key] for key in keys}
result = requests.post(url, constructed_message)
print(result)