Private
Public Access
1
0

more coverage

This commit is contained in:
Sander Roosendaal
2021-04-26 18:26:16 +02:00
parent 9e2a97e721
commit 594ee6239a
11 changed files with 133 additions and 91 deletions

View File

@@ -35,12 +35,12 @@ def get_weather_data(long,lat,unixtime):
try:
s = requests.get(url)
except ConnectionError:
except ConnectionError: # pragma: no cover
return 0
if s.ok:
return s.json()
else:
else: # pragma: no cover
return 0
# Get Metar data
@@ -56,12 +56,12 @@ def get_metar_data(airportcode,unixtime):
try:
s = requests.get(url)
except:
except: # pragma: no cover
message = 'Failed to download METAR data'
return [0,0,message,'','']
if s.ok:
if s.ok: # pragma: no cover
try:
doc = etree.fromstring(s.content)
except AttributeError:
@@ -108,7 +108,7 @@ def get_wind_data(lat,long,unixtime):
data = get_weather_data(lat,long,unixtime)
summary = ''
temperature = 20
if data:
if data: # pragma: no cover
try:
# we are getting wind in mph
windspeed = data['currently']['windSpeed']*0.44704
@@ -157,7 +157,7 @@ def get_wind_data(lat,long,unixtime):
message = 'Summary for your location at '+timestamp+': '+summary
message += '. Temperature '+str(temperature)+'F/'+str(temperaturec)+'C'
if data:
if data: # pragma: no cover
message += '. Wind: '+str(windspeed)+' m/s. Wind Bearing: '+str(windbearing)+' degrees'