Browse Source

修改format字符串

locky 1 năm trước cách đây
mục cha
commit
b791c3174a
2 tập tin đã thay đổi với 9 bổ sung11 xóa
  1. 6 7
      Controller/DetectController.py
  2. 3 4
      Controller/DetectControllerV2.py

+ 6 - 7
Controller/DetectController.py

@@ -53,13 +53,13 @@ class NotificationView(View):
             V1_PUSH_LOGGER.info('旧移动侦测接口uid:{},时间戳:{},事件类型:{}'.format(uid, n_time, event_type))
 
             event_type = int(event_type)
-            pkey = '{uid}_{channel}_{event_type}_ptl'.format(uid=uid, event_type=event_type, channel=channel)
-            ykey = '{uid}_redis_qs'.format(uid=uid)
+            pkey = '{}_{}_{}_ptl'.format(uid, event_type, channel)
+            ykey = '{}_redis_qs'.format(uid)
             is_sys_msg = DevicePushService.judge_sys_msg(event_type)
             if is_sys_msg:
-                dkey = '{uid}_{channel}_{event_type}_flag'.format(uid=uid, event_type=event_type, channel=channel)
+                dkey = '{}_{}_{}_flag'.format(uid, event_type, channel)
             else:
-                dkey = '{uid}_{channel}_flag'.format(uid=uid, channel=channel)
+                dkey = '{}_{}_flag'.format(uid, channel)
 
             have_ykey = redisObj.get_data(key=ykey)  # uid_set 数据库缓存
             have_pkey = redisObj.get_data(key=pkey)  # 一分钟限制key
@@ -140,15 +140,14 @@ class NotificationView(View):
                 return JsonResponse(status=200, data=res_data)
 
             elif is_st == '1':
-                obj = '{uid}/{channel}/{filename}.jpeg'.format(uid=uid, channel=channel, filename=n_time)
+                obj = '{}/{}/{}.jpeg'.format(uid, channel, n_time)
                 url = bucket.sign_url('PUT', obj, 3600)
                 res_data = {'code': 0, 'img_push': url, 'msg': 'success 1'}
 
             elif is_st == '3':
                 img_url_list = []
                 for i in range(int(is_st)):
-                    obj = '{uid}/{channel}/{filename}_{st}.jpeg'. \
-                        format(uid=uid, channel=channel, filename=n_time, st=i)
+                    obj = '{}/{}/{}_{}.jpeg'.format(uid, channel, n_time, i)
                     url = bucket.sign_url('PUT', obj, 3600)
                     img_url_list.append(url)
 

+ 3 - 4
Controller/DetectControllerV2.py

@@ -69,12 +69,11 @@ class NotificationV2View(View):
             # 判断是否为系统消息
             is_sys_msg = DevicePushService.judge_sys_msg(event_type)
             if is_sys_msg:
-                push_interval = '{uid}_{channel}_{event_type}_flag'.format(uid=uid, channel=channel,
-                                                                           event_type=event_type)
+                push_interval = '{}_{}_{}_flag'.format(uid, channel, event_type)
             else:
-                push_interval = '{uid}_{channel}_flag'.format(uid=uid, channel=channel)
+                push_interval = '{}_{}_flag'.format(uid, channel)
 
-            req_limiting = '{uid}_{channel}_{event_type}_ptl'.format(uid=uid, channel=channel, event_type=event_type)
+            req_limiting = '{}_{}_{}_ptl'.format(uid, channel, event_type)
             cache_req_limiting = redis_obj.get_data(key=req_limiting)  # 获取请求限流缓存数据
             cache_app_push = redis_obj.get_data(key=push_interval)  # 获取APP推送消息时间间隔缓存数据
             if event_type not in [606, 607]: