@@ -0,0 +1,2273 @@
+#!/usr/bin/python%0A%0Aimport json%0Aimport requests%0Aimport math%0Aimport time%0A%0ADGR = u'%5CN%7BDEGREE SIGN%7D'%0A%0A%0A# def json_load_byteified(file_handle):%0A#     return _byteify(%0A#         json.load(file_handle, object_hook=_byteify),%0A#         ignore_dicts=True%0A#     )%0A#%0A#%0A# def json_loads_byteified(json_text):%0A#     return _byteify(%0A#         json.loads(json_text, object_hook=_byteify),%0A#         ignore_dicts=True%0A#     )%0A#%0A#%0A# def _byteify(data, ignore_dicts = False):%0A#     # if this is a unicode string, return its string representation%0A#     if isinstance(data, unicode):%0A#         return data.encode('utf-8')%0A#     # if this is a list of values, return list of byteified values%0A#     if isinstance(data, list):%0A#         return %5B_byteify(item, ignore_dicts=True) for item in data%5D%0A#     # if this is a dictionary, return dictionary of byteified keys and values%0A#     # but only if we haven't already byteified it%0A#     if isinstance(data, dict) and not ignore_dicts:%0A#         return %7B%0A#             _byteify(key, ignore_dicts=True): _byteify(value, ignore_dicts=True)%0A#             for key, value in data.iteritems()%0A#         %7D%0A#     # if it's anything else, return it in its original form%0A#     return data%0A%0A%0Adef get_weather():%0A    OWM_APP_KEY = open('./conf/owm-apikey.txt', 'r').read().strip('%5Cn')%0A    #threading.Timer(9.0, get_weather).start()%0A%0A    c = requests.get(%22http://api.openweathermap.org/data/2.5/weather?q=tampere,fi&units=metric&lang=fi&APPID=%22+OWM_APP_KEY)%0A    f = requests.get(%22http://api.openweathermap.org/data/2.5/forecast/city?q=tampere,fi&units=metric&lang=fi&APPID=%22+OWM_APP_KEY)%0A    # current = json_loads_byteified(c.content)%0A    # forecast = json_loads_byteified(f.content)%0A    current = json.loads(c.text)%0A    forecast = json.loads(f.text)%0A    i = 1%0A    data = %5B%5D%0A    temp = %5Bstr(int(math.ceil(current%5B%22main%22%5D%5B%22temp%22%5D)))+DGR+%22C%22,%0A            current%5B%22weather%22%5D%5B0%5D%5B%22description%22%5D,%0A            %22%22%5D%0A    data.append(temp)%0A    for item in forecast%5B%22list%22%5D:%0A        temp = %5Btime.strftime(%22%25H:%25M%22, time.localtime(item%5B%22dt%22%5D)),%0A                str(int(math.ceil(item%5B%22main%22%5D%5B%22temp%22%5D)))+DGR+%22C%22,%0A                item%5B%22weather%22%5D%5B0%5D%5B%22description%22%5D%5D%0A        data.append(temp)%0A        if i == 5:%0A            break%0A        else:%0A            i += 1%0A    return data%0A

started new better? weather service