2022-02-24 17:21:25 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Created on Thu Feb 24 17:14:05 2022
|
|
|
|
|
|
|
|
@author: antoine
|
|
|
|
"""
|
|
|
|
|
|
|
|
################
|
|
|
|
### UniSquat ###
|
|
|
|
################
|
|
|
|
|
|
|
|
"""
|
|
|
|
Indique toutes les salles disponibles dans les différents départements de
|
|
|
|
l'Université de Strasbourg.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
# Modules :
|
|
|
|
import datetime
|
2022-02-24 19:29:03 +01:00
|
|
|
# Fichiers locaux :
|
2022-02-24 17:21:25 +01:00
|
|
|
import date_tools
|
|
|
|
import rooms_get as ro
|
2022-02-24 19:29:03 +01:00
|
|
|
import definitions as lib
|
2022-02-24 17:21:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Fonctions :
|
|
|
|
|
|
|
|
def main() :
|
|
|
|
"""
|
|
|
|
Fonction principale.
|
|
|
|
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
None.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
print("~~~ UniSquat ~~~\n")
|
|
|
|
|
|
|
|
date_choice = 0
|
|
|
|
|
|
|
|
while date_choice not in (1,2) :
|
|
|
|
date_choice = int(input("Souhaitez-vous afficher les salles disponibles maintenant (1), où à une date précise (2) ?\n> "))
|
|
|
|
|
|
|
|
if date_choice == 1 :
|
2022-02-24 19:29:03 +01:00
|
|
|
date = datetime.datetime.today()
|
2022-02-24 17:21:25 +01:00
|
|
|
else :
|
|
|
|
date = date_tools.date_input()
|
|
|
|
|
2022-02-25 10:51:34 +01:00
|
|
|
available_rooms = ro.getrooms(date)
|
2022-02-24 17:21:25 +01:00
|
|
|
|
2022-02-24 19:29:03 +01:00
|
|
|
print("Les salles suivantes sont disponibles à " + str(date.hour) + ":" + str(date.minute) + ", le " + str(date.day) + " :\n")
|
2022-02-25 10:51:34 +01:00
|
|
|
for room in available_rooms.values() :
|
|
|
|
if room["free"]:
|
2022-02-25 11:05:05 +01:00
|
|
|
deltasec = room["occupied_at"].timestamp()-date.timestamp()
|
|
|
|
print(" - " + room["name"]+" | occuppée dans : "+str(int(deltasec/60+0.5))+" minutes")
|
|
|
|
print("Voici celles occupées : ")
|
|
|
|
for room in available_rooms.values() :
|
|
|
|
if not room["free"]:
|
|
|
|
deltasec = room["free_at"].timestamp()-date.timestamp()
|
|
|
|
print(" - " + room["name"]+" | libre dans : "+str(int(deltasec/60+0.5))+" minutes")
|
|
|
|
|
2022-02-25 11:20:18 +01:00
|
|
|
if __name__=="__main__":
|
|
|
|
main()
|