0.5 improvements
This commit is contained in:
parent
6008cb5022
commit
06574c575a
|
|
@ -0,0 +1,25 @@
|
||||||
|
noaacap changelog
|
||||||
|
##
|
||||||
|
Version: 0.5
|
||||||
|
Release: TBD
|
||||||
|
Bug fix for long messages to ensure myZone is included
|
||||||
|
Improve error handling for configuration errors
|
||||||
|
Add -v command line switch to print version and copyright
|
||||||
|
##
|
||||||
|
Version: 0.4
|
||||||
|
Release: August 24, 2017
|
||||||
|
Switched to compressed zcs to improve capacity
|
||||||
|
Improved messsage + \n length check
|
||||||
|
##
|
||||||
|
Version: 0.3
|
||||||
|
Release: August 22, 2017
|
||||||
|
Changes: Implement NWS-CANCL messages, implement DB id consisting of
|
||||||
|
Office + Phenomena + Significance + ETN
|
||||||
|
##
|
||||||
|
Version: 0.2
|
||||||
|
Release: August 19, 2017
|
||||||
|
Changes: Make sure message does not exceed 67 chars
|
||||||
|
##
|
||||||
|
Version: 0.1
|
||||||
|
Release: August 7, 2017
|
||||||
|
Initial Release
|
||||||
Binary file not shown.
|
|
@ -1,29 +1,12 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
## Author: Dan Srebnick, K2DLS
|
## Author: Dan Srebnick, K2DLS
|
||||||
##
|
|
||||||
## Version: 0.4
|
|
||||||
## Release: August 24, 2017
|
|
||||||
## Switched to compressed zcs to improve capacity
|
|
||||||
## Improved messsage + \n length check
|
|
||||||
##
|
|
||||||
## Version: 0.3
|
|
||||||
## Release: August 22, 2017
|
|
||||||
## Changes: Implement NWS-CANCL messages, implement DB id consisting of
|
|
||||||
## Office + Phenomena + Significance + ETN
|
|
||||||
##
|
|
||||||
## Version: 0.2
|
|
||||||
## Release: August 19, 2017
|
|
||||||
## Changes: Make sure message + \n does not exceed 67 chars
|
|
||||||
##
|
|
||||||
## Version: 0.1
|
|
||||||
## Release: August 7, 2017
|
|
||||||
##
|
|
||||||
## License: BSD-2-Clause (/usr/local/share/noaacap/license.txt)
|
## License: BSD-2-Clause (/usr/local/share/noaacap/license.txt)
|
||||||
##
|
|
||||||
## This program is called from aprx.
|
## This program is called from aprx.
|
||||||
##
|
##
|
||||||
|
version = "0.5"
|
||||||
|
|
||||||
|
import sys
|
||||||
import pytz, datetime
|
import pytz, datetime
|
||||||
import string
|
import string
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -33,17 +16,36 @@ import os
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
if len(sys.argv) == 2 and sys.argv[1] == '-v':
|
||||||
|
print "noaacap.py by K2DLS, version " + version
|
||||||
|
print
|
||||||
|
print "A weather alert beacon exec for aprx >= 2.9"
|
||||||
|
print "Licensed under the BSD 2 Clause license"
|
||||||
|
print "Copyright 2017 by Daniel L. Srebnick"
|
||||||
|
print
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
conffile = '/etc/noaacap.conf'
|
||||||
|
|
||||||
|
if not os.path.isfile(conffile):
|
||||||
|
exit("\nError: " + conffile + " not found\n")
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.path.isfile('/etc/noaacap.conf')
|
config.read(conffile)
|
||||||
except:
|
except:
|
||||||
exit("\nError: /etc/noaacap.conf not found\n")
|
exit("\nError: Check " + conffile + " for proper [noaacap] section heading\n")
|
||||||
else:
|
|
||||||
config.read('/etc/noaacap.conf')
|
|
||||||
|
|
||||||
|
try:
|
||||||
myTZ = config.get('noaacap', 'myTZ')
|
myTZ = config.get('noaacap', 'myTZ')
|
||||||
|
except:
|
||||||
|
exit("\nError: Check " + conffile + " for proper myTZ value in [noaacap] section\n")
|
||||||
|
|
||||||
|
try:
|
||||||
myZone = config.get('noaacap', 'myZone')
|
myZone = config.get('noaacap', 'myZone')
|
||||||
|
except:
|
||||||
|
exit("\nError: Check " + conffile + " for proper myZone value in [noaacap] section\n")
|
||||||
|
|
||||||
def aprstime(timestr,TZ):
|
def aprstime(timestr,TZ):
|
||||||
local = pytz.timezone (TZ)
|
local = pytz.timezone (TZ)
|
||||||
|
|
@ -191,20 +193,22 @@ for i in range(0, count):
|
||||||
event = "CANCL"
|
event = "CANCL"
|
||||||
|
|
||||||
hit = 1
|
hit = 1
|
||||||
suffix = exputc + "z," + type + "," + zcs + "{" + t + "00"
|
message = exputc + "z," + type + "," + zcs
|
||||||
|
|
||||||
# Make sure message does not exceed 67 chars (66 + newline)
|
# Make sure message does not exceed 67 chars. If it
|
||||||
# If it does, trim it. Also be certain that myZone
|
# does, trim it. Also be certain that myZone is included
|
||||||
# is included in the trimmed zcs.
|
# included in the trimmed zcs.
|
||||||
while len(suffix) > 66:
|
|
||||||
if not myZone in parsezcs(zcs):
|
while len(message) > 67:
|
||||||
zcs = myZone + "-" + zcs
|
|
||||||
suffix = exputc + "z," + type + "," + zcs + "{" + t + "00"
|
|
||||||
n = zcs.rfind('-')
|
n = zcs.rfind('-')
|
||||||
zcs = zcs[0:n]
|
zcs = zcs[0:n]
|
||||||
suffix = exputc + "z," + type + "," + zcs + "{" + t + "00"
|
message = exputc + "z," + type + "," + zcs
|
||||||
|
if not myZone in parsezcs(zcs):
|
||||||
|
zcs = myZone + "-" + zcs
|
||||||
|
message = exputc + "z," + type + "," + zcs
|
||||||
|
|
||||||
print ":NWS_" + event + ":" + suffix
|
line = "{" + t + "00"
|
||||||
|
print ":NWS_" + event + ":" + message + line
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue