Skip to content

Commit

Permalink
Handle attribute error exceptions seen during some image uploadss. (see
Browse files Browse the repository at this point in the history
  • Loading branch information
jnga committed Aug 13, 2018
1 parent 8c6e101 commit eba98a8
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions gobotany/plantshare/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit eba98a8

Please sign in to comment.