How to use the datacite.errors.DataCiteError function in datacite

To help you get started, we’ve selected a few datacite 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 galterlibrary / InvenioRDM-at-NU / cd2h_repo_project / modules / doi / tasks.py View on Github external
doi_pid.register()

            # Update deposit/record
            deposit['doi'] = minted_doi
            record['doi'] = minted_doi
            deposit.commit()
            record.commit()
            # The above only flushes (no db commit). The below is needed to
            # persist the changes to the db.
            db.session.commit()

            # Re-index deposit/record
            RecordIndexer().index(deposit)
            RecordIndexer().index(record)

    except (HttpError, DataCiteError) as e:
        register_doi.retry(exc=e)
    except RequestError:
        current_app.logger.exception('Could not index {}.'.format(record))
    except Exception as e:
        current_app.logger.exception(
            'Exception in register_doi for recid_pid_value: {}. Retrying...'
            .format(recid_pid_value))
        register_doi.retry(exc=e)
github inveniosoftware / invenio / invenio / modules / pidstore / providers / datacite.py View on Github external
def update(self, pid, *args, **kwargs):
        """Update metadata associated with a DOI.

        This can be called before/after a DOI is registered.
        """
        url = self._get_url(kwargs)
        doc = self._get_doc(kwargs)

        if pid.is_deleted():
            pid.log("UPDATE", "Reactivate in DataCite")

        try:
            # Set metadata
            self.api.metadata_post(doc)
            self.api.doi_post(pid.pid_value, url)
        except DataCiteError as e:
            pid.log("UPDATE", "Failed with %s" % e.__class__.__name__)
            return False
        except HttpError as e:
            pid.log("UPDATE", "Failed with HttpError - %s" % unicode(e))
            return False
        else:
            if pid.is_deleted():
                pid.log(
                    "UPDATE",
                    "Successfully updated and possibly registered in DataCite"
                )
            else:
                pid.log("UPDATE", "Successfully updated in DataCite")
        return True
github EUDAT-B2SHARE / b2share / b2share / modules / records / minters.py View on Github external
else:
        doi_id = generate_doi(rec_pid.pid_value)
        doi = DataCiteProvider.create(doi_id,
                                      object_type='rec',
                                      object_uuid=rec_pid.object_uuid,
                                      status=PIDStatus.RESERVED)
        data['_pid'].append({'value': doi_id, 'type': 'DOI'})

    throw_on_failure = current_app.config.get('CFG_FAIL_ON_MISSING_DOI', True)
    try:
        doc = datacite_v31.serialize(doi.pid, data)
        if fake_it: # don't actually register DOI, just pretend to do so
            doi.pid.register()
        else:
            doi.register(url=url, doc=doc)
    except DataCiteError as e:
        if throw_on_failure:
            raise e
        else:
            current_app.logger.warning(e)