Skip to content

Commit

Permalink
add Cloudflare-specific error message on login request
Browse files Browse the repository at this point in the history
  • Loading branch information
gitolicious authored and rbignon committed Jun 18, 2021
1 parent 605af57 commit 11a9654
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion doctoshotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,14 @@ def __init__(self, *args, **kwargs):
self.patient = None

def do_login(self):
self.open(self.BASEURL + '/sessions/new')
try:
self.open(self.BASEURL + '/sessions/new')
except ServerError as e:
if e.response.status_code in [503] \
and 'text/html' in e.response.headers['Content-Type'] \
and 'cloudflare' in e.response.text:
log('Request blocked by CloudFlare', color='red')
raise
try:
self.login.go(json={'kind': 'patient',
'username': self.username,
Expand Down

0 comments on commit 11a9654

Please sign in to comment.