EXCEPTION WHEN OTHERS THEN IF pextra_scope IS NULL THEN UPDATE %tbl SET (val,mtime) = (pval,pmtime) WHERE (%id_field,stat,time_scope,time_loc,space_scope,space_loc) = (p%id_field,pstat,ptime_scope,ptime_loc,pspace_scope,pspace_loc); ELSE UPDATE %tbl SET (val,mtime) = (pval,pmtime) WHERE (%id_field,stat,time_scope,time_loc,space_scope,space_loc,extra_scope,extra_loc) = (p%id_field,pstat,ptime_scope,ptime_loc,pspace_scope,pspace_loc,pextra_scope,pextra_loc); END IF; END; RETURN; END $$ language plpgsql; """)) con.commit() now_time_coords = Scores2.make_time_coords(time_now, SpinConfig.get_pvp_season(gamedata['matchmaking']['season_starts'], time_now), SpinConfig.get_pvp_week(gamedata['matchmaking']['week_origin'], time_now), SpinConfig.get_pvp_day(gamedata['matchmaking']['week_origin'], time_now), use_day = True) for kind in tbl: # for each time scope for freq in Scores2.FREQ_VALUES: # find earliest time loc recorded for this scope in MongoDB live_time_range = mongo_scores._scores2_get_time_range(kind, freq) if verbose: print kind, freq, 'live time range', live_time_range if live_time_range[0] < 0: continue # no data for loc in xrange(live_time_range[0], live_time_range[1]+1):
def main(args): global gamedata global basedata global hivedata global lootdata global time_now opts, args = getopt.gnu_getopt(args, 'cg:', []) game_id = 'ALL' output = 'txt' for key, val in opts: if key == '-g': game_id = val if key == '-c': output = 'csv' time_now = int(time.time()) date_now = datetime.datetime.utcfromtimestamp(time_now) gamedata = SpinJSON.load(open(SpinConfig.gamedata_filename())) cur_week = SpinConfig.get_pvp_week(gamedata['matchmaking']['week_origin'], time_now) today5pm = SpinConfig.cal_to_unix(SpinConfig.unix_to_cal(time_now)) + 17*60*60 if time_now < today5pm: cur_day = ((date_now.weekday() + 3) % 7 + 1) else: cur_day = ((date_now.weekday() + 4) % 7 + 1) if output == 'txt': print 'Sauron v0.01.015 | %s, %s %s (Week %s, Day %s) %s GMT:<br>' % (date_now.strftime('%A')[:3].upper(), date_now.strftime("%B")[:3].upper(), date_now.strftime('%d, %Y'), cur_week, cur_day, date_now.strftime('%H:%M:%S')) print '=======================================================================' print '\n TITLES :\n' print ' TR - Thunder Run' print ' BFM - Battlefront Mars' print '' print ' ALL TITLES :\n' print ' TEST CALENDAR (Coming soon)' print ' EVENT CALENDAR (Coming soon)' print '' print '=======================================================================' print ' LEGEND' print '=======================================================================\n' print ' EVENT DETAILS :\n' print ' ONP: Ops Needs Points event' print ' IMM: Immortal event' print ' TUT: Tutorial event' print ' ID: AI base/attack id' print ' UNT: Number of AI units' print ' DPS: Total harmful damage per second of AI units/turrets' print ' HLT: Total max health of AI units/turrets' print ' SPC: Total unit space taken up by AI units' print ' TUR: Number of turrets' print ' SPT: Total sprite count of AI buildings, units, and scenery for gauging frame rates.' print ' CCL: Estimated difficulty in terms of CC level.' print '' if output == 'csv': print 'Level, Type, Base ID, Estimate CCL, ONP, Unit Count, Unit Health, Unit DPS, Unit Space, Turret Count, Turret Health, Turret DPS, Sprite Count, Loot' if game_id is 'ALL': for id in GAME_IDS: try: gamedata = SpinJSON.load(open(SpinConfig.gamedata_filename(override_game_id = id))) basedata = SpinJSON.load(open('./%s/built/%s_ai_bases_compiled.json' % (id, id))) hivedata = SpinJSON.load(open('./%s/built/%s_hives_compiled.json' % (id, id))) lootdata = SpinJSON.load(open('./%s/built/%s_loot_tables_compiled.json' % (id, id))) except IOError: print 'ERROR: Can\'t find compiled gamedata files for %s. Please run cd ../gameserver; ./make-gamedata.sh -u -g %s\n' % (id, id) return if output == 'txt': print_event_details_txt(id) elif output == 'csv': print_event_details_csv(id) else: if game_id not in GAME_IDS: print 'Invalid game id: %s' % game_id return try: gamedata = SpinJSON.load(open(SpinConfig.gamedata_filename(override_game_id = game_id))) basedata = SpinJSON.load(open('./%s/built/%s_ai_bases_compiled.json' % (game_id, game_id))) hivedata = SpinJSON.load(open('./%s/built/%s_hives_compiled.json' % (game_id, game_id))) lootdata = SpinJSON.load(open('./%s/built/%s_loot_tables_compiled.json' % (game_id, game_id))) except IOError: print 'ERROR: Can\'t find compiled gamedata files for %s. Please run cd ../gameserver; ./make-gamedata.sh -u -g %s\n' % (game_id, game_id) return if output == 'txt': print_event_details_txt(game_id) elif output == 'csv': print_event_details_csv(game_id)