From 384f0edc7e77b1ba9dcc60c37773b2edf4584f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Sun, 1 Oct 2017 22:22:57 +0200 Subject: [PATCH] Fixes #25 --- ogn/parser/parse.py | 7 ++++--- tests/parser/test_parse.py | 7 +++++++ tests/parser/valid_beacon_data/aprs_receiver.txt | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ogn/parser/parse.py b/ogn/parser/parse.py index 2f88666..ba91724 100644 --- a/ogn/parser/parse.py +++ b/ogn/parser/parse.py @@ -74,8 +74,9 @@ def parse_comment(aprs_comment, dstcall="APRS", aprs_type="position"): if rc_data: rc_data.update({'beacon_type': 'receiver_beacon'}) return rc_data - - raise OgnParseError(aprs_comment) + else: + return {'user_comment': aprs_comment, + 'beacon_type': 'receiver_beacon'} elif dstcall == "OGFLR": ac_data = parse_aircraft_beacon(aprs_comment) ac_data.update({'beacon_type': 'aircraft_beacon'}) @@ -117,4 +118,4 @@ def parse_comment(aprs_comment, dstcall="APRS", aprs_type="position"): ac_data.update({'beacon_type': 'spot_beacon'}) return ac_data else: - raise ValueError("dstcall {} unknown".format(dstcall)) + raise OgnParseError("No parser for dstcall {} found. APRS comment: {}".format(dstcall, aprs_comment)) diff --git a/tests/parser/test_parse.py b/tests/parser/test_parse.py index 8d6d715..a7e3189 100644 --- a/tests/parser/test_parse.py +++ b/tests/parser/test_parse.py @@ -63,6 +63,13 @@ class TestStringMethods(unittest.TestCase): with self.assertRaises(AprsParseError): parse("Lachens>APRS,TCPIwontbeavalidstring") + def test_v026_chile(self): + # receiver beacons from chile have a APRS position message with a pure user comment + raw_message = "VITACURA1>APRS,TCPIP*,qAC,GLIDERN4:/201146h3322.79SI07034.80W&/A=002329 Vitacura Municipal Aerodrome, Club de Planeadores Vitacura" + message = parse(raw_message) + + self.assertEqual(message['user_comment'], "Vitacura Municipal Aerodrome, Club de Planeadores Vitacura") + @mock.patch('ogn.parser.parse_module.createTimestamp') def test_default_reference_date(self, createTimestamp_mock): valid_aprs_string = "Lachens>APRS,TCPIP*,qAC,GLIDERN2:/165334h4344.70NI00639.19E&/A=005435 v0.2.1 CPU:0.3 RAM:1764.4/2121.4MB NTP:2.8ms/+4.9ppm +47.0C RF:+0.70dB" diff --git a/tests/parser/valid_beacon_data/aprs_receiver.txt b/tests/parser/valid_beacon_data/aprs_receiver.txt index 846ac90..0f724ca 100644 --- a/tests/parser/valid_beacon_data/aprs_receiver.txt +++ b/tests/parser/valid_beacon_data/aprs_receiver.txt @@ -22,5 +22,6 @@ CNF3a>APRS,TCPIP*,qAC,GLIDERN3:>042143h v0.2.5.ARM CPU:0.6 RAM:514.6/970.8MB NTP VITACURA2>APRS,TCPIP*,qAC,GLIDERN3:/042136h3322.81SI07034.95W&/A=002345 v0.2.5.ARM CPU:0.3 RAM:695.0/970.5MB NTP:0.6ms/-5.7ppm +51.5C RF:+0-0.0ppm/+1.32dB VITACURA2>APRS,TCPIP*,qAC,GLIDERN3:>042136h v0.2.5.ARM CPU:0.3 RAM:695.0/970.5MB NTP:0.6ms/-5.7ppm +52.1C 0/0Acfts[1h] RF:+0-0.0ppm/+1.32dB/+2.1dB@10km[193897]/+9.0dB@10km[10/20] # -# since 0.2.6 the ogn comment of a receiver beacon is just optional +# since 0.2.6 the ogn comment of a receiver beacon is just optional, it also can be a user comment Ulrichamn>APRS,TCPIP*,qAC,GLIDERN1:/085616h5747.30NI01324.77E&/A=001322 +ROBLE3>APRS,TCPIP*,qAC,GLIDERN4:/200022h3258.58SI07100.78W&/A=007229 Contact: achanes@manquehue.net, brito.felipe@gmail.com