diff --git a/CHANGELOG.md b/CHANGELOG.md index 3658667..75163ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ Formatted as described on http://keepachangelog.com/. ## Unreleased +## [2.2.1] - 2017-03-07 + +### Fixed + +- Web service has internal server error when fragment has no molblock (#45) + ## [2.2.0] - 2017-02-23 ### Changed diff --git a/kripodb/version.py b/kripodb/version.py index 634bd63..7412679 100644 --- a/kripodb/version.py +++ b/kripodb/version.py @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version_info__ = ('2', '2', '0') +__version_info__ = ('2', '2', '1') __version__ = '.'.join(__version_info__) diff --git a/kripodb/webservice/server.py b/kripodb/webservice/server.py index 7c7c2d8..75c9378 100644 --- a/kripodb/webservice/server.py +++ b/kripodb/webservice/server.py @@ -14,6 +14,8 @@ """Kripo datafiles wrapped in a webservice""" from __future__ import absolute_import +from _ctypes import ArgumentError + from pkg_resources import resource_filename import logging @@ -125,7 +127,8 @@ def get_fragments(fragment_ids=None, pdb_codes=None): # connexion.problem is using json.dumps instead of flask custom json encoder, so performing convert myself # TODO remove mol2string conversion when https://github.com/zalando/connexion/issues/266 is fixed for fragment in fragments: - fragment['mol'] = MolToMolBlock(fragment['mol']) + if fragment['mol']: + fragment['mol'] = MolToMolBlock(fragment['mol']) ext = {'absent_identifiers': missing_ids, 'fragments': fragments} return connexion.problem(404, title, description, ext=ext) return fragments @@ -154,6 +157,11 @@ def get_fragment_svg(fragment_id, width, height): with FragmentsDb(fragments_db_filename) as fragmentsdb: try: fragment = fragmentsdb[fragment_id] + if not fragment['mol']: + title = 'Not Found' + description = 'Fragment with identifier \'{0}\' has no molblock'.format(fragment_id) + ext = {'identifier': fragment_id} + return connexion.problem(404, title, description, ext=ext) mol = fragment['mol'] return mol2svg(mol, width, height) except LookupError: