exceptions.py 3.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# -*- coding: utf-8 -*-

# Copyright(C) 2014 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.

class BrowserIncorrectPassword(Exception):
    pass


class BrowserForbidden(Exception):
    pass


class BrowserBanned(BrowserIncorrectPassword):
    pass


class BrowserUnavailable(Exception):
    pass


36 37 38 39 40
class BrowserInteraction(Exception):
    pass


class BrowserQuestion(BrowserInteraction):
41 42 43 44 45
    """
    When raised by a browser,
    """
    def __init__(self, *fields):
        self.fields = fields
46 47


48 49 50 51 52
class BrowserRedirect(BrowserInteraction):
    def __init__(self, url):
        self.url = url


53
class CaptchaQuestion(Exception):
54 55 56
    """Site requires solving a CAPTCHA (base class)"""
    # could be improved to pass the name of the backendconfig key

57
    def __init__(self, type=None, **kwargs):
58
        super(CaptchaQuestion, self).__init__("The site requires solving a captcha")
59
        self.type = type
60 61
        for key, value in kwargs.items():
            setattr(self, key, value)
62 63


64 65 66 67 68 69 70 71 72 73
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):
74
    type = 'g_recaptcha'
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92

    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)


93 94 95 96 97 98 99 100
class BrowserHTTPNotFound(BrowserUnavailable):
    pass


class BrowserHTTPError(BrowserUnavailable):
    pass


101 102 103 104
class BrowserHTTPSDowngrade(BrowserUnavailable):
    pass


105 106 107 108
class BrowserSSLError(BrowserUnavailable):
    pass


109 110
class ParseError(Exception):
    pass
111 112 113 114 115 116


class FormFieldConversionWarning(UserWarning):
    """
    A value has been set to a form's field and has been implicitly converted.
    """
Jean Walrave's avatar
Jean Walrave committed
117

118

Jean Walrave's avatar
Jean Walrave committed
119 120
class NoAccountsException(Exception):
    pass
121 122 123 124


class ModuleInstallError(Exception):
    pass
125 126 127 128


class ModuleLoadError(Exception):
    def __init__(self, module_name, msg):
129
        super(ModuleLoadError, self).__init__(msg)
130
        self.module = module_name
131 132 133 134


class ActionNeeded(Exception):
    pass
135 136


137 138 139 140
class AuthMethodNotImplemented(ActionNeeded):
    pass


141 142
class BrowserPasswordExpired(ActionNeeded):
    pass