chenjunkai 6 rokov pred
rodič
commit
cc9cafe46a
1 zmenil súbory, kde vykonal 13 pridanie a 12 odobranie
  1. 13 12
      Controller/EquipmentStatus.py

+ 13 - 12
Controller/EquipmentStatus.py

@@ -107,18 +107,19 @@ def getTZ(request):
         if len(uid) == 20:
             print(uid)
             info = CommonService.getIpIpInfo(ip=ip, lang=lang)
-            tz = info['utc_offset']
-            # 增加GMT,且补:00
-            if len(tz) == 5:
-                gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
-                if ':' not in gmtz:
-                    gmtz = gmtz + ':00'
-                info['gmt_offset'] = gmtz
-            elif len(tz) == 8:
-                gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
-                info['gmt_offset'] = gmtz
-            else:
-                return
+            try:
+                tz = info['utc_offset']
+                # 增加GMT,且补:00
+                if len(tz) == 5:
+                    gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
+                    if ':' not in gmtz:
+                        gmtz = gmtz + ':00'
+                    info['gmt_offset'] = gmtz
+                elif len(tz) == 8:
+                    gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
+                    info['gmt_offset'] = gmtz
+            except Exception as e:
+                pass
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': info})
         else:
             return JsonResponse(status=200, data={'code': 404, 'msg': '令牌错误'})