From eba98a85764b22971158e752034711cdabedf9c6 Mon Sep 17 00:00:00 2001 From: jnga Date: Mon, 13 Aug 2018 15:18:35 -0400 Subject: [PATCH] Handle attribute error exceptions seen during some image uploadss. (see #694) --- gobotany/plantshare/models.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/gobotany/plantshare/models.py b/gobotany/plantshare/models.py index 5b5978fde..aa994facf 100644 --- a/gobotany/plantshare/models.py +++ b/gobotany/plantshare/models.py @@ -423,15 +423,23 @@ def _extract_gps_data(self, img): direction = gps_info[EXIF_GPSLATITUDEREF] if direction.upper() == 'S': latitude = latitude * -1 - self.target_object.latitude = latitude - # Get longitude. - degrees, minutes, seconds = self._get_dms( - gps_info[EXIF_GPSLONGITUDE]) - longitude = self._get_coordinate(degrees, minutes, seconds) - direction = gps_info[EXIF_GPSLONGITUDEREF] - if direction.upper() == 'W': - longitude = longitude * -1 - self.target_object.longitude = longitude + try: + self.target_object.latitude = latitude + except AttributeError: + print 'target_object NoneType, no latitude attribute' + finally: + # Get longitude. + degrees, minutes, seconds = self._get_dms( + gps_info[EXIF_GPSLONGITUDE]) + longitude = self._get_coordinate(degrees, minutes, + seconds) + direction = gps_info[EXIF_GPSLONGITUDEREF] + if direction.upper() == 'W': + longitude = longitude * -1 + try: + self.target_object.longitude = longitude + except AttributeError: + print 'target_object NoneType, no longitude attribute' class PlantshareGpsImage(ImageSpec):