def get_Data(self): global WEATHER_DATA global WEATHER_LOAD if WEATHER_LOAD == True: try: r = ping.doOne("8.8.8.8", 1.5) if r != None and r <= 1.5: print "KravenWeather: Weather download from OpenWeatherMap" res = requests.get(URL, timeout=1.5) self.data = res.json() WEATHER_DATA = self.data WEATHER_LOAD = False except: pass timeout = max(15, int( config.plugins.KravenVB.refreshInterval.value)) * 1000.0 * 60.0 self.timer.start(int(timeout), True) else: self.data = WEATHER_DATA
def get_Data(self): global WEATHER_DATA global WEATHER_LOAD if WEATHER_LOAD == True: try: r = ping.doOne("8.8.8.8", 1.5) if r != None and r <= 1.5: print "KravenWeather: Weather download from RealTek" self.data = {} index = 0 res = requests.get(URL, timeout=1.5) root = fromstring( res.text.replace('xmlns="http://www.accuweather.com"', '')) for child in root.findall('currentconditions'): self.data['Day_%s' % str(index)] = {} self.data['Day_%s' % str(index)]['temp'] = child.find( 'temperature').text self.data['Day_%s' % str(index)]['skytextday'] = child.find( 'weathertext').text self.data['Day_%s' % str(index)]['skycodeday'] = child.find( 'weathericon').text self.data['Day_%s' % str(index)]['humidity'] = child.find( 'humidity').text self.data['Day_%s' % str(index)]['winddisplay'] = child.find( 'winddirection').text self.data['Day_%s' % str(index)]['windspeed'] = child.find( 'windspeed').text self.data['Day_%s' % str(index)]['feelslike'] = child.find( 'realfeel').text for child in root.findall('forecast'): for item in child.findall('day'): for entrie in item.findall('daytime'): if index > 0: self.data['Day_%s' % str(index)] = {} self.data['Day_%s' % str( index)]['skycodeday'] = entrie.find( 'weathericon').text self.data['Day_%s' % str( index)]['skytextday'] = entrie.find( 'txtshort').text self.data['Day_%s' % str(index)]['day'] = item.find( 'obsdate').text self.data['Day_%s' % str(index)]['low'] = entrie.find( 'lowtemperature').text self.data['Day_%s' % str(index)]['high'] = entrie.find( 'hightemperature').text self.data['Day_%s' % str(index)]['precip'] = entrie.find( 'rainamount').text index += 1 WEATHER_DATA = self.data WEATHER_LOAD = False except: pass timeout = max(15, int( config.plugins.KravenVB.refreshInterval.value)) * 1000.0 * 60.0 self.timer.start(int(timeout), True) else: self.data = WEATHER_DATA