portail/scripts/generate_global_info.py

28 lines
730 B
Python
Raw Normal View History

2019-08-30 19:34:40 +00:00
import os, json, pytz
2019-08-30 19:16:24 +00:00
from datetime import datetime, timedelta
2019-08-30 19:07:25 +00:00
def main():
2019-08-30 19:34:40 +00:00
zone = ' '.join(pytz.country_timezones['fr'])
tz = pytz.timezone(zone)
now = datetime.now(tz)
2019-08-30 19:16:24 +00:00
2019-08-30 19:07:25 +00:00
info = {
2019-08-30 19:34:40 +00:00
"lastupdate": datetime.strftime(now, "%d/%m/%Y %X")
2019-08-30 19:07:25 +00:00
}
save(info)
def save(info):
# Récupération du répertoire racine du repo
rootFolder = os.path.join(os.path.dirname(__file__), '..')
# Répertoire pour stocker le fichier de sortie
dataFolder = os.path.join(rootFolder, 'site', 'data')
statsFilePath = os.path.abspath(
os.path.join(dataFolder, 'global.json'))
with open(statsFilePath, "w") as file_write:
json.dump(info, file_write)
if __name__ == "__main__":
main()