diff --git a/noaacap/DEBIAN/control b/noaacap/DEBIAN/control index fad6076..2ffa597 100644 --- a/noaacap/DEBIAN/control +++ b/noaacap/DEBIAN/control @@ -1,5 +1,5 @@ Package: noaacap -Version: 1.4.0 +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 95658c1..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.0" +version = "1.5" import sys import pytz @@ -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')) @@ -30,16 +31,26 @@ 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 - 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') +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: @@ -281,7 +292,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 @@ -306,7 +319,7 @@ for i in range(0, count): k += 1 curr_item = j - try: + try: next_item = sorted_zcs[k] except: next_item = '' @@ -321,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 @@ -339,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 @@ -359,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('-') @@ -373,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: 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 d1e5d2e..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.0. 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 @@ -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 06/25/2025 diff --git a/noaacap/usr/local/share/noaacap/ppmap.db b/noaacap/usr/local/share/noaacap/ppmap.db index 2fee906..68dd9b3 100644 Binary files a/noaacap/usr/local/share/noaacap/ppmap.db and b/noaacap/usr/local/share/noaacap/ppmap.db differ