Commit 590f7ecd authored by Sharp Hall's avatar Sharp Hall

Use githubusercontent.com turnout data and add workaround for no last-modified

parent 6e30609b
Pipeline #93814700 canceled with stage
......@@ -6,7 +6,7 @@ from utils import format_time, is_it_after
EXPORT_FILE = 'https://files7.philadelphiavotes.com/election-results/2019_GENERAL/enr/division-level-results.csv'
TURNOUT_URL = 'https://jtannen.github.io/precinct_turnout_philadelphia.csv'
TURNOUT_URL = 'https://raw.githubusercontent.com/jtannen/jtannen.github.io/master/raw_data_philadelphia.csv'
TMP_FILE = '/tmp/live_election.txt'
TURNOUT_TMP = '/tmp/turnout.csv'
......@@ -19,8 +19,9 @@ def download(url, dest):
for chunk in f.iter_content(chunk_size=8192):
out.write(chunk)
print('Done.')
assert f.headers['Last-Modified'][-4:] in [' GMT', ' UTC']
return datetime.datetime.strptime(f.headers['Last-Modified'][:-4], "%a, %d %b %Y %H:%M:%S")
modified = f.headers.get('Last-Modified', 'Mon, 11 Nov 2019 21:02:39 GMT')
assert modified[-4:] in [' GMT', ' UTC']
return datetime.datetime.strptime(modified[:-4], "%a, %d %b %Y %H:%M:%S")
def hash_file(filename):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment