Add timeout for slow/no response from NWS servers
This commit is contained in:
parent
6df0666323
commit
38d066b26e
|
|
@ -1,5 +1,5 @@
|
|||
Package: noaacap
|
||||
Version: 0.8
|
||||
Version: 0.9
|
||||
Section: hamradio
|
||||
Priority: extra
|
||||
Maintainer: Dan Srebnick <k2dls at k2dls.net>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
##
|
||||
## See /usr/local/share/noaacap/CHANGELOG for change history
|
||||
##
|
||||
version = "0.8"
|
||||
version = "0.9"
|
||||
|
||||
import sys
|
||||
import pytz
|
||||
|
|
@ -87,7 +87,12 @@ except:
|
|||
|
||||
url = 'https://alerts.weather.gov/cap/wwaatmget.php?x=' + myZone + '&y=0'
|
||||
|
||||
r = requests.get(url)
|
||||
try:
|
||||
r = requests.get(url, timeout=2)
|
||||
except requests.exceptions.Timeout:
|
||||
log.error("Timeout exception requesting " + url)
|
||||
ErrExit()
|
||||
|
||||
if r.status_code != 200:
|
||||
log.error(str(r.status_code) + " " + url)
|
||||
ErrExit()
|
||||
|
|
@ -252,7 +257,12 @@ for i in range(0, count):
|
|||
t = t + chr(s+61)
|
||||
|
||||
# Pull specific alert to get compressed UGC zones
|
||||
rs = requests.get(entries[i].id.string)
|
||||
try:
|
||||
rs = requests.get(entries[i].id.string, timeout=2)
|
||||
except requests.exceptions.Timeout:
|
||||
log.error("Timeout exception requesting " + url)
|
||||
ErrExit()
|
||||
|
||||
if rs.status_code != 200:
|
||||
log.error(str(rs.status_code) + " " + rs)
|
||||
ErrExit()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
*** /dev/null
|
||||
--- /dev/null
|
||||
***************
|
||||
*** 9
|
||||
- version = "0.9"
|
||||
--- 9 -----
|
||||
+ version = "0.8"
|
||||
***************
|
||||
*** 90,95
|
||||
- try:
|
||||
- r = requests.get(url, timeout=2)
|
||||
- except requests.exceptions.Timeout:
|
||||
- log.error("Timeout exception requesting " + url)
|
||||
- ErrExit()
|
||||
-
|
||||
--- 90 -----
|
||||
+ r = requests.get(url)
|
||||
***************
|
||||
*** 260,265
|
||||
- try:
|
||||
- rs = requests.get(entries[i].id.string, timeout=2)
|
||||
- except requests.exceptions.Timeout:
|
||||
- log.error("Timeout exception requesting " + url)
|
||||
- ErrExit()
|
||||
-
|
||||
--- 255 -----
|
||||
+ rs = requests.get(entries[i].id.string)
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
noaacap changelog
|
||||
##
|
||||
Version: 0.9
|
||||
Release: February 20, 2018
|
||||
Added timeout for non/slow response of NWS servers
|
||||
##
|
||||
Version: 0.8
|
||||
Release: January 29, 2018
|
||||
Added added handling for expired alerts
|
||||
|
|
|
|||
Loading…
Reference in New Issue