Merge branch 'master' of https://forge.chapril.org/CretinsMotorisesIngenieux/FreeRooms_Unistra
This commit is contained in:
commit
018fbd6bbd
@ -38,11 +38,7 @@ def is_bissextile(year) :
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 :
|
return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
|
||||||
return True
|
|
||||||
else :
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def month_days(month, year) :
|
def month_days(month, year) :
|
||||||
"""
|
"""
|
||||||
|
@ -54,8 +54,8 @@ def main() :
|
|||||||
minutes = date.now().time().minute
|
minutes = date.now().time().minute
|
||||||
|
|
||||||
ro.sched_get(date_d)
|
ro.sched_get(date_d)
|
||||||
used_rooms = ro.used_rooms_get(datet)
|
total_rooms, used_rooms = ro.used_rooms_get(datet)
|
||||||
available_rooms = ro.available_rooms_get(used_rooms)
|
available_rooms = ro.available_rooms_get(total_rooms, used_rooms)
|
||||||
|
|
||||||
print("Les salles suivantes sont disponibles à " + str(hour) + ":" + str(minutes) + ", le " + str(date_d) + " :\n")
|
print("Les salles suivantes sont disponibles à " + str(hour) + ":" + str(minutes) + ", le " + str(date_d) + " :\n")
|
||||||
for room in available_rooms :
|
for room in available_rooms :
|
||||||
|
34
rooms.txt
34
rooms.txt
@ -1,34 +0,0 @@
|
|||||||
C10 MATH
|
|
||||||
C11 MATH
|
|
||||||
C13 MATH
|
|
||||||
C14 MATH
|
|
||||||
C15 MATH
|
|
||||||
C1 MATH
|
|
||||||
C31-GPI
|
|
||||||
C31-GPI,C14 MATH
|
|
||||||
C32-MF
|
|
||||||
C33-DUAS
|
|
||||||
C41-MPA
|
|
||||||
C42-CMI
|
|
||||||
C4 MATH
|
|
||||||
C5 MATH
|
|
||||||
C6 MATH
|
|
||||||
C7 MATH
|
|
||||||
C7 MATH,salle non définie
|
|
||||||
C8 MATH
|
|
||||||
C9 MATH
|
|
||||||
Grand Amphi de Maths-Frenkel
|
|
||||||
Petit Amphi de Maths
|
|
||||||
S. 301 MATH
|
|
||||||
S. 309
|
|
||||||
S. 418
|
|
||||||
T01 MATH
|
|
||||||
T02 MATH
|
|
||||||
T03 MATH
|
|
||||||
T11 MATH
|
|
||||||
T20 MATH (PC)
|
|
||||||
T21 MATH (PC)
|
|
||||||
T22 MATH (PC)
|
|
||||||
T23 MATH
|
|
||||||
T24 MATH
|
|
||||||
T40-GPI MATH (PC)
|
|
42
rooms_get.py
42
rooms_get.py
@ -20,18 +20,9 @@ Created on Thu Feb 24 08:51:58 2022
|
|||||||
import requests
|
import requests
|
||||||
import icalendar
|
import icalendar
|
||||||
|
|
||||||
|
|
||||||
# Variables générales :
|
# Variables générales :
|
||||||
sched_filen = "schedule.ics"
|
|
||||||
rooms_filen = "rooms.txt"
|
rooms_filen = "rooms.txt"
|
||||||
|
|
||||||
|
|
||||||
# Récupération des salles :
|
|
||||||
r_file = open(rooms_filen, "r")
|
|
||||||
rooms = r_file.read().splitlines()
|
|
||||||
r_file.close()
|
|
||||||
|
|
||||||
|
|
||||||
# Fonctions :
|
# Fonctions :
|
||||||
|
|
||||||
def sched_get(date) :
|
def sched_get(date) :
|
||||||
@ -46,7 +37,7 @@ def sched_get(date) :
|
|||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
None.
|
Le texte du résultat de la requête.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -56,10 +47,7 @@ def sched_get(date) :
|
|||||||
|
|
||||||
r = requests.get("https://adecons.unistra.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources=30626&projectId=8&calType=ical&firstDate="+year+"-"+month+"-"+day+"&lastDate="+year+"-"+month+"-"+day)
|
r = requests.get("https://adecons.unistra.fr/jsp/custom/modules/plannings/anonymous_cal.jsp?resources=30626&projectId=8&calType=ical&firstDate="+year+"-"+month+"-"+day+"&lastDate="+year+"-"+month+"-"+day)
|
||||||
|
|
||||||
# Téléchargement au format iCal
|
return r.content
|
||||||
f = open(sched_filen, "wb")
|
|
||||||
f.write(r.content)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
|
|
||||||
def used_rooms_get(datet) :
|
def used_rooms_get(datet) :
|
||||||
@ -75,30 +63,30 @@ def used_rooms_get(datet) :
|
|||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
used_rooms : list
|
used_rooms : list
|
||||||
Liste des salles occupées.
|
Liste des salles occupées. total_rooms : list
|
||||||
|
Toutes les salles mentionnées dans le fichier
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Récupération des informations sur l'EDT téléchargé :
|
# Récupération des informations sur l'EDT téléchargé :
|
||||||
cal_file = open(sched_filen, "rb")
|
cal = icalendar.Calendar.from_ical(sched_get(datet))
|
||||||
cal = icalendar.Calendar.from_ical(cal_file.read())
|
|
||||||
|
|
||||||
used_rooms = []
|
used_rooms = []
|
||||||
|
total_rooms = []
|
||||||
|
|
||||||
for comp in cal.walk():
|
for comp in cal.walk():
|
||||||
if comp.name == "VEVENT" :
|
if comp.name == "VEVENT" :
|
||||||
ev_dstart = comp.decoded("dtstart")
|
ev_dstart = comp.decoded("dtstart")
|
||||||
ev_dend = comp.decoded("dtend")
|
ev_dend = comp.decoded("dtend")
|
||||||
|
roomname = str(comp.get("location"))
|
||||||
|
if not roomname in total_rooms:
|
||||||
|
total_rooms.append(roomname)
|
||||||
if ev_dstart.timestamp() <= datet.timestamp() and ev_dend.timestamp() > datet.timestamp() :
|
if ev_dstart.timestamp() <= datet.timestamp() and ev_dend.timestamp() > datet.timestamp() :
|
||||||
if comp.get("location") not in used_rooms :
|
if not roomname in used_rooms :
|
||||||
used_rooms.append(str(comp.get("location")))
|
used_rooms.append(roomname)
|
||||||
|
|
||||||
cal_file.close()
|
return total_rooms, used_rooms
|
||||||
|
|
||||||
return used_rooms
|
def available_rooms_get(total_rooms, used_rooms) :
|
||||||
|
|
||||||
|
|
||||||
def available_rooms_get(used_rooms) :
|
|
||||||
"""
|
"""
|
||||||
Créé la liste des salles disponibles d'après la liste des salles occupées
|
Créé la liste des salles disponibles d'après la liste des salles occupées
|
||||||
'used_rooms'.
|
'used_rooms'.
|
||||||
@ -107,6 +95,8 @@ def available_rooms_get(used_rooms) :
|
|||||||
----------
|
----------
|
||||||
used_rooms : list
|
used_rooms : list
|
||||||
Liste des salles occupées.
|
Liste des salles occupées.
|
||||||
|
total_rooms : list
|
||||||
|
Liste de toute les salles
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
@ -117,7 +107,7 @@ def available_rooms_get(used_rooms) :
|
|||||||
|
|
||||||
available_rooms = []
|
available_rooms = []
|
||||||
|
|
||||||
for room in rooms :
|
for room in total_rooms :
|
||||||
if room not in used_rooms :
|
if room not in used_rooms :
|
||||||
available_rooms.append(room)
|
available_rooms.append(room)
|
||||||
|
|
||||||
|
1153
schedule.ics
1153
schedule.ics
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user