55except ImportError :
66 from distutils .core import setup
77
8- setup (
9- name = "pyapns" ,
10- version = "0.3.2" ,
11- description = "A universal Apple Push Notification Service (APNS) provider." ,
12- long_description = """
8+ DOC = \
9+ """
1310Features:
1411
1512 * XML-RPC Based, works with any client in any language
3936 >>> provision('myapp', open('cert.pem').read(), 'sandbox')
4037 >>> notify('myapp', 'hexlified_token_str', {'aps':{'alert': 'Hello!'}})
4138
42- The Multi-Application Model
43- ---------------------------
44- pyapns supports multiple applications. Before pyapns can send notifications,
45- you must first provision the application with an Application ID, the environment
46- (either 'sandbox' or 'production') and the certificate file. The `provision`
47- method takes 4 arguments, `app_id`, `path_to_cert_or_cert`, `environment`
48- and `timeout`. A connection is kept alive for each application provisioned
49- for the fastest service possible. The application ID is an arbitrary
50- identifier and is not used in communication with the APNS servers.
51-
52- When a connection can not be made within the specified `timeout` a timeout
53- error will be thrown by the server. This usually indicates that the wrong
54- [type of] certification file is being used, a blocked port or the wrong environment.
55-
56- Sending Notifications
57- ---------------------
58- Calling `notify` will send the message immediately if a connection is already
59- established. The first notification may be delayed a second while the server
60- connects. ``notify`` takes ``app_id``, ``token_or_token_list`` and
61- `notification_or_notification_list`. Multiple notifications can be batched
62- for better performance by using paired arrays of token/notifications. When
63- performing batched notifications, the token and notification arrays must be
64- exactly the same length.
65-
66- The full notification dictionary must be included as the notification::
67-
68- {'aps': {
69- 'sound': 'flynn.caf',
70- 'badge': 0,
71- 'message': 'Hello from pyapns :)'
72- }
73- } # etc...
74-
75- Retrieving Inactive Tokens
76- --------------------------
77- Call `feedback` with the `app_id`. A list of tuples will be retrieved from the
78- APNS server that it deems inactive. These are returned as a list of 2-element
79- lists with a `Datetime` object and the token string.
80-
81- XML-RPC Methods
82- ---------------
83-
84- ``provision``
85- -------------
86-
87- ::
88-
89- Arguments
90- app_id String the application id for the provided
91- certification
92- cert String a path to a .pem file or the a
93- string with the entie file
94- environment String the APNS server to use - either
95- 'production' or 'sandbox'
96- timeout Integer timeout for connection attempts to
97- the APS servers
98- Returns
99- None
100-
101- ``notify``
102- ----------
103-
104- ::
105-
106- Arguments
107- app_id String the application id to send the
108- message to
109- tokens String or Array an Array of tokens or a single
110- token string
111- notifications String or Array an Array of notification
112- dictionaries or a single
113- notification dictionary
114-
115- Returns
116- None
117-
118- ``feedback``
119- ------------
120-
121- ::
122-
123- Arguments
124- app_id String the application id to retrieve
125- retrieve feedback for
126-
127- Returns
128- Array(Array(Datetime(time_expired), String(token)), ...)
129-
130-
131- The Python API
132- --------------
133- pyapns also provides a Python API that makes the use of pyapns even simpler.
134- The Python API must be configured before use but configuration files make it easier.
135- The pyapns `client` module currently supports configuration from Django settings and
136- Pylons config. To configure using Django, the following must be present in
137- your settings file::
138-
139- PYAPNS_CONFIG = {
140- 'HOST': 'http://localhost:8077/',
141- 'TIMEOUT': 15, # OPTIONAL, host timeout in seconds
142- 'INITIAL': [ # OPTIONAL, see below
143- ('craigsfish', '/home/samsutch/craigsfish/apscert.pem', 'sandbox'),
144- ]
145- }
146-
147- Optionally, with Django settings, you can skip manual provisioning by including a
148- list of `(name, path, environment)` tuples that are guaranteed to be provisioned
149- by the time you call `notify` or `feedback`.
150-
151- Configuring for pylons is just as simple, but automatic provisioning isn't
152- possible, in your configuration file include::
39+ A lot more documentation and the issue tracker can be found on the `github page
40+ <http://github.com/samuraisam/pyapns>`.
41+ """
15342
154- pyapns_host = http://localhost:8077/
155- pyapns_timeout = 15
156-
157- For explanations of the configuration variables see the docs for
158- `pyapns.client.configure`.
159-
160- Each of these functions can be called synchronously and asynchronously. To make
161- them perform asynchronously simply supply a callback. The request will then be
162- made in another thread and callback with the results. When calling asynchronously
163- no value will be returned::
164-
165- def got_feedback(tuples):
166- trim_inactive_tokens(tuples)
167- feedback('myapp', callback=got_feedback)
168-
169- ``pyapns.client.configure(opts)``
170- ---------------------------------
171-
172- ::
173-
174- Takes a dictionary of options and configures the client.
175- Currently configurable options are 'HOST', 'TIMEOUT' and 'INITIAL' the latter
176- of which is only read once.
177-
178- Config Options:
179- HOST - A full host name with port, ending with a forward slash
180- TIMEOUT - An integer specifying how many seconds to timeout a
181- connection to the pyapns server (prevents deadlocking
182- the parent thread).
183- INITIAL - A List of tuples to be supplied to provision when
184- the first configuration happens.
185-
186- ``pyapns.client.provision(app_id, path_to_cert_or_cert, environment, timeout=15, callback=None)``
187- -------------------------------------------------------------------------------------------------
188-
189- ::
190-
191- Provisions the app_id and initializes a connection to the APNS server.
192- Multiple calls to this function will be ignored by the pyapns daemon
193- but are still sent so pick a good place to provision your apps, optimally
194- once.
195-
196- Arguments:
197- app_id the app_id to provision for APNS
198- path_to_cert_or_cert absolute path to the APNS SSL cert or a
199- string containing the .pem file
200- environment either 'sandbox' or 'production'
201- timeout number of seconds to timeout connection
202- attempts to the APPLE APS SERVER
203- callback a callback to be executed when done
204- Returns:
205- None
206-
207- ``pyapns.client.notify(app_id, tokens, notifications, callback=None)``
208- ----------------------------------------------------------------------
209-
210- ::
211-
212- Sends push notifications to the APNS server. Multiple
213- notifications can be sent by sending pairing the token/notification
214- arguments in lists [token1, token2], [notification1, notification2].
215-
216- Arguments:
217- app_id provisioned app_id to send to
218- tokens token to send the notification or a
219- list of tokens
220- notifications notification dicts or a list of notifications
221- callback a callback to be executed when done
222- Returns:
223- None
224-
225- ``pyapns.client.feedback(app_id, callback=None)``
226- -------------------------------------------------
227-
228- ::
229-
230- Retrieves a list of inactive tokens from the APNS server and the times
231- it thinks they went inactive.
232-
233- Arguments:
234- app_id the app_id to query
235- Returns:
236- Feedback tuples like [(datetime_expired, token_str), ...]
237-
238- .. _Twisted: http://pypi.python.org/pypi/Twisted
239- .. _pyOpenSSL: http://pypi.python.org/pypi/pyOpenSSL
240- .. _python-epoll: http://pypi.python.org/pypi/python-epoll/
241- .. _py-kqueue: http://pypi.python.org/pypi/py-kqueue/2.0.1
242-
243- """ ,
43+ setup (
44+ name = "pyapns" ,
45+ version = "0.4.0" ,
46+ description = "A universal Apple Push Notification Service (APNS) provider." ,
47+ long_description = DOC
24448 author = "Samuel Sutch" ,
24549 author_email = "samuraiblog@gmail.com" ,
24650 license = "MIT" ,
@@ -257,4 +61,4 @@ def got_feedback(tuples):
25761 packages = ['pyapns' ],
25862 package_data = {},
25963 install_requires = ['Twisted>=8.2.0' , 'pyOpenSSL>=0.10' ]
260- )
64+ )
0 commit comments