Пример #1
0
  def perform(args):
    try:
      env = os.environ['RACK_ENV'] = os.environ.get('RACK_ENV', 'development')
      match_id = args['match_id']

      sc2reader_to_esdb = SC2ReaderToEsdb()
      ggthost = 'ggtracker.com'
      blobenv = 'prod'

      if env == 'development':
        ggthost = 'localhost:3000'
        blobenv = 'dev'

      replay = ggfactory.load_replay("http://{}/matches/{}/replay".format(ggthost, match_id))
      url = urllib.urlopen("http://gg2-matchblobs-{}.s3.amazonaws.com/{}".format(blobenv, match_id))

      mb_string = url.read()
      blob = json.loads(mb_string)

      unicode_ident_ids = blob['MineralsCollectionRate'].keys()
      for blobkey in ['MineralsCollectionRate', 'VespeneCollectionRate', 'WorkersActiveCount']:
        for ident_id in unicode_ident_ids:
          blob[blobkey][int(ident_id)] = blob[blobkey][ident_id]

      sc2reader_to_esdb.reprocessEntityStatsForAllPlayers(replay, blob)

    except Exception as e:
      tb = traceback.format_exc()
      exc_type, exc_obj, exc_tb = sys.exc_info()
      fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]      
      logging.getLogger("jobs").info("stats computation failed for replay {}. oh well. exception={}. {} {} {} {}".format(args['hash'], e, exc_type, fname, exc_tb.tb_lineno, tb))
      pass
Пример #2
0
 def get_parsed_replay(self, i):
     replayfile = open(
         "sc2parse/testfiles/replay{replaynum}.SC2Replay".format(
             replaynum=i), "rb")
     replay = ggfactory.load_replay(replayfile)
     replayfile.close()
     return replay
Пример #3
0
  def perform(args):
    try:
      env = os.environ['RACK_ENV'] = os.environ.get('RACK_ENV', 'development')
      match_id = args['match_id']

      sc2reader_to_esdb = SC2ReaderToEsdb()
      ggthost = 'gggreplays.com'
      blobenv = 'prod'

      if env == 'development':
        ggthost = 'localhost:3000'
        blobenv = 'dev'

      replay = ggfactory.load_replay("http://{}/matches/{}/replay".format(ggthost, match_id))
      url = urllib.urlopen("http://gg2-matchblobs-{}.s3.amazonaws.com/{}".format(blobenv, match_id))

      mb_string = url.read()
      blob = json.loads(mb_string)

      unicode_ident_ids = blob['MineralsCollectionRate'].keys()
      for blobkey in ['MineralsCollectionRate', 'VespeneCollectionRate', 'WorkersActiveCount']:
        for ident_id in unicode_ident_ids:
          blob[blobkey][int(ident_id)] = blob[blobkey][ident_id]

      sc2reader_to_esdb.reprocessEntityStatsForAllPlayers(replay, blob)

    except Exception as e:
      tb = traceback.format_exc()
      exc_type, exc_obj, exc_tb = sys.exc_info()
      fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]      
      logging.getLogger("jobs").info("stats computation failed for replay {}. oh well. exception={}. {} {} {} {}".format(args['hash'], e, exc_type, fname, exc_tb.tb_lineno, tb))
      pass
Пример #4
0
from pprint import PrettyPrinter
pprint = PrettyPrinter(indent=2).pprint

import sys, sc2reader
import json
from sc2parse import ggfactory
sc2reader.log_utils.log_to_console('INFO')

for filename in sys.argv[1:]:
    try:
        if True or replay.category == 'Ladder':
            replay = ggfactory.load_replay(filename, verbose=True, load_level=4)
            for player in replay.players:
                print player
                for base in player.bases:
                    print base, base.location
                    print "  Ordered at",divmod(base.ordered_at/16,60)
                    if base.started_at != None:
                        print "  Started at",divmod(base.started_at/16,60)
                    else:
                        print "  Start time unknown"
                    print "  Confirmed at",divmod(base.confirmed_at/16,60)
                    if base.finished_at != None:
                        print "  Finished at",divmod(base.finished_at/16,60)
                    else:
                        print "  Unfinished"
                    print
                print "\n\n"
            # if not [u for u in replay.objects.values() if u.name=='Hive']: continue
            # print replay.map_name, replay.length, replay.start_time
            # for player in replay.players:
Пример #5
0
import sys
import sc2reader
from sc2parse import ggfactory

# usage GGFACTORY_CACHE_DIR=testcache python engagement.py <ggtracker match id>

replay = ggfactory.load_replay("http://ggtracker.com/matches/{}/replay".format(sys.argv[1]))
Пример #6
0
 def get_parsed_replay(self, i):
     replayfile = open("sc2parse/testfiles/replay{replaynum}.SC2Replay".format(replaynum=i), "rb")
     replay = ggfactory.load_replay(replayfile)
     replayfile.close()
     return replay
Пример #7
0
import sys
import sc2reader
from sc2parse import ggfactory

# usage GGFACTORY_CACHE_DIR=testcache python engagement.py <ggtracker match id>

replay = ggfactory.load_replay("http://ggtracker.com/matches/{}/replay".format(
    sys.argv[1]))
Пример #8
0
from pprint import PrettyPrinter
pprint = PrettyPrinter(indent=2).pprint

import sys, sc2reader
import json
from sc2parse import ggfactory
sc2reader.log_utils.log_to_console('INFO')

for filename in sys.argv[1:]:
    try:
        if True or replay.category == 'Ladder':
            replay = ggfactory.load_replay(filename,
                                           verbose=True,
                                           load_level=4)
            for player in replay.players:
                print player
                for base in player.bases:
                    print base, base.location
                    print "  Ordered at", divmod(base.ordered_at / 16, 60)
                    if base.started_at != None:
                        print "  Started at", divmod(base.started_at / 16, 60)
                    else:
                        print "  Start time unknown"
                    print "  Confirmed at", divmod(base.confirmed_at / 16, 60)
                    if base.finished_at != None:
                        print "  Finished at", divmod(base.finished_at / 16,
                                                      60)
                    else:
                        print "  Unfinished"
                    print
                print "\n\n"