Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
theo@manjaro | ee35260d97 | |
theo@manjaro | dda111f4cf |
7
app.py
7
app.py
|
@ -16,6 +16,7 @@ import pytz
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
import git
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
|
@ -68,6 +69,12 @@ GLOBAL_CONTEXT["DOMAIN"] = "https://unisquat.alwaysdata.net"
|
||||||
# Timezone du serveur :
|
# Timezone du serveur :
|
||||||
TIMEZONE = pytz.timezone("Europe/Paris")
|
TIMEZONE = pytz.timezone("Europe/Paris")
|
||||||
|
|
||||||
|
# Branche actuelle git
|
||||||
|
GLOBAL_CONTEXT["GIT_BRANCH"] = git.get_active_branch_name()
|
||||||
|
|
||||||
|
# Hash du commit actuel git
|
||||||
|
GLOBAL_CONTEXT["GIT_COMMIT"] = git.get_git_revision()
|
||||||
|
|
||||||
# Globales :
|
# Globales :
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def get_active_branch_name(base_path="."):
|
||||||
|
head_dir = Path(base_path) / ".git" / "HEAD"
|
||||||
|
with head_dir.open("r") as f:
|
||||||
|
content = f.read().splitlines()
|
||||||
|
|
||||||
|
for line in content:
|
||||||
|
if line[0:4] == "ref:":
|
||||||
|
return line.partition("refs/heads/")[2]
|
||||||
|
|
||||||
|
def get_git_revision(base_path=".", short = True):
|
||||||
|
git_dir = Path(base_path) / '.git'
|
||||||
|
with (git_dir / 'HEAD').open('r') as head:
|
||||||
|
ref = head.readline().split(' ')[-1].strip()
|
||||||
|
|
||||||
|
with (git_dir / ref).open('r') as git_hash:
|
||||||
|
hash = git_hash.readline().strip()
|
||||||
|
if short:
|
||||||
|
return hash[:7]
|
||||||
|
else:
|
||||||
|
return hash
|
|
@ -22,6 +22,7 @@ import pytz
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
# Fichiers locaux :
|
# Fichiers locaux :
|
||||||
from objects import Room
|
from objects import Room
|
||||||
|
@ -248,13 +249,8 @@ def get_tot_rooms(datet, depts, ignore_list) :
|
||||||
# sur une période de 'margintime' mois :
|
# sur une période de 'margintime' mois :
|
||||||
cals = list() # Liste des EDT des départements choisis
|
cals = list() # Liste des EDT des départements choisis
|
||||||
for d in depts :
|
for d in depts :
|
||||||
if datet.month < 12 :
|
|
||||||
result = sched_get(datet, d.link,
|
result = sched_get(datet, d.link,
|
||||||
datet.replace(month = datet.month + margintime),
|
datet + datetime.timedelta(margintime),
|
||||||
NO_CACHE)
|
|
||||||
else :
|
|
||||||
result = sched_get(datet, d.link,
|
|
||||||
datet.replace(month = 1, year = datet.year + 1),
|
|
||||||
NO_CACHE)
|
NO_CACHE)
|
||||||
# # Utilisation du module 'ics' pour le tri du calendrier dans l'ordre
|
# # Utilisation du module 'ics' pour le tri du calendrier dans l'ordre
|
||||||
# # chronologique :
|
# # chronologique :
|
||||||
|
|
Loading…
Reference in New Issue