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)
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
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
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
def _check_auth(self): if not self.passkey: raise AuthException( 'Your authentication credentials are missing, check your config.' ) return True
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
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
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
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
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
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
def _checkAuth(self): if not self.api_key: raise AuthException('Your authentication credentials for ' + self.name + ' are missing, check your config.') return True
def _checkAuth(self): if self.username and self.password: return True raise AuthException('Your authentication credentials for ' + self.name + ' are missing, check your config.')