Closed brianwu02 closed 10 years ago
My suspicion is that you're using an old version of nflgame
. Could you try updating? Make sure nfldb
is up to date too, for good measure.
pip install -U nflgame
pip install -U nfldb
Wow, who woulda thunk updating would fix bugs :D. Thank you thank you!
So is this simply a minor bug where nflgame is in some weird edge case state causing UnboundLocalError or is nfl.com the culprit?
Nope, this is just a good ol' fashion bug that would have been caught by an integration test if they existed for nflgame
(or by static analysis in a more civilized language). Note the afflicted piece of code:
for i, t in enumerate(pool.imap(fetch, players.items()), 1):
gid, name, purl = t
progress(i, len(players))
if pid is None:
errors.append('Could not get profile URL for (%s, %s)'
% (gid, name))
continue
assert gid not in metas
pid = profile_id_from_url(purl)
metas[gid] = {'gsis_id': gid, 'gsis_name': name,
'profile_url': purl, 'profile_id': pid}
reverse[pid] = gid
You can see on line 4 that pid
is referenced before it's ever assigned a few lines below it. My guess is that I rearranged the code and didn't test it. And it wasn't triggered because this code is only executed when there is a new player added to the league that hasn't been seen by nflgame
before.
So hopefully fixed for good! :-)
(The intention is that weird edge states induced by NFL.com are handled gracefully. The program shouldn't die because of malformed data.)
running nflgame-update-players:
i wish i could provide more information about the error above other than i was running nfldb-update in cron job and error first occured on 12-01.
Here is last successful update:
Here is the first failure: