Selaa lähdekoodia

正式V2 添加info

lhq 4 vuotta sitten
vanhempi
commit
c4c3a119f4
1 muutettua tiedostoa jossa 23 lisäystä ja 3 poistoa
  1. 23 3
      Controller/DetectControllerV2.py

+ 23 - 3
Controller/DetectControllerV2.py

@@ -54,8 +54,9 @@ class NotificationView(View):
 
     def validation(self, request_dict):
         logger = logging.getLogger('info')
-        logger.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')
@@ -81,7 +82,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)
@@ -159,7 +161,8 @@ class NotificationView(View):
             print("没有redi_list")
             res_data = {'code': 0, 'msg': 'no redi_list success!'}
             return JsonResponse(status=200, data=res_data)
-
+        logger.info("(当前设备从数据库中获取的所有信息)redis_list:")
+        logger.info(redis_list)
         # is_sys_msg = self.is_sys_msg(int(event_type))
         nickname = redis_list[0]['uid_set__nickname']
         detect_interval = redis_list[0]['uid_set__detect_interval']
@@ -249,13 +252,19 @@ 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:
                 if push_type == 0:  # ios apns
                     print('do_apns')
+                    logger.info('do_apns')
                     # self.do_apns(**kwag_args)
                     do_apns_code = self.do_apns(**kwag_args)
+                    logger.info("出来do_apns了")
+                    logger.info(do_apns_code)
                     if isinstance(do_apns_code, int):
                         push_server_status = do_apns_code
                     else:
@@ -324,6 +333,7 @@ class NotificationView(View):
                 del up['uid_set__nickname']
                 del up['uid_set__detect_interval']
                 del up['uid_set__detect_group']
+            logger.info(redis_list)
             logger.info("出来了")
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success 0 or 2' ,'re_list':redis_list})
 
@@ -556,6 +566,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']))
@@ -569,6 +584,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, 请求有问题。
@@ -580,11 +597,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):