Skip to content

Commit

Permalink
Properly handle ssl errors on get_url
Browse files Browse the repository at this point in the history
Fix tests related to ssl errors and record them
  • Loading branch information
lepinkainen committed Dec 29, 2015
1 parent 30a40b2 commit 33ab772
Show file tree
Hide file tree
Showing 6 changed files with 1,204 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cache: pip
python:
- "2.7"
env:
- VCR_RECORD_MODE=none
- VCR_RECORD_MODE=all
- VCR_RECORD_MODE=none # only use recorded tests, errors on nonexisting tests
- VCR_RECORD_MODE=all # don't use recorded tests, do it LIVE

# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
Expand Down
4 changes: 4 additions & 0 deletions pyfibot/modules/module_urltitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ def _handle_youtube_gdata(url):

r = bot.get_url(api_url, params=params)

# get_url returns None on exception
if r is None:
return False

if not r.status_code == 200:
error = r.json().get('error')
if error:
Expand Down
3 changes: 3 additions & 0 deletions pyfibot/pyfibot.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def getUrl(self, url, nocache=False, params=None, headers=None, cookies=None):
except requests.exceptions.InvalidSchema:
log.error("Invalid schema in URI: %s" % url)
return None
except requests.exceptions.SSLError:
log.error("SSL Error when connecting to %s" % url)
return None
except requests.exceptions.ConnectionError:
log.error("Connection error when connecting to %s" % url)
return None
Expand Down

0 comments on commit 33ab772

Please sign in to comment.