Quellcode durchsuchen

fix a bug that catch error by 'and'

chenhaiyang vor 4 Jahren
Ursprung
Commit
0d1793c804
2 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen
  1. 1 1
      app/controllers/equipment/ahu/basic.py
  2. 2 2
      app/services/platform.py

+ 1 - 1
app/controllers/equipment/ahu/basic.py

@@ -63,7 +63,7 @@ async def get_freq_controlled(project_id: str, equipment_id: str) -> None:
         count = await review_service.get_fill_count()
         try:
             hot_rate = count.get('hotNum') / (count.get('hotNum') + count.get('coldNum') + count.get('normalNum'))
-        except ZeroDivisionError and KeyError:
+        except ZeroDivisionError or KeyError:
             hot_rate = 0.0
         supply_air_temperature_set = await platform.get_duration(
             InfoCode.supply_air_temperature_set,

+ 2 - 2
app/services/platform.py

@@ -79,7 +79,7 @@ class DataPlatformService(Service):
             if arrow.get(latest_time, TIME_FMT).shift(minutes=15) < arrow.get(self._now_time, TIME_FMT):
                 logger.info(f'delayed data - {object_id}: ({latest_time}, {latest_data})')
             value = round_half_up(latest_data, 2)
-        except KeyError and IndexError:
+        except KeyError or IndexError:
             value = np.NAN
         except TypeError:
             value = -1.0
@@ -151,7 +151,7 @@ class DataPlatformService(Service):
             if arrow.get(latest_time, TIME_FMT).shift(minutes=15) < arrow.get(end_time, TIME_FMT):
                 logger.info(f'delayed data - {object_id}: ({latest_time}, {latest_data})')
             value = round_half_up(latest_data, 2)
-        except KeyError and IndexError:
+        except KeyError or IndexError:
             value = np.NAN
         except TypeError:
             value = -1.0