Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jpush.options(options)
if user_ids is None:
push.audience = jpush.all_
return str(push.send())
elif len(user_ids) > 1000:
ans = []
for i in range(len(user_ids) // 1000 + 1):
ret = send_push(msg, user_ids[i * 1000: (i + 1) * 1000])
ans.append(ret)
return ans
elif len(user_ids) == 0:
return ''
else:
push.audience = jpush.audience(
jpush.alias(*user_ids)
)
return str(push.send())
def test_audience(self):
_jpush = jpush.JPush(app_key, master_secret)
push = _jpush.create_push()
push.audience = jpush.audience(
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"
def audience():
push = _jpush.create_push()
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
jpush.alias("alias1", "alias2")
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()
import jpush as jpush
from conf import app_key, master_secret
_jpush = jpush.JPush(app_key, master_secret)
_jpush.set_logging("DEBUG")
push = _jpush.create_push()
push.audience = jpush.audience(
jpush.tag("tag1", "tag2"),
jpush.alias("alias1", "alias2")
)
push.notification = jpush.notification(alert="Hello world with audience!")
push.platform = jpush.all_
print (push.payload)
push.send()