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:
|
if filename not in self.__files:
|
||||||
self.logger.info("Adding file %s.", filename)
|
self.logger.info("Adding file %s.", filename)
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
self.__files.append(filename)
|
try:
|
||||||
gpx = gpxpy.parse(f)
|
self.__files.append(filename)
|
||||||
for raw in gpx.tracks:
|
gpx = gpxpy.parse(f)
|
||||||
track = Track(raw)
|
for raw in gpx.tracks:
|
||||||
self.__tracks.append(track)
|
track = Track(raw)
|
||||||
trk_month = track.start_time.month
|
self.__tracks.append(track)
|
||||||
trk_year = track.start_time.year
|
trk_month = track.start_time.month
|
||||||
|
trk_year = track.start_time.year
|
||||||
|
|
||||||
if trk_year not in self.__distance:
|
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] = {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
|
self.__distance[trk_year][trk_month] += track.distance / 1000
|
||||||
|
|
||||||
if trk_year not in self.__duration:
|
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] = {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()
|
self.__duration[trk_year][trk_month] += track.duration.total_seconds()
|
||||||
|
|
||||||
if trk_year not in self.__avg_speed:
|
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] = {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.__avg_speed[trk_year][trk_month] = self.__distance[trk_year][trk_month] / (self.__duration[trk_year][trk_month] / 3600)
|
||||||
self.logger.info("Adding done.")
|
self.logger.info("Adding done.")
|
||||||
|
except Exception as exception:
|
||||||
|
# TODO: Add logging mechanism.
|
||||||
|
pass
|
||||||
|
|
||||||
def years(self):
|
def years(self):
|
||||||
ret = None
|
ret = None
|
||||||
|
Loading…
Reference in New Issue
Block a user