|
@@ -11,6 +11,7 @@
|
|
|
@file: DetectController.py
|
|
|
@Contact: chanjunkai@163.com
|
|
|
"""
|
|
|
+import logging
|
|
|
import os
|
|
|
import time
|
|
|
|
|
@@ -48,7 +49,10 @@ class NotificationView(View):
|
|
|
return self.validation(request.POST)
|
|
|
|
|
|
def validation(self, request_dict):
|
|
|
-
|
|
|
+ logger = logging.getLogger('info')
|
|
|
+ logger.info("进来推送接口了")
|
|
|
+ logger.info(request_dict)
|
|
|
+ logger.info(SERVER_TYPE)
|
|
|
uidToken = request_dict.get('uidToken', None)
|
|
|
etk = request_dict.get('etk', None)
|
|
|
channel = request_dict.get('channel', '1')
|
|
@@ -69,7 +73,8 @@ class NotificationView(View):
|
|
|
else:
|
|
|
utko = UidTokenObject(uidToken)
|
|
|
uid = utko.UID
|
|
|
-
|
|
|
+ logger.info("当前调用推送接口的uid:")
|
|
|
+ logger.info(uid)
|
|
|
pkey = '{uid}_{channel}_{event_type}_ptl'.format(uid=uid, event_type=event_type, channel=channel)
|
|
|
# ykey = 'MUJ887NLR8K8GBM9111A_redis_qs'.format(uid=uid)
|
|
|
ykey = '{uid}_redis_qs'.format(uid=uid)
|
|
@@ -205,6 +210,9 @@ class NotificationView(View):
|
|
|
kwag_args['token_val'] = token_val
|
|
|
kwag_args['msg_title'] = msg_title
|
|
|
kwag_args['msg_text'] = msg_text
|
|
|
+ logger.info('推送要的数据:')
|
|
|
+ logger.info(kwag_args)
|
|
|
+ logger.info(detect_med_type)
|
|
|
push_server_status = 0
|
|
|
#推送
|
|
|
if detect_med_type == 2 or detect_med_type == 0:
|
|
@@ -455,6 +463,11 @@ class NotificationView(View):
|
|
|
|
|
|
def do_apns(self, uid, channel, appBundleId, token_val, event_type, n_time, msg_title,
|
|
|
msg_text):
|
|
|
+ logger = logging.getLogger('info')
|
|
|
+ logger.info("进来do_apns函数了")
|
|
|
+ logger.info(token_val)
|
|
|
+ logger.info(APNS_MODE)
|
|
|
+ logger.info(os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
|
|
|
try:
|
|
|
cli = apns2.APNSClient(mode=APNS_MODE,
|
|
|
client_cert=os.path.join(BASE_DIR, APNS_CONFIG[appBundleId]['pem_path']))
|
|
@@ -468,6 +481,8 @@ class NotificationView(View):
|
|
|
n = apns2.Notification(payload=payload, priority=apns2.PRIORITY_LOW)
|
|
|
res = cli.push(n=n, device_token=token_val, topic=appBundleId)
|
|
|
print(res.status_code)
|
|
|
+ logger.info("推送状态:")
|
|
|
+ logger.info(res.status_code)
|
|
|
|
|
|
# 200, 推送成功。
|
|
|
# 400, 请求有问题。
|
|
@@ -479,11 +494,14 @@ class NotificationView(View):
|
|
|
else:
|
|
|
print('apns push fail')
|
|
|
print(res.reason)
|
|
|
+ logger.info('apns push fail')
|
|
|
+ logger.info(res.reason)
|
|
|
return res.status_code
|
|
|
except (ValueError, ArithmeticError):
|
|
|
return 'The program has a numeric format exception, one of the arithmetic exceptions'
|
|
|
except Exception as e:
|
|
|
print(repr(e))
|
|
|
+ logger.info(repr(e))
|
|
|
return repr(e)
|
|
|
|
|
|
def do_update_detect_interval(self, uid, channel, redisObject, detect_interval):
|