]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/batch/badges/gen_badges.py
Implemented some (preliminary) JSON API to retrieve player data
[xonotic/xonstat.git] / xonstat / batch / badges / gen_badges.py
index 82620b26e4e4ef90aec6161c4b31ee431962d81d..44d73aec3da4f1ea2a16690cf9e965c954777b33 100644 (file)
@@ -7,6 +7,7 @@ import sqlalchemy.sql.functions as func
 from sqlalchemy import distinct
 from pyramid.paster import bootstrap
 from xonstat.models import *
+from xonstat.util import datetime_seconds
 
 from skin import Skin
 from playerdata import PlayerData
@@ -42,23 +43,24 @@ skin_minimal = Skin( "minimal",
         nick_pos        = (36,16),
         num_gametypes   = 3,
         nick_maxwidth   = 300,
-        gametype_pos    = (78,30),
+        gametype_pos    = (70,30),
         gametype_color  = (0.0, 0.0, 0.0),
         gametype_text   = "%s:",
-        gametype_width  = 96,
+        gametype_width  = 100,
         gametype_fontsize = 10,
         gametype_align  = -1,
-        elo_pos         = (82,30),
+        gametype_upper  = False,
+        elo_pos         = (75,30),
         elo_text        = "Elo %.0f",
         elo_color       = (0.7, 0.7, 0.7),
         elo_align       = 1,
         rank_pos        = None,
-        nostats_pos     = (82,30),
-        nostats_fontsize = 10,
-        nostats_angle   = 0,
-        nostats_text    = "no stats!",
-        nostats_color   = (0.7, 0.4, 0.4),
-        nostats_center  = False,
+        nostats_pos     = None,
+        #nostats_pos     = (75,30),
+        #nostats_fontsize = 10,
+        #nostats_angle   = 0,
+        #nostats_text    = "no stats yet!",
+        #nostats_color   = (0.7, 0.4, 0.4),
         kdr_pos         = (392,15),
         kdr_fontsize    = 10,
         kdr_colortop    = (0.6, 0.8, 0.6),
@@ -112,7 +114,6 @@ for arg in sys.argv[1:]:
 if len(skins) == 0:
     skins = [ skin_classic, skin_minimal ]
 
-
 # environment setup
 env = bootstrap('../../../development.ini')
 req = env['request']
@@ -146,8 +147,7 @@ playerdata = PlayerData()
 if len(players) > 0:
     stop = datetime.now()
     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 "Query took %.2f seconds" % (datetime_seconds(td))
 
     print "Creating badges for %d players ..." % len(players)
     start = datetime.now()
@@ -159,20 +159,18 @@ if len(players) > 0:
         playerdata.get_data(player_id)
         sstop = datetime.now()
         td = sstop-sstart
-        total_seconds = float(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
-        data_time += total_seconds
+        data_time += datetime_seconds(td)
 
         sstart = datetime.now()
         for sk in skins:
             sk.render_image(playerdata, "output/%s/%d.png" % (str(sk), player_id[0]))
         sstop = datetime.now()
         td = sstop-sstart
-        total_seconds = float(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
-        render_time += total_seconds
+        render_time += datetime_seconds(td)
 
     stop = datetime.now()
     td = stop-start
-    total_seconds = float(td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
+    total_seconds = datetime_seconds(td)
     print "Creating the badges took %.1f seconds (%.3f s per player)" % (total_seconds, total_seconds/float(len(players)))
     print "Total time for rendering images: %.3f s" % render_time
     print "Total time for getting data: %.3f s" % data_time