From 607d5d84ee1427501276ab6df3c4fca3bdeac56a Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sat, 25 Aug 2012 08:55:11 -0400 Subject: [PATCH] Python 2.6.x doesn't have total_seconds(). --- xonstat/batch/badges/gen_badges.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xonstat/batch/badges/gen_badges.py b/xonstat/batch/badges/gen_badges.py index f631eac..d747c96 100644 --- a/xonstat/batch/badges/gen_badges.py +++ b/xonstat/batch/badges/gen_badges.py @@ -424,7 +424,7 @@ def render_image(data): # environment setup -env = bootstrap('../../../development.ini') +env = bootstrap('../../../development.ini.home') req = env['request'] req.matchdict = {'id':3} @@ -437,7 +437,9 @@ players = DBSession.query(Player).\ filter(Player.active_ind == True).\ limit(NUM_PLAYERS).all() stop = datetime.now() -print "Query took %.2f seconds" % (stop-start).total_seconds() +td = stop-start +total_seconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 +print "Query took %.2f seconds" % (total_seconds) print "Creating badges for %d players ..." % len(players) start = datetime.now() @@ -448,14 +450,20 @@ for player in players: sstart = datetime.now() data = get_data(player) sstop = datetime.now() - data_time += (sstop-sstart).total_seconds() + td = sstop-sstart + total_seconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 + data_time += total_seconds sstart = datetime.now() render_image(data) sstop = datetime.now() - render_time += (sstop-sstart).total_seconds() + td = sstop-sstart + total_seconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 + render_time += total_seconds stop = datetime.now() -print "Creating the badges took %.2f seconds (%.2f s per player)" % ((stop-start).total_seconds(), (stop-start).total_seconds()/float(len(players))) +td = stop-start +total_seconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 +print "Creating the badges took %.2f seconds (%.2f s per player)" % (total_seconds, total_seconds/float(len(players))) print "Total time for redering images: %.2f s" % render_time print "Total time for getting data: %.2f s" % data_time -- 2.39.2