Jeffrey Goettsch avatar Jeffrey Goettsch committed a60d342 Merge

version 0.3.1

Comments (0)

Files changed (12)

-The primary author of py-pushnotify is Jeffrey Goettsch <jgoettsch@gmail.com>
+Authors
+-------
+
+The primary author of pushnotify is Jeffrey Goettsch <jgoettsch@gmail.com>
 who may be found online at https://bitbucket.org/jgoettsch/.
+Changelog
+---------
+
+version 0.3.1
+
+* Prowl.Client.retrieve_token and Prowl.Client.retrieve_apikey now raise a pushnotify.exceptions.ProviderKeyError if the specified Provider Key is invalid
+
 version 0.3
 
 * added support for Prowl: http://www.prowlapp.com/
-If you have already downloaded py-pushnotify, simply run the following
-command inside this directory:
+Installation
+------------
 
-    python setup.py install
+If you have already downloaded pushnotify, run the following
+command inside this directory::
 
-If you have not yet downloaded py-pushnotify, it would be easier to do
-the following:
+    $ python setup.py install
 
-    pip -e install py-pushnotify
+If you have not yet downloaded pushnotify, it would be easier to do
+the following::
+
+    $ pip install pushnotify
+
+Either method will install pushnotify into your current environment.
+clean:
+	rm -rf dist build Manifest
+
+test:
+	nosetests --with-coverage --cover-package=pushnotify pushnotify/tests/tests.py
+
+check:
+	python setup.py check
+
+build: test check
+	python setup.py sdist bdist_wininst
+
+upload: build
+	python setup.py register sdist bdist_wininst upload
-py-pushnotify
--------------
+==========
+pushnotify
+==========
 
-py-pushnotify is a package for sending push notifications. It currently
+pushnotify is a package for sending push notifications. It currently
 supports Android devices running Notify My Android and Pushover, and iOS
 devices running Pushover and Prowl.
 
 See
 
-    https://www.notifymyandroid.com/
-    https://pushover.net/ and
-    http://www.prowlapp.com/
+* https://www.notifymyandroid.com/
+* https://pushover.net/ and
+* http://www.prowlapp.com/
 
 for more details about these applications.
 
-All development for py-pushnotify takes place on bitbucket:
+Development
+-----------
 
-    https://bitbucket.org/jgoettsch/py-pushnotify/
+All development for pushnotify takes place on bitbucket:
 
-If you discover a bug, please go to the above page and create an issue
-ticket. If you have any questions, please contact the author.
-See AUTHORS.txt.
+* https://bitbucket.org/jgoettsch/py-pushnotify/
+
+To get started you can do the following::
+
+    $ hg clone https://bitbucket.org/jgoettsch/py-pushnotify/
+    $ cd py-pushnotify
+    $ pip install -r requirements_dev.txt
+
+If you discover a bug, please create an issue ticket:
+
+* https://bitbucket.org/jgoettsch/py-pushnotify/issues/new
+
+To run the test suite, you will have to create three modules:
+
+* pushnotify/tests/nmakeys.py:
+
+    This file must contain two global variables: API_KEYS and
+    DEVELOPER_KEY. API_KEYS is a list containing at least one valid API
+    key as a string. DEVELOPER_KEY is a string containing a valid
+    developer key.
+    
+* pushnotify/tests/prowlkeys.py:
+
+    This file must contain two global variables: API_KEYS and
+    PROVIDER_KEY. API_KEYS is a list containing at least one valid API
+    key as a string. PROVIDER_KEY is a string containing a valid
+    provider key. REG_TOKEN is a valid registration token that has
+    already been validated through the retrieve_token/retrieve_apikey
+    process.
+
+* pushnotify/tests/pushoverkeys.py:
+
+    This file must contain three global variables: TOKEN, USER, and
+    DEVICE. TOKEN is a string containing a valid API token. USER is a
+    string containing a valid user identifier. DEVICE is a string
+    containing a valid device identifier for the given user.
+Tasks/TODO
+----------
+
 For all tasks and issues, see the issues list on bitbucket:
 
-    https://bitbucket.org/jgoettsch/py-pushnotify/issues
+* https://bitbucket.org/jgoettsch/py-pushnotify/issues

pushnotify/exceptions.py

     pass
 
 
+class ProviderKeyError(PushNotifyError):
+    """Raised when a provided Provider key is invalid.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+    pass
+
+
 class RateLimitExceeded(PushNotifyError):
     """Raised when too many requests are submitted in too small a time
     frame.

pushnotify/prowl.py

             raise exceptions.FormatError(self._last_message,
                                          int(self._last_code))
         elif self._last_code == '401':
-            raise exceptions.ApiKeyError(self._last_message,
-                                         int(self._last_code))
+            if 'provider' not in self._last_message.lower():
+                raise exceptions.ApiKeyError(self._last_message,
+                                             int(self._last_code))
+            else:
+                raise exceptions.ProviderKeyError(self._last_message,
+                                                  int(self._last_code))
         elif self._last_code == '406':
             raise exceptions.RateLimitExceeded(self._last_message,
                                                int(self._last_code))
             token: A string containing a registration token returned
                 from the retrieve_token method.
 
+        Raises:
+            pushnotify.exceptions.ProviderKeyError
+
         Returns:
             A string containing the API key.
 
         associated a 'Retrieve success URL' with your provider key, they
         will be redirected there.
 
+        Raises:
+            pushnotify.exceptions.ProviderKeyError
+
         Returns:
             A two-item tuple where the first item is a string containing
             a registration token, and the second item is a string

pushnotify/pushover.py

     def notify(self, title, message, kwargs=None):
         """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)

pushnotify/tests/tests.py

         # invalid providerkey
 
         self.client.providerkey = self.client.providerkey[0:-1]
-        self.assertRaises(exceptions.ApiKeyError,
+        self.assertRaises(exceptions.ProviderKeyError,
                           self.client.retrieve_apikey, PROWL_REG_TOKEN)
 
     def test_retrieve_token_valid(self):
         """
 
         self.client.providerkey = self.client.providerkey[0:-1]
-        self.assertRaises(exceptions.ApiKeyError,
+        self.assertRaises(exceptions.ProviderKeyError,
                           self.client.retrieve_token)
 
     def test_verify_user_valid(self):
 
         """
 
+        # 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
+
         msg = 'a' * 513
 
-        self.assertRaises(exceptions.FormatError, self.client.notify,
-                          self.title, msg)
+        try:
+            self.client.notify(self.title, msg)
+        except exceptions.FormatError:
+            pass
 
     def test_verify_user_valid(self):
         """Test veriy_user with a valid user token.

runtests.sh

-#!/usr/bin/env sh
-
-set -x
-nosetests --with-coverage --cover-package=pushnotify pushnotify/tests/tests.py
 from distutils.core import setup
 
 
-version = '0.3'
+version = '0.3.1'
 
+with open('README.txt') as fh:
+    long_description = fh.read()
+
+with open('INSTALL.txt') as fh:
+    long_description = '\n\n'.join([long_description, fh.read()])
+
+with open('CHANGELOG.txt') as fh:
+    long_description = '\n\n'.join([long_description, fh.read()])
 
 setup(
     name='pushnotify',
     description=(
         'py-pushnotify is a package for sending push notifications to '
         'Android and iOS devices.'),
-    long_description=(
-        'py-pushnotify is a package for sending push notifications. It '
-        'currently supports Android devices running Notify My Android '
-        'and Pushover, and iOS devices running Pushover and Prowl.'),
+    long_description=long_description,
     download_url=('https://bitbucket.org/jgoettsch/py-pushnotify/get/'
                   '{0}.tar.gz').format(version),
     classifiers=[
         'License :: OSI Approved :: BSD License',
         'Operating System :: OS Independent',
         'Programming Language :: Python',
+        'Programming Language :: Python :: 2',
         'Topic :: Software Development',
         'Topic :: Software Development :: Libraries',
         'Topic :: Software Development :: Libraries :: Python Modules',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.