Commit 65be2ab6 authored by fendouai's avatar fendouai

Merge branch 'master' into dev

parents 3ff1f3fb 0e0198dd
......@@ -5,6 +5,14 @@
对应的 REST API 文档:<http://docs.jpush.io/server/rest_api_v3_push/>
## 兼容版本
+ Python 2.7
+ Python 3 还没有兼容,以后会兼容。
建议 Python3 的开发者继续使用 jpush 3.1.2,pip 地址:
> https://pypi.python.org/pypi?:action=display&name=jpush&version=3.1.2
## 环境配置
pip 方式:
......@@ -44,9 +52,9 @@ except common.Unauthorized:
except common.APIConnectionException:
raise common.APIConnectionException("conn error")
except common.JPushFailure:
print "JPushFailure"
print ("JPushFailure")
except:
print "Exception"
print ("Exception")
```
## 日志说明
logging level 默认的是 WARNING ,为了方便调试建议设置为 DEBUG
......
.. image:: https://travis-ci.org/jpush/jpush-api-python-client.svg?branch=master
:target: https://travis-ci.org/jpush/jpush-api-python-client
.. image:: https://badge.fury.io/gh/jpush%2Fjpush-api-python-client.svg
:target: http://badge.fury.io/gh/jpush%2Fjpush-api-python-client
.. image:: https://badge.fury.io/py/jpush.svg
:target: http://badge.fury.io/py/jpush
.. image:: https://pypip.in/download/jpush/badge.svg
:target: https://pypi.python.org/pypi/jpush/
:alt: Downloads
=======================
JPush API Python Client
=======================
JPush's officially supported Python client library for accessing JPush APIs.
JPush Rest API Documents: `http://docs.jpush.io/server/rest_api_v3_push/ <http://docs.jpush.io/server/rest_api_v3_push/>`_
JPush Rest API Documents: http://docs.jpush.io/server/rest_api_v3_push/
You can download the latest release file here: `Releases <https://github.com/jpush/jpush-api-python-client/releases>`_
You can download the latest release file here: https://github.com/jpush/jpush-api-python-client/releases
------------
Installation
------------
To install jpush-api-python-client, simply:
.. code-block:: sh
$ sudo pip install jpush
or alternatively install via easy_install:
.. code-block:: sh
$ sudo easy_install jpush
or from source:
.. code-block:: sh
$ sudo python setup.py install
-------
......@@ -48,14 +32,12 @@ with Python.
To run jpush-api-python-client tests, simply:
.. code-block:: sh
$ nosetests tests/push tests/devices --verbosity=2
--------
Examples
--------
You can see more examples in `examples <https://github.com/jpush/jpush-api-python-client/blob/master/examples>`_
You can see more examples in https://github.com/jpush/jpush-api-python-client/blob/master/examples
Simple iOS Push
---------------
......@@ -85,8 +67,3 @@ Questions
--------
The best place to ask questions is our community site:
http://community.jpush.cn/
--------
Thanks to
--------
`crystal-wei <https://github.com/crystal-wei>`_ for reporting the jpush-api-python-client issues;
"""Python package for using the JPush API"""
from .conf import app_key, master_secret
__all__ = [
app_key,
master_secret,
]
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
#-*- encoding:utf-8 -*-
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
reg_id = '1507bfd3f7c466c355c'
entity = jpush.device_tag(jpush.add("ddd", "tageee"))
result=device.set_devicemobile(reg_id, entity)
print result.status_code
print result.payload
\ No newline at end of file
print (result.status_code)
print (result.payload)
\ No newline at end of file
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
device = _jpush.create_device()
......
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
from jpush import common
_jpush = jpush.JPush(app_key, master_secret)
......@@ -18,6 +18,6 @@ except common.Unauthorized:
except common.APIConnectionException:
raise common.APIConnectionException("conn")
except common.JPushFailure:
print "JPushFailure"
print ("JPushFailure")
except:
print "Exception"
\ No newline at end of file
print ("Exception")
\ No newline at end of file
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
......@@ -9,5 +9,5 @@ push.audience = jpush.audience(
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print push.payload
print (push.payload)
push.send()
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
......@@ -7,5 +7,5 @@ push.audience = jpush.all_
push.notification = jpush.notification(alert="a sms message from python jpush api")
push.platform = jpush.all_
push.smsmessage=jpush.smsmessage("a sms message from python jpush api",0)
print push.payload
print (push.payload)
push.send()
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
......
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
report=_jpush.create_report();
......
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
......
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
......@@ -14,4 +14,4 @@ push=push.payload
trigger=jpush.schedulepayload.trigger("2016-07-17 12:00:00")
schedulepayload=jpush.schedulepayload.schedulepayload("name",True,trigger,push)
result=schedule.post_schedule(schedulepayload)
print result.status_code
print (result.status_code)
import jpush as jpush
from examples.conf import app_key, master_secret
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
schedule = _jpush.create_schedule()
......
......@@ -72,7 +72,7 @@ class JPush(object):
if (level == "NOTSET"):
logging.basicConfig(level=logging.NOTSET)
else:
print "set logging level failed ,the level is invalid."
print ("set logging level failed ,the level is invalid.")
def create_push(self):
"""Create a Push notification."""
......
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
......@@ -28,17 +28,17 @@ class TestAudience(unittest.TestCase):
push.platform = jpush.all_
try:
response = push.send()
print response.status_code
self.assertEqual(response.status_code, 200)
except common.Unauthorized, e:
except common.Unauthorized as e:
self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e:
except common.APIConnectionException as e:
self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn")
except common.JPushFailure, e:
except common.JPushFailure as e:
self.assertFalse(isinstance(e, common.JPushFailure))
print "JPushFailure"
print ("JPushFailure")
except:
self.assertFalse(1)
print "Exception"
print ("Exception")
......@@ -42,17 +42,16 @@ class TestMessage(unittest.TestCase):
push.platform = jpush.all_
try:
response = push.send()
print response.status_code
self.assertEqual(response.status_code, 200)
except common.Unauthorized, e:
except common.Unauthorized as e:
self.assertFalse(isinstance(e, common.Unauthorized))
raise common.Unauthorized("Unauthorized")
except common.APIConnectionException, e:
except common.APIConnectionException as e:
self.assertFalse(isinstance(e, common.APIConnectionException))
raise common.APIConnectionException("conn")
except common.JPushFailure, e:
except common.JPushFailure as e:
self.assertFalse(isinstance(e, common.JPushFailure))
print "JPushFailure"
print ("JPushFailure")
except:
self.assertFalse(1)
print "Exception"
print ("Exception")
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
......@@ -23,7 +23,6 @@ class TestEntity(unittest.TestCase):
try:
result = report.get_users("DAY","2016-04-10","3")
self.assertEqual(result.status_code, 200)
except common.JPushFailure, e:
print e
except common.JPushFailure as e:
self.assertIsInstance(e, common.JPushFailure)
# please put your app_key and master_secret here
app_key = u'6be9204c30b9473e87bad4dc'
master_secret = u'9349ad7c90292a603c512e92'
......@@ -37,8 +37,7 @@ class TestEntity(unittest.TestCase):
try:
result = schedule.get_schedule_by_id("3fc6e2fa-15a6-11e6-83d4-0021f653c222")
self.assertNotEqual(result.status_code, 200)
except common.JPushFailure, e:
print e
except common.JPushFailure as e:
self.assertIsInstance(e, common.JPushFailure)
def test_get_schedule_list(self):
......@@ -70,7 +69,6 @@ class TestEntity(unittest.TestCase):
try:
result = schedule.delete_schedule("e9c553d0-0850-11e6-b6d4-0021f652c102")
self.assertNotEqual(result.status_code, 200)
except common.JPushFailure, e:
print e
except common.JPushFailure as e:
self.assertIsInstance(e, common.JPushFailure)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment