Kaynağa Gözat

打印异常continue

locky 2 yıl önce
ebeveyn
işleme
a5a498b56d
1 değiştirilmiş dosya ile 15 ekleme ve 6 silme
  1. 15 6
      Service/HuaweiPushService/HuaweiPushService.py

+ 15 - 6
Service/HuaweiPushService/HuaweiPushService.py

@@ -77,8 +77,11 @@ class HuaweiPushObject:
             android_notification_attributes = dir(android_notification)
             for attr in android_notification_attributes:
                 if not attr.startswith('__') and not attr.endswith('__'):
-                    value = getattr(android_notification, attr)
-                    LOGGER.info('android_notification_attributes {}: {}'.format(attr, value))
+                    try:
+                        value = getattr(android_notification, attr)
+                        LOGGER.info('android_notification_attributes {}: {}'.format(attr, value))
+                    except Exception as e:
+                        continue
 
             # 安卓配置
             android = messaging.AndroidConfig(
@@ -94,8 +97,11 @@ class HuaweiPushObject:
             android_attributes = dir(android)
             for attr in android_attributes:
                 if not attr.startswith('__') and not attr.endswith('__'):
-                    value = getattr(android_attributes, attr)
-                    LOGGER.info('android_attributes {}: {}'.format(attr, value))
+                    try:
+                        value = getattr(android_attributes, attr)
+                        LOGGER.info('android_attributes {}: {}'.format(attr, value))
+                    except Exception as e:
+                        continue
 
             message = messaging.Message(
                 notification=notification,
@@ -106,8 +112,11 @@ class HuaweiPushObject:
             message_attributes = dir(message)
             for attr in message_attributes:
                 if not attr.startswith('__') and not attr.endswith('__'):
-                    value = getattr(message_attributes, attr)
-                    LOGGER.info('message_attributes {}: {}'.format(attr, value))
+                    try:
+                        value = getattr(message_attributes, attr)
+                        LOGGER.info('message_attributes {}: {}'.format(attr, value))
+                    except Exception as e:
+                        continue
 
             try:
                 import certifi