diff --git a/get_data.py b/get_data.py new file mode 100644 index 0000000..97bb8b4 --- /dev/null +++ b/get_data.py @@ -0,0 +1,83 @@ +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< +#include +#include + +#define TAILLE_MAX_BUFFER 50 +#define TAILLE_MOT 8 + +int main() +{ + + FILE *file = popen("python get_data.py","r"); + + char a[TAILLE_MAX_BUFFER], b[TAILLE_MAX_BUFFER], c[TAILLE_MAX_BUFFER]; + + fscanf(file,"%s",a); + fscanf(file,"%s",b); + fscanf(file,"%s",c); + pclose(file); + + int i; + char heure[TAILLE_MOT],minute[TAILLE_MOT],temperature[TAILLE_MOT]; + for(i=0;i<8;i++){ + heure[i]=a[i+2]; + minute[i]=b[i+1]; + temperature[i]=c[i+1]; + } + + heure[8]='\0'; + minute[8]='\0'; + temperature[8]='\0'; + + + + printf("%s\n",heure); + printf("%s\n",minute); + printf("%s\n",temperature); + + return(0); +} -- libgit2 0.21.2