How to use the jpush.common.JPushFailure function in jpush

To help you get started, we’ve selected a few jpush examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jpush / jpush-api-python-client / tests / report / test_report.py View on Github external
def test_get_schedule_by_invalid_id(self):
        try:
            result = report.get_users("DAY","2016-04-10","3")
            self.assertEqual(result.status_code, 200)
        except common.JPushFailure, e:
            print e
            self.assertIsInstance(e, common.JPushFailure)
github jpush / jpush-api-python-client / tests / report / test_report.py View on Github external
def test_get_schedule_by_invalid_id(self):
        try:
            result = report.get_users("DAY","2016-04-10","3")
            self.assertEqual(result.status_code, 200)
        except common.JPushFailure, e:
            print e
            self.assertIsInstance(e, common.JPushFailure)
github jpush / jpush-api-python-client / tests / push / test_audience.py View on Github external
jpush.alias("alias1", "alias2")
        )
        push.notification = jpush.notification(alert="Hello world with audience!")
        push.platform = jpush.all_
        try:
            response = push.send()
            print response.status_code
            self.assertEqual(response.status_code, 200)
        except common.Unauthorized, e:
            self.assertFalse(isinstance(e, common.Unauthorized))
            raise common.Unauthorized("Unauthorized")
        except common.APIConnectionException, e:
            self.assertFalse(isinstance(e, common.APIConnectionException))
            raise common.APIConnectionException("conn")
        except common.JPushFailure, e:
            self.assertFalse(isinstance(e, common.JPushFailure))
            print "JPushFailure"
        except:
            self.assertFalse(1)
            print "Exception"
github jpush / jpush-api-python-client / tests / devices / test_devices.py View on Github external
def test_get_device(self):
        reg_id = '090c1f59f89'
        try:
            device.get_deviceinfo(reg_id)
        except common.JPushFailure:
            self.assertEqual(1, 1)
        except:
            self.assertEqual(1, 0)
github jpush / jpush-api-python-client / tests / push / test_message.py View on Github external
_jpush = jpush.JPush(app_key, master_secret)
        push = _jpush.create_push()
        push.audience = jpush.all_
        push.notification = jpush.notification(alert="hello python jpush api")
        push.platform = jpush.all_
        try:
            response = push.send()
            print response.status_code
            self.assertEqual(response.status_code, 200)
        except common.Unauthorized, e:
            self.assertFalse(isinstance(e, common.Unauthorized))
            raise common.Unauthorized("Unauthorized")
        except common.APIConnectionException, e:
            self.assertFalse(isinstance(e, common.APIConnectionException))
            raise common.APIConnectionException("conn")
        except common.JPushFailure, e:
            self.assertFalse(isinstance(e, common.JPushFailure))
            print "JPushFailure"
        except:
            self.assertFalse(1)
            print "Exception"
github jpush / jpush-api-python-client / tests / push / test_message.py View on Github external
push = _jpush.create_push()
        push.audience = jpush.all_
        push.notification = jpush.notification(alert="hello python jpush api")
        push.platform = jpush.all_
        try:
            response = push.send()
            print response.status_code
            self.assertEqual(response.status_code, 200)
        except common.Unauthorized, e:
            self.assertFalse(isinstance(e, common.Unauthorized))
            raise common.Unauthorized("Unauthorized")
        except common.APIConnectionException, e:
            self.assertFalse(isinstance(e, common.APIConnectionException))
            raise common.APIConnectionException("conn")
        except common.JPushFailure, e:
            self.assertFalse(isinstance(e, common.JPushFailure))
            print "JPushFailure"
        except:
            self.assertFalse(1)
            print "Exception"
github jpush / jpush-api-python-client / tests / push / test_audience.py View on Github external
jpush.tag("tag1", "tag2"),
            jpush.alias("alias1", "alias2")
        )
        push.notification = jpush.notification(alert="Hello world with audience!")
        push.platform = jpush.all_
        try:
            response = push.send()
            print response.status_code
            self.assertEqual(response.status_code, 200)
        except common.Unauthorized, e:
            self.assertFalse(isinstance(e, common.Unauthorized))
            raise common.Unauthorized("Unauthorized")
        except common.APIConnectionException, e:
            self.assertFalse(isinstance(e, common.APIConnectionException))
            raise common.APIConnectionException("conn")
        except common.JPushFailure, e:
            self.assertFalse(isinstance(e, common.JPushFailure))
            print "JPushFailure"
        except:
            self.assertFalse(1)
            print "Exception"
github jpush / jpush-api-python-client / jpush / __init__.py View on Github external
from .report import (
    Report,
    ReportResponse,
)

from .schedule import (
    Schedule,
    schedulepayload,
)

__all__ = [
    JPush,
    GroupPush,
    Admin,
    JPushFailure,
    Unauthorized,
    all_,
    Push,
    tag,
    tag_and,
    tag_not,
    alias,
    registration_id,
    notification,
    ios,
    android,
    winphone,
    message,
    smsmessage,
    platform,
    audience,
github jpush / jpush-api-python-client / jpush / core.py View on Github external
method, url, '\n\t'.join('%s: %s' % (key, value) for (key, value) in headers.items()), body)
        try:
            response = self.session.request(method, url, data=body, params=params,
                                            headers=headers, timeout=self.timeout)
        except requests.exceptions.ConnectTimeout:
            raise common.APIConnectionException("Connection to api.jpush.cn timed out.")
        except Exception:
            raise common.APIRequestException("Connection to api.jpush.cn error.")

        logger.debug("Received %s response. Headers:\n\t%s\nBody:\n\t%s", response.status_code, '\n\t'.join(
                '%s: %s' % (key, value) for (key, value) in response.headers.items()), response.content)

        if response.status_code == 401:
            raise common.Unauthorized("Please check your AppKey and Master Secret")
        elif not (200 <= response.status_code < 300):
            raise common.JPushFailure.from_response(response)
        return response