Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pass
self.zot = None
self.zotLastMod = None
try:
self.zot = zotero.Zotero(library_id, library_type, api_key)
self.zotLastMod = self.zot.last_modified_version() # v1.1.1
DBInstance.dbInstanceCache[(library_id, library_type, api_key)] = self
if library_type == 'group':
log("Loading: https://www.zotero.org/groups/%s/items" % library_id)
else:
log("Loading: %s" % library_id)
except zotero_errors.UserNotAuthorised:
error("UserNotAuthorised: Set correct Zotero API key in settings.py for library ID %s." % library_id)
raise SystemExit(1)
return self
def error_handler(zot, req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEntityTooLarge,
428: ze.PreConditionRequired,
429: ze.TooManyRequests,
}
def err_msg(req):
""" Return a nicely-formatted error message
"""
return "\nCode: %s\nURL: %s\nMethod: %s\nResponse: %s" % (
req.status_code,
# error.msg,
req.url,
req.request.method,
def error_handler(req):
""" Error handler for HTTP requests
"""
error_codes = {
400: ze.UnsupportedParams,
401: ze.UserNotAuthorised,
403: ze.UserNotAuthorised,
404: ze.ResourceNotFound,
409: ze.Conflict,
412: ze.PreConditionFailed,
413: ze.RequestEntityTooLarge,
428: ze.PreConditionRequired,
429: ze.TooManyRequests,
}
def err_msg(req):
""" Return a nicely-formatted error message
"""
return "\nCode: %s\nURL: %s\nMethod: %s\nResponse: %s" % (
req.status_code,
# error.msg,
req.url,
def _verify_client_validity(self):
# Check if Zotero can be accessed with current credentials
try:
self._client.collections()
except zotero_errors.PyZoteroError as err:
self._client = None
if isinstance(err, zotero_errors.UserNotAuthorised):
raise HTTPError(403)
else:
raise err
def _verify_client_validity(self):
# Check if Zotero can be accessed with current credentials
try:
self._client.collections()
except zotero_errors.PyZoteroError as err:
self._client = None
if isinstance(err, zotero_errors.UserNotAuthorised):
raise HTTPError(403)
else:
raise err