Fixed update_population crash, when it downloaded incomplete data.

This commit is contained in:
A. Svensson 2015-02-18 21:59:17 +01:00
parent a8e54ece4c
commit ee86f4db15

View File

@ -48,6 +48,7 @@ class ServerParser(object):
soup_data = BeautifulSoup(raw_data)
for server_data in soup_data.find_all('div', 'live_game_status'):
server = self._parse_server_data(server_data)
if server:
servers.append(server)
logging.info('Number of servers parsed: {}'.format(len(servers)))
@ -55,7 +56,12 @@ class ServerParser(object):
def _parse_server_data(self, data):
'''Parse the individual parts of each server.'''
try:
title = data.find('b').text.splitlines()[0].strip()
except AttributeError:
# HACK: I think this happends because the raw data was incomplete.
# No complete data, no server update.
return None
game_url = data.find('span', 'smaller').text
tmp = data.find('a')