From 5bd856c8fcde81d582e086b00678891645fd8109 Mon Sep 17 00:00:00 2001 From: Tomasz Wolniewicz <twoln@umk.pl> Date: Wed, 21 Feb 2024 21:22:21 +0100 Subject: [PATCH] The feeds comparison script --- utils/compare_garr_psnc.sh | 16 +++++++++++ utils/compare_sha.py | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100755 utils/compare_garr_psnc.sh create mode 100644 utils/compare_sha.py diff --git a/utils/compare_garr_psnc.sh b/utils/compare_garr_psnc.sh new file mode 100755 index 0000000..cb66610 --- /dev/null +++ b/utils/compare_garr_psnc.sh @@ -0,0 +1,16 @@ +#!/bin/bash +if [ -z $1 ] +then + echo provide agriment 1 - to compare production and 0 to compare pre-preproduction + exit +fi +date +LEVEL=$1 +GARR='http://test-ot-1.aai-test.garr.it/' +PSNC='https://technical.edugain.org/new/' +URL=${GARR}'api.php?action=list_entity_sha1&opt='${LEVEL} +wget -q -O f1.json $URL +URL=${PSNC}'api.php?action=list_entity_sha1&opt='${LEVEL} +wget -q -O f2.json $URL +python3 compare_sha.py f1.json f2.json +rm f1.json f2.json diff --git a/utils/compare_sha.py b/utils/compare_sha.py new file mode 100644 index 0000000..0a523c5 --- /dev/null +++ b/utils/compare_sha.py @@ -0,0 +1,59 @@ +import sys +import json + +if len(sys.argv) != 3: + print("Usage: "+sys.argv[0]+" first_file second_file") + sys.exit() + +E1 = {} +E2 = {} +F1 = {} +F2 = {} +onlyE1=[] +onlyE2=[] +modified=[] + +# first load both jsons +inp = sys.argv[1] +f = open(inp,"r") +x=json.load(f) +f.close() +for l in x: + E1[l[0]] = l[1] + F1[l[0]] = l[2] + +inp = sys.argv[2] +f = open(inp,"r") +x=json.load(f) +f.close() +for l in x: + E2[l[0]] = l[1] + F2[l[0]] = l[2] + +# now find the diffs +for l in E1: + if l not in E2: + onlyE1.append(l) + continue + if E1[l] != E2[l]: + modified.append(l) + continue + +for l in E2: + if l not in E1: + onlyE2.append(l) + +if len(onlyE1) > 0: + print("Only in feed 1") + for l in onlyE1: + print(l) + +if len(onlyE2) > 0: + print("Only in feed 2") + for l in onlyE2: + print(l) + +if len(modified) > 0: + print("Modified") + for l in modified: + print(l+"; "+F1[l]+"; "+F2[l]) -- GitLab