From: Olivier Matz Date: Wed, 12 May 2021 08:18:41 +0000 (+0200) Subject: init X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=vitemadose-check.git init --- c97a23387987734641832a310f84329406b38a7d diff --git a/vitemadose-check.py b/vitemadose-check.py new file mode 100644 index 0000000..c5f0ac9 --- /dev/null +++ b/vitemadose-check.py @@ -0,0 +1,30 @@ +import json +import os +import sys + +def print_chronodose(basedir, dept): + print('------ %d' % (dept)) + filename = os.path.join(basedir, '%d.json' % dept) + with open(filename) as f: + jdata = json.load(f) + + for centre in jdata['centres_disponibles']: + appointment_schedules = centre.get('appointment_schedules') + if not appointment_schedules: + continue + for appointment_schedule in appointment_schedules: + name = appointment_schedule.get('name') + total = appointment_schedule.get('total') + if name == 'chronodose' and total != 0: + break + else: + continue + + print(centre['nom']) + print(f' {total} creneau(x) chronodose') + print(f' {centre["url"]}') + print(' %s' % ', '.join(centre["vaccine_type"])) + +basedir = sys.argv[1] +print_chronodose(basedir, 59) +print_chronodose(basedir, 62) diff --git a/vitemadose-check.sh b/vitemadose-check.sh new file mode 100755 index 0000000..fd9dcfc --- /dev/null +++ b/vitemadose-check.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +ROOTDIR=$(dirname $(readlink -e $0)) +touch ${ROOTDIR}/last +other_pids=$(pidof -x -o $$ vitemadose-check.sh) +[ -n "${other_pids}" ] && kill ${other_pids} + +while true; do + mv ${ROOTDIR}/last ${ROOTDIR}/prev + #git pull --rebase + rm -f ${ROOTDIR}/rdv.zip + rm -rf ${ROOTDIR}/rdv + wget -O ${ROOTDIR}/rdv.zip https://gitlab.com/ViteMaDose/vitemadose/-/jobs/artifacts/main/download?job=trouver_les_rdv + mkdir ${ROOTDIR}/rdv + cd ${ROOTDIR}/rdv + unzip ../rdv.zip + cd ${ROOTDIR} + python3 vitemadose-check.py ${ROOTDIR}/rdv/data/output > ${ROOTDIR}/last + if ! cmp -s last prev; then + echo "nouveaux creneaux" + notify-send -i $PWD/vitemadose.png "nouveaux creneaux" + fi + echo ================== + cat last + echo ================== + sleep 120 +done diff --git a/vitemadose.png b/vitemadose.png new file mode 100644 index 0000000..b77dcf1 Binary files /dev/null and b/vitemadose.png differ