]> jfr.im git - erebus.git/blobdiff - modules/weatherstack_weather.py
reddark - add topic suffix and move updateinterval to config
[erebus.git] / modules / weatherstack_weather.py
index a79ff78d115fc1fa5a2822e5933f4c0efc3e634f..937f1dc19b905a7e85799cd63c43a9a59c18f3dc 100644 (file)
@@ -53,7 +53,10 @@ def _weather(place):
                return "Weather is not enabled - please set the API key in the config file"
 
        if place is not None:
-               weather = json.load(urlopen(('http://api.weatherstack.com/current?access_key=%s&query=%s' % (lib.parent.cfg.get('weatherstack_weather', 'key'), quote_plus(place))).encode('utf8')))
+               url = 'http://api.weatherstack.com/current?access_key=%s&query=%s' % (lib.parent.cfg.get('weatherstack_weather', 'key'), quote_plus(place))
+               if sys.version_info.major < 3:
+                       url = url.encode('utf8')
+               weather = json.load(urlopen(url))
                if lib.parent.cfg.getboolean('debug', 'weather'):
                        lib.parent.log('*', "?", repr(weather))
                if 'error' in weather: