Skip to content

Commit

Permalink
More hotfixes after testing on staging
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni committed Nov 25, 2020
1 parent e5ffd4a commit 55a46e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ckanext/doi/commands/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ckanext.doi.model.crud import DOIQuery
from ckanext.doi.model.doi import DOI
from ckanext.doi.model.repo import Repository
from datacite.errors import DataCiteServerError
from datacite.errors import DataCiteError

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -113,7 +113,7 @@ def update_doi(self, pkg_id):
try:
client.set_metadata(record.identifier, xml_dict)
print(u'Updated "{0}".'.format(title))
except DataCiteServerError as e:
except DataCiteError as e:
print(u'Error while trying to update "{0}" (DOI {1}): {2}'.format(title,
record.identifier,
e.message))
Expand Down
2 changes: 1 addition & 1 deletion ckanext/doi/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def check_for_update(self, doi, xml_dict):
:return: True if the two are the same, False if not
'''
posted_xml = self.get_metadata(doi)
if posted_xml is None:
if posted_xml is None or posted_xml.strip() == u'':
return False
posted_xml_dict = dict(xmltodict.parse(posted_xml).get(u'resource', {}))
new_xml_dict = dict(xmltodict.parse(schema42.tostring(xml_dict))[u'resource'])
Expand Down
4 changes: 4 additions & 0 deletions ckanext/doi/lib/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ def _add_required(key, get_func):
# handle an item
metadata_dict, errors = plugin.build_metadata_dict(pkg_dict, metadata_dict, errors)

for k in required:
if metadata_dict.get(k) is None and errors.get(k) is None:
errors[k] = DOIMetadataException('Required field cannot be None')

required_errors = {k: e for k, e in errors.items() if k in required}
if len(required_errors) > 0:
error_msg = 'Could not extract metadata for the following required keys: {0}'.format(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from setuptools import find_packages, setup

__version__ = u'2.0.1'
__version__ = u'2.0.2'

with open(u'README.md', u'r') as f:
__long_description__ = f.read()
Expand Down

0 comments on commit 55a46e6

Please sign in to comment.