python-pushover
aims at providing comprehensive Python bindings for the API
of the Pushover Notification Service as documented here.
You can install python-pushover(old version) from Pypi with:
$ pip install python-pushover
Or you can install it(newer version) directly from GitHub:
not good: git clone https://github.com/Thibauth/python-pushover.git or
tested: git clone https://github.com/selay01/python-pushover.git
cd python-pushover
pip install .
You can pass the token
argument to Client
to initialize the module,
and then the user
argument when it need:
from pushover import Client
client = Client("<api-token>")
client.message("Hello!", "<user-key>", title="Hello")
You can also pass the token
argument and the user
optional argument
to Client
to initialize the module at the same time:
from pushover import Client
client = Client("<api-token>", "<user-key>")
client.message("Hello!", title="Hello")
Attachments can be sent with the attachment
parameter which takes as
argument as file object:
with open('/path/to/my/image.png', 'rb') as image:
client.message('Message with image', attachment=image)
python-pushover
also comes with a command line utility pushover
that
you can use as follows:
pushover --token <api-token> --user <user-key> "Hello,there"
Use pushover --help
to see the list of available options.
Both the pushover
module and the pushover
command line utility support
reading arguments from a configuration file.
The most basic configuration file looks like this:
[Default]
api_token=aaaaaa
user_key=xxxxxx
You can have additional sections and specify a device as well:
[Sam-iPhone]
api_token=bbbbbb
user_key=yyyyyy
device=iPhone
python-pushover
will attempt to read the configuration from
~/.pushoverrc
by default. The section to read can be specified by using the
profile
argument. With the configuration file above, you can send a message
by simply doing:
from pushover import Client
Client().message("Hello!", title="Hello")
or pushover --title "Hello" "Hello!"
from the command line.
You can access the full API documentation here.