Skip to content

Commit

Permalink
Return metar not available for not available queries.
Browse files Browse the repository at this point in the history
Metar query wait and error messages.
  • Loading branch information
joanpc committed Mar 27, 2015
1 parent 7daed8d commit b184c63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions PI_noaaWeather.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ def metarWindowHandler(self, inMessage, inWidget, inParam1, inParam2):
query = buff[0].strip()
if len(query) == 4:
self.weather.weatherClientSend('?' + query)
XPSetWidgetDescriptor(self.metarQueryOutput, 'Quering, please wait.')
else:
XPSetWidgetDescriptor(self.metarQueryOutput, 'Please insert a valid ICAO code.')
return 1
Expand All @@ -1029,7 +1030,7 @@ def metarWindowHandler(self, inMessage, inWidget, inParam1, inParam2):
def metarQueryCallback(self, msg):
''' Callback for metar queries '''

if self.metarWindow and XPIsWidgetVisible(self.metarWindowWidget):
if self.metarWindow:
XPSetWidgetDescriptor(self.metarQueryOutput, '%s %s' % (msg['metar']['icao'], msg['metar']['metar']))

def metarQueryWindowToggle(self):
Expand Down Expand Up @@ -1190,7 +1191,7 @@ def floopCallback(self, elapsedMe, elapsedSim, counter, refcon):
if 'precipitation' in wdata['metar']:
p = wdata['metar']['precipitation']
for precp in p:
precip, wet = c.metar2xpprecipitation(precp, p[precp]['int'], p[precp]['int'], p[precp]['recent'] )
precip, wet = c.metar2xpprecipitation(precp, p[precp]['int'], p[precp]['int'], p[precp]['recent'])

if precip is not False:
rain = precip
Expand Down
5 changes: 3 additions & 2 deletions noaweather/weatherServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ def handle(self):
# Icao
response = {}
apt = gfs.metar.getMetar(gfs.metar.connection, data[1:])
if len(apt) > 4:
if len(apt) and apt[5]:
response['metar'] = gfs.metar.parseMetar(apt[0], apt[5], apt[3])
else:
response = [False]
response['metar'] = {'icao': 'METAR STATION',
'metar': 'NOT AVAILABLE'}

elif data == '!shutdown':
conf.serverSave()
Expand Down

0 comments on commit b184c63

Please sign in to comment.