From 1cf4a990f67e27950c06a44f6b1230c995259900 Mon Sep 17 00:00:00 2001 From: Ross Whitfield Date: Mon, 29 Apr 2024 14:16:36 +1000 Subject: [PATCH] Update checks --- src/dasmon_app/dasmon_listener/amq_consumer.py | 4 ++-- src/webmon_app/reporting/dasmon/view_util.py | 2 +- src/webmon_app/reporting/reduction/view_util.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dasmon_app/dasmon_listener/amq_consumer.py b/src/dasmon_app/dasmon_listener/amq_consumer.py index 897248d8..4fda3af9 100644 --- a/src/dasmon_app/dasmon_listener/amq_consumer.py +++ b/src/dasmon_app/dasmon_listener/amq_consumer.py @@ -189,10 +189,10 @@ def on_message(self, frame): # elif 'timestamp' in data_dict: # timestamp = data_dict['timestamp'] for key in data_dict: - if key == "monitors" and type(data_dict[key]) == dict: + if key == "monitors" and isinstance(data_dict[key], dict): for item in data_dict[key]: # Protect against old API - if not type(data_dict[key][item]) == dict: + if not isinstance(data_dict[key][item], dict): key_id = self.retrieve_parameter("monitor_count_%s" % str(item)) store_and_cache( instrument, diff --git a/src/webmon_app/reporting/dasmon/view_util.py b/src/webmon_app/reporting/dasmon/view_util.py index 209481c8..57c8a81e 100644 --- a/src/webmon_app/reporting/dasmon/view_util.py +++ b/src/webmon_app/reporting/dasmon/view_util.py @@ -1083,7 +1083,7 @@ def get_signals(instrument_id): if len(latests) == 0: latests = PVStringCache.objects.filter(instrument=instrument_id, name=item.pv_name) latest = latests.latest("update_time") - if type(latest.value) == float: + if isinstance(latest.value, float): value = "%g" % latest.value else: value = "%s" % latest.value diff --git a/src/webmon_app/reporting/reduction/view_util.py b/src/webmon_app/reporting/reduction/view_util.py index 01902e53..d1ed8579 100644 --- a/src/webmon_app/reporting/reduction/view_util.py +++ b/src/webmon_app/reporting/reduction/view_util.py @@ -80,7 +80,7 @@ def send_template_request(instrument_id, template_dict, user="unknown"): """ use_default = False if "use_default" in template_dict: - if type(template_dict["use_default"]) == bool: + if isinstance(template_dict["use_default"], bool): use_default = template_dict["use_default"] else: use_default = template_dict["use_default"].lower() == "true"