Add hash checking to getMembershipworksData

to minimize unnecessary updates
This commit is contained in:
Adam Goldsmith 2018-05-10 11:12:51 -04:00
parent c24ba626a7
commit a22de02d3e

View File

@ -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):