From b0b7b6ea01e677bf34dfc812badcb0fa2c7bab71 Mon Sep 17 00:00:00 2001 From: K2IE Date: Mon, 23 Jun 2025 10:17:45 -0400 Subject: [PATCH 1/4] Fixes issues #7 and #8. --- noaacap/DEBIAN/control | 2 +- noaacap/usr/local/bin/noaacap.py | 6 ++++-- noaacap/usr/local/share/noaacap/README | 8 ++++---- noaacap/usr/local/share/noaacap/ppmap.db | Bin 12288 -> 12288 bytes 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/noaacap/DEBIAN/control b/noaacap/DEBIAN/control index fad6076..735f734 100644 --- a/noaacap/DEBIAN/control +++ b/noaacap/DEBIAN/control @@ -1,5 +1,5 @@ Package: noaacap -Version: 1.4.0 +Version: 1.4.2 Section: hamradio Priority: extra Maintainer: Dan Srebnick diff --git a/noaacap/usr/local/bin/noaacap.py b/noaacap/usr/local/bin/noaacap.py index 95658c1..e298b86 100755 --- a/noaacap/usr/local/bin/noaacap.py +++ b/noaacap/usr/local/bin/noaacap.py @@ -6,7 +6,7 @@ ## ## See /usr/local/share/noaacap/CHANGELOG for change history ## -version = "1.4.0" +version = "1.4.2" import sys import pytz @@ -281,7 +281,9 @@ for i in range(0, count): sorted_zcs = (sorted(zcs_discrete)) # Move myZone to first position in case of truncation - move_entry(sorted_zcs,myZone,0) + if myZone in sorted_zcs: + move_entry(sorted_zcs,myZone,0) + log.debug("myZone found in sorted zcs and moved to index 0") # Move adjacent zones, if present, after myZone adjZone2Index = 1 diff --git a/noaacap/usr/local/share/noaacap/README b/noaacap/usr/local/share/noaacap/README index d1e5d2e..2618384 100644 --- a/noaacap/usr/local/share/noaacap/README +++ b/noaacap/usr/local/share/noaacap/README @@ -1,4 +1,4 @@ -The current release of noaacap is 1.4.0. If you are running older than this +The current release of noaacap is 1.4.2. If you are running older than this version, please update before asking for support. This software is written in python3 and has been tested with aprx 2.9.x. @@ -63,8 +63,8 @@ the following command: timedatectl list-timezones | grep America. myZone should be set to your zone code. A list of zone codes may be found at https://www.weather.gov/pimar/PubZone. Only list one zone. The program will send the alert for all affected zones that will fit in the allocated 67 -characters. You could instead use a county code if you wish. However the -associated zone may also be sent, wasting characters. +characters. You could instead use a county code, if you wish. However, +NOAA now seems to return zones rather than counties in some cases. As an example, if you're located in Lancaster, PA, the map shows that you are in zone 066. Enter PAZ066 for myZone. @@ -89,4 +89,4 @@ weather alerts via this program. Dan Srebnick, K2IE 02/06/2020 -Updated 04/03/2024 +Updated 07/23/2025 diff --git a/noaacap/usr/local/share/noaacap/ppmap.db b/noaacap/usr/local/share/noaacap/ppmap.db index 2fee906399dc89b7177cff8a97765c976b203d03..68dd9b36d4fa36965dfdab3f6887b98d4a9ba036 100644 GIT binary patch delta 80 zcmV-W0I&amV1QtdG!HfbxB~$E001ef%<&6Z1C##`6#+c4S-TGdL;%r~7Z8O8;tk&o m(G9V2FAbAyE((+D9T*Qqcyw}QZDk-xWnpvySV*%19{v$z+8e9@ delta 62 zcmV-E0Kxx&V1QtdG!7pC0008B000tw43ap0ll~7D0Xwl-yAK0G0O6At5QPEZv!M_$ U4UvEplWZ;uliM8_vjZOe5lVIw*#H0l From 19246878ed3be64243fbd68a6ecbfb8c4d2d4ea1 Mon Sep 17 00:00:00 2001 From: K2IE Date: Tue, 24 Jun 2025 15:46:42 -0400 Subject: [PATCH 2/4] Fix date in README --- noaacap/usr/local/share/noaacap/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noaacap/usr/local/share/noaacap/README b/noaacap/usr/local/share/noaacap/README index 2618384..58b7835 100644 --- a/noaacap/usr/local/share/noaacap/README +++ b/noaacap/usr/local/share/noaacap/README @@ -89,4 +89,4 @@ weather alerts via this program. Dan Srebnick, K2IE 02/06/2020 -Updated 07/23/2025 +Updated 06/23/2025 From b9e37c865693484e7121c198d12e2c8749a5b223 Mon Sep 17 00:00:00 2001 From: Scott Weis KB2EAR Date: Tue, 24 Jun 2025 12:06:01 -0400 Subject: [PATCH 3/4] Add command-line argument parsing --- noaacap/usr/local/bin/noaacap.py | 33 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/noaacap/usr/local/bin/noaacap.py b/noaacap/usr/local/bin/noaacap.py index e298b86..e8730b2 100755 --- a/noaacap/usr/local/bin/noaacap.py +++ b/noaacap/usr/local/bin/noaacap.py @@ -22,6 +22,7 @@ import configparser import re import logging from systemd.journal import JournalHandler +import argparse log = logging.getLogger('noaacap') log.addHandler(JournalHandler(SYSLOG_IDENTIFIER='noaacap')) @@ -33,13 +34,23 @@ if len(sys.argv) == 2 and sys.argv[1] == '-v': print("Copyright 2017-2024 by Daniel L. Srebnick\n") sys.exit(0) +# Command-line argument parsing +parser = argparse.ArgumentParser(description="noaacap.py - NOAA CAP Parser for APRS.") +parser.add_argument('--config', '-c', + help='Path to the configuration file (default: /etc/noaacap.conf)', + default='/etc/noaacap.conf') +parser.add_argument('--dbfile', '-d', + help='Path to the database file (default: /dev/shm/noaaconf.db)', + default='/dev/shm/noaaconf.db') +args = parser.parse_args() + # We need this function early in execution def ErrExit(): log.error("Exiting") print() exit(0) -conffile = '/etc/noaacap.conf' +conffile = args.config if not os.path.isfile(conffile): log.error(conffile + " not found") @@ -112,7 +123,7 @@ soup = BeautifulSoup(r.text, 'xml') entries = soup.find_all('entry') count = len(entries) -dbfile = '/dev/shm/noaaconf.db' +dbfile = args.dbfile if count == 0: log.info("Exiting - no events found") if os.path.isfile(dbfile): @@ -194,9 +205,9 @@ for i in range(0, count): EventBegin, EventEnd = vtecparse(VTEC) except: log.debug("VTEC parse failed") - continue #Loop if error parsing P-VTEC + continue #Loop if error parsing P-VTEC - if ProductClass != "/O": #Loop if not operational + if ProductClass != "/O": #Loop if not operational continue EventEnd = "20" + EventEnd @@ -209,7 +220,7 @@ for i in range(0, count): except: exp = now -# log.debug('Time Now: ' + datetime.datetime.strftime(now,"%y-%m-%d %H:%M")) +# log.debug('Time Now: ' + datetime.datetime.strftime(now,"%y-%m-%d %H:%M")) # log.debug('Expiration: ' + datetime.datetime.strftime(exp,"%y-%m-%d %H:%M")) if now > exp: @@ -308,7 +319,7 @@ for i in range(0, count): k += 1 curr_item = j - try: + try: next_item = sorted_zcs[k] except: next_item = '' @@ -323,12 +334,12 @@ for i in range(0, count): i_curr_plus1 = i_curr_suffix + 1 # Always print entire first item - if k == 1: + if k == 1: zcs = curr_item # Did prefix change? elif prev_prefix != curr_prefix: zcs = zcs + "-" + curr_item - # Current suffix is 1 more than previous + # Current suffix is 1 more than previous elif i_prev_plus1 == i_curr_suffix: if i_next_suffix != i_curr_plus1: zcs = zcs + ">" + curr_suffix @@ -341,7 +352,7 @@ for i in range(0, count): # For debugging only # print (zcs) - + prev_item = curr_item prev_prefix = curr_prefix prev_suffix = curr_suffix @@ -361,7 +372,7 @@ for i in range(0, count): log.info("Msg: " + message) # Make sure message does not exceed 67 chars. If it does, trim it. - + n = 0 while len(message) > 67: n = zcs.rfind('-') @@ -375,7 +386,7 @@ for i in range(0, count): print(":NWS_" + event + ":" + message + line) if myResend > 0: resend[id] = bytes(str(myResend), 'utf-8') - + break if hit == 0: From 3108a06c11dd7717fd2b19fa90564d083e32a8b6 Mon Sep 17 00:00:00 2001 From: K2IE Date: Tue, 24 Jun 2025 18:14:06 -0400 Subject: [PATCH 4/4] Version 1.5 released --- noaacap/DEBIAN/control | 2 +- noaacap/DEBIAN/copyright | 2 +- noaacap/usr/local/bin/noaacap.py | 6 +++--- noaacap/usr/local/share/noaacap/CHANGELOG | 12 ++++++++++++ noaacap/usr/local/share/noaacap/README | 6 +++--- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/noaacap/DEBIAN/control b/noaacap/DEBIAN/control index 735f734..2ffa597 100644 --- a/noaacap/DEBIAN/control +++ b/noaacap/DEBIAN/control @@ -1,5 +1,5 @@ Package: noaacap -Version: 1.4.2 +Version: 1.5 Section: hamradio Priority: extra Maintainer: Dan Srebnick diff --git a/noaacap/DEBIAN/copyright b/noaacap/DEBIAN/copyright index ce27b2d..842b570 100644 --- a/noaacap/DEBIAN/copyright +++ b/noaacap/DEBIAN/copyright @@ -1,3 +1,3 @@ -Copyright: 2017-2020 Daniel L. Srebnick +Copyright: 2017-2025 Daniel L. Srebnick License: BSD-2-clause Files: * diff --git a/noaacap/usr/local/bin/noaacap.py b/noaacap/usr/local/bin/noaacap.py index e8730b2..e6fc041 100755 --- a/noaacap/usr/local/bin/noaacap.py +++ b/noaacap/usr/local/bin/noaacap.py @@ -6,7 +6,7 @@ ## ## See /usr/local/share/noaacap/CHANGELOG for change history ## -version = "1.4.2" +version = "1.5" import sys import pytz @@ -31,11 +31,11 @@ if len(sys.argv) == 2 and sys.argv[1] == '-v': print("noaacap.py by K2IE, version " + version + "\n") print("A weather alert beacon exec for aprx >= 2.9 and Direwolf >= 1.3") print("Licensed under the BSD 2 Clause license") - print("Copyright 2017-2024 by Daniel L. Srebnick\n") + print("Copyright 2017-2025 by Daniel L. Srebnick\n") sys.exit(0) # Command-line argument parsing -parser = argparse.ArgumentParser(description="noaacap.py - NOAA CAP Parser for APRS.") +parser = argparse.ArgumentParser(description="noaacap.py - APRS Weather Alerts beacon exec for aprx & Dire Wolf") parser.add_argument('--config', '-c', help='Path to the configuration file (default: /etc/noaacap.conf)', default='/etc/noaacap.conf') diff --git a/noaacap/usr/local/share/noaacap/CHANGELOG b/noaacap/usr/local/share/noaacap/CHANGELOG index 4de785d..0c3c74f 100644 --- a/noaacap/usr/local/share/noaacap/CHANGELOG +++ b/noaacap/usr/local/share/noaacap/CHANGELOG @@ -1,5 +1,17 @@ noaacap changelog ## +Version: 1.5 +Release: June 25, 2025 +Add command argument parsing +## +Version: 1.4.1 +Release: June 23, 2025 +Add XH phenomena and fix county bug +## +Version: 1.4 +Release: April 3, 2024 +Complete rewrite of zone parsing +## Version: 1.3.1 Release: April 2, 2024 Fix expiration date parsing issue diff --git a/noaacap/usr/local/share/noaacap/README b/noaacap/usr/local/share/noaacap/README index 58b7835..1397784 100644 --- a/noaacap/usr/local/share/noaacap/README +++ b/noaacap/usr/local/share/noaacap/README @@ -1,5 +1,5 @@ -The current release of noaacap is 1.4.2. If you are running older than this -version, please update before asking for support. +The current release of noaacap is 1.5. If you are running an older version +than this, please update before asking for support. This software is written in python3 and has been tested with aprx 2.9.x. If you are running a version < 2.9.0 you should first update aprx. The current @@ -89,4 +89,4 @@ weather alerts via this program. Dan Srebnick, K2IE 02/06/2020 -Updated 06/23/2025 +Updated 06/25/2025