import locale import threading import time import requests import json import traceback #import feedparser LOCALE_LOCK = threading.Lock() time_format = 24 # 12 or 24 weather_api_token = '76e35ed2404406f58fe91265afacbb2b' # create account at https://darksky.net/dev/ weather_lang = 'fr' # see https://darksky.net/dev/docs/forecast for full list of language parameters values weather_unit = 'auto' # see https://darksky.net/dev/docs/forecast for full list of unit parameters values latitude = '39.917' # Set this if IP location lookup does not work for you (must be a string) longitude = '116.433' # Set this if IP location lookup does not work for you (must be a string) def tick(): if time_format == 12: heure = int(time.strftime('%M %p')) #hour in 12h format minute = int(time.strftime('%M %p')) else: heure = int(time.strftime('%H')) #hour in 24h format minute =int(time.strftime('%M')) return(heure,minute) def get_weather(): weather_req_url = "https://api.darksky.net/forecast/%s/%s,%s?lang=%s&units=%s" % (weather_api_token, latitude, longitude, weather_lang, weather_unit) r = requests.get(weather_req_url) weather_obj = json.loads(r.text) temperature2 = int(weather_obj['currently']['temperature']) return(temperature2) def dec2bin(d,nb=6): if d == 0: return "0".zfill(nb) if d<0: d += 1<