From c8045797fbf205d5aeabeeea69d4598e3ed3f85a Mon Sep 17 00:00:00 2001 From: xssfox Date: Sun, 8 Sep 2024 09:47:42 +1000 Subject: [PATCH] add new named branches --- lambda/sonde_api_to_iot_core/__init__.py | 19 ++++++++++--------- lambda/sonde_api_to_iot_core/__main__.py | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lambda/sonde_api_to_iot_core/__init__.py b/lambda/sonde_api_to_iot_core/__init__.py index 8dea6c6..ae62465 100644 --- a/lambda/sonde_api_to_iot_core/__init__.py +++ b/lambda/sonde_api_to_iot_core/__init__.py @@ -310,14 +310,15 @@ def telemetry_filter(telemetry): return ("errors",f"SondeMonitor version is out of date and doesn't handle DFM radiosondes correctly. Please update to 6.2.8.8 or later") if telemetry["software_name"] == "rdzTTGOsonde": ttgo_branch, ttgo_version = parse_rdz_ttgo_version(telemetry["software_version"]) - if ttgo_branch == "devel": - if ttgo_version < (20230427,0,0): - return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later") - elif ttgo_branch == "master": - if ttgo_version < (0,9,3): - return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later") - else: - return ("errors",f"rdzTTGOsonde branch and version was unable to be determined. We are unsure if this version handles DFM sondes correctly. Please update to master 0.9.3, devel20230427 or later") + if ttgo_branch not in ["main", "dev"]: # presume that this is fixed in the new named branch releases + if ttgo_branch == "devel": + if ttgo_version < (20230427,0,0): + return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later") + elif ttgo_branch == "master": + if ttgo_version < (0,9,3): + return ("errors",f"rdzTTGOsonde version is out of date and doesn't handle DFM radiosondes correctly. Please update to master 0.9.3, devel20230427 or later") + else: + return ("errors",f"rdzTTGOsonde branch and version was unable to be determined. We are unsure if this version handles DFM sondes correctly. Please update to master 0.9.3, devel20230427 or later") # Check if DFM17->DFM09 misid - https://github.com/projecthorus/sondehub-infra/issues/141 if "subtype" in telemetry and telemetry["subtype"] == "DFM09": try: @@ -357,7 +358,7 @@ def parse_rdz_ttgo_version(version): # RDZ TTGO has two branches, master and devel, however there are also a bunch of other custom versions # devel20230829, master_v0.9.3, master_v0.9.2, devel20230427, devLZ20230812, devel20230829.NE, Alex_ver_2.7_M, multich_v3 # in the cases that don't match develxxxx or master_vxxxx format we'll give a 0,0,0 version here - m = re.search(r'([a-zA-Z_]+?)_?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?', version) + m = re.search(r'([a-zA-Z_]+?)(?:_v)?(\d+)(?:\.(\d+))?(?:\.(\d+))?', version) return (m.groups()[0],tuple([int(x if x != None else 0) for x in m.groups()[1:]])) except: return ("unknown", (0,0,0)) diff --git a/lambda/sonde_api_to_iot_core/__main__.py b/lambda/sonde_api_to_iot_core/__main__.py index fd25bc2..65c6e0e 100644 --- a/lambda/sonde_api_to_iot_core/__main__.py +++ b/lambda/sonde_api_to_iot_core/__main__.py @@ -135,6 +135,27 @@ def test_good_ttgo_master_payload(self): sns.publish.assert_called() self.assertEqual(output["body"], "^v^ telm logged") self.assertEqual(output["statusCode"], 200) + def test_good_ttgo_devel_payload_new_name(self): + payload = copy.deepcopy(example_body) + payload[0]["datetime"] = datetime.datetime.now().isoformat() + payload[0]["software_name"] = "rdzTTGOsonde" + payload[0]["software_version"] = "dev20230829" + payload[0]["type"] = "DFM" + output = lambda_handler(compress_payload(payload), fakeContext()) + sns.publish.assert_called() + self.assertEqual(output["body"], "^v^ telm logged") + self.assertEqual(output["statusCode"], 200) + def test_good_ttgo_main_payload(self): + payload = copy.deepcopy(example_body) + payload[0]["datetime"] = datetime.datetime.now().isoformat() + payload[0]["software_name"] = "rdzTTGOsonde" + payload[0]["software_version"] = "main1234" + payload[0]["type"] = "DFM" + output = lambda_handler(compress_payload(payload), fakeContext()) + sns.publish.assert_called() + self.assertEqual(output["body"], "^v^ telm logged") + self.assertEqual(output["statusCode"], 200) + def test_bad_ttgo_devel_payload(self): payload = copy.deepcopy(example_body) payload[0]["datetime"] = datetime.datetime.now().isoformat()