Add exception catching
This commit is contained in:
parent
320bab0188
commit
7a7d6dedf3
@ -61,26 +61,30 @@ class Tracks(object):
|
||||
if filename not in self.__files:
|
||||
self.logger.info("Adding file %s.", filename)
|
||||
with open(filename, 'r') as f:
|
||||
self.__files.append(filename)
|
||||
gpx = gpxpy.parse(f)
|
||||
for raw in gpx.tracks:
|
||||
track = Track(raw)
|
||||
self.__tracks.append(track)
|
||||
trk_month = track.start_time.month
|
||||
trk_year = track.start_time.year
|
||||
try:
|
||||
self.__files.append(filename)
|
||||
gpx = gpxpy.parse(f)
|
||||
for raw in gpx.tracks:
|
||||
track = Track(raw)
|
||||
self.__tracks.append(track)
|
||||
trk_month = track.start_time.month
|
||||
trk_year = track.start_time.year
|
||||
|
||||
if trk_year not in self.__distance:
|
||||
self.__distance[trk_year] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0}
|
||||
self.__distance[trk_year][trk_month] += track.distance / 1000
|
||||
if trk_year not in self.__distance:
|
||||
self.__distance[trk_year] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0}
|
||||
self.__distance[trk_year][trk_month] += track.distance / 1000
|
||||
|
||||
if trk_year not in self.__duration:
|
||||
self.__duration[trk_year] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0}
|
||||
self.__duration[trk_year][trk_month] += track.duration.total_seconds()
|
||||
if trk_year not in self.__duration:
|
||||
self.__duration[trk_year] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0}
|
||||
self.__duration[trk_year][trk_month] += track.duration.total_seconds()
|
||||
|
||||
if trk_year not in self.__avg_speed:
|
||||
self.__avg_speed[trk_year] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0}
|
||||
self.__avg_speed[trk_year][trk_month] = self.__distance[trk_year][trk_month] / (self.__duration[trk_year][trk_month] / 3600)
|
||||
self.logger.info("Adding done.")
|
||||
if trk_year not in self.__avg_speed:
|
||||
self.__avg_speed[trk_year] = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0}
|
||||
self.__avg_speed[trk_year][trk_month] = self.__distance[trk_year][trk_month] / (self.__duration[trk_year][trk_month] / 3600)
|
||||
self.logger.info("Adding done.")
|
||||
except Exception as exception:
|
||||
# TODO: Add logging mechanism.
|
||||
pass
|
||||
|
||||
def years(self):
|
||||
ret = None
|
||||
|
Loading…
Reference in New Issue
Block a user