From 664804540b0055f83f303c90c29f228c5c3d23bd Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 31 Mar 2018 20:00:01 +0200 Subject: [PATCH] stable_backport: add *CaptchaQuestion exceptions --- .../stable_backport_data/weboob_exceptions.py | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tools/stable_backport_data/weboob_exceptions.py b/tools/stable_backport_data/weboob_exceptions.py index 0db9fb13f2..e1912dfbf1 100644 --- a/tools/stable_backport_data/weboob_exceptions.py +++ b/tools/stable_backport_data/weboob_exceptions.py @@ -7,4 +7,40 @@ class AuthMethodNotImplemented(Exception): class CaptchaQuestion(Exception): - pass + """Site requires solving a CAPTCHA (base class)""" + # could be improved to pass the name of the backendconfig key + + def __init__(self, type=None, **kwargs): + super(CaptchaQuestion, self).__init__("The site requires solving a captcha") + self.type = type + for key, value in kwargs.items(): + setattr(self, key, value) + + +class ImageCaptchaQuestion(CaptchaQuestion): + type = 'image_captcha' + + image_data = None + + def __init__(self, image_data): + super(ImageCaptchaQuestion, self).__init__(self.type, image_data=image_data) + + +class NocaptchaQuestion(CaptchaQuestion): + type = 'g_recaptcha' + + website_key = None + website_url = None + + def __init__(self, website_key, website_url): + super(NocaptchaQuestion, self).__init__(self.type, website_key=website_key, website_url=website_url) + + +class RecaptchaQuestion(CaptchaQuestion): + type = 'g_recaptcha' + + website_key = None + website_url = None + + def __init__(self, website_key, website_url): + super(RecaptchaQuestion, self).__init__(self.type, website_key=website_key, website_url=website_url) -- GitLab