diff --git a/bicycle_statistics/__main__.py b/bicycle_statistics/__main__.py index f99f882..669c3f2 100644 --- a/bicycle_statistics/__main__.py +++ b/bicycle_statistics/__main__.py @@ -13,8 +13,8 @@ LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s" UPDATE_INTERVAL = 60 -logging.basicConfig(format=LOG_FORMAT, level=log_level, filename=LOG_FILE) -# logging.basicConfig(format=LOG_FORMAT, level=log_level) +# logging.basicConfig(format=LOG_FORMAT, level=log_level, filename=LOG_FILE) +logging.basicConfig(format=LOG_FORMAT, level=log_level) log = logging.getLogger('bicycle-statistics') def parse_args(): diff --git a/gpx2html/__init__.py b/gpx2html/__init__.py index b7c6e68..f890f95 100755 --- a/gpx2html/__init__.py +++ b/gpx2html/__init__.py @@ -140,12 +140,12 @@ class Gpx2Html(object): 'Average Speed', 'Month', 'km/h', os.path.join(self.outfolder, 'avg_spd.png')) + now = datetime.datetime.now() # Accumulated distance: accumulated_distance = dict() for year in self.tracks.years(): acc_year_dist = list() start_date = datetime.datetime(year, 1, 1) - now = datetime.datetime.now() end_date = datetime.datetime(year, 12, 31) if year == now.year: end_date = now @@ -162,6 +162,25 @@ class Gpx2Html(object): "Accumulated Distance", 'Month', 'km', os.path.join(self.outfolder, 'acc_dist.png')) + # Expected year distance: + start_date =datetime.datetime(now.year, 1, 1) + end_date = now + tracks = self.tracks.tracks(start_date, end_date) + acc_year_dist = list() + exp_year_dist = list() + for date in generate_date_list(start_date, end_date): + date_distance = get_distance_by_date(tracks, date) + try: + acc_year_dist.append(date_distance + acc_year_dist[-1]) + except IndexError: + acc_year_dist.append(date_distance) + expexted_distance = acc_year_dist[-1] / date.timetuple().tm_yday * 365 + exp_year_dist.append(expexted_distance) + xyz = dict() + xyz['driven'] = acc_year_dist + xyz['expected'] = exp_year_dist + plot_line_chart(xyz, MONTH_LABELS[:now.month], "Distance", 'Month', + 'km', os.path.join(self.outfolder, 'exp_dist.png')) end_date = datetime.datetime.today() @@ -268,6 +287,7 @@ class Gpx2Html(object): handle.write('
\n') handle.write('\n'.format('distance.png')) handle.write('\n'.format('acc_dist.png')) + handle.write('\n'.format('exp_dist.png')) handle.write('\n'.format('avg_spd.png')) handle.write('\n'.format('last_14_days.png')) handle.write('
\n')