Merge pull request #412 from terminalmage/scores

Catch ConnectionResetError when making API request
This commit is contained in:
facetoe 2016-07-22 20:30:34 +08:00 committed by GitHub
commit 2603a394cd
2 changed files with 3 additions and 3 deletions

View File

@ -76,7 +76,7 @@ class ScoresBackend(SettingsBase):
exc.code, exc.reason, exc.url, exc.code, exc.reason, exc.url,
) )
return {} return {}
except URLError as exc: except (ConnectionResetError, URLError) as exc:
self.logger.critical('Error making request to %s: %s', url, exc) self.logger.critical('Error making request to %s: %s', url, exc)
return {} return {}

View File

@ -269,7 +269,7 @@ class MLB(ScoresBackend):
ret['delay'] = game.get('reason', 'Unknown') ret['delay'] = game.get('reason', 'Unknown')
elif ret['status'] == 'postponed': elif ret['status'] == 'postponed':
ret['postponed'] = game.get('reason', 'Unknown Reason') ret['postponed'] = game.get('reason', 'Unknown Reason')
elif ret['status'] == 'game_over': elif ret['status'] in ('game_over', 'completed_early'):
ret['status'] = 'final' ret['status'] = 'final'
elif ret['status'] not in ('in_progress', 'final'): elif ret['status'] not in ('in_progress', 'final'):
ret['status'] = 'pregame' ret['status'] = 'pregame'
@ -277,7 +277,7 @@ class MLB(ScoresBackend):
try: try:
inning = game.get('inning', '0') inning = game.get('inning', '0')
ret['extra_innings'] = inning \ ret['extra_innings'] = inning \
if ret['status'] == 'final' and int(inning) > 9 \ if ret['status'] == 'final' and int(inning) != 9 \
else '' else ''
except ValueError: except ValueError:
ret['extra_innings'] = '' ret['extra_innings'] = ''