from sqlalchemy import distinct
from pyramid.paster import bootstrap
from xonstat.models import *
+from xonstat.util import datetime_seconds
-from render import PlayerData, Skin
+from skin import Skin
+from playerdata import PlayerData
-# maximal number of query results (for testing, set to 0 to get all)
+# maximal number of query results (for testing, set to None to get all)
NUM_PLAYERS = None
# we look for players who have activity within the past DELTA hours
# classic skin WITHOUT NAME - writes PNGs into "output//###.png"
skin_classic = Skin( "",
- bg = "asfalt",
+ bg = "broken_noise",
+ overlay = "overlay_classic",
)
# more fancy skin [** WIP **]- writes PNGs into "output/archer/###.png"
skin_archer = Skin( "archer",
bg = "background_archer-v1",
- overlay = "",
+ overlay = None,
)
# minimal skin - writes PNGs into "output/minimal/###.png"
overlay = "overlay_minimal",
width = 560,
height = 40,
- num_gametypes = 4,
- gametype_pos = (25,30),
- gametype_text = "%s :",
- gametype_width = 120,
+ nick_fontsize = 16,
+ nick_pos = (36,16),
+ num_gametypes = 3,
+ nick_maxwidth = 300,
+ gametype_pos = (70,30),
+ gametype_color = (0.0, 0.0, 0.0),
+ gametype_text = "%s:",
+ gametype_width = 100,
gametype_fontsize = 10,
+ gametype_align = -1,
+ gametype_upper = False,
elo_pos = (75,30),
elo_text = "Elo %.0f",
- elo_color = (1.0, 1.0, 0.6),
+ elo_color = (0.7, 0.7, 0.7),
+ elo_align = 1,
rank_pos = None,
- nostats_pos = (80,30),
- nostats_fontsize = 10,
- nostats_angle = 0,
- nostats_text = "no stats!",
+ 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),
+ kdr_colormid = (0.6, 0.6, 0.6),
+ kdr_colorbot = (0.8, 0.6, 0.6),
kills_pos = None,
deaths_pos = None,
winp_pos = (508,15),
+ winp_fontsize = 10,
+ winp_colortop = (0.6, 0.8, 0.8),
+ winp_colormid = (0.6, 0.6, 0.6),
+ winp_colorbot = (0.8, 0.8, 0.6),
wins_pos = None,
loss_pos = None,
- ptime_pos = (458,30),
- ptime_color = (0.8, 0.8, 0.9),
+ ptime_pos = (451,30),
+ ptime_color = (0.7, 0.7, 0.7),
)
+
# parse cmdline parameters (for testing)
skins = []
if arg == "force":
DELTA = 2**24 # large enough to enforce update, and doesn't result in errors
elif arg == "test":
- NUM_PLAYERS = 200
+ NUM_PLAYERS = 100
else:
print """Usage: gen_badges.py [options] [skin list]
Options:
-force Force updating all badges (delta = 2^24)
- -testing Limit number of players to 200 (for testing)
+ -test Limit number of players to 100 (for testing)
-help Show this help text
Skin list:
Space-separated list of skins to use when creating badges.
If no skins are given, classic and minmal will be used by default.
NOTE: Output directories must exists before running the program!
"""
- sys.exit(-1)
+ sys.exit(-1)
else:
if arg == "classic":
skins.append(skin_classic)
if len(skins) == 0:
skins = [ skin_classic, skin_minimal ]
-
# environment setup
env = bootstrap('../../../development.ini')
req = env['request']
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()
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