From b184c63280c6e3f1a76e034d257ded36316b982e Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 27 Mar 2015 16:30:20 -0500 Subject: [PATCH] Return metar not available for not available queries. Metar query wait and error messages. --- PI_noaaWeather.py | 5 +++-- noaweather/weatherServer.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PI_noaaWeather.py b/PI_noaaWeather.py index 28254df..f1216f5 100644 --- a/PI_noaaWeather.py +++ b/PI_noaaWeather.py @@ -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 @@ -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): @@ -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 diff --git a/noaweather/weatherServer.py b/noaweather/weatherServer.py index 6c5cdb6..b96279d 100644 --- a/noaweather/weatherServer.py +++ b/noaweather/weatherServer.py @@ -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()