Package pushnotify :: Module pushover :: Class Client
[hide private]
[frames] | no frames]

Class Client

source code

object --+
         |
        Client

Client for sending push notifications to Android and iOS devices
with the Pushover application installed.

Member Vars:
    token: A string containing a valid API token.

Instance Methods [hide private]
 
__init__(self, token, users=None)
Initialize the Pushover client.
source code
 
_parse_response(self, stream, verify=False) source code
 
_post(self, url, data) source code
 
_raise_exception(self) source code
 
notify(self, title, message, kwargs=None)
Send a notification to each user/device in self.users.
source code
 
verify_user(self, user)
Verify a user token.
source code
 
verify_device(self, user, device)
Verify a device for a user.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, token, users=None)
(Constructor)

source code 
Initialize the Pushover client.

Args:
    token: A string of 30 characters containing a valid API
        token.
    users: A list containing 1 or 2-item tuples, where the first
        item is a string of 30 characters containing a user
        token, and the second is an optional string of up to 25
        characters containing a device name for the given user.
        (default: None)

Overrides: object.__init__

notify(self, title, message, kwargs=None)

source code 
Send a notification to each user/device in self.users.

As of 2012-09-18, this is not returning a 4xx status code as
per the Pushover API docs, but instead chopping the delivered
messages off at 512 characters.

Args:
    title: A string of up to 100 characters containing the
        title of the message (i.e. subject or brief description)
    message: A string of up to 512 characters containing the
        notification text.
    kwargs: A dictionary with any of the following strings as
            keys:
        priority: The integer 1, which will make the
            notification display in red and override any set
            quiet hours.
        url: A string of up to 500 characters containing a URL
            to attach to the notification.
        url_title: A string of up to 50 characters containing a
            title to give the attached URL.
        (default: None)

Raises:
    pushnotify.exceptions.ApiKeyError
    pushnotify.exceptions.FormatError
    pushnotify.exceptions.RateLimitExceeded
    pushnotify.exceptions.ServerError
    pushnotify.exceptions.UnrecognizedResponseError

verify_user(self, user)

source code 
Verify a user token.

Args:
    user: A string containing a valid user token.

Returns:
    A boolean containing True if the user token is valid, and
    False if it is not.

verify_device(self, user, device)

source code 
Verify a device for a user.

Args:
    user: A string containing a valid user token.
    device: A string containing a device name.

Raises:
    pushnotify.exceptions.ApiKeyError

Returns:
    A boolean containing True if the device is valid, and
    False if it is not.