Prepare for 0.7 release

This commit is contained in:
Dan Srebnick 2017-09-27 12:00:00 -04:00
parent 7982c94e53
commit fd74397415
5 changed files with 48 additions and 5 deletions

4
README
View File

@ -49,6 +49,10 @@ at https://alerts.weather.gov/. Only list one county. The program will then
send the alert for all affected zones. You could instead use a zone code if send the alert for all affected zones. You could instead use a zone code if
you want to be more specific. you want to be more specific.
myResend should be set to 0 for no message resends or to an interval of your
choosing. If noaacap beacons every 2 minutes, a value of 30 would provide
hourly resends.
USE USE
It would be good to hear from users of this software. Please email It would be good to hear from users of this software. Please email

View File

@ -1,3 +1,4 @@
[noaacap] [noaacap]
myTZ = America/New_York myTZ = America/New_York
myZone = NJZ014 myZone = NJZ014
myResend = 0

View File

@ -6,7 +6,7 @@
## ##
## See /usr/local/share/noaacap/CHANGELOG for change history ## See /usr/local/share/noaacap/CHANGELOG for change history
## ##
version = "0.6" version = "0.7"
import sys import sys
import pytz import pytz
@ -24,7 +24,7 @@ from systemd.journal import JournalHandler
log = logging.getLogger('noaacap') log = logging.getLogger('noaacap')
log.addHandler(JournalHandler(SYSLOG_IDENTIFIER='noaacap')) log.addHandler(JournalHandler(SYSLOG_IDENTIFIER='noaacap'))
log.setLevel(logging.INFO) log.setLevel(logging.DEBUG)
log.info("Starting") log.info("Starting")
if len(sys.argv) == 2 and sys.argv[1] == '-v': if len(sys.argv) == 2 and sys.argv[1] == '-v':
@ -66,6 +66,14 @@ except:
log.error("Check " + conffile + " for proper myZone value in [noaacap] section") log.error("Check " + conffile + " for proper myZone value in [noaacap] section")
Exiting() Exiting()
try:
myResend = int(config.get('noaacap', 'myResend'))
except:
log.error("Check " + conffile + " for proper myResend value in [noaacap] section")
log.error("Try 0 (for no resend)")
log.error("or 30 (for 1h if beacon cycle-size 2m)")
Exiting()
url = 'https://alerts.weather.gov/cap/wwaatmget.php?x=' + myZone + '&y=0' url = 'https://alerts.weather.gov/cap/wwaatmget.php?x=' + myZone + '&y=0'
r = requests.get(url) r = requests.get(url)
@ -152,7 +160,10 @@ for i in range(0, count):
else: else:
if i == 0: if i == 0:
alerts = db.DB() alerts = db.DB()
alerts.open(dbfile, None, db.DB_HASH, db.DB_CREATE) alerts.open(dbfile, "Alerts", db.DB_HASH, db.DB_CREATE)
if myResend > 0:
resend = db.DB()
resend.open(dbfile, "Resend", db.DB_HASH, db.DB_CREATE)
pp = db.DB() pp = db.DB()
pp.open(ppmap, None, db.DB_HASH, db.DB_RDONLY) pp.open(ppmap, None, db.DB_HASH, db.DB_RDONLY)
@ -172,9 +183,26 @@ for i in range(0, count):
id = bytes(str(Office + Phenomena + Significance + ETN), 'utf-8') id = bytes(str(Office + Phenomena + Significance + ETN), 'utf-8')
# Do we have this alert?
if alerts.has_key(id): if alerts.has_key(id):
# Is the updated time unchanged?
if alerts[id].decode('utf-8') == updated: if alerts[id].decode('utf-8') == updated:
log.debug(id.decode('utf-8') + " " + updated + " found") log.debug(id.decode('utf-8') + " " + updated + " found")
# Is resend behavoir desired?
if myResend > 0:
try:
recount = int(resend[id].decode('utf-8')) - 1
except:
resend[id] = bytes(str(myResend), 'utf-8')
recount = int(resend[id].decode('utf-8')) - 1
if recount > 0:
resend[id] = bytes(str(recount), 'utf-8')
log.debug(id.decode('utf-8') + " resend in " + str(recount) +
" iterations")
continue
else:
continue continue
alerts[id] = updated alerts[id] = updated
@ -239,6 +267,8 @@ for i in range(0, count):
line = "{" + t + "00" line = "{" + t + "00"
print(":NWS_" + event + ":" + message + line) print(":NWS_" + event + ":" + message + line)
if myResend > 0:
resend[id] = bytes(str(myResend), 'utf-8')
break break

View File

@ -1,5 +1,9 @@
noaacap changelog noaacap changelog
## ##
Version: 0.7
Release: TBD
Added myResend parameter to control message resends.
##
Version: 0.6 Version: 0.6
Release: September 15, 2017 Release: September 15, 2017
Converted to Python3 Converted to Python3

View File

@ -44,6 +44,10 @@ at https://alerts.weather.gov/. Only list one county. The program will then
send the alert for all affected zones. You could instead use a zone code if send the alert for all affected zones. You could instead use a zone code if
you want to be more specific. you want to be more specific.
myResend should be set to 0 for no message resends or to an interval of your
choosing. If noaacap beacons every 2 minutes, a value of 30 would provide
hourly resends.
USE USE
It would be good to hear from users of this software. Please email It would be good to hear from users of this software. Please email