예제 #1
0
    def _checkAuthFromData(self, data):

        if 'feed' not in data or 'entries' not in data:
            return self._checkAuth()

        try:
            bozo = int(data['bozo'])
            bozo_exception = data['bozo_exception']
            err_code = int(data['feed']['error']['code'])
            err_desc = data['feed']['error']['description']
            if not err_code or err_desc:
                raise
        except Exception:
            return True

        if err_code == 100:
            raise AuthException("Your API key for " + self.name +
                                " is incorrect, check your config.")
        elif err_code == 101:
            raise AuthException(
                "Your account on " + self.name +
                " has been suspended, contact the administrator.")
        elif err_code == 102:
            raise AuthException(
                "Your account isn't allowed to use the API on " + self.name +
                ", contact the administrator")
        elif bozo == 1:
            raise Exception(bozo_exception)
        else:
            logger.log(
                u"Unknown error given from " + self.name + ": " + err_desc,
                logger.ERROR)
예제 #2
0
파일: newznab.py 프로젝트: 6328484/sickr425
    def _checkAuthFromData(self, data):

        try:
            data[b'feed']
            data[b'entries']
        except (AttributeError, KeyError):
            return self._checkAuth()

        try:
            if int(data[b'bozo']) == 1:
                raise Exception(data[b'bozo_exception'])
        except (AttributeError, KeyError):
            pass

        try:
            err_code = data[b'feed'][b'error'][b'code']
            err_desc = data[b'feed'][b'error'][b'description']

            if int(err_code) == 100:
                raise AuthException("Your API key for " + self.name +
                                    " is incorrect, check your config.")
            elif int(err_code) == 101:
                raise AuthException(
                    "Your account on " + self.name +
                    " has been suspended, contact the administrator.")
            elif int(err_code) == 102:
                raise AuthException(
                    "Your account isn't allowed to use the API on " +
                    self.name + ", contact the administrator")
            raise Exception("Unknown error: %s" % err_desc)
        except (AttributeError, KeyError):
            pass

        return True
예제 #3
0
파일: hdbits.py 프로젝트: weevis/SickRage
    def _checkAuth(self):

        if not self.username or not self.passkey:
            raise AuthException("Your authentication credentials for " +
                                self.name + " are missing, check your config.")

        return True
예제 #4
0
    def _check_auth(self):

        if not self.username or not self.passkey:
            raise AuthException(('Your authentication credentials for %s are '
                                 'missing, check your config.') % self.name)

        return True
예제 #5
0
    def _check_auth(self):
        if not self.passkey:
            raise AuthException(
                'Your authentication credentials are missing, check your config.'
            )

        return True
예제 #6
0
    def _checkAuthFromData(self, parsed_data, is_XML=True):

        if parsed_data is None:
            return self._checkAuth()

        if is_XML:
            # provider doesn't return xml on error
            return True
        else:
            parsedJSON = parsed_data

            if 'notice' in parsedJSON:
                description_text = parsedJSON.get('notice')

                if 'information is incorrect' in parsedJSON.get('notice'):
                    logger.log(
                        u"Incorrect authentication credentials for " +
                        self.name + " : " + str(description_text),
                        logger.DEBUG)
                    raise AuthException(
                        "Your authentication credentials for " + self.name +
                        " are incorrect, check your config.")

                elif '0 results matched your terms' in parsedJSON.get(
                        'notice'):
                    return True

                else:
                    logger.log(
                        u"Unknown error given from " + self.name + " : " +
                        str(description_text), logger.DEBUG)
                    return False

            return True
예제 #7
0
    def _checkAuthFromData(self, data):
        if not self.passkey:
            self._checkAuth()
        elif not (data['entries'] and data['feed']):
            logger.log(u"Incorrect authentication credentials for " + self.name, logger.DEBUG)
            raise AuthException(
                u"Your authentication credentials for " + self.name + " are incorrect, check your config")

        return True
예제 #8
0
    def _checkAuthFromData(self, parsedJSON):

        if parsedJSON is None:
            return self._check_auth()

        if 'api-error' in parsedJSON:
            logger.log("Incorrect authentication credentials: {0}".format(parsedJSON['api-error']), logger.DEBUG)
            raise AuthException(
                "Your authentication credentials for " + self.name + " are incorrect, check your config.")

        return True
예제 #9
0
    def _checkAuthFromData(self, data):

        if 'error' in data:
            logger.log(
                u'Incorrect authentication credentials for ' + self.name +
                ' : ' + data['error'], logger.DEBUG)
            raise AuthException('Your authentication credentials for ' +
                                self.name +
                                ' are incorrect, check your config.')

        return True
예제 #10
0
    def _checkAuthFromData(self, parsedJSON):

        if 'status' in parsedJSON and 'message' in parsedJSON:
            if parsedJSON.get('status') == 5:
                logger.log(
                    u"Incorrect authentication credentials for " + self.name +
                    " : " + parsedJSON['message'], logger.DEBUG)
                raise AuthException("Your authentication credentials for " +
                                    self.name +
                                    " are incorrect, check your config.")

        return True
예제 #11
0
    def _checkAuthFromData(self, parsedJSON):

        if parsedJSON is None:
            return self._checkAuth()

        if 'api-error' in parsedJSON:
            logging.debug("Incorrect authentication credentials: % s" %
                          parsedJSON['api-error'])
            raise AuthException("Your authentication credentials for " +
                                self.name +
                                " are incorrect, check your config.")

        return True
예제 #12
0
    def _checkAuth(self):
        if not self.api_key:
            raise AuthException('Your authentication credentials for ' + self.name + ' are missing, check your config.')

        return True
예제 #13
0
    def _checkAuth(self):
        if self.username and self.password:
            return True

        raise AuthException('Your authentication credentials for ' +
                            self.name + ' are missing, check your config.')