locky преди 2 години
родител
ревизия
a5a498b56d
променени са 1 файла, в които са добавени 15 реда и са изтрити 6 реда
  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