From a22de02d3e72d820ce41efb3b599cca1ea746486 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 10 May 2018 11:12:51 -0400 Subject: [PATCH] Add hash checking to getMembershipworksData to minimize unnecessary updates --- doorUpdater.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doorUpdater.py b/doorUpdater.py index 8ce22df..213a030 100755 --- a/doorUpdater.py +++ b/doorUpdater.py @@ -4,6 +4,8 @@ import requests import csv from io import StringIO import urllib3 +from hashlib import md5 +import os from passwords import * @@ -69,6 +71,15 @@ def getMembershipworksData(): print(r.text) sys.exit(1) + newHash = md5(bytes(r.text, 'utf8')).hexdigest() + if os.path.exists('/tmp/doorUpdaterLastHash'): + with open('/tmp/doorUpdaterLastHash', 'r') as f: + if newHash == f.read(): + print("hashes are the same, not updating") + sys.exit(0) + with open('/tmp/doorUpdaterLastHash', 'w') as f: + f.write(newHash) + return r.text def makeMember(member, doorAuth):