How to use the pyzotero.zotero_errors.UploadError function in pyzotero

To help you get started, we’ve selected a few pyzotero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github urschrei / pyzotero / pyzotero / zotero.py View on Github external
# errors
        upload_list.append(("file", open(attachment, "rb").read()))
        upload_pairs = tuple(upload_list)
        try:
            self.zinstance._check_backoff()
            upload = requests.post(
                url=authdata["url"],
                files=upload_pairs,
                headers={
                    # "Content-Type": authdata['contentType'],
                    "User-Agent": "Pyzotero/%s"
                    % __version__
                },
            )
        except (requests.exceptions.ConnectionError):
            raise ze.UploadError("ConnectionError")
        try:
            upload.raise_for_status()
        except requests.exceptions.HTTPError:
            error_handler(zinstance, upload)
        backoff = upload.get("backoff")
        if backoff:
            zinstance._set_backoff(backoff)
        # now check the responses
        return self._register_upload(authdata, reg_key)