init master
authorOlivier Matz <zer0@droids-corp.org>
Wed, 12 May 2021 08:18:41 +0000 (10:18 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Wed, 12 May 2021 08:18:41 +0000 (10:18 +0200)
vitemadose-check.py [new file with mode: 0644]
vitemadose-check.sh [new file with mode: 0755]
vitemadose.png [new file with mode: 0644]

diff --git a/vitemadose-check.py b/vitemadose-check.py
new file mode 100644 (file)
index 0000000..c5f0ac9
--- /dev/null
@@ -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 (executable)
index 0000000..fd9dcfc
--- /dev/null
@@ -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 (file)
index 0000000..b77dcf1
Binary files /dev/null and b/vitemadose.png differ