This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
vincennes-2014/update-vincennes-content.py

24 lines
693 B
Python
Executable File

#! /usr/bin/env python
import json
import requests
from hobo.deploy.signals import notify_agents
from hobo.environment.models import Variable
PARTS = ['menu', 'demarches', 'partenaires', 'agenda', 'magazine', 'autopromo',
'services', 'acces-directs', 'kiosque', 'grand-projets', 'actualites']
for part in PARTS:
r = requests.get('https://www.vincennes.fr/api/data/(Element)/' + part)
r.raise_for_status()
variable, created = Variable.objects.get_or_create(
name=part.replace('-', '_'),
defaults={'auto': True})
if variable.json == r.json():
continue
variable.value = json.dumps(r.json())
variable.save()
notify_agents(None)