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.
2015-11-04 10:14:05 +01:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
2017-12-28 10:53:55 +01:00
|
|
|
import json
|
2015-11-04 10:14:05 +01:00
|
|
|
import requests
|
|
|
|
|
2017-12-28 10:53:55 +01:00
|
|
|
from hobo.deploy.signals import notify_agents
|
|
|
|
from hobo.environment.models import Variable
|
2015-11-04 10:14:05 +01:00
|
|
|
|
|
|
|
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()
|
2017-12-28 10:53:55 +01:00
|
|
|
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)
|