-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathClassTempo.py
41 lines (37 loc) · 1.05 KB
/
ClassTempo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Gruik coded by GuiguiAbloc
# http://blog.guiguiabloc.fr
# http://api.domogeek.fr
#
import urllib2
import sys
import json
import datetime
from datetime import timedelta
class EDFTempo:
def TempoToday(self):
now = datetime.datetime.now()
today= now.strftime("%Y-%m-%d")
try:
page = urllib2.urlopen('https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter='+today+'&TypeAlerte=TEMPO')
except:
return None
response = json.load(page)
colortoday = response['JourJ']['Tempo']
return colortoday
def TempoTomorrow(self):
now = datetime.datetime.now()
datetomorrow = now + timedelta(days=1)
tomorrow = datetomorrow.strftime("%Y-%m-%d")
try:
page = urllib2.urlopen('https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter='+tomorrow+'&TypeAlerte=TEMPO')
except:
return None
response = json.load(page)
try:
colortomorrow = response['JourJ']['Tempo']
return colortomorrow
except:
return "no color"