Commit 066e02d6 authored by fendouai's avatar fendouai

add basic exception

parent aa47582e
import jpush as jpush import jpush as jpush
from jpush import core from jpush import core
from conf import app_key, master_secret from conf import app_key, master_secret
from jpush import common
_jpush = jpush.JPush(app_key, master_secret) _jpush = jpush.JPush(app_key, master_secret)
push = _jpush.create_push() push = _jpush.create_push()
push.audience = jpush.all_ push.audience = jpush.all_
push.notification = jpush.notification(alert="Hello,python sdk!") push.notification = jpush.notification(alert="hello python jpush api")
push.platform = jpush.all_ push.platform = jpush.all_
core.logger.debug('logger debug message test') core.logger.debug('logger debug message test')
push.send() push.send()
...@@ -21,8 +21,14 @@ BASE_SCHEDULEURL="https://api.jpush.cn/v3/schedules/" ...@@ -21,8 +21,14 @@ BASE_SCHEDULEURL="https://api.jpush.cn/v3/schedules/"
BASE_LISTURL="https://api.jpush.cn/v3/schedules?page=" BASE_LISTURL="https://api.jpush.cn/v3/schedules?page="
logger = logging.getLogger('jpush') logger = logging.getLogger('jpush')
class Unauthorized(Exception): class Unauthorized(Exception):
"""Raised when we get a 401 from the server""" """Raised when we get a 401 from the server"""
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class JPushFailure(Exception): class JPushFailure(Exception):
...@@ -63,3 +69,53 @@ class JPushFailure(Exception): ...@@ -63,3 +69,53 @@ class JPushFailure(Exception):
return cls(error, error_code, details, response, response.status_code, return cls(error, error_code, details, response, response.status_code,
response.content) response.content)
class APIConnectionException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class APIRequestException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
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